@inkeep/cxkit-primitives 0.0.0-dev-20250221234142
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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/atoms/api/analytics/conversation.cjs +1 -0
- package/dist/atoms/api/analytics/conversation.d.cts +3 -0
- package/dist/atoms/api/analytics/conversation.d.ts +3 -0
- package/dist/atoms/api/analytics/conversation.js +37 -0
- package/dist/atoms/api/analytics/events.cjs +1 -0
- package/dist/atoms/api/analytics/events.d.cts +2 -0
- package/dist/atoms/api/analytics/events.d.ts +2 -0
- package/dist/atoms/api/analytics/events.js +30 -0
- package/dist/atoms/api/analytics/feedback.cjs +1 -0
- package/dist/atoms/api/analytics/feedback.d.cts +11 -0
- package/dist/atoms/api/analytics/feedback.d.ts +11 -0
- package/dist/atoms/api/analytics/feedback.js +26 -0
- package/dist/atoms/avatars/ai.cjs +1 -0
- package/dist/atoms/avatars/ai.d.cts +3 -0
- package/dist/atoms/avatars/ai.d.ts +3 -0
- package/dist/atoms/avatars/ai.js +88 -0
- package/dist/atoms/avatars/user.cjs +1 -0
- package/dist/atoms/avatars/user.d.cts +3 -0
- package/dist/atoms/avatars/user.d.ts +3 -0
- package/dist/atoms/avatars/user.js +27 -0
- package/dist/atoms/codeblock/index.cjs +1 -0
- package/dist/atoms/codeblock/index.d.cts +10 -0
- package/dist/atoms/codeblock/index.d.ts +10 -0
- package/dist/atoms/codeblock/index.js +40 -0
- package/dist/atoms/custom-styles.cjs +1 -0
- package/dist/atoms/custom-styles.d.cts +5 -0
- package/dist/atoms/custom-styles.d.ts +5 -0
- package/dist/atoms/custom-styles.js +57 -0
- package/dist/atoms/dialog.cjs +1 -0
- package/dist/atoms/dialog.d.cts +68 -0
- package/dist/atoms/dialog.d.ts +68 -0
- package/dist/atoms/dialog.js +185 -0
- package/dist/atoms/icons/built-in-icon-renderer.cjs +1 -0
- package/dist/atoms/icons/built-in-icon-renderer.d.cts +6 -0
- package/dist/atoms/icons/built-in-icon-renderer.d.ts +6 -0
- package/dist/atoms/icons/built-in-icon-renderer.js +49 -0
- package/dist/atoms/icons/built-in-icons.cjs +1 -0
- package/dist/atoms/icons/built-in-icons.d.cts +72 -0
- package/dist/atoms/icons/built-in-icons.d.ts +72 -0
- package/dist/atoms/icons/built-in-icons.js +79 -0
- package/dist/atoms/icons/checkbox-icon.cjs +1 -0
- package/dist/atoms/icons/checkbox-icon.d.cts +1 -0
- package/dist/atoms/icons/checkbox-icon.d.ts +1 -0
- package/dist/atoms/icons/checkbox-icon.js +24 -0
- package/dist/atoms/icons/custom-icon.cjs +1 -0
- package/dist/atoms/icons/custom-icon.d.cts +6 -0
- package/dist/atoms/icons/custom-icon.d.ts +6 -0
- package/dist/atoms/icons/custom-icon.js +19 -0
- package/dist/atoms/icons/index.cjs +1 -0
- package/dist/atoms/icons/index.d.cts +2 -0
- package/dist/atoms/icons/index.d.ts +2 -0
- package/dist/atoms/icons/index.js +6 -0
- package/dist/atoms/icons/inkeep-default-icons.cjs +1 -0
- package/dist/atoms/icons/inkeep-default-icons.d.cts +2 -0
- package/dist/atoms/icons/inkeep-default-icons.d.ts +2 -0
- package/dist/atoms/icons/inkeep-default-icons.js +23 -0
- package/dist/atoms/link.cjs +1 -0
- package/dist/atoms/link.d.cts +14 -0
- package/dist/atoms/link.d.ts +14 -0
- package/dist/atoms/link.js +35 -0
- package/dist/atoms/markdown/components.cjs +1 -0
- package/dist/atoms/markdown/components.d.cts +27 -0
- package/dist/atoms/markdown/components.d.ts +27 -0
- package/dist/atoms/markdown/components.js +64 -0
- package/dist/atoms/markdown/index.cjs +1 -0
- package/dist/atoms/markdown/index.d.cts +15 -0
- package/dist/atoms/markdown/index.d.ts +15 -0
- package/dist/atoms/markdown/index.js +79 -0
- package/dist/atoms/markdown/rehype-inline-code-property.cjs +1 -0
- package/dist/atoms/markdown/rehype-inline-code-property.d.cts +1 -0
- package/dist/atoms/markdown/rehype-inline-code-property.d.ts +1 -0
- package/dist/atoms/markdown/rehype-inline-code-property.js +12 -0
- package/dist/atoms/portal-with-theme.cjs +1 -0
- package/dist/atoms/portal-with-theme.d.cts +2 -0
- package/dist/atoms/portal-with-theme.d.ts +2 -0
- package/dist/atoms/portal-with-theme.js +12 -0
- package/dist/atoms/portal.cjs +1 -0
- package/dist/atoms/portal.d.cts +8 -0
- package/dist/atoms/portal.d.ts +8 -0
- package/dist/atoms/portal.js +19 -0
- package/dist/atoms/shadow/context.cjs +2 -0
- package/dist/atoms/shadow/context.d.cts +14 -0
- package/dist/atoms/shadow/context.d.ts +14 -0
- package/dist/atoms/shadow/context.js +55 -0
- package/dist/atoms/shadow/create.cjs +1 -0
- package/dist/atoms/shadow/create.d.cts +8 -0
- package/dist/atoms/shadow/create.d.ts +8 -0
- package/dist/atoms/shadow/create.js +56 -0
- package/dist/atoms/shadow/index.d.cts +1 -0
- package/dist/atoms/shadow/index.d.ts +1 -0
- package/dist/atoms/shadow/root.cjs +1 -0
- package/dist/atoms/shadow/root.d.cts +5 -0
- package/dist/atoms/shadow/root.d.ts +5 -0
- package/dist/atoms/shadow/root.js +22 -0
- package/dist/atoms/shadow/use-ensured-forwarded-ref.cjs +1 -0
- package/dist/atoms/shadow/use-ensured-forwarded-ref.d.cts +2 -0
- package/dist/atoms/shadow/use-ensured-forwarded-ref.d.ts +2 -0
- package/dist/atoms/shadow/use-ensured-forwarded-ref.js +11 -0
- package/dist/atoms/shadow/utils.cjs +1 -0
- package/dist/atoms/shadow/utils.d.cts +9 -0
- package/dist/atoms/shadow/utils.d.ts +9 -0
- package/dist/atoms/shadow/utils.js +16 -0
- package/dist/components/chat-button.cjs +1 -0
- package/dist/components/chat-button.d.cts +11 -0
- package/dist/components/chat-button.d.ts +11 -0
- package/dist/components/chat-button.js +42 -0
- package/dist/components/embedded-chat/chat-provider.cjs +1 -0
- package/dist/components/embedded-chat/chat-provider.d.cts +19 -0
- package/dist/components/embedded-chat/chat-provider.d.ts +19 -0
- package/dist/components/embedded-chat/chat-provider.js +22 -0
- package/dist/components/embedded-chat/use-captcha.cjs +1 -0
- package/dist/components/embedded-chat/use-captcha.d.cts +13 -0
- package/dist/components/embedded-chat/use-captcha.d.ts +13 -0
- package/dist/components/embedded-chat/use-captcha.js +56 -0
- package/dist/components/embedded-chat/use-chat-action.cjs +1 -0
- package/dist/components/embedded-chat/use-chat-action.d.cts +9 -0
- package/dist/components/embedded-chat/use-chat-action.d.ts +9 -0
- package/dist/components/embedded-chat/use-chat-action.js +26 -0
- package/dist/components/embedded-chat/use-inkeep-chat.cjs +4 -0
- package/dist/components/embedded-chat/use-inkeep-chat.d.cts +25 -0
- package/dist/components/embedded-chat/use-inkeep-chat.d.ts +25 -0
- package/dist/components/embedded-chat/use-inkeep-chat.js +227 -0
- package/dist/components/embedded-chat.cjs +17 -0
- package/dist/components/embedded-chat.d.cts +415 -0
- package/dist/components/embedded-chat.d.ts +415 -0
- package/dist/components/embedded-chat.js +1840 -0
- package/dist/components/embedded-search/search-provider.cjs +1 -0
- package/dist/components/embedded-search/search-provider.d.cts +21 -0
- package/dist/components/embedded-search/search-provider.d.ts +21 -0
- package/dist/components/embedded-search/search-provider.js +19 -0
- package/dist/components/embedded-search/search-query.graphql.cjs +82 -0
- package/dist/components/embedded-search/search-query.graphql.js +86 -0
- package/dist/components/embedded-search/transform-results.cjs +1 -0
- package/dist/components/embedded-search/transform-results.d.cts +3 -0
- package/dist/components/embedded-search/transform-results.d.ts +3 -0
- package/dist/components/embedded-search/transform-results.js +113 -0
- package/dist/components/embedded-search/use-inkeep-search.cjs +1 -0
- package/dist/components/embedded-search/use-inkeep-search.d.cts +21 -0
- package/dist/components/embedded-search/use-inkeep-search.d.ts +21 -0
- package/dist/components/embedded-search/use-inkeep-search.js +137 -0
- package/dist/components/embedded-search.cjs +1 -0
- package/dist/components/embedded-search.d.cts +229 -0
- package/dist/components/embedded-search.d.ts +229 -0
- package/dist/components/embedded-search.js +390 -0
- package/dist/components/factory.cjs +1 -0
- package/dist/components/factory.d.cts +19 -0
- package/dist/components/factory.d.ts +19 -0
- package/dist/components/factory.js +39 -0
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +11 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.js +31 -0
- package/dist/components/intelligent-form/actions/context-model-response.cjs +9 -0
- package/dist/components/intelligent-form/actions/context-model-response.d.cts +10 -0
- package/dist/components/intelligent-form/actions/context-model-response.d.ts +10 -0
- package/dist/components/intelligent-form/actions/context-model-response.js +36 -0
- package/dist/components/intelligent-form/actions/escalation-schema.cjs +1 -0
- package/dist/components/intelligent-form/actions/escalation-schema.d.cts +2 -0
- package/dist/components/intelligent-form/actions/escalation-schema.d.ts +2 -0
- package/dist/components/intelligent-form/actions/escalation-schema.js +48 -0
- package/dist/components/intelligent-form/actions/qa-model-messages.cjs +27 -0
- package/dist/components/intelligent-form/actions/qa-model-messages.d.cts +2 -0
- package/dist/components/intelligent-form/actions/qa-model-messages.d.ts +2 -0
- package/dist/components/intelligent-form/actions/qa-model-messages.js +45 -0
- package/dist/components/intelligent-form/actions/qa-model-response.cjs +1 -0
- package/dist/components/intelligent-form/actions/qa-model-response.d.cts +14 -0
- package/dist/components/intelligent-form/actions/qa-model-response.d.ts +14 -0
- package/dist/components/intelligent-form/actions/qa-model-response.js +46 -0
- package/dist/components/intelligent-form/intelligent-form-provider.cjs +1 -0
- package/dist/components/intelligent-form/intelligent-form-provider.d.cts +29 -0
- package/dist/components/intelligent-form/intelligent-form-provider.d.ts +29 -0
- package/dist/components/intelligent-form/intelligent-form-provider.js +23 -0
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.cjs +1 -0
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.d.cts +30 -0
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.d.ts +30 -0
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.js +157 -0
- package/dist/components/intelligent-form.cjs +1 -0
- package/dist/components/intelligent-form.d.cts +135 -0
- package/dist/components/intelligent-form.d.ts +135 -0
- package/dist/components/intelligent-form.js +568 -0
- package/dist/components/modal/modal-provider.cjs +1 -0
- package/dist/components/modal/modal-provider.d.cts +13 -0
- package/dist/components/modal/modal-provider.d.ts +13 -0
- package/dist/components/modal/modal-provider.js +8 -0
- package/dist/components/modal/use-inkeep-modal.cjs +1 -0
- package/dist/components/modal/use-inkeep-modal.d.cts +8 -0
- package/dist/components/modal/use-inkeep-modal.d.ts +8 -0
- package/dist/components/modal/use-inkeep-modal.js +30 -0
- package/dist/components/modal.cjs +1 -0
- package/dist/components/modal.d.cts +18 -0
- package/dist/components/modal.d.ts +18 -0
- package/dist/components/modal.js +40 -0
- package/dist/components/searchbar.cjs +1 -0
- package/dist/components/searchbar.d.cts +23 -0
- package/dist/components/searchbar.d.ts +23 -0
- package/dist/components/searchbar.js +54 -0
- package/dist/components/tagline-logo-icon.cjs +1 -0
- package/dist/components/tagline-logo-icon.d.cts +1 -0
- package/dist/components/tagline-logo-icon.d.ts +1 -0
- package/dist/components/tagline-logo-icon.js +34 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.d.cts +12 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.js +27 -0
- package/dist/hooks/use-boolean.cjs +1 -0
- package/dist/hooks/use-boolean.d.cts +10 -0
- package/dist/hooks/use-boolean.d.ts +10 -0
- package/dist/hooks/use-boolean.js +17 -0
- package/dist/hooks/use-browser-storage.cjs +1 -0
- package/dist/hooks/use-browser-storage.d.cts +17 -0
- package/dist/hooks/use-browser-storage.d.ts +17 -0
- package/dist/hooks/use-browser-storage.js +88 -0
- package/dist/hooks/use-component-classnames.cjs +1 -0
- package/dist/hooks/use-component-classnames.d.cts +6 -0
- package/dist/hooks/use-component-classnames.d.ts +6 -0
- package/dist/hooks/use-component-classnames.js +14 -0
- package/dist/hooks/use-container-size.cjs +1 -0
- package/dist/hooks/use-container-size.d.cts +5 -0
- package/dist/hooks/use-container-size.d.ts +5 -0
- package/dist/hooks/use-container-size.js +18 -0
- package/dist/hooks/use-copy-to-clipboard.cjs +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.cts +3 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +3 -0
- package/dist/hooks/use-copy-to-clipboard.js +19 -0
- package/dist/hooks/use-instant-update.cjs +1 -0
- package/dist/hooks/use-instant-update.d.cts +17 -0
- package/dist/hooks/use-instant-update.d.ts +17 -0
- package/dist/hooks/use-instant-update.js +16 -0
- package/dist/hooks/use-is-mounted.cjs +1 -0
- package/dist/hooks/use-is-mounted.d.cts +1 -0
- package/dist/hooks/use-is-mounted.d.ts +1 -0
- package/dist/hooks/use-is-mounted.js +11 -0
- package/dist/hooks/use-media-query.cjs +1 -0
- package/dist/hooks/use-media-query.d.cts +1 -0
- package/dist/hooks/use-media-query.d.ts +1 -0
- package/dist/hooks/use-media-query.js +14 -0
- package/dist/hooks/use-resize-observer.cjs +1 -0
- package/dist/hooks/use-resize-observer.d.cts +12 -0
- package/dist/hooks/use-resize-observer.d.ts +12 -0
- package/dist/hooks/use-resize-observer.js +32 -0
- package/dist/hooks/use-scroll-to-bottom.cjs +1 -0
- package/dist/hooks/use-scroll-to-bottom.d.cts +13 -0
- package/dist/hooks/use-scroll-to-bottom.d.ts +13 -0
- package/dist/hooks/use-scroll-to-bottom.js +52 -0
- package/dist/hooks/use-scrolling-fades.cjs +1 -0
- package/dist/hooks/use-scrolling-fades.d.cts +2 -0
- package/dist/hooks/use-scrolling-fades.d.ts +2 -0
- package/dist/hooks/use-scrolling-fades.js +18 -0
- package/dist/hooks/use-settle-action.cjs +1 -0
- package/dist/hooks/use-settle-action.d.cts +3 -0
- package/dist/hooks/use-settle-action.d.ts +3 -0
- package/dist/hooks/use-settle-action.js +11 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +152 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/fa6/index.cjs +1 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/fa6/index.js +92 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/fi/index.cjs +1 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/fi/index.js +8 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/hi2/index.cjs +1 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/hi2/index.js +8 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/io5/index.cjs +1 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/io5/index.js +128 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/lib/iconBase.cjs +1 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/lib/iconBase.js +109 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/lib/iconContext.cjs +1 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/lib/iconContext.js +13 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/lu/index.cjs +1 -0
- package/dist/node_modules/.pnpm/react-icons@5.4.0_react@19.0.0/node_modules/react-icons/lu/index.js +68 -0
- package/dist/providers/attachment-item-provider.cjs +1 -0
- package/dist/providers/attachment-item-provider.d.cts +9 -0
- package/dist/providers/attachment-item-provider.d.ts +9 -0
- package/dist/providers/attachment-item-provider.js +13 -0
- package/dist/providers/attachments-bar-provider.cjs +1 -0
- package/dist/providers/attachments-bar-provider.d.cts +30 -0
- package/dist/providers/attachments-bar-provider.d.ts +30 -0
- package/dist/providers/attachments-bar-provider.js +64 -0
- package/dist/providers/base-events-provider.cjs +1 -0
- package/dist/providers/base-events-provider.d.cts +8 -0
- package/dist/providers/base-events-provider.d.ts +8 -0
- package/dist/providers/base-events-provider.js +39 -0
- package/dist/providers/chat-events-provider.cjs +1 -0
- package/dist/providers/chat-events-provider.d.cts +12 -0
- package/dist/providers/chat-events-provider.d.ts +12 -0
- package/dist/providers/chat-events-provider.js +66 -0
- package/dist/providers/chat-form-provider.cjs +1 -0
- package/dist/providers/chat-form-provider.d.cts +23 -0
- package/dist/providers/chat-form-provider.d.ts +23 -0
- package/dist/providers/chat-form-provider.js +66 -0
- package/dist/providers/config-provider.cjs +1 -0
- package/dist/providers/config-provider.d.cts +24 -0
- package/dist/providers/config-provider.d.ts +24 -0
- package/dist/providers/config-provider.js +37 -0
- package/dist/providers/conversation-provider.cjs +1 -0
- package/dist/providers/conversation-provider.d.cts +12 -0
- package/dist/providers/conversation-provider.d.ts +12 -0
- package/dist/providers/conversation-provider.js +49 -0
- package/dist/providers/feedback-item-provider.cjs +1 -0
- package/dist/providers/feedback-item-provider.d.cts +10 -0
- package/dist/providers/feedback-item-provider.d.ts +10 -0
- package/dist/providers/feedback-item-provider.js +16 -0
- package/dist/providers/feedback-provider.cjs +1 -0
- package/dist/providers/feedback-provider.d.cts +19 -0
- package/dist/providers/feedback-provider.d.ts +19 -0
- package/dist/providers/feedback-provider.js +82 -0
- package/dist/providers/form-field-provider.cjs +1 -0
- package/dist/providers/form-field-provider.d.cts +15 -0
- package/dist/providers/form-field-provider.d.ts +15 -0
- package/dist/providers/form-field-provider.js +17 -0
- package/dist/providers/help-menu-provider.cjs +1 -0
- package/dist/providers/help-menu-provider.d.cts +11 -0
- package/dist/providers/help-menu-provider.d.ts +11 -0
- package/dist/providers/help-menu-provider.js +19 -0
- package/dist/providers/index.cjs +1 -0
- package/dist/providers/index.d.cts +19 -0
- package/dist/providers/index.d.ts +19 -0
- package/dist/providers/index.js +63 -0
- package/dist/providers/intelligent-form-field-provider.cjs +1 -0
- package/dist/providers/intelligent-form-field-provider.d.cts +15 -0
- package/dist/providers/intelligent-form-field-provider.d.ts +15 -0
- package/dist/providers/intelligent-form-field-provider.js +19 -0
- package/dist/providers/markdown-provider.cjs +1 -0
- package/dist/providers/markdown-provider.d.cts +9 -0
- package/dist/providers/markdown-provider.d.ts +9 -0
- package/dist/providers/markdown-provider.js +8 -0
- package/dist/providers/message-attachments-provider.cjs +1 -0
- package/dist/providers/message-attachments-provider.d.cts +13 -0
- package/dist/providers/message-attachments-provider.d.ts +13 -0
- package/dist/providers/message-attachments-provider.js +27 -0
- package/dist/providers/message-provider.cjs +1 -0
- package/dist/providers/message-provider.d.cts +10 -0
- package/dist/providers/message-provider.d.ts +10 -0
- package/dist/providers/message-provider.js +14 -0
- package/dist/providers/root-provider.cjs +1 -0
- package/dist/providers/root-provider.d.cts +8 -0
- package/dist/providers/root-provider.d.ts +8 -0
- package/dist/providers/root-provider.js +21 -0
- package/dist/providers/search-events-provider.cjs +1 -0
- package/dist/providers/search-events-provider.d.cts +11 -0
- package/dist/providers/search-events-provider.d.ts +11 -0
- package/dist/providers/search-events-provider.js +18 -0
- package/dist/providers/source-item-provider.cjs +1 -0
- package/dist/providers/source-item-provider.d.cts +12 -0
- package/dist/providers/source-item-provider.d.ts +12 -0
- package/dist/providers/source-item-provider.js +13 -0
- package/dist/providers/theme-provider.cjs +1 -0
- package/dist/providers/theme-provider.d.cts +3 -0
- package/dist/providers/theme-provider.d.ts +3 -0
- package/dist/providers/theme-provider.js +65 -0
- package/dist/providers/user-provider.cjs +1 -0
- package/dist/providers/user-provider.d.cts +13 -0
- package/dist/providers/user-provider.d.ts +13 -0
- package/dist/providers/user-provider.js +34 -0
- package/dist/providers/widget-provider.cjs +1 -0
- package/dist/providers/widget-provider.d.cts +9 -0
- package/dist/providers/widget-provider.d.ts +9 -0
- package/dist/providers/widget-provider.js +8 -0
- package/dist/utils/component-ids.cjs +1 -0
- package/dist/utils/component-ids.d.cts +632 -0
- package/dist/utils/component-ids.d.ts +632 -0
- package/dist/utils/component-ids.js +340 -0
- package/dist/utils/compose-event-handlers.cjs +1 -0
- package/dist/utils/compose-event-handlers.d.cts +3 -0
- package/dist/utils/compose-event-handlers.d.ts +3 -0
- package/dist/utils/compose-event-handlers.js +10 -0
- package/dist/utils/compose-refs.cjs +1 -0
- package/dist/utils/compose-refs.d.cts +5 -0
- package/dist/utils/compose-refs.d.ts +5 -0
- package/dist/utils/compose-refs.js +30 -0
- package/dist/utils/default-settings.cjs +1 -0
- package/dist/utils/default-settings.d.cts +244 -0
- package/dist/utils/default-settings.d.ts +244 -0
- package/dist/utils/default-settings.js +75 -0
- package/dist/utils/form.cjs +1 -0
- package/dist/utils/form.d.cts +3 -0
- package/dist/utils/form.d.ts +3 -0
- package/dist/utils/form.js +17 -0
- package/dist/utils/generate-uid.cjs +1 -0
- package/dist/utils/generate-uid.d.cts +2 -0
- package/dist/utils/generate-uid.d.ts +2 -0
- package/dist/utils/generate-uid.js +14 -0
- package/dist/utils/get-message-metadata.cjs +10 -0
- package/dist/utils/get-message-metadata.d.cts +8 -0
- package/dist/utils/get-message-metadata.d.ts +8 -0
- package/dist/utils/get-message-metadata.js +142 -0
- package/dist/utils/graphql-client.cjs +1 -0
- package/dist/utils/graphql-client.d.cts +8 -0
- package/dist/utils/graphql-client.d.ts +8 -0
- package/dist/utils/graphql-client.js +23 -0
- package/dist/utils/highlight-emphasis.cjs +1 -0
- package/dist/utils/highlight-emphasis.d.cts +4 -0
- package/dist/utils/highlight-emphasis.d.ts +4 -0
- package/dist/utils/highlight-emphasis.js +15 -0
- package/dist/utils/merge-props.cjs +1 -0
- package/dist/utils/merge-props.d.cts +7 -0
- package/dist/utils/merge-props.d.ts +7 -0
- package/dist/utils/merge-props.js +41 -0
- package/dist/utils/misc.cjs +1 -0
- package/dist/utils/misc.d.cts +13 -0
- package/dist/utils/misc.d.ts +13 -0
- package/dist/utils/misc.js +36 -0
- package/dist/utils/reset-query-params.cjs +1 -0
- package/dist/utils/reset-query-params.d.cts +1 -0
- package/dist/utils/reset-query-params.d.ts +1 -0
- package/dist/utils/reset-query-params.js +13 -0
- package/dist/utils/tools/links-schema.cjs +1 -0
- package/dist/utils/tools/links-schema.d.cts +64 -0
- package/dist/utils/tools/links-schema.d.ts +64 -0
- package/dist/utils/tools/links-schema.js +85 -0
- package/dist/utils/transform-source/breadcrumbs.cjs +1 -0
- package/dist/utils/transform-source/breadcrumbs.d.cts +2 -0
- package/dist/utils/transform-source/breadcrumbs.d.ts +2 -0
- package/dist/utils/transform-source/breadcrumbs.js +16 -0
- package/dist/utils/transform-source/common-words/long.cjs +1 -0
- package/dist/utils/transform-source/common-words/long.d.cts +1 -0
- package/dist/utils/transform-source/common-words/long.d.ts +1 -0
- package/dist/utils/transform-source/common-words/long.js +69 -0
- package/dist/utils/transform-source/common-words/lowercase.cjs +1 -0
- package/dist/utils/transform-source/common-words/lowercase.d.cts +1 -0
- package/dist/utils/transform-source/common-words/lowercase.d.ts +1 -0
- package/dist/utils/transform-source/common-words/lowercase.js +48 -0
- package/dist/utils/transform-source/common-words/short.cjs +1 -0
- package/dist/utils/transform-source/common-words/short.d.cts +1 -0
- package/dist/utils/transform-source/common-words/short.d.ts +1 -0
- package/dist/utils/transform-source/common-words/short.js +141 -0
- package/dist/utils/transform-source/description.cjs +1 -0
- package/dist/utils/transform-source/description.d.cts +2 -0
- package/dist/utils/transform-source/description.d.ts +2 -0
- package/dist/utils/transform-source/description.js +10 -0
- package/dist/utils/transform-source/icon.cjs +1 -0
- package/dist/utils/transform-source/icon.d.cts +2 -0
- package/dist/utils/transform-source/icon.d.ts +2 -0
- package/dist/utils/transform-source/icon.js +9 -0
- package/dist/utils/transform-source/index.cjs +1 -0
- package/dist/utils/transform-source/index.d.cts +2 -0
- package/dist/utils/transform-source/index.d.ts +2 -0
- package/dist/utils/transform-source/index.js +21 -0
- package/dist/utils/transform-source/tabs.cjs +1 -0
- package/dist/utils/transform-source/tabs.d.cts +2 -0
- package/dist/utils/transform-source/tabs.d.ts +2 -0
- package/dist/utils/transform-source/tabs.js +13 -0
- package/dist/utils/transform-source/title.cjs +1 -0
- package/dist/utils/transform-source/title.d.cts +2 -0
- package/dist/utils/transform-source/title.d.ts +2 -0
- package/dist/utils/transform-source/title.js +12 -0
- package/dist/utils/transform-source/utils/description-without-title.cjs +1 -0
- package/dist/utils/transform-source/utils/description-without-title.d.cts +11 -0
- package/dist/utils/transform-source/utils/description-without-title.d.ts +11 -0
- package/dist/utils/transform-source/utils/description-without-title.js +12 -0
- package/dist/utils/transform-source/utils/index.cjs +1 -0
- package/dist/utils/transform-source/utils/index.d.cts +6 -0
- package/dist/utils/transform-source/utils/index.d.ts +6 -0
- package/dist/utils/transform-source/utils/index.js +16 -0
- package/dist/utils/transform-source/utils/misc.cjs +1 -0
- package/dist/utils/transform-source/utils/misc.d.cts +2 -0
- package/dist/utils/transform-source/utils/misc.d.ts +2 -0
- package/dist/utils/transform-source/utils/misc.js +15 -0
- package/dist/utils/transform-source/utils/standardize-common-words.cjs +1 -0
- package/dist/utils/transform-source/utils/standardize-common-words.d.cts +1 -0
- package/dist/utils/transform-source/utils/standardize-common-words.d.ts +1 -0
- package/dist/utils/transform-source/utils/standardize-common-words.js +26 -0
- package/dist/utils/transform-source/utils/standardize-organization-display-name.cjs +1 -0
- package/dist/utils/transform-source/utils/standardize-organization-display-name.d.cts +8 -0
- package/dist/utils/transform-source/utils/standardize-organization-display-name.d.ts +8 -0
- package/dist/utils/transform-source/utils/standardize-organization-display-name.js +10 -0
- package/dist/utils/transform-source/utils/standardize-suffixes.cjs +1 -0
- package/dist/utils/transform-source/utils/standardize-suffixes.d.cts +5 -0
- package/dist/utils/transform-source/utils/standardize-suffixes.d.ts +5 -0
- package/dist/utils/transform-source/utils/standardize-suffixes.js +16 -0
- package/dist/utils/transform-source/utils/strip-branding-keywords.cjs +1 -0
- package/dist/utils/transform-source/utils/strip-branding-keywords.d.cts +17 -0
- package/dist/utils/transform-source/utils/strip-branding-keywords.d.ts +17 -0
- package/dist/utils/transform-source/utils/strip-branding-keywords.js +14 -0
- package/package.json +111 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),o=r.createContext(null);function a({error:e,styleSheets:t,root:n}){switch(e?.name){case"NotSupportedError":t.length>0&&n&&(n.adoptedStyleSheets=t);break;default:throw e}}exports.Context=o;exports.handleError=a;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Context } from 'react';
|
|
2
|
+
export declare const Context: Context<ShadowRoot | null>;
|
|
3
|
+
interface ErrorWithStyleSheets {
|
|
4
|
+
error: Error;
|
|
5
|
+
styleSheets: CSSStyleSheet[];
|
|
6
|
+
root: ShadowRoot | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function handleError({ error, styleSheets, root }: ErrorWithStyleSheets): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Context } from 'react';
|
|
2
|
+
export declare const Context: Context<ShadowRoot | null>;
|
|
3
|
+
interface ErrorWithStyleSheets {
|
|
4
|
+
error: Error;
|
|
5
|
+
styleSheets: CSSStyleSheet[];
|
|
6
|
+
root: ShadowRoot | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function handleError({ error, styleSheets, root }: ErrorWithStyleSheets): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext as o } from "react";
|
|
3
|
+
const a = o(null);
|
|
4
|
+
function c({ error: t, styleSheets: e, root: n }) {
|
|
5
|
+
switch (t?.name) {
|
|
6
|
+
case "NotSupportedError":
|
|
7
|
+
e.length > 0 && n && (n.adoptedStyleSheets = e);
|
|
8
|
+
break;
|
|
9
|
+
default:
|
|
10
|
+
throw t;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
a as Context,
|
|
15
|
+
c as handleError
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("react"),h=require("@radix-ui/react-avatar"),n=require("./factory.cjs"),B=require("../atoms/avatars/ai.cjs"),_=require("../providers/config-provider.cjs"),f=require("../utils/compose-event-handlers.cjs");function p(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(a,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return a.default=t,Object.freeze(a)}const v=p(h),A=n.ikp("div",{_id:"chatButton__Container"}),P=n.ikp("button",{_id:"chatButton__Button"}),b=n.ikp("div",{_id:"chatButton__Text"}),S=n.ikp(v.Root,{_id:"chatButton__AvatarContent"}),k=n.ikp(v.Image,{_id:"chatButton__AvatarImage"}),d=i.memo(t=>{const{onLoadingStatusChange:a,...e}=t,{aiChatSettings:o}=_.useInkeepConfig(),{botAvatarSrcUrl:m,botAvatarDarkSrcUrl:l}=o??{},r=l??m,[u,c]=i.useState(r);i.useEffect(()=>{c(r)},[r]);const g=C=>{C==="error"&&c(null)};return u?s.jsx(k,{src:u,"data-type":"image",onLoadingStatusChange:f.composeEventHandlers(a,g),...e}):s.jsx(B.default,{"data-type":"icon",...t})});exports.ChatButton=P;exports.ChatButtonAvatarContent=S;exports.ChatButtonAvatarImage=d;exports.ChatButtonContainer=A;exports.ChatButtonPrimitiveAvatarImage=d;exports.ChatButtonText=b;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ForwardRefExoticComponent, DetailedHTMLProps, HTMLAttributes, ButtonHTMLAttributes, RefAttributes, MemoExoticComponent } from 'react';
|
|
2
|
+
import { PolymorphicProps } from './factory';
|
|
3
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
4
|
+
declare const ChatButtonPrimitiveContainer: ForwardRefExoticComponent< PolymorphicProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "_id"> & Partial<Pick< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "_id">>>;
|
|
5
|
+
declare const ChatButtonPrimitiveButton: ForwardRefExoticComponent< PolymorphicProps & Omit< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "_id"> & Partial<Pick< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "_id">>>;
|
|
6
|
+
declare const ChatButtonPrimitiveText: ForwardRefExoticComponent< PolymorphicProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "_id"> & Partial<Pick< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "_id">>>;
|
|
7
|
+
declare const PrimitiveChatButtonAvatarContent: ForwardRefExoticComponent< PolymorphicProps & Omit<AvatarPrimitive.AvatarProps & RefAttributes<HTMLSpanElement>, "_id"> & Partial<Pick<AvatarPrimitive.AvatarProps & RefAttributes<HTMLSpanElement>, "_id">>>;
|
|
8
|
+
declare const PrimitiveChatButtonAvatarImage: ForwardRefExoticComponent< PolymorphicProps & Omit<AvatarPrimitive.AvatarImageProps & RefAttributes<HTMLImageElement>, "_id"> & Partial<Pick<AvatarPrimitive.AvatarImageProps & RefAttributes<HTMLImageElement>, "_id">>>;
|
|
9
|
+
type ChatButtonPrimitiveAvatarImageProps = ComponentPropsWithRef<'svg'> | ComponentPropsWithRef<typeof PrimitiveChatButtonAvatarImage>;
|
|
10
|
+
export declare const ChatButtonPrimitiveAvatarImage: MemoExoticComponent<(props: ChatButtonPrimitiveAvatarImageProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
export { ChatButtonPrimitiveContainer as ChatButtonContainer, ChatButtonPrimitiveText as ChatButtonText, ChatButtonPrimitiveButton as ChatButton, ChatButtonPrimitiveAvatarImage as ChatButtonAvatarImage, PrimitiveChatButtonAvatarContent as ChatButtonAvatarContent, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ForwardRefExoticComponent, DetailedHTMLProps, HTMLAttributes, ButtonHTMLAttributes, RefAttributes, MemoExoticComponent } from 'react';
|
|
2
|
+
import { PolymorphicProps } from './factory';
|
|
3
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
4
|
+
declare const ChatButtonPrimitiveContainer: ForwardRefExoticComponent< PolymorphicProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "_id"> & Partial<Pick< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "_id">>>;
|
|
5
|
+
declare const ChatButtonPrimitiveButton: ForwardRefExoticComponent< PolymorphicProps & Omit< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "_id"> & Partial<Pick< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "_id">>>;
|
|
6
|
+
declare const ChatButtonPrimitiveText: ForwardRefExoticComponent< PolymorphicProps & Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "_id"> & Partial<Pick< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "_id">>>;
|
|
7
|
+
declare const PrimitiveChatButtonAvatarContent: ForwardRefExoticComponent< PolymorphicProps & Omit<AvatarPrimitive.AvatarProps & RefAttributes<HTMLSpanElement>, "_id"> & Partial<Pick<AvatarPrimitive.AvatarProps & RefAttributes<HTMLSpanElement>, "_id">>>;
|
|
8
|
+
declare const PrimitiveChatButtonAvatarImage: ForwardRefExoticComponent< PolymorphicProps & Omit<AvatarPrimitive.AvatarImageProps & RefAttributes<HTMLImageElement>, "_id"> & Partial<Pick<AvatarPrimitive.AvatarImageProps & RefAttributes<HTMLImageElement>, "_id">>>;
|
|
9
|
+
type ChatButtonPrimitiveAvatarImageProps = ComponentPropsWithRef<'svg'> | ComponentPropsWithRef<typeof PrimitiveChatButtonAvatarImage>;
|
|
10
|
+
export declare const ChatButtonPrimitiveAvatarImage: MemoExoticComponent<(props: ChatButtonPrimitiveAvatarImageProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
export { ChatButtonPrimitiveContainer as ChatButtonContainer, ChatButtonPrimitiveText as ChatButtonText, ChatButtonPrimitiveButton as ChatButton, ChatButtonPrimitiveAvatarImage as ChatButtonAvatarImage, PrimitiveChatButtonAvatarContent as ChatButtonAvatarContent, };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { memo as C, useState as d, useEffect as B } from "react";
|
|
4
|
+
import * as i from "@radix-ui/react-avatar";
|
|
5
|
+
import { ikp as t } from "./factory.js";
|
|
6
|
+
import g from "../atoms/avatars/ai.js";
|
|
7
|
+
import { useInkeepConfig as _ } from "../providers/config-provider.js";
|
|
8
|
+
import { composeEventHandlers as A } from "../utils/compose-event-handlers.js";
|
|
9
|
+
const k = t("div", {
|
|
10
|
+
_id: "chatButton__Container"
|
|
11
|
+
}), L = t("button", {
|
|
12
|
+
_id: "chatButton__Button"
|
|
13
|
+
}), b = t("div", {
|
|
14
|
+
_id: "chatButton__Text"
|
|
15
|
+
}), T = t(i.Root, {
|
|
16
|
+
_id: "chatButton__AvatarContent"
|
|
17
|
+
}), f = t(i.Image, {
|
|
18
|
+
_id: "chatButton__AvatarImage"
|
|
19
|
+
}), y = C((o) => {
|
|
20
|
+
const { onLoadingStatusChange: s, ...m } = o, { aiChatSettings: u } = _(), { botAvatarSrcUrl: c, botAvatarDarkSrcUrl: h } = u ?? {}, a = h ?? c, [n, r] = d(a);
|
|
21
|
+
return B(() => {
|
|
22
|
+
r(a);
|
|
23
|
+
}, [a]), n ? /* @__PURE__ */ e(
|
|
24
|
+
f,
|
|
25
|
+
{
|
|
26
|
+
src: n,
|
|
27
|
+
"data-type": "image",
|
|
28
|
+
onLoadingStatusChange: A(s, (v) => {
|
|
29
|
+
v === "error" && r(null);
|
|
30
|
+
}),
|
|
31
|
+
...m
|
|
32
|
+
}
|
|
33
|
+
) : /* @__PURE__ */ e(g, { "data-type": "icon", ...o });
|
|
34
|
+
});
|
|
35
|
+
export {
|
|
36
|
+
L as ChatButton,
|
|
37
|
+
T as ChatButtonAvatarContent,
|
|
38
|
+
y as ChatButtonAvatarImage,
|
|
39
|
+
k as ChatButtonContainer,
|
|
40
|
+
y as ChatButtonPrimitiveAvatarImage,
|
|
41
|
+
b as ChatButtonText
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),c=require("./use-inkeep-chat.cjs"),a=require("../../providers/feedback-provider.cjs"),u=require("@radix-ui/react-tooltip"),d=require("../../providers/chat-form-provider.cjs"),v=require("../../providers/conversation-provider.cjs"),h=require("../../providers/chat-events-provider.cjs");function l(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const P=l(u),s=i.createContext(void 0),C=e=>t.jsx(v.InkeepConversationProvider,{children:t.jsx(h.ChatEventsProviderWithBase,{children:t.jsx(d.ChatFormProvider,{children:t.jsx(j,{...e})})})}),j=({children:e,...o})=>{const r=c.useInkeepChat();return t.jsx(s.Provider,{value:{...r,...o},children:t.jsx(a.FeedbackProvider,{children:t.jsx(P.Provider,{children:e})})})},p=()=>{const e=i.useContext(s);if(!e)throw new Error("useChat must be used within a ChatProvider");return e};exports.ChatProvider=C;exports.useChat=p;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useInkeepChat } from './use-inkeep-chat';
|
|
2
|
+
export interface EmbeddedChatProviderProps {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to show the chat.
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
7
|
+
isHidden?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether to autofocus the chat input on load.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
shouldAutoFocusInput?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type ChatContextValue = ReturnType<typeof useInkeepChat> & Omit<ChatProviderProps, 'children'>;
|
|
15
|
+
export interface ChatProviderProps extends Pick<EmbeddedChatProviderProps, 'shouldAutoFocusInput' | 'isHidden'> {
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare const ChatProvider: React.FC<ChatProviderProps>;
|
|
19
|
+
export declare const useChat: () => ChatContextValue;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useInkeepChat } from './use-inkeep-chat';
|
|
2
|
+
export interface EmbeddedChatProviderProps {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to show the chat.
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
7
|
+
isHidden?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether to autofocus the chat input on load.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
shouldAutoFocusInput?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type ChatContextValue = ReturnType<typeof useInkeepChat> & Omit<ChatProviderProps, 'children'>;
|
|
15
|
+
export interface ChatProviderProps extends Pick<EmbeddedChatProviderProps, 'shouldAutoFocusInput' | 'isHidden'> {
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare const ChatProvider: React.FC<ChatProviderProps>;
|
|
19
|
+
export declare const useChat: () => ChatContextValue;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as n, createContext as m } from "react";
|
|
4
|
+
import { useInkeepChat as h } from "./use-inkeep-chat.js";
|
|
5
|
+
import { FeedbackProvider as s } from "../../providers/feedback-provider.js";
|
|
6
|
+
import * as a from "@radix-ui/react-tooltip";
|
|
7
|
+
import { ChatFormProvider as d } from "../../providers/chat-form-provider.js";
|
|
8
|
+
import { InkeepConversationProvider as c } from "../../providers/conversation-provider.js";
|
|
9
|
+
import { ChatEventsProviderWithBase as v } from "../../providers/chat-events-provider.js";
|
|
10
|
+
const e = m(void 0), w = (t) => /* @__PURE__ */ r(c, { children: /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(p, { ...t }) }) }) }), p = ({ children: t, ...o }) => {
|
|
11
|
+
const i = h();
|
|
12
|
+
return /* @__PURE__ */ r(e.Provider, { value: { ...i, ...o }, children: /* @__PURE__ */ r(s, { children: /* @__PURE__ */ r(a.Provider, { children: t }) }) });
|
|
13
|
+
}, I = () => {
|
|
14
|
+
const t = n(e);
|
|
15
|
+
if (!t)
|
|
16
|
+
throw new Error("useChat must be used within a ChatProvider");
|
|
17
|
+
return t;
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
w as ChatProvider,
|
|
21
|
+
I as useChat
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("altcha-lib"),l=require("react"),f={getSolution:async()=>{},prefetchSolution:()=>{},invalidateSolution:()=>{}},u=async n=>{try{const t=await fetch(n,{method:"GET"});if(!t.ok)throw new Error(`Failed to fetch challenge: ${t.statusText}`);const o=await t.json(),{challenge:e,algorithm:r,salt:c,maxnumber:s}=o,{promise:a}=await h.solveChallenge(e,c,r,s),i=await a||void 0;if(!i)throw new Error("Challenge not solved");return{number:i.number,...o}}catch(t){console.error("Error solving captcha:",t)}},g=({fetchUrl:n,bypassChallenge:t=!1,shouldMakeInitialRequest:o=!0})=>{if(t)return f;const e=l.useRef(null),r=l.useCallback(()=>{e.current||(e.current=u(n))},[n]),c=l.useCallback(async()=>{let a=await e.current;return a||(e.current=u(n),a=await e.current),e.current=null,a},[n]),s=l.useCallback(()=>{e.current=null},[]);return l.useEffect(()=>{o&&r()},[r,o]),{getSolution:c,prefetchSolution:r,invalidateSolution:s}};exports.fetchAndSolveChallenge=u;exports.useCaptcha=g;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Payload } from 'altcha-lib/types';
|
|
2
|
+
interface UseCaptchaOptions {
|
|
3
|
+
fetchUrl: string;
|
|
4
|
+
bypassChallenge?: boolean;
|
|
5
|
+
shouldMakeInitialRequest?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const fetchAndSolveChallenge: (fetchUrl: string) => Promise<Payload | undefined>;
|
|
8
|
+
export declare const useCaptcha: ({ fetchUrl, bypassChallenge, shouldMakeInitialRequest, }: UseCaptchaOptions) => {
|
|
9
|
+
getSolution: () => Promise<Payload | undefined>;
|
|
10
|
+
prefetchSolution: () => void;
|
|
11
|
+
invalidateSolution: () => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Payload } from 'altcha-lib/types';
|
|
2
|
+
interface UseCaptchaOptions {
|
|
3
|
+
fetchUrl: string;
|
|
4
|
+
bypassChallenge?: boolean;
|
|
5
|
+
shouldMakeInitialRequest?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const fetchAndSolveChallenge: (fetchUrl: string) => Promise<Payload | undefined>;
|
|
8
|
+
export declare const useCaptcha: ({ fetchUrl, bypassChallenge, shouldMakeInitialRequest, }: UseCaptchaOptions) => {
|
|
9
|
+
getSolution: () => Promise<Payload | undefined>;
|
|
10
|
+
prefetchSolution: () => void;
|
|
11
|
+
invalidateSolution: () => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { solveChallenge as f } from "altcha-lib";
|
|
3
|
+
import { useRef as h, useCallback as s, useEffect as m } from "react";
|
|
4
|
+
const g = {
|
|
5
|
+
getSolution: async () => {
|
|
6
|
+
},
|
|
7
|
+
prefetchSolution: () => {
|
|
8
|
+
},
|
|
9
|
+
invalidateSolution: () => {
|
|
10
|
+
}
|
|
11
|
+
}, u = async (n) => {
|
|
12
|
+
try {
|
|
13
|
+
const t = await fetch(n, {
|
|
14
|
+
method: "GET"
|
|
15
|
+
});
|
|
16
|
+
if (!t.ok)
|
|
17
|
+
throw new Error(`Failed to fetch challenge: ${t.statusText}`);
|
|
18
|
+
const e = await t.json(), { challenge: o, algorithm: r, salt: a, maxnumber: c } = e, { promise: l } = await f(
|
|
19
|
+
o,
|
|
20
|
+
a,
|
|
21
|
+
r,
|
|
22
|
+
c
|
|
23
|
+
), i = await l || void 0;
|
|
24
|
+
if (!i)
|
|
25
|
+
throw new Error("Challenge not solved");
|
|
26
|
+
return { number: i.number, ...e };
|
|
27
|
+
} catch (t) {
|
|
28
|
+
console.error("Error solving captcha:", t);
|
|
29
|
+
}
|
|
30
|
+
}, v = ({
|
|
31
|
+
fetchUrl: n,
|
|
32
|
+
bypassChallenge: t = !1,
|
|
33
|
+
shouldMakeInitialRequest: e = !0
|
|
34
|
+
}) => {
|
|
35
|
+
if (t)
|
|
36
|
+
return g;
|
|
37
|
+
const o = h(null), r = s(() => {
|
|
38
|
+
o.current || (o.current = u(n));
|
|
39
|
+
}, [n]), a = s(async () => {
|
|
40
|
+
let l = await o.current;
|
|
41
|
+
return l || (o.current = u(n), l = await o.current), o.current = null, l;
|
|
42
|
+
}, [n]), c = s(() => {
|
|
43
|
+
o.current = null;
|
|
44
|
+
}, []);
|
|
45
|
+
return m(() => {
|
|
46
|
+
e && r();
|
|
47
|
+
}, [r, e]), {
|
|
48
|
+
getSolution: a,
|
|
49
|
+
prefetchSolution: r,
|
|
50
|
+
invalidateSolution: c
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
u as fetchAndSolveChallenge,
|
|
55
|
+
v as useCaptcha
|
|
56
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../providers/conversation-provider.cjs"),u=require("../../providers/chat-events-provider.cjs"),d=require("../../providers/chat-form-provider.cjs"),p=require("../modal/modal-provider.cjs"),v=e=>{const{logEvent:t}=u.useChatEvents(),{conversation:o}=c.useInkeepConversation(),{openForm:r}=d.useChatForm(),s=p.useModal(),i=a=>{e.action.type==="OPEN_FORM"?(a?.onOpenForm?.(),r?.(e.action.formConfig)):e.action.type==="INVOKE_CALLBACK"&&(e.action.callback({conversation:o}),e.action.shouldCloseModal&&s?.closeModal())},n=e.action.type,l=n==="OPEN_LINK"?e.action.url:void 0;return{handleAction:i,logHelpAction:()=>{"name"in e&&t({eventName:"get_help_option_clicked",properties:{actionType:n,name:e.name,url:l,conversationId:o.id}})}}};exports.useChatAction=v;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IkpChatAction } from '@inkeep/cxkit-types';
|
|
2
|
+
interface HandleAction {
|
|
3
|
+
onOpenForm?: Function;
|
|
4
|
+
}
|
|
5
|
+
export declare const useChatAction: (chatAction: IkpChatAction) => {
|
|
6
|
+
handleAction: (opts?: HandleAction) => void;
|
|
7
|
+
logHelpAction: () => void;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IkpChatAction } from '@inkeep/cxkit-types';
|
|
2
|
+
interface HandleAction {
|
|
3
|
+
onOpenForm?: Function;
|
|
4
|
+
}
|
|
5
|
+
export declare const useChatAction: (chatAction: IkpChatAction) => {
|
|
6
|
+
handleAction: (opts?: HandleAction) => void;
|
|
7
|
+
logHelpAction: () => void;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useInkeepConversation as a } from "../../providers/conversation-provider.js";
|
|
3
|
+
import { useChatEvents as m } from "../../providers/chat-events-provider.js";
|
|
4
|
+
import { useChatForm as c } from "../../providers/chat-form-provider.js";
|
|
5
|
+
import { useModal as u } from "../modal/modal-provider.js";
|
|
6
|
+
const g = (o) => {
|
|
7
|
+
const { logEvent: t } = m(), { conversation: e } = a(), { openForm: r } = c(), s = u(), i = (p) => {
|
|
8
|
+
o.action.type === "OPEN_FORM" ? (p?.onOpenForm?.(), r?.(o.action.formConfig)) : o.action.type === "INVOKE_CALLBACK" && (o.action.callback({
|
|
9
|
+
conversation: e
|
|
10
|
+
}), o.action.shouldCloseModal && s?.closeModal());
|
|
11
|
+
}, n = o.action.type, l = n === "OPEN_LINK" ? o.action.url : void 0;
|
|
12
|
+
return { handleAction: i, logHelpAction: () => {
|
|
13
|
+
"name" in o && t({
|
|
14
|
+
eventName: "get_help_option_clicked",
|
|
15
|
+
properties: {
|
|
16
|
+
actionType: n,
|
|
17
|
+
name: o.name,
|
|
18
|
+
url: l,
|
|
19
|
+
conversationId: e.id
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
} };
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
g as useChatAction
|
|
26
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const be=require("openai"),t=require("react"),qe=require("../../atoms/api/analytics/conversation.cjs"),Pe=require("../../providers/config-provider.cjs"),Ee=require("../../providers/conversation-provider.cjs"),_e=require("../../providers/chat-events-provider.cjs"),$=require("../../utils/get-message-metadata.cjs"),V=require("../../utils/misc.cjs"),X=require("../../utils/reset-query-params.cjs"),Ne=require("../../providers/chat-form-provider.cjs"),Re=require("../../providers/widget-provider.cjs"),Ae=require("../../hooks/use-media-query.cjs"),Le=require("./use-captcha.cjs"),$e=require("../modal/modal-provider.cjs"),xe=()=>{const{chatId:m,setConversation:Y,conversation:Z,resetConversation:ee}=Ee.useInkeepConversation(),{baseSettings:k,aiChatSettings:x}=Pe.useInkeepConfig(),{baseUrl:D,bypassChallenge:U}=k,K=$e.useModal(),{getSolution:te,prefetchSolution:b,invalidateSolution:O}=Le.useCaptcha({fetchUrl:`${D}/v1/challenge`,bypassChallenge:U,shouldMakeInitialRequest:K?K.open:!0}),se=new be({baseURL:`${D}/v1`,apiKey:k.apiKey,dangerouslyAllowBrowser:!0}),{onInputMessageChange:ne,tools:oe,prompts:ae,model:re,onToolCall:ie}=x,[h,_]=t.useState(""),T=t.useRef(null);t.useEffect(()=>{ne?.(h)},[h]);const[u,l]=t.useState([]),[F,p]=t.useState(!1),[ce,f]=t.useState(!1),[le,Q]=t.useState(null),[v,W]=t.useState(null),[I,y]=t.useState([]),ue=e=>{y(n=>[...n,e])},[de,z]=t.useState({}),i=t.useRef([]),S=t.useRef(null),{logEvent:q}=_e.useChatEvents(),B=ae?.map((e,n)=>({id:`system-${n}`,role:"system",content:e})),[ge,me]=t.useState(!!m);t.useEffect(()=>{if(m){const{apiKey:e,analyticsBaseUrl:n}=k;q({eventName:"chat_shared_session_loaded",properties:{conversationId:m}}),qe.getConversation(m,e,n).then(o=>{if(o){me(!1),Y({...o,id:""});const a=o.messages.map(c=>({id:Date.now().toString()+c.id,content:V.parseIfJson(c.content),role:c.role,links:c.links}));l(a),i.current=a}})}},[m]);const he=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${k.organizationDisplayName??"Administrator"}`;default:return`Hmm..
|
|
2
|
+
|
|
3
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`}},H=e=>{Q(e),l(n=>{const o=[...n],a=o[o.length-1];return a&&(a.content=he(e)),o}),p(!1),f(!1),O(),b()},N=!h.trim()&&!I.length||F,pe=e=>{e.key==="Enter"&&!e.shiftKey&&!N&&!e.nativeEvent.isComposing&&(e.preventDefault(),R())},fe=e=>{const n=e.target.value;_(n)},R=async(e=h)=>{if(N&&(!e||e.trim().length===0))return;p(!0);const n=v?u.length===2:u.length===0,o=$.getMessageMetadata(v,I,n);let a;const c=$.serializeAttachments(I);I.length&&c?a=[{type:"text",text:c}]:a=e;const P={id:`${Date.now().toString()}1`,role:"user",content:a,metadata:o},E=[...u.length?[]:B,P];m&&X.resetQueryParams(),l(C=>[...C,...E]),i.current=[...i.current,...E],y([]),_(""),q({eventName:"chat_message_submitted",properties:{messages:i.current,messageId:P.id,content:e,workflowId:v?.id}});try{const C={model:re,messages:i.current,stream:!0,tools:oe,tool_choice:"auto"},j=await te(),Me=j?btoa(JSON.stringify(j)):null,G=U?void 0:{"X-INKEEP-CHALLENGE-SOLUTION":Me},M=se.beta.chat.completions.stream(C,G?{headers:G}:void 0),s={id:`${Date.now().toString()}2`,role:"assistant",content:"",links:[]};l(d=>[...d,s]),M.on("content",(d,A)=>{f(!0),s.content=A,l(L=>{const r=[...L],g=r.findIndex(w=>w.id===s.id);return g===-1?[...r,s]:(r[g]={...s},r)})}),M.on("tool_calls.function.arguments.done",d=>{const{name:A,arguments:L}=d;if(A==="provideLinks"){const r=JSON.parse(L);r.links?.length>0&&(s.links=r.links,l(g=>{const w=[...g],we=w.findIndex(ke=>ke.id===s.id);return w[we]={...s},w}))}else{const r=ie?.(d);r&&z(g=>({...g,[s.id]:[...g[s.id]||[],r]}))}}),M.on("error",d=>{H(d)}),M.finalChatCompletion().then(()=>{i.current=[...i.current,s],S.current=null,p(!1),f(!1),b(),q({eventName:"chat_message_bot_response_received",properties:{messages:i.current,messageId:s.id,question:V.getMessageContent(P),responseMessage:s,linksUsedInResponse:s.links,workflowId:v?.id}})}),S.current=M.controller}catch(C){H(C),p(!1),f(!1)}},ve=()=>{S.current&&(S.current.abort(),S.current=null),p(!1),f(!1),b()},J=()=>{Q(null),l([]),i.current=[],ee(),z({}),y([]),X.resetQueryParams(),W(null),O(),b(),q({eventName:"chat_history_cleared",properties:{conversationId:Z.id}})},Ie=e=>{W(e);const{initialReplyMessage:n,displayName:o}=e,a={id:u.length.toString(),role:"user",content:o},c={id:(u.length+1).toString(),role:"assistant",content:n,links:[]},E=[{id:`system-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
|
|
4
|
+
${$.serializeWorkflow(e)}`},...B,a,c];l(E),y([])},{openForm:ye}=Ne.useChatForm(),Se=Re.useWidget();t.useImperativeHandle(x.chatFunctionsRef,()=>({submitMessage:R,updateInputMessage(e){_(e)},clearChat:J,openForm:e=>{Se?.setView("chat"),ye(e)},focusInput:()=>{T.current?.focus()}}));const Ce=Ae.useMediaQuery("(max-width: 768px)");return{messages:u,input:h,isLoading:F,isStreaming:ce,isLoadingConversation:ge,error:le,isSubmitDisabled:N,handleInputChange:fe,handleInputKeyDown:pe,handleSubmit:R,stop:ve,clear:J,handleWorkflow:Ie,selectedWorkflow:v,messageAttachments:I,setMessageAttachments:y,addAttachment:ue,messageToolCalls:de,isEmpty:u.length===0,inputRef:T,isMobile:Ce}};exports.useInkeepChat=xe;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { KeyboardEvent, Dispatch, SetStateAction, RefObject } from 'react';
|
|
2
|
+
import { ToolCallAction, MessageAttachment, Workflow, Message } from '@inkeep/cxkit-types';
|
|
3
|
+
export declare const useInkeepChat: () => {
|
|
4
|
+
messages: Message[];
|
|
5
|
+
input: string;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
isStreaming: boolean;
|
|
8
|
+
isLoadingConversation: boolean;
|
|
9
|
+
error: unknown;
|
|
10
|
+
isSubmitDisabled: boolean;
|
|
11
|
+
handleInputChange: (e: React.ChangeEvent<HTMLElement>) => void;
|
|
12
|
+
handleInputKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
13
|
+
handleSubmit: (content?: string) => Promise<void>;
|
|
14
|
+
stop: () => void;
|
|
15
|
+
clear: () => void;
|
|
16
|
+
handleWorkflow: (workflow: Workflow) => void;
|
|
17
|
+
selectedWorkflow: Workflow | null;
|
|
18
|
+
messageAttachments: MessageAttachment[];
|
|
19
|
+
setMessageAttachments: Dispatch<SetStateAction<MessageAttachment[]>>;
|
|
20
|
+
addAttachment: (attachment: MessageAttachment) => void;
|
|
21
|
+
messageToolCalls: Record<string, ToolCallAction[]>;
|
|
22
|
+
isEmpty: boolean;
|
|
23
|
+
inputRef: RefObject<HTMLTextAreaElement | null>;
|
|
24
|
+
isMobile: boolean;
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { KeyboardEvent, Dispatch, SetStateAction, RefObject } from 'react';
|
|
2
|
+
import { ToolCallAction, MessageAttachment, Workflow, Message } from '@inkeep/cxkit-types';
|
|
3
|
+
export declare const useInkeepChat: () => {
|
|
4
|
+
messages: Message[];
|
|
5
|
+
input: string;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
isStreaming: boolean;
|
|
8
|
+
isLoadingConversation: boolean;
|
|
9
|
+
error: unknown;
|
|
10
|
+
isSubmitDisabled: boolean;
|
|
11
|
+
handleInputChange: (e: React.ChangeEvent<HTMLElement>) => void;
|
|
12
|
+
handleInputKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
13
|
+
handleSubmit: (content?: string) => Promise<void>;
|
|
14
|
+
stop: () => void;
|
|
15
|
+
clear: () => void;
|
|
16
|
+
handleWorkflow: (workflow: Workflow) => void;
|
|
17
|
+
selectedWorkflow: Workflow | null;
|
|
18
|
+
messageAttachments: MessageAttachment[];
|
|
19
|
+
setMessageAttachments: Dispatch<SetStateAction<MessageAttachment[]>>;
|
|
20
|
+
addAttachment: (attachment: MessageAttachment) => void;
|
|
21
|
+
messageToolCalls: Record<string, ToolCallAction[]>;
|
|
22
|
+
isEmpty: boolean;
|
|
23
|
+
inputRef: RefObject<HTMLTextAreaElement | null>;
|
|
24
|
+
isMobile: boolean;
|
|
25
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import be from "openai";
|
|
3
|
+
import { useState as c, useRef as D, useEffect as X, useImperativeHandle as _e } from "react";
|
|
4
|
+
import { getConversation as Ee } from "../../atoms/api/analytics/conversation.js";
|
|
5
|
+
import { useInkeepConfig as Ne } from "../../providers/config-provider.js";
|
|
6
|
+
import { useInkeepConversation as xe } from "../../providers/conversation-provider.js";
|
|
7
|
+
import { useChatEvents as Ae } from "../../providers/chat-events-provider.js";
|
|
8
|
+
import { getMessageMetadata as Le, serializeAttachments as Re, serializeWorkflow as $e } from "../../utils/get-message-metadata.js";
|
|
9
|
+
import { parseIfJson as De, getMessageContent as Pe } from "../../utils/misc.js";
|
|
10
|
+
import { resetQueryParams as j } from "../../utils/reset-query-params.js";
|
|
11
|
+
import { useChatForm as Ue } from "../../providers/chat-form-provider.js";
|
|
12
|
+
import { useWidget as Ke } from "../../providers/widget-provider.js";
|
|
13
|
+
import { useMediaQuery as Oe } from "../../hooks/use-media-query.js";
|
|
14
|
+
import { useCaptcha as Te } from "./use-captcha.js";
|
|
15
|
+
import { useModal as We } from "../modal/modal-provider.js";
|
|
16
|
+
const tt = () => {
|
|
17
|
+
const { chatId: g, setConversation: Y, conversation: Z, resetConversation: ee } = xe(), { baseSettings: S, aiChatSettings: P } = Ne(), { baseUrl: U, bypassChallenge: K } = S, O = We(), { getSolution: te, prefetchSolution: b, invalidateSolution: T } = Te({
|
|
18
|
+
fetchUrl: `${U}/v1/challenge`,
|
|
19
|
+
bypassChallenge: K,
|
|
20
|
+
shouldMakeInitialRequest: O ? O.open : !0
|
|
21
|
+
}), se = new be({
|
|
22
|
+
baseURL: `${U}/v1`,
|
|
23
|
+
apiKey: S.apiKey,
|
|
24
|
+
dangerouslyAllowBrowser: !0
|
|
25
|
+
}), { onInputMessageChange: ne, tools: oe, prompts: ae, model: re, onToolCall: ie } = P, [p, x] = c(""), W = D(null);
|
|
26
|
+
X(() => {
|
|
27
|
+
ne?.(p);
|
|
28
|
+
}, [p]);
|
|
29
|
+
const [m, l] = c([]), [F, f] = c(!1), [ce, h] = c(!1), [le, z] = c(null), [I, B] = c(null), [w, y] = c([]), me = (e) => {
|
|
30
|
+
y((s) => [...s, e]);
|
|
31
|
+
}, [ue, H] = c({}), r = D([]), C = D(null), { logEvent: _ } = Ae(), J = ae?.map((e, s) => ({
|
|
32
|
+
id: `system-${s}`,
|
|
33
|
+
role: "system",
|
|
34
|
+
content: e
|
|
35
|
+
})), [de, ge] = c(!!g);
|
|
36
|
+
X(() => {
|
|
37
|
+
if (g) {
|
|
38
|
+
const { apiKey: e, analyticsBaseUrl: s } = S;
|
|
39
|
+
_({
|
|
40
|
+
eventName: "chat_shared_session_loaded",
|
|
41
|
+
properties: {
|
|
42
|
+
conversationId: g
|
|
43
|
+
}
|
|
44
|
+
}), Ee(g, e, s).then((n) => {
|
|
45
|
+
if (n) {
|
|
46
|
+
ge(!1), Y({ ...n, id: "" });
|
|
47
|
+
const o = n.messages.map((i) => ({
|
|
48
|
+
id: Date.now().toString() + i.id,
|
|
49
|
+
content: De(i.content),
|
|
50
|
+
role: i.role,
|
|
51
|
+
links: i.links
|
|
52
|
+
}));
|
|
53
|
+
l(o), r.current = o;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, [g]);
|
|
58
|
+
const pe = (e) => {
|
|
59
|
+
switch (e.code) {
|
|
60
|
+
case 400:
|
|
61
|
+
return e.message;
|
|
62
|
+
case 403:
|
|
63
|
+
return `There seems to be a configuration error. Please contact ${S.organizationDisplayName ?? "Administrator"}`;
|
|
64
|
+
default:
|
|
65
|
+
return `Hmm..
|
|
66
|
+
|
|
67
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`;
|
|
68
|
+
}
|
|
69
|
+
}, q = (e) => {
|
|
70
|
+
z(e), l((s) => {
|
|
71
|
+
const n = [...s], o = n[n.length - 1];
|
|
72
|
+
return o && (o.content = pe(e)), n;
|
|
73
|
+
}), f(!1), h(!1), T(), b();
|
|
74
|
+
}, A = !p.trim() && !w.length || F, fe = (e) => {
|
|
75
|
+
e.key === "Enter" && !e.shiftKey && !A && !e.nativeEvent.isComposing && (e.preventDefault(), L());
|
|
76
|
+
}, he = (e) => {
|
|
77
|
+
const s = e.target.value;
|
|
78
|
+
x(s);
|
|
79
|
+
}, L = async (e = p) => {
|
|
80
|
+
if (A && (!e || e.trim().length === 0)) return;
|
|
81
|
+
f(!0);
|
|
82
|
+
const s = I ? m.length === 2 : m.length === 0, n = Le(I, w, s);
|
|
83
|
+
let o;
|
|
84
|
+
const i = Re(w);
|
|
85
|
+
w.length && i ? o = [{ type: "text", text: i }] : o = e;
|
|
86
|
+
const E = {
|
|
87
|
+
id: `${Date.now().toString()}1`,
|
|
88
|
+
role: "user",
|
|
89
|
+
content: o,
|
|
90
|
+
metadata: n
|
|
91
|
+
}, N = [...m.length ? [] : J, E];
|
|
92
|
+
g && j(), l((v) => [...v, ...N]), r.current = [...r.current, ...N], y([]), x(""), _({
|
|
93
|
+
eventName: "chat_message_submitted",
|
|
94
|
+
properties: {
|
|
95
|
+
messages: r.current,
|
|
96
|
+
messageId: E.id,
|
|
97
|
+
content: e,
|
|
98
|
+
workflowId: I?.id
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
try {
|
|
102
|
+
const v = {
|
|
103
|
+
model: re,
|
|
104
|
+
messages: r.current,
|
|
105
|
+
stream: !0,
|
|
106
|
+
tools: oe,
|
|
107
|
+
tool_choice: "auto"
|
|
108
|
+
}, G = await te(), Me = G ? btoa(JSON.stringify(G)) : null, V = K ? void 0 : {
|
|
109
|
+
"X-INKEEP-CHALLENGE-SOLUTION": Me
|
|
110
|
+
}, M = se.beta.chat.completions.stream(
|
|
111
|
+
v,
|
|
112
|
+
V ? { headers: V } : void 0
|
|
113
|
+
), t = {
|
|
114
|
+
id: `${Date.now().toString()}2`,
|
|
115
|
+
role: "assistant",
|
|
116
|
+
content: "",
|
|
117
|
+
links: []
|
|
118
|
+
};
|
|
119
|
+
l((u) => [...u, t]), M.on("content", (u, R) => {
|
|
120
|
+
h(!0), t.content = R, l(($) => {
|
|
121
|
+
const a = [...$], d = a.findIndex((k) => k.id === t.id);
|
|
122
|
+
return d === -1 ? [...a, t] : (a[d] = { ...t }, a);
|
|
123
|
+
});
|
|
124
|
+
}), M.on("tool_calls.function.arguments.done", (u) => {
|
|
125
|
+
const { name: R, arguments: $ } = u;
|
|
126
|
+
if (R === "provideLinks") {
|
|
127
|
+
const a = JSON.parse($);
|
|
128
|
+
a.links?.length > 0 && (t.links = a.links, l((d) => {
|
|
129
|
+
const k = [...d], ke = k.findIndex((Se) => Se.id === t.id);
|
|
130
|
+
return k[ke] = { ...t }, k;
|
|
131
|
+
}));
|
|
132
|
+
} else {
|
|
133
|
+
const a = ie?.(u);
|
|
134
|
+
a && H((d) => ({
|
|
135
|
+
...d,
|
|
136
|
+
[t.id]: [...d[t.id] || [], a]
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
}), M.on("error", (u) => {
|
|
140
|
+
q(u);
|
|
141
|
+
}), M.finalChatCompletion().then(() => {
|
|
142
|
+
r.current = [...r.current, t], C.current = null, f(!1), h(!1), b(), _({
|
|
143
|
+
eventName: "chat_message_bot_response_received",
|
|
144
|
+
properties: {
|
|
145
|
+
messages: r.current,
|
|
146
|
+
messageId: t.id,
|
|
147
|
+
question: Pe(E),
|
|
148
|
+
responseMessage: t,
|
|
149
|
+
linksUsedInResponse: t.links,
|
|
150
|
+
workflowId: I?.id
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}), C.current = M.controller;
|
|
154
|
+
} catch (v) {
|
|
155
|
+
q(v), f(!1), h(!1);
|
|
156
|
+
}
|
|
157
|
+
}, Ie = () => {
|
|
158
|
+
C.current && (C.current.abort(), C.current = null), f(!1), h(!1), b();
|
|
159
|
+
}, Q = () => {
|
|
160
|
+
z(null), l([]), r.current = [], ee(), H({}), y([]), j(), B(null), T(), b(), _({
|
|
161
|
+
eventName: "chat_history_cleared",
|
|
162
|
+
properties: {
|
|
163
|
+
conversationId: Z.id
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}, we = (e) => {
|
|
167
|
+
B(e);
|
|
168
|
+
const { initialReplyMessage: s, displayName: n } = e, o = {
|
|
169
|
+
id: m.length.toString(),
|
|
170
|
+
role: "user",
|
|
171
|
+
content: n
|
|
172
|
+
}, i = {
|
|
173
|
+
id: (m.length + 1).toString(),
|
|
174
|
+
role: "assistant",
|
|
175
|
+
content: s,
|
|
176
|
+
links: []
|
|
177
|
+
}, N = [{
|
|
178
|
+
id: `system-${e.id}`,
|
|
179
|
+
role: "system",
|
|
180
|
+
content: `Company has asked user to follow this guided workflow:
|
|
181
|
+
${$e(
|
|
182
|
+
e
|
|
183
|
+
)}`
|
|
184
|
+
}, ...J, o, i];
|
|
185
|
+
l(N), y([]);
|
|
186
|
+
}, { openForm: ye } = Ue(), Ce = Ke();
|
|
187
|
+
_e(P.chatFunctionsRef, () => ({
|
|
188
|
+
submitMessage: L,
|
|
189
|
+
updateInputMessage(e) {
|
|
190
|
+
x(e);
|
|
191
|
+
},
|
|
192
|
+
clearChat: Q,
|
|
193
|
+
openForm: (e) => {
|
|
194
|
+
Ce?.setView("chat"), ye(e);
|
|
195
|
+
},
|
|
196
|
+
focusInput: () => {
|
|
197
|
+
W.current?.focus();
|
|
198
|
+
}
|
|
199
|
+
}));
|
|
200
|
+
const ve = Oe("(max-width: 768px)");
|
|
201
|
+
return {
|
|
202
|
+
messages: m,
|
|
203
|
+
input: p,
|
|
204
|
+
isLoading: F,
|
|
205
|
+
isStreaming: ce,
|
|
206
|
+
isLoadingConversation: de,
|
|
207
|
+
error: le,
|
|
208
|
+
isSubmitDisabled: A,
|
|
209
|
+
handleInputChange: he,
|
|
210
|
+
handleInputKeyDown: fe,
|
|
211
|
+
handleSubmit: L,
|
|
212
|
+
stop: Ie,
|
|
213
|
+
clear: Q,
|
|
214
|
+
handleWorkflow: we,
|
|
215
|
+
selectedWorkflow: I,
|
|
216
|
+
messageAttachments: w,
|
|
217
|
+
setMessageAttachments: y,
|
|
218
|
+
addAttachment: me,
|
|
219
|
+
messageToolCalls: ue,
|
|
220
|
+
isEmpty: m.length === 0,
|
|
221
|
+
inputRef: W,
|
|
222
|
+
isMobile: ve
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
export {
|
|
226
|
+
tt as useInkeepChat
|
|
227
|
+
};
|