@useknest/widget-react 0.1.0-beta.14 → 0.1.0-beta.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../src/ChatWidget.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAMX,UAAU,EACV,UAAU,EACV,MAAM,uBAAuB,CAAC;AAK/B,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qGAAqG;IACrG,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,EAC1B,iBAAiB,EACjB,IAAe,EACf,WAAmB,EACnB,IAAI,EACJ,SAAS,EACT,EAAE,eAAe,2CA2iBjB"}
1
+ {"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../src/ChatWidget.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAMX,UAAU,EACV,UAAU,EACV,MAAM,uBAAuB,CAAC;AAK/B,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qGAAqG;IACrG,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,EAC1B,iBAAiB,EACjB,IAAe,EACf,WAAmB,EACnB,IAAI,EACJ,SAAS,EACT,EAAE,eAAe,2CA4jBjB"}
package/dist/index.js CHANGED
@@ -1,58 +1,58 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".knest-chat-card{display:flex;flex-direction:column;height:100%;background:#fff;color:#374151;border-radius:1rem;box-shadow:0 10px 15px -3px #0000001a;overflow:hidden;font-family:system-ui,-apple-system,sans-serif}.knest-loading-container{display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg,#fdfbf7,#fff)}.knest-loading-content{display:flex;flex-direction:column;align-items:center;gap:1.5rem}.knest-spinner-ring{width:3rem;height:3rem;border:3px solid #f3f4f6;border-top-color:#3b82f6;border-radius:50%;animation:knest-spin .8s linear infinite}@keyframes knest-spin{to{transform:rotate(360deg)}}.knest-loading-text{font-size:.875rem;font-weight:500;color:#6b7280;margin:0}.knest-error-container{display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg,#fef2f2,#fff);padding:2rem}.knest-error-content{text-align:center;max-width:300px}.knest-error-text{font-size:.875rem;color:#991b1b;margin:0;line-height:1.5}.knest-header{border-bottom:1px solid #f3f4f6;padding:1rem}.knest-header-content{display:flex;align-items:center;gap:.75rem}.knest-avatar-img{width:2rem;height:2rem;object-fit:cover;border-radius:.25rem}.knest-header h2{font-size:1.125rem;font-weight:600;color:#111827;margin:0 0 .25rem}.knest-badge{display:inline-block;padding:.25rem .5rem;border-radius:9999px;font-size:.75rem;font-weight:500;color:#fff}.knest-messages-container{flex:1;overflow-y:auto}.knest-separator{margin:0 1.5rem;border-bottom:1px solid #e5e7eb}.knest-message-wrapper{display:flex;flex-direction:column}.knest-message{display:flex;gap:1rem;padding:1.25rem 1.5rem;align-items:center}.knest-message-avatar{display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0}.knest-message-avatar .knest-avatar-img{width:100%;height:100%;border-radius:.25rem;object-fit:cover}.knest-user-avatar{width:2rem;height:2rem;border-radius:.25rem;display:flex;align-items:center;justify-content:center;color:#fff;font-size:.875rem;font-weight:500}.knest-message-content{flex:1;min-width:0}.knest-message-content p{margin:0 0 .5rem;font-size:.875rem;line-height:1.625;color:inherit;word-wrap:break-word}.knest-message-content p:last-child{margin-bottom:0}.knest-message-content code{background-color:#f3f4f6;padding:.125rem .375rem;border-radius:.25rem;font-family:ui-monospace,monospace;font-size:.8125rem;color:#ef4444}.knest-message-content pre{background-color:#1f2937;color:#f9fafb;padding:12px;border-radius:6px;overflow-x:auto;margin:8px 0}.knest-message-content pre code{background-color:transparent;padding:0;color:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.8125rem;line-height:1.5}.knest-message-content .token.keyword,.knest-message-content .token.builtin,.knest-message-content .token.tag{color:#ff7b72}.knest-message-content .token.string,.knest-message-content .token.attr-value{color:#a5d6ff}.knest-message-content .token.number,.knest-message-content .token.boolean{color:#79c0ff}.knest-message-content .token.function,.knest-message-content .token.class-name{color:#d2a8ff}.knest-message-content .token.comment{color:#8b949e;font-style:italic}.knest-message-content .token.variable,.knest-message-content .token.property{color:#ffa657}.knest-message-content .token.operator,.knest-message-content .token.punctuation{color:#c9d1d9}.knest-message-content a{color:inherit;text-decoration:underline}.knest-message-content ul,.knest-message-content ol{margin:8px 0;padding-left:24px}.knest-message-content li{margin:4px 0;color:inherit}.knest-message-content strong{font-weight:600;color:inherit}.knest-message-content em{font-style:italic}.knest-loading{display:flex;gap:.25rem;align-items:center}.knest-dot{width:.5rem;height:.5rem;background:#9ca3af;border-radius:50%;animation:knest-bounce 1.4s infinite ease-in-out both}.knest-dot:nth-child(2){animation-delay:.16s}.knest-dot:nth-child(3){animation-delay:.32s}@keyframes knest-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.knest-sources{margin-top:.75rem}.knest-sources-label{font-size:.75rem;font-weight:500;color:#6b7280;margin-bottom:.5rem}.knest-source-item{display:flex;gap:.5rem;padding:.5rem .75rem;margin-bottom:.25rem;border:1px solid #e5e7eb;border-radius:.375rem;background:#f9fafb;text-decoration:none;transition:all .15s}.knest-source-item:hover{border-color:#d1d5db;background:#f3f4f6}.knest-source-icon{width:1rem;height:1rem;color:#6b7280;flex-shrink:0}.knest-source-text{flex:1;min-width:0}.knest-source-breadcrumb{font-size:.75rem;color:#6b7280;margin-bottom:.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-source-title{font-size:.875rem;font-weight:500;color:#374151;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-examples{border-top:1px solid #e5e7eb;padding:1.25rem 1.5rem}.knest-examples h3{font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:#6b7280;margin:0 0 1rem}.knest-example-btn{width:100%;padding:.75rem;margin-bottom:.75rem;border:1px solid #e5e7eb;border-radius:.5rem;background:#fff;text-align:left;font-size:.875rem;color:#374151;cursor:pointer;transition:background .15s}.knest-example-btn:hover{background:#f9fafb}.knest-input-section{border-top:1px solid #f3f4f6;padding:1rem}.knest-input-wrapper{display:flex;align-items:center;gap:.5rem}.knest-input-field{flex:1;padding:.75rem 1rem;border:1px solid #e5e7eb;border-radius:.5rem;background:#f9fafb;font-size:.875rem;color:#374151;outline:none}.knest-input-field:focus{background:#fff;border-color:#d1d5db}.knest-input-field:disabled{opacity:.5}.knest-attach-btn{width:2.5rem;height:2.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:.5rem;background:#e5e7eb;color:#6b7280;cursor:pointer;transition:background .15s;flex-shrink:0}.knest-attach-btn:hover:not(:disabled){background:#d1d5db}.knest-attach-btn:disabled{opacity:.4;cursor:not-allowed}.knest-attach-icon{width:1rem;height:1rem}.knest-file-preview{display:flex;flex-wrap:wrap;gap:.375rem;margin-bottom:.5rem}.knest-file-chip{display:inline-flex;align-items:center;gap:.25rem;padding:.25rem .5rem;background:#f3f4f6;border:1px solid #e5e7eb;border-radius:9999px;font-size:.75rem;color:#374151;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-chip-remove{background:none;border:none;padding:0;font-size:1rem;line-height:1;color:#9ca3af;cursor:pointer;flex-shrink:0}.knest-chip-remove:hover{color:#374151}.knest-attach-error{font-size:.75rem;color:#dc2626;margin:0 0 .375rem}.knest-send-btn{width:2.5rem;height:2.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:.5rem;background:#e5e7eb;color:#6b7280;cursor:pointer;transition:background .15s}.knest-send-btn:hover:not(:disabled){background:#d1d5db}.knest-send-btn:disabled{opacity:.5;cursor:not-allowed}.knest-send-icon{width:1rem;height:1rem}.knest-attachments{display:flex;flex-direction:column;gap:.5rem;margin-top:.5rem}.knest-attachment-image-link{display:inline-block}.knest-attachment-image{max-width:240px;border-radius:.5rem;display:block}.knest-attachment-file{display:inline-flex;align-items:center;gap:.375rem;padding:.375rem .625rem;border:1px solid #e5e7eb;border-radius:9999px;background:#f9fafb;text-decoration:none;font-size:.8125rem;color:#374151;transition:background .15s}.knest-attachment-file:hover:not(.knest-attachment-disabled){background:#f3f4f6}.knest-attachment-disabled{opacity:.5;pointer-events:none}.knest-attachment-file-icon{width:.875rem;height:.875rem;color:#6b7280;flex-shrink:0}.knest-attachment-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:160px}.knest-attachment-file-size{color:#9ca3af;flex-shrink:0}.knest-reset-row{display:flex;justify-content:center;margin-top:.5rem}.knest-reset-btn{background:none;border:none;padding:0;font-size:.75rem;color:#9ca3af;cursor:pointer;transition:color .15s}.knest-reset-btn:hover{color:#6b7280}.knest-footer{margin-top:.75rem;display:flex;justify-content:center}.knest-powered-by{display:flex;align-items:center;gap:.125rem;font-size:.75rem;color:#6b7280;text-decoration:none;transition:color .15s}.knest-powered-by:hover{color:#374151;text-decoration:underline}.knest-bubble-container{position:fixed;bottom:24px;right:24px;z-index:9999;display:flex;flex-direction:column;align-items:flex-end;gap:16px;font-family:system-ui,-apple-system,sans-serif}.knest-bubble-button{width:56px;height:56px;border-radius:50%;border:none;color:#fff;cursor:pointer;box-shadow:0 4px 12px #00000026;display:flex;align-items:center;justify-content:center;transition:transform .2s,box-shadow .2s}.knest-bubble-button:hover{transform:scale(1.05);box-shadow:0 6px 16px #0003}.knest-bubble-spinner{animation:knest-spin 1s linear infinite}.knest-bubble-panel{width:380px;height:520px;max-width:calc(100vw - 48px);max-height:calc(100vh - 100px);border-radius:1rem;border:1px solid rgba(0,0,0,.1);box-shadow:0 10px 15px -3px #0000001a;overflow:hidden}.knest-bubble-panel .knest-chat-card{height:100%}@media (max-width: 440px){.knest-bubble-container{bottom:16px;right:16px}.knest-bubble-panel{width:calc(100vw - 32px);height:calc(100vh - 100px)}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { jsx as e, jsxs as l } from "react/jsx-runtime";
3
- import { useState as d, useEffect as M, useRef as V } from "react";
4
- import { fetchSignedUrl as oe, formatContent as le, DEFAULT_BRAND_COLOR as q, isImageType as ce, formatFileSize as ie, DEFAULT_AVATAR_URL as de, DEFAULT_EXAMPLE_QUESTIONS as he, initWidgetSentry as X, PUBLIC_SUPABASE_URL as ue, PUBLIC_SUPABASE_PUBLISHABLE_KEY as me, initWidgetAuth as fe, saveChatStateDebounced as ke, subscribeToThread as ge, AUTH_ERROR_MESSAGE as ve, ACCEPTED_FILE_TYPES_STRING as pe, fetchWidgetConfig as Ce, loadChatState as be, DEFAULT_WELCOME_MESSAGE as Y, validateAttachment as Ne, MAX_ATTACHMENTS_PER_MESSAGE as Ee, uploadAttachment as Le, captureWidgetException as $, streamChatMessage as we, clearChatState as Ue } from "@useknest/widget-core";
5
- function Me({
6
- message: r,
7
- isLoading: T = !1,
8
- avatarUrl: W = "/default-avatar.svg",
9
- brandColor: y = q,
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".knest-chat-card{display:flex;flex-direction:column;height:100%;background:#fff;color:#374151;border-radius:1rem;box-shadow:0 10px 15px -3px #0000001a;overflow:hidden;font-family:system-ui,-apple-system,sans-serif}.knest-loading-container{display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg,#fdfbf7,#fff)}.knest-loading-content{display:flex;flex-direction:column;align-items:center;gap:1.5rem}.knest-spinner-ring{width:3rem;height:3rem;border:3px solid #f3f4f6;border-top-color:#3b82f6;border-radius:50%;animation:knest-spin .8s linear infinite}@keyframes knest-spin{to{transform:rotate(360deg)}}.knest-loading-text{font-size:.875rem;font-weight:500;color:#6b7280;margin:0}.knest-error-container{display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg,#fef2f2,#fff);padding:2rem}.knest-error-content{text-align:center;max-width:300px}.knest-error-text{font-size:.875rem;color:#991b1b;margin:0;line-height:1.5}.knest-header{border-bottom:1px solid #f3f4f6;padding:1rem}.knest-header-content{display:flex;align-items:center;gap:.75rem}.knest-avatar-img{width:2rem;height:2rem;object-fit:cover;border-radius:.25rem}.knest-header h2{font-size:1.125rem;font-weight:600;color:#111827;margin:0 0 .25rem}.knest-badge{display:inline-block;padding:.25rem .5rem;border-radius:9999px;font-size:.75rem;font-weight:500;color:#fff}.knest-messages-container{flex:1;overflow-y:auto}.knest-separator{margin:0 1.5rem;border-bottom:1px solid #e5e7eb}.knest-message-wrapper{display:flex;flex-direction:column}.knest-message{display:flex;gap:1rem;padding:1.25rem 1.5rem;align-items:center}.knest-message-avatar{display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0}.knest-message-avatar .knest-avatar-img{width:100%;height:100%;border-radius:.25rem;object-fit:cover}.knest-user-avatar{width:2rem;height:2rem;border-radius:.25rem;display:flex;align-items:center;justify-content:center;color:#fff;font-size:.875rem;font-weight:500}.knest-message-content{flex:1;min-width:0}.knest-message-content p{margin:0 0 .5rem;font-size:.875rem;line-height:1.625;color:inherit;word-wrap:break-word}.knest-message-content p:last-child{margin-bottom:0}.knest-message-content code{background-color:#f3f4f6;padding:.125rem .375rem;border-radius:.25rem;font-family:ui-monospace,monospace;font-size:.8125rem;color:#ef4444}.knest-message-content pre{background-color:#1f2937;color:#f9fafb;padding:12px;border-radius:6px;overflow-x:auto;margin:8px 0}.knest-message-content pre code{background-color:transparent;padding:0;color:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.8125rem;line-height:1.5}.knest-message-content .token.keyword,.knest-message-content .token.builtin,.knest-message-content .token.tag{color:#ff7b72}.knest-message-content .token.string,.knest-message-content .token.attr-value{color:#a5d6ff}.knest-message-content .token.number,.knest-message-content .token.boolean{color:#79c0ff}.knest-message-content .token.function,.knest-message-content .token.class-name{color:#d2a8ff}.knest-message-content .token.comment{color:#8b949e;font-style:italic}.knest-message-content .token.variable,.knest-message-content .token.property{color:#ffa657}.knest-message-content .token.operator,.knest-message-content .token.punctuation{color:#c9d1d9}.knest-message-content a{color:inherit;text-decoration:underline}.knest-message-content ul,.knest-message-content ol{margin:8px 0;padding-left:24px}.knest-message-content li{margin:4px 0;color:inherit}.knest-message-content strong{font-weight:600;color:inherit}.knest-message-content em{font-style:italic}.knest-loading{display:flex;gap:.25rem;align-items:center}.knest-dot{width:.5rem;height:.5rem;background:#9ca3af;border-radius:50%;animation:knest-bounce 1.4s infinite ease-in-out both}.knest-dot:nth-child(2){animation-delay:.16s}.knest-dot:nth-child(3){animation-delay:.32s}@keyframes knest-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.knest-sources{margin-top:.75rem}.knest-sources-label{font-size:.75rem;font-weight:500;color:#6b7280;margin-bottom:.5rem}.knest-source-item{display:flex;gap:.5rem;padding:.5rem .75rem;margin-bottom:.25rem;border:1px solid #e5e7eb;border-radius:.375rem;background:#f9fafb;text-decoration:none;transition:all .15s}.knest-source-item:hover{border-color:#d1d5db;background:#f3f4f6}.knest-source-icon{width:1rem;height:1rem;color:#6b7280;flex-shrink:0}.knest-source-text{flex:1;min-width:0}.knest-source-breadcrumb{font-size:.75rem;color:#6b7280;margin-bottom:.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-source-title{font-size:.875rem;font-weight:500;color:#374151;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-examples{border-top:1px solid #e5e7eb;padding:1.25rem 1.5rem}.knest-examples h3{font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:#6b7280;margin:0 0 1rem}.knest-example-btn{width:100%;padding:.75rem;margin-bottom:.75rem;border:1px solid #e5e7eb;border-radius:.5rem;background:#fff;text-align:left;font-size:.875rem;color:#374151;cursor:pointer;transition:background .15s}.knest-example-btn:hover{background:#f9fafb}.knest-presence-caption{display:flex;align-items:center;gap:.375rem;font-size:.75rem;color:#6b7280;margin:0 0 .375rem}.knest-online-dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#22c55e;flex-shrink:0}.knest-human-takeover-caption{font-size:.75rem;color:#9ca3af;text-align:center;margin:.1875rem 0 .75rem}.knest-input-section{border-top:1px solid #f3f4f6;padding:1rem}.knest-input-wrapper{display:flex;align-items:center;gap:.5rem}.knest-input-field{flex:1;padding:.75rem 1rem;border:1px solid #e5e7eb;border-radius:.5rem;background:#f9fafb;font-size:.875rem;color:#374151;outline:none}.knest-input-field:focus{background:#fff;border-color:#d1d5db}.knest-input-field:disabled{opacity:.5}.knest-attach-btn{width:2.5rem;height:2.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:.5rem;background:#e5e7eb;color:#6b7280;cursor:pointer;transition:background .15s;flex-shrink:0}.knest-attach-btn:hover:not(:disabled){background:#d1d5db}.knest-attach-btn:disabled{opacity:.4;cursor:not-allowed}.knest-attach-icon{width:1rem;height:1rem}.knest-file-preview{display:flex;flex-wrap:wrap;gap:.375rem;margin-bottom:.5rem}.knest-file-chip{display:inline-flex;align-items:center;gap:.25rem;padding:.25rem .5rem;background:#f3f4f6;border:1px solid #e5e7eb;border-radius:9999px;font-size:.75rem;color:#374151;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-chip-remove{background:none;border:none;padding:0;font-size:1rem;line-height:1;color:#9ca3af;cursor:pointer;flex-shrink:0}.knest-chip-remove:hover{color:#374151}.knest-attach-error{font-size:.75rem;color:#dc2626;margin:0 0 .375rem}.knest-send-btn{width:2.5rem;height:2.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:.5rem;background:#e5e7eb;color:#6b7280;cursor:pointer;transition:background .15s}.knest-send-btn:hover:not(:disabled){background:#d1d5db}.knest-send-btn:disabled{opacity:.5;cursor:not-allowed}.knest-send-icon{width:1rem;height:1rem}.knest-attachments{display:flex;flex-direction:column;gap:.5rem;margin-top:.5rem}.knest-attachment-image-link{display:inline-block}.knest-attachment-image{max-width:240px;border-radius:.5rem;display:block}.knest-attachment-file{display:inline-flex;align-items:center;gap:.375rem;padding:.375rem .625rem;border:1px solid #e5e7eb;border-radius:9999px;background:#f9fafb;text-decoration:none;font-size:.8125rem;color:#374151;transition:background .15s}.knest-attachment-file:hover:not(.knest-attachment-disabled){background:#f3f4f6}.knest-attachment-disabled{opacity:.5;pointer-events:none}.knest-attachment-file-icon{width:.875rem;height:.875rem;color:#6b7280;flex-shrink:0}.knest-attachment-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:160px}.knest-attachment-file-size{color:#9ca3af;flex-shrink:0}.knest-reset-row{display:flex;justify-content:center;margin-top:.5rem}.knest-reset-btn{background:none;border:none;padding:0;font-size:.75rem;color:#9ca3af;cursor:pointer;transition:color .15s}.knest-reset-btn:hover{color:#6b7280}.knest-footer{margin-top:.75rem;display:flex;justify-content:center}.knest-powered-by{display:flex;align-items:center;gap:.125rem;font-size:.75rem;color:#6b7280;text-decoration:none;transition:color .15s}.knest-powered-by:hover{color:#374151;text-decoration:underline}.knest-bubble-container{position:fixed;bottom:24px;right:24px;z-index:9999;display:flex;flex-direction:column;align-items:flex-end;gap:16px;font-family:system-ui,-apple-system,sans-serif}.knest-bubble-button{width:56px;height:56px;border-radius:50%;border:none;color:#fff;cursor:pointer;box-shadow:0 4px 12px #00000026;display:flex;align-items:center;justify-content:center;transition:transform .2s,box-shadow .2s}.knest-bubble-button:hover{transform:scale(1.05);box-shadow:0 6px 16px #0003}.knest-bubble-spinner{animation:knest-spin 1s linear infinite}.knest-bubble-panel{width:380px;height:520px;max-width:calc(100vw - 48px);max-height:calc(100vh - 100px);border-radius:1rem;border:1px solid rgba(0,0,0,.1);box-shadow:0 10px 15px -3px #0000001a;overflow:hidden}.knest-bubble-panel .knest-chat-card{height:100%}@media (max-width: 440px){.knest-bubble-container{bottom:16px;right:16px}.knest-bubble-panel{width:calc(100vw - 32px);height:calc(100vh - 100px)}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { jsx as e, jsxs as o } from "react/jsx-runtime";
3
+ import { useState as i, useEffect as M, useRef as q } from "react";
4
+ import { fetchSignedUrl as ue, formatContent as me, DEFAULT_BRAND_COLOR as ee, isImageType as fe, formatFileSize as ke, DEFAULT_AVATAR_URL as ge, DEFAULT_EXAMPLE_QUESTIONS as ve, initWidgetSentry as J, PUBLIC_SUPABASE_URL as pe, PUBLIC_SUPABASE_PUBLISHABLE_KEY as Ce, initWidgetAuth as Ne, saveChatStateDebounced as be, subscribeToThread as Ee, AUTH_ERROR_MESSAGE as Le, HUMAN_TAKEOVER_CAPTION as we, PRESENCE_LABEL_WIDGET as Ae, ACCEPTED_FILE_TYPES_STRING as Ue, fetchWidgetConfig as Me, loadChatState as xe, DEFAULT_WELCOME_MESSAGE as Z, validateAttachment as Se, MAX_ATTACHMENTS_PER_MESSAGE as ye, uploadAttachment as Ie, captureWidgetException as K, streamChatMessage as Pe, clearChatState as Te } from "@useknest/widget-core";
5
+ function _e({
6
+ message: s,
7
+ isLoading: W = !1,
8
+ avatarUrl: B = "/default-avatar.svg",
9
+ brandColor: x = ee,
10
10
  showAvatar: f = !0,
11
- publishableApiKey: p,
12
- baseUrl: w
11
+ publishableApiKey: v,
12
+ baseUrl: A
13
13
  }) {
14
- const [C, x] = d(!1), [S, B] = d({});
14
+ const [p, S] = i(!1), [y, R] = i({});
15
15
  M(() => {
16
- if (!r.attachments?.length || !p) return;
17
- const n = r.attachments.filter(
18
- (o) => o.storagePath && !o.url && !S[o.storagePath]
16
+ if (!s.attachments?.length || !v) return;
17
+ const n = s.attachments.filter(
18
+ (l) => l.storagePath && !l.url && !y[l.storagePath]
19
19
  );
20
20
  n.length !== 0 && Promise.all(
21
- n.map(async (o) => {
22
- const c = await oe({
23
- publishableApiKey: p,
24
- storagePath: o.storagePath,
25
- baseUrl: w
21
+ n.map(async (l) => {
22
+ const c = await ue({
23
+ publishableApiKey: v,
24
+ storagePath: l.storagePath,
25
+ baseUrl: A
26
26
  });
27
- return { storagePath: o.storagePath, url: c };
27
+ return { storagePath: l.storagePath, url: c };
28
28
  })
29
- ).then((o) => {
29
+ ).then((l) => {
30
30
  const c = {};
31
- for (const { storagePath: k, url: L } of o)
32
- L && (c[k] = L);
33
- Object.keys(c).length > 0 && B((k) => ({ ...k, ...c }));
31
+ for (const { storagePath: g, url: L } of l)
32
+ L && (c[g] = L);
33
+ Object.keys(c).length > 0 && R((g) => ({ ...g, ...c }));
34
34
  });
35
- }, [r.attachments, p, w]);
36
- const E = (n) => n.url || (n.storagePath ? S[n.storagePath] : void 0), _ = () => x(!0), u = r.content ? le(r.content) : "";
37
- return /* @__PURE__ */ e("div", { className: "knest-message-wrapper", children: /* @__PURE__ */ l("div", { className: "knest-message", children: [
38
- f && /* @__PURE__ */ e("div", { className: "knest-message-avatar", children: r.role === "assistant" ? C ? /* @__PURE__ */ e("div", { className: "knest-user-avatar", style: { backgroundColor: y }, children: "AI" }) : /* @__PURE__ */ e(
35
+ }, [s.attachments, v, A]);
36
+ const b = (n) => n.url || (n.storagePath ? y[n.storagePath] : void 0), O = () => S(!0), m = s.content ? me(s.content) : "";
37
+ return /* @__PURE__ */ e("div", { className: "knest-message-wrapper", children: /* @__PURE__ */ o("div", { className: "knest-message", children: [
38
+ f && /* @__PURE__ */ e("div", { className: "knest-message-avatar", children: s.role === "assistant" ? p ? /* @__PURE__ */ e("div", { className: "knest-user-avatar", style: { backgroundColor: x }, children: "AI" }) : /* @__PURE__ */ e(
39
39
  "img",
40
40
  {
41
- src: W,
41
+ src: B,
42
42
  alt: "Avatar",
43
43
  className: "knest-avatar-img",
44
- onError: _
44
+ onError: O
45
45
  }
46
- ) : /* @__PURE__ */ e("div", { className: "knest-user-avatar", style: { backgroundColor: y }, children: "U" }) }),
47
- /* @__PURE__ */ l("div", { className: "knest-message-content", children: [
48
- !r.content && T && r.role === "assistant" ? /* @__PURE__ */ l("div", { className: "knest-loading", children: [
46
+ ) : /* @__PURE__ */ e("div", { className: "knest-user-avatar", style: { backgroundColor: x }, children: "U" }) }),
47
+ /* @__PURE__ */ o("div", { className: "knest-message-content", children: [
48
+ !s.content && W && s.role === "assistant" ? /* @__PURE__ */ o("div", { className: "knest-loading", children: [
49
49
  /* @__PURE__ */ e("div", { className: "knest-dot" }),
50
50
  /* @__PURE__ */ e("div", { className: "knest-dot" }),
51
51
  /* @__PURE__ */ e("div", { className: "knest-dot" })
52
- ] }) : /* @__PURE__ */ e("div", { dangerouslySetInnerHTML: { __html: u } }),
53
- r.attachments && r.attachments.length > 0 && /* @__PURE__ */ e("div", { className: "knest-attachments", children: r.attachments.map((n, o) => {
54
- const c = E(n);
55
- return ce(n.fileType) ? c ? /* @__PURE__ */ e(
52
+ ] }) : /* @__PURE__ */ e("div", { dangerouslySetInnerHTML: { __html: m } }),
53
+ s.attachments && s.attachments.length > 0 && /* @__PURE__ */ e("div", { className: "knest-attachments", children: s.attachments.map((n, l) => {
54
+ const c = b(n);
55
+ return fe(n.fileType) ? c ? /* @__PURE__ */ e(
56
56
  "a",
57
57
  {
58
58
  href: c,
@@ -61,8 +61,8 @@ function Me({
61
61
  className: "knest-attachment-image-link",
62
62
  children: /* @__PURE__ */ e("img", { src: c, alt: n.fileName, className: "knest-attachment-image" })
63
63
  },
64
- o
65
- ) : null : /* @__PURE__ */ l(
64
+ l
65
+ ) : null : /* @__PURE__ */ o(
66
66
  "a",
67
67
  {
68
68
  href: c || "#",
@@ -89,15 +89,15 @@ function Me({
89
89
  }
90
90
  ),
91
91
  /* @__PURE__ */ e("span", { className: "knest-attachment-file-name", children: n.fileName }),
92
- /* @__PURE__ */ e("span", { className: "knest-attachment-file-size", children: ie(n.fileSize) })
92
+ /* @__PURE__ */ e("span", { className: "knest-attachment-file-size", children: ke(n.fileSize) })
93
93
  ]
94
94
  },
95
- o
95
+ l
96
96
  );
97
97
  }) }),
98
- r.sources && r.sources.length > 0 && /* @__PURE__ */ l("div", { className: "knest-sources", children: [
98
+ s.sources && s.sources.length > 0 && /* @__PURE__ */ o("div", { className: "knest-sources", children: [
99
99
  /* @__PURE__ */ e("div", { className: "knest-sources-label", children: "Sources" }),
100
- r.sources.slice(0, 1).map((n, o) => /* @__PURE__ */ l(
100
+ s.sources.slice(0, 1).map((n, l) => /* @__PURE__ */ o(
101
101
  "a",
102
102
  {
103
103
  href: n.url,
@@ -123,167 +123,175 @@ function Me({
123
123
  )
124
124
  }
125
125
  ),
126
- /* @__PURE__ */ l("div", { className: "knest-source-text", children: [
126
+ /* @__PURE__ */ o("div", { className: "knest-source-text", children: [
127
127
  n.breadcrumb && /* @__PURE__ */ e("div", { className: "knest-source-breadcrumb", children: n.breadcrumb }),
128
128
  /* @__PURE__ */ e("div", { className: "knest-source-title", children: n.title })
129
129
  ] })
130
130
  ]
131
131
  },
132
- o
132
+ l
133
133
  ))
134
134
  ] })
135
135
  ] })
136
136
  ] }) });
137
137
  }
138
- function Ae({
139
- publishableApiKey: r,
140
- mode: T = "inline",
141
- defaultOpen: W = !1,
142
- user: y,
138
+ function Oe({
139
+ publishableApiKey: s,
140
+ mode: W = "inline",
141
+ defaultOpen: B = !1,
142
+ user: x,
143
143
  _internal: f
144
144
  }) {
145
- const [p, w] = d(null), [C, x] = d(!0), [S, B] = d(null), [E, _] = d(!1), [u, n] = d([]), [o, c] = d(""), [k, L] = d(!1), [h, R] = d(void 0), [A, J] = d(W), [I, P] = d([]), [j, D] = d(!1), [H, U] = d(null), F = V(null), G = V(null), Z = p?.avatarUrl || de, K = p?.exampleQuestions || he, O = p?.brandColor || q;
145
+ const [v, A] = i(null), [p, S] = i(!0), [y, R] = i(null), [b, O] = i(!1), [m, n] = i([]), [l, c] = i(""), [g, L] = i(!1), [u, D] = i(void 0), [I, te] = i(B), [P, T] = i([]), [j, F] = i(!1), [V, U] = i(null), [ne, Q] = i(!1), [se, X] = i(!1), z = q(null), Y = q(null), ae = v?.avatarUrl || ge, re = v?.exampleQuestions || ve, H = v?.brandColor || ee;
146
146
  M(() => {
147
- typeof requestIdleCallback < "u" ? requestIdleCallback(() => X()) : setTimeout(() => X(), 0);
148
- const t = f?.supabaseUrl || ue, s = f?.supabasePublishableKey || me, m = fe(t, s);
147
+ typeof requestIdleCallback < "u" ? requestIdleCallback(() => J()) : setTimeout(() => J(), 0);
148
+ const t = f?.supabaseUrl || pe, r = f?.supabasePublishableKey || Ce, d = Ne(t, r);
149
149
  (async () => {
150
- const g = await Ce(
151
- r,
150
+ const w = await Me(
151
+ s,
152
152
  f?.baseUrl,
153
- (v) => {
154
- w(v);
153
+ (_) => {
154
+ A(_);
155
155
  }
156
156
  );
157
- if (g.error) {
158
- B(g.error), x(!1);
157
+ if (w.error) {
158
+ R(w.error), S(!1);
159
159
  return;
160
160
  }
161
- w(g.config), x(!1);
162
- const b = be(r);
163
- b && b.messages.length > 0 ? (n(b.messages), R(b.threadId), c(b.input)) : n([
161
+ A(w.config), S(!1);
162
+ const k = xe(s);
163
+ k && k.messages.length > 0 ? (n(k.messages), D(k.threadId), c(k.input)) : n([
164
164
  {
165
165
  role: "assistant",
166
- content: g.config?.welcomeMessage || Y
166
+ content: w.config?.welcomeMessage || Z
167
167
  }
168
168
  ]);
169
- const a = await m;
170
- a || console.warn("Widget auth initialization failed"), _(a);
169
+ const E = await d;
170
+ E || console.warn("Widget auth initialization failed"), O(E);
171
171
  })();
172
- }, [r, f]), M(() => {
173
- u.length > 0 && F.current && F.current.scrollIntoView({ behavior: "smooth" });
174
- }, [u]), M(() => {
175
- u.length <= 1 && !o || ke(r, {
176
- threadId: h,
177
- messages: u,
178
- input: o,
172
+ }, [s, f]), M(() => {
173
+ m.length > 0 && z.current && z.current.scrollIntoView({ behavior: "smooth" });
174
+ }, [m]), M(() => {
175
+ m.length <= 1 && !l || be(s, {
176
+ threadId: u,
177
+ messages: m,
178
+ input: l,
179
179
  savedAt: Date.now()
180
180
  });
181
- }, [u, h, o, r]), M(() => !h || !E ? void 0 : ge(h, (s) => {
182
- if (s.role !== "human") return;
183
- const m = s.metadata?.attachments ?? [];
184
- n(
185
- (i) => i.some((g) => g.id === s.id) ? i : [
186
- ...i,
187
- {
188
- id: s.id,
189
- role: "assistant",
190
- content: s.content,
191
- ...m.length > 0 ? { attachments: m } : {}
192
- }
193
- ]
194
- );
195
- }), [h, E]);
196
- const ee = (t) => {
197
- const s = Array.from(t.target.files || []);
181
+ }, [m, u, l, s]), M(() => {
182
+ if (!(!u || !b))
183
+ return Ee(
184
+ u,
185
+ (t) => {
186
+ if (t.role !== "human") return;
187
+ const r = t.metadata?.attachments ?? [];
188
+ n(
189
+ (d) => d.some((h) => h.id === t.id) ? d : [
190
+ ...d,
191
+ {
192
+ id: t.id,
193
+ role: "assistant",
194
+ content: t.content,
195
+ ...r.length > 0 ? { attachments: r } : {}
196
+ }
197
+ ]
198
+ );
199
+ },
200
+ { role: "visitor", onPresenceChange: (t) => X(t) }
201
+ );
202
+ }, [u, b]);
203
+ const le = (t) => {
204
+ const r = Array.from(t.target.files || []);
198
205
  t.target.value = "", U(null);
199
- for (const m of s) {
200
- const i = Ne(m);
201
- if (i) {
202
- U(i);
206
+ for (const d of r) {
207
+ const h = Se(d);
208
+ if (h) {
209
+ U(h);
203
210
  return;
204
211
  }
205
212
  }
206
- P((m) => {
207
- const i = Ee - m.length;
208
- return [...m, ...s.slice(0, i)];
213
+ T((d) => {
214
+ const h = ye - d.length;
215
+ return [...d, ...r.slice(0, h)];
209
216
  });
210
- }, te = (t) => {
211
- P((s) => s.filter((m, i) => i !== t));
212
- }, z = async () => {
213
- if (!o.trim() || k || !E) return;
214
- const t = o.trim();
217
+ }, oe = (t) => {
218
+ T((r) => r.filter((d, h) => h !== t));
219
+ }, G = async (t) => {
220
+ const r = t ?? l;
221
+ if (!r.trim() || g || !b) return;
222
+ const d = r.trim();
215
223
  c(""), L(!0), U(null);
216
- let s = [];
217
- if (I.length > 0 && h) {
218
- D(!0);
224
+ let h = [];
225
+ if (P.length > 0 && u) {
226
+ F(!0);
219
227
  try {
220
- s = await Promise.all(
221
- I.map(
222
- (a) => Le({
223
- publishableApiKey: r,
224
- threadId: h,
228
+ h = await Promise.all(
229
+ P.map(
230
+ (a) => Ie({
231
+ publishableApiKey: s,
232
+ threadId: u,
225
233
  file: a,
226
234
  baseUrl: f?.baseUrl
227
235
  })
228
236
  )
229
237
  );
230
238
  } catch (a) {
231
- $(a instanceof Error ? a.message : "Upload failed", {
232
- threadId: h,
239
+ K(a instanceof Error ? a.message : "Upload failed", {
240
+ threadId: u,
233
241
  baseUrl: f?.baseUrl
234
- }), U(a instanceof Error ? a.message : "Upload failed."), L(!1), D(!1);
242
+ }), U(a instanceof Error ? a.message : "Upload failed."), L(!1), F(!1);
235
243
  return;
236
244
  }
237
- D(!1), P([]);
245
+ F(!1), T([]);
238
246
  }
239
- const m = s.length > 0 ? { attachments: s } : void 0;
247
+ const w = h.length > 0 ? { attachments: h } : void 0;
240
248
  n((a) => [
241
249
  ...a,
242
- { role: "user", content: t, ...s.length > 0 ? { attachments: s } : {} }
250
+ { role: "user", content: d, ...h.length > 0 ? { attachments: h } : {} }
243
251
  ]);
244
- const i = u.length + 1;
252
+ const k = m.length + 1;
245
253
  n((a) => [...a, { role: "assistant", content: "" }]);
246
- let g = "", b = [];
247
- await we({
248
- publishableApiKey: r,
249
- content: t,
250
- threadId: h,
254
+ let E = "", _ = [];
255
+ await Pe({
256
+ publishableApiKey: s,
257
+ content: d,
258
+ threadId: u,
251
259
  baseUrl: f?.baseUrl,
252
- metadata: m,
253
- user: y,
260
+ metadata: w,
261
+ user: x,
254
262
  callbacks: {
255
263
  onInit: (a) => {
256
- h || R(a);
264
+ u || D(a);
257
265
  },
258
266
  onContent: (a) => {
259
- g += a, n((v) => {
260
- const N = [...v];
261
- return N[i] = {
267
+ E += a, n((C) => {
268
+ const N = [...C];
269
+ return N[k] = {
262
270
  role: "assistant",
263
- content: g
271
+ content: E
264
272
  }, N;
265
273
  });
266
274
  },
267
275
  onComplete: (a) => {
268
- b = a, n((v) => {
269
- const N = [...v];
270
- return N[i] = {
276
+ _ = a, n((C) => {
277
+ const N = [...C];
278
+ return N[k] = {
271
279
  role: "assistant",
272
- content: g,
273
- sources: b
280
+ content: E,
281
+ sources: _
274
282
  }, N;
275
283
  });
276
284
  },
277
285
  onDone: ({ humanTakeover: a }) => {
278
- a && n((v) => [
279
- ...v.slice(0, i),
280
- ...v.slice(i + 1)
286
+ Q(!!a), a && !E && n((C) => [
287
+ ...C.slice(0, k),
288
+ ...C.slice(k + 1)
281
289
  ]);
282
290
  },
283
291
  onError: (a) => {
284
- $(a, { userMessage: t, threadId: h, baseUrl: f?.baseUrl }), n((v) => {
285
- const N = [...v];
286
- return N[i] = {
292
+ K(a, { userMessage: d, threadId: u, baseUrl: f?.baseUrl }), n((C) => {
293
+ const N = [...C];
294
+ return N[k] = {
287
295
  role: "assistant",
288
296
  content: `Error: ${a}`
289
297
  }, N;
@@ -291,95 +299,100 @@ function Ae({
291
299
  }
292
300
  }
293
301
  }), L(!1);
294
- }, ne = () => {
295
- Ue(r), R(void 0), n([
296
- { role: "assistant", content: p?.welcomeMessage || Y }
297
- ]), c(""), P([]), U(null);
298
- }, se = (t) => {
299
- t.key === "Enter" && !t.shiftKey && (t.preventDefault(), z());
300
- }, re = async (t) => {
301
- c(t), setTimeout(() => z(), 0);
302
- }, Q = C ? /* @__PURE__ */ e("div", { className: "knest-chat-card", children: /* @__PURE__ */ e("div", { className: "knest-loading-container", children: /* @__PURE__ */ l("div", { className: "knest-loading-content", children: [
302
+ }, ce = () => {
303
+ Te(s), D(void 0), n([
304
+ { role: "assistant", content: v?.welcomeMessage || Z }
305
+ ]), c(""), T([]), U(null), Q(!1), X(!1);
306
+ }, ie = (t) => {
307
+ t.key === "Enter" && !t.shiftKey && (t.preventDefault(), G());
308
+ }, de = (t) => {
309
+ G(t);
310
+ }, $ = p ? /* @__PURE__ */ e("div", { className: "knest-chat-card", children: /* @__PURE__ */ e("div", { className: "knest-loading-container", children: /* @__PURE__ */ o("div", { className: "knest-loading-content", children: [
303
311
  /* @__PURE__ */ e("div", { className: "knest-spinner-ring" }),
304
312
  /* @__PURE__ */ e("p", { className: "knest-loading-text", children: "Loading chat..." })
305
- ] }) }) }) : S === "auth" ? /* @__PURE__ */ e("div", { className: "knest-chat-card", children: /* @__PURE__ */ e("div", { className: "knest-error-container", children: /* @__PURE__ */ e("div", { className: "knest-error-content", children: /* @__PURE__ */ e("p", { className: "knest-error-text", children: ve }) }) }) }) : /* @__PURE__ */ l("div", { className: "knest-chat-card", children: [
306
- /* @__PURE__ */ l("div", { className: "knest-messages-container", children: [
307
- u.map((t, s) => /* @__PURE__ */ l("div", { children: [
313
+ ] }) }) }) : y === "auth" ? /* @__PURE__ */ e("div", { className: "knest-chat-card", children: /* @__PURE__ */ e("div", { className: "knest-error-container", children: /* @__PURE__ */ e("div", { className: "knest-error-content", children: /* @__PURE__ */ e("p", { className: "knest-error-text", children: Le }) }) }) }) : /* @__PURE__ */ o("div", { className: "knest-chat-card", children: [
314
+ /* @__PURE__ */ o("div", { className: "knest-messages-container", children: [
315
+ m.map((t, r) => /* @__PURE__ */ o("div", { children: [
308
316
  /* @__PURE__ */ e(
309
- Me,
317
+ _e,
310
318
  {
311
319
  message: t,
312
- isLoading: !t.content && k && t.role === "assistant",
313
- avatarUrl: Z,
314
- brandColor: O,
315
- publishableApiKey: r,
320
+ isLoading: !t.content && g && t.role === "assistant",
321
+ avatarUrl: ae,
322
+ brandColor: H,
323
+ publishableApiKey: s,
316
324
  baseUrl: f?.baseUrl
317
325
  }
318
326
  ),
319
- s < u.length - 1 && /* @__PURE__ */ e("div", { className: "knest-separator" })
320
- ] }, s)),
321
- u.length === 1 && !C && /* @__PURE__ */ l("div", { className: "knest-examples", children: [
327
+ r < m.length - 1 && /* @__PURE__ */ e("div", { className: "knest-separator" })
328
+ ] }, r)),
329
+ m.length === 1 && !p && /* @__PURE__ */ o("div", { className: "knest-examples", children: [
322
330
  /* @__PURE__ */ e("h3", { children: "Example Questions" }),
323
- K.map((t, s) => /* @__PURE__ */ e(
331
+ re.map((t, r) => /* @__PURE__ */ e(
324
332
  "button",
325
333
  {
326
- onClick: () => re(t),
334
+ onClick: () => de(t),
327
335
  className: "knest-example-btn",
328
- style: s === 0 ? { borderColor: O, borderWidth: "2px" } : {},
336
+ style: r === 0 ? { borderColor: H, borderWidth: "2px" } : {},
329
337
  children: t
330
338
  },
331
- s
339
+ r
332
340
  ))
333
341
  ] }),
334
- /* @__PURE__ */ e("div", { ref: F })
342
+ ne && /* @__PURE__ */ e("p", { className: "knest-human-takeover-caption", children: we }),
343
+ /* @__PURE__ */ e("div", { ref: z })
335
344
  ] }),
336
- /* @__PURE__ */ l("div", { className: "knest-input-section", children: [
345
+ /* @__PURE__ */ o("div", { className: "knest-input-section", children: [
346
+ se && /* @__PURE__ */ o("p", { className: "knest-presence-caption", children: [
347
+ /* @__PURE__ */ e("span", { className: "knest-online-dot" }),
348
+ Ae
349
+ ] }),
337
350
  /* @__PURE__ */ e(
338
351
  "input",
339
352
  {
340
- ref: G,
353
+ ref: Y,
341
354
  type: "file",
342
- accept: pe,
355
+ accept: Ue,
343
356
  multiple: !0,
344
357
  style: { display: "none" },
345
- onChange: ee
358
+ onChange: le
346
359
  }
347
360
  ),
348
- I.length > 0 && /* @__PURE__ */ e("div", { className: "knest-file-preview", children: I.map((t, s) => /* @__PURE__ */ l("span", { className: "knest-file-chip", children: [
361
+ P.length > 0 && /* @__PURE__ */ e("div", { className: "knest-file-preview", children: P.map((t, r) => /* @__PURE__ */ o("span", { className: "knest-file-chip", children: [
349
362
  t.name,
350
363
  /* @__PURE__ */ e(
351
364
  "button",
352
365
  {
353
366
  type: "button",
354
367
  className: "knest-chip-remove",
355
- onClick: () => te(s),
368
+ onClick: () => oe(r),
356
369
  "aria-label": `Remove ${t.name}`,
357
370
  children: "×"
358
371
  }
359
372
  )
360
- ] }, s)) }),
361
- H && /* @__PURE__ */ e("p", { className: "knest-attach-error", children: H }),
362
- /* @__PURE__ */ l("div", { className: "knest-input-wrapper", children: [
373
+ ] }, r)) }),
374
+ V && /* @__PURE__ */ e("p", { className: "knest-attach-error", children: V }),
375
+ /* @__PURE__ */ o("div", { className: "knest-input-wrapper", children: [
363
376
  /* @__PURE__ */ e(
364
377
  "input",
365
378
  {
366
379
  type: "text",
367
- value: o,
380
+ value: l,
368
381
  onChange: (t) => c(t.target.value),
369
- onKeyDown: se,
382
+ onKeyDown: ie,
370
383
  placeholder: "Ask me anything...",
371
- disabled: k || j || !E,
384
+ disabled: g || j || !b,
372
385
  className: "knest-input-field"
373
386
  }
374
387
  ),
375
388
  /* @__PURE__ */ e(
376
389
  "button",
377
390
  {
378
- onClick: () => G.current?.click(),
379
- disabled: !h || k || j,
391
+ onClick: () => Y.current?.click(),
392
+ disabled: !u || g || j,
380
393
  className: "knest-attach-btn",
381
394
  type: "button",
382
- title: h ? "Attach file" : "Send a message first to enable attachments",
395
+ title: u ? "Attach file" : "Send a message first to enable attachments",
383
396
  "aria-label": "Attach file",
384
397
  children: /* @__PURE__ */ e(
385
398
  "svg",
@@ -404,8 +417,8 @@ function Ae({
404
417
  /* @__PURE__ */ e(
405
418
  "button",
406
419
  {
407
- onClick: z,
408
- disabled: k || j || !o.trim() || !E,
420
+ onClick: () => G(),
421
+ disabled: g || j || !l.trim() || !b,
409
422
  className: "knest-send-btn",
410
423
  "aria-label": "Send message",
411
424
  children: /* @__PURE__ */ e("svg", { className: "knest-send-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e(
@@ -420,8 +433,8 @@ function Ae({
420
433
  }
421
434
  )
422
435
  ] }),
423
- u.length > 1 && !k && /* @__PURE__ */ e("div", { className: "knest-reset-row", children: /* @__PURE__ */ e("button", { onClick: ne, className: "knest-reset-btn", children: "Clear chat" }) }),
424
- /* @__PURE__ */ e("div", { className: "knest-footer", children: /* @__PURE__ */ l(
436
+ m.length > 1 && !g && /* @__PURE__ */ e("div", { className: "knest-reset-row", children: /* @__PURE__ */ e("button", { onClick: ce, className: "knest-reset-btn", children: "Clear chat" }) }),
437
+ /* @__PURE__ */ e("div", { className: "knest-footer", children: /* @__PURE__ */ o(
425
438
  "a",
426
439
  {
427
440
  href: "https://useknest.com",
@@ -430,7 +443,7 @@ function Ae({
430
443
  className: "knest-powered-by",
431
444
  children: [
432
445
  /* @__PURE__ */ e("span", { children: "Powered by" }),
433
- /* @__PURE__ */ l(
446
+ /* @__PURE__ */ o(
434
447
  "svg",
435
448
  {
436
449
  width: "14",
@@ -497,19 +510,19 @@ function Ae({
497
510
  ) })
498
511
  ] })
499
512
  ] });
500
- if (T === "inline")
501
- return Q;
502
- const ae = C ? "#9ca3af" : O;
503
- return /* @__PURE__ */ l("div", { className: "knest-bubble-container", children: [
504
- A && /* @__PURE__ */ e("div", { className: "knest-bubble-panel", children: Q }),
513
+ if (W === "inline")
514
+ return $;
515
+ const he = p ? "#9ca3af" : H;
516
+ return /* @__PURE__ */ o("div", { className: "knest-bubble-container", children: [
517
+ I && /* @__PURE__ */ e("div", { className: "knest-bubble-panel", children: $ }),
505
518
  /* @__PURE__ */ e(
506
519
  "button",
507
520
  {
508
- className: ["knest-bubble-button", C && "knest-bubble-loading"].filter(Boolean).join(" "),
509
- onClick: () => J(!A),
510
- "aria-label": C ? "Loading chat" : A ? "Close chat" : "Open chat",
511
- style: { backgroundColor: ae },
512
- children: C ? /* @__PURE__ */ l(
521
+ className: ["knest-bubble-button", p && "knest-bubble-loading"].filter(Boolean).join(" "),
522
+ onClick: () => te(!I),
523
+ "aria-label": p ? "Loading chat" : I ? "Close chat" : "Open chat",
524
+ style: { backgroundColor: he },
525
+ children: p ? /* @__PURE__ */ o(
513
526
  "svg",
514
527
  {
515
528
  width: "24",
@@ -542,7 +555,7 @@ function Ae({
542
555
  )
543
556
  ]
544
557
  }
545
- ) : A ? /* @__PURE__ */ e(
558
+ ) : I ? /* @__PURE__ */ e(
546
559
  "svg",
547
560
  {
548
561
  width: "24",
@@ -577,6 +590,6 @@ function Ae({
577
590
  ] });
578
591
  }
579
592
  export {
580
- Me as ChatMessage,
581
- Ae as ChatWidget
593
+ _e as ChatMessage,
594
+ Oe as ChatWidget
582
595
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useknest/widget-react",
3
- "version": "0.1.0-beta.14",
3
+ "version": "0.1.0-beta.15",
4
4
  "type": "module",
5
5
  "description": "Native React component for Knest chat widget",
6
6
  "files": [
@@ -22,7 +22,7 @@
22
22
  "react-dom": "^18.0.0 || ^19.0.0"
23
23
  },
24
24
  "dependencies": {
25
- "@useknest/widget-core": "0.1.0-beta.14"
25
+ "@useknest/widget-core": "0.1.0-beta.15"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/react": "^18.3.3",