react-ai-ragbot
Version:
React component library that provides plug-and-play AI chat and voice assistant UIs. Designed to work seamlessly with the node-ragbot backend, it enables developers to quickly add an OpenAI-powered conversational experience to any website or app. Features
144 lines (143 loc) • 46.4 kB
JavaScript
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.bottom-20{bottom:5rem}.bottom-6{bottom:1.5rem}.right-0{right:0}.right-6{right:1.5rem}.z-10{z-index:10}.z-50{z-index:50}.z-\\[60\\]{z-index:60}.mx-6{margin-left:1.5rem;margin-right:1.5rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.ml-0\\.5{margin-left:.125rem}.mt-1\\.5{margin-top:.375rem}.inline-block{display:inline-block}.flex{display:flex}.h-11{height:2.75rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-3\\.5{height:.875rem}.h-32{height:8rem}.h-4{height:1rem}.h-6{height:1.5rem}.h-8{height:2rem}.h-\\[500px\\]{height:500px}.h-full{height:100%}.max-h-20{max-height:5rem}.min-h-\\[44px\\]{min-height:44px}.w-0\\.5{width:.125rem}.w-1{width:.25rem}.w-11{width:2.75rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-4{width:1rem}.w-6{width:1.5rem}.w-8{width:2rem}.w-96{width:24rem}.w-full{width:100%}.min-w-0{min-width:0px}.max-w-\\[calc\\(100\\%-40px\\)\\]{max-width:calc(100% - 40px)}.max-w-lg{max-width:32rem}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.resize-none{resize:none}.flex-row-reverse{flex-direction:row-reverse}.flex-col{flex-direction:column}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-3{gap:.75rem}.gap-4{gap:1rem}.space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.25rem * var(--tw-space-x-reverse));margin-left:calc(.25rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-y-auto{overflow-y:auto}.overflow-y-scroll{overflow-y:scroll}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-2xl{border-radius:1rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-xl{border-radius:.75rem}.rounded-b-2xl{border-bottom-right-radius:1rem;border-bottom-left-radius:1rem}.rounded-t-2xl{border-top-left-radius:1rem;border-top-right-radius:1rem}.rounded-tl-sm{border-top-left-radius:.125rem}.border{border-width:1px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-t{border-top-width:1px}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-200\\/20{border-color:#e5e7eb33}.border-gray-200\\/50{border-color:#e5e7eb80}.border-gray-700{--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1))}.border-gray-700\\/50{border-color:#37415180}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-red-800\\/50{border-color:#991b1b80}.border-slate-200{--tw-border-opacity: 1;border-color:rgb(226 232 240 / var(--tw-border-opacity, 1))}.border-slate-200\\/60{border-color:#e2e8f099}.border-slate-200\\/80{border-color:#e2e8f0cc}.border-slate-600{--tw-border-opacity: 1;border-color:rgb(71 85 105 / var(--tw-border-opacity, 1))}.border-slate-600\\/60{border-color:#47556999}.border-slate-600\\/80{border-color:#475569cc}.bg-black\\/50{background-color:#00000080}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-gray-50\\/50{background-color:#f9fafb80}.bg-gray-800\\/50{background-color:#1f293780}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.bg-gray-900\\/90{background-color:#111827e6}.bg-gray-900\\/95{background-color:#111827f2}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-900\\/20{background-color:#7f1d1d33}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity, 1))}.bg-slate-50\\/80{background-color:#f8fafccc}.bg-slate-700{--tw-bg-opacity: 1;background-color:rgb(51 65 85 / var(--tw-bg-opacity, 1))}.bg-slate-700\\/80{background-color:#334155cc}.bg-slate-800{--tw-bg-opacity: 1;background-color:rgb(30 41 59 / var(--tw-bg-opacity, 1))}.bg-slate-800\\/80{background-color:#1e293bcc}.bg-slate-800\\/90{background-color:#1e293be6}.bg-slate-900\\/95{background-color:#0f172af2}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\\/80{background-color:#fffc}.bg-white\\/90{background-color:#ffffffe6}.bg-white\\/95{background-color:#fffffff2}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-blue-500{--tw-gradient-from: #3b82f6 var(--tw-gradient-from-position);--tw-gradient-to: rgb(59 130 246 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-green-500{--tw-gradient-from: #22c55e var(--tw-gradient-from-position);--tw-gradient-to: rgb(34 197 94 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-slate-700{--tw-gradient-from: #334155 var(--tw-gradient-from-position);--tw-gradient-to: rgb(51 65 85 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-cyan-500{--tw-gradient-to: #06b6d4 var(--tw-gradient-to-position)}.to-purple-600{--tw-gradient-to: #9333ea var(--tw-gradient-to-position)}.to-slate-600{--tw-gradient-to: #475569 var(--tw-gradient-to-position)}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-left{text-align:left}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-medium{font-weight:500}.font-semibold{font-weight:600}.leading-relaxed{line-height:1.625}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-slate-100{--tw-text-opacity: 1;color:rgb(241 245 249 / var(--tw-text-opacity, 1))}.text-slate-200{--tw-text-opacity: 1;color:rgb(226 232 240 / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity, 1))}.text-slate-500{--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity, 1))}.text-slate-800{--tw-text-opacity: 1;color:rgb(30 41 59 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.placeholder-slate-400::-moz-placeholder{--tw-placeholder-opacity: 1;color:rgb(148 163 184 / var(--tw-placeholder-opacity, 1))}.placeholder-slate-400::placeholder{--tw-placeholder-opacity: 1;color:rgb(148 163 184 / var(--tw-placeholder-opacity, 1))}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-blue-500\\/30{--tw-shadow-color: rgb(59 130 246 / .3);--tw-shadow: var(--tw-shadow-colored)}.shadow-slate-900\\/30{--tw-shadow-color: rgb(15 23 42 / .3);--tw-shadow: var(--tw-shadow-colored)}.backdrop-blur-lg{--tw-backdrop-blur: blur(16px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-md{--tw-backdrop-blur: blur(12px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.ragbot-voice,.ragbot-chat{text-align:left}.hover\\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:border-blue-600:hover{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.hover\\:border-red-600:hover{--tw-border-opacity: 1;border-color:rgb(220 38 38 / var(--tw-border-opacity, 1))}.hover\\:bg-blue-600:hover{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.hover\\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.hover\\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity, 1))}.hover\\:bg-slate-700:hover{--tw-bg-opacity: 1;background-color:rgb(51 65 85 / var(--tw-bg-opacity, 1))}.hover\\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\\:text-slate-200:hover{--tw-text-opacity: 1;color:rgb(226 232 240 / var(--tw-text-opacity, 1))}.hover\\:text-slate-700:hover{--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity, 1))}.hover\\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\\:border-blue-500:focus{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\\:ring-4:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\\:ring-blue-500\\/30:focus{--tw-ring-color: rgb(59 130 246 / .3)}.focus\\:ring-blue-500\\/40:focus{--tw-ring-color: rgb(59 130 246 / .4)}.active\\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}')),document.head.appendChild(t)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
(function(D,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],a):(D=typeof globalThis<"u"?globalThis:D||self,a(D.ReactRagbot={},D.React))})(this,(function(D,a){"use strict";var X={exports:{}},$={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var se;function de(){if(se)return $;se=1;var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function f(d,l,o){var x=null;if(o!==void 0&&(x=""+o),l.key!==void 0&&(x=""+l.key),"key"in l){o={};for(var u in l)u!=="key"&&(o[u]=l[u])}else o=l;return l=o.ref,{$$typeof:r,type:d,key:x,ref:l!==void 0?l:null,props:o}}return $.Fragment=n,$.jsx=f,$.jsxs=f,$}var J={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ae;function ue(){return ae||(ae=1,process.env.NODE_ENV!=="production"&&(function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===F?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case i:return"Fragment";case C:return"Profiler";case _:return"StrictMode";case M:return"Suspense";case H:return"SuspenseList";case W:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case A:return"Portal";case E:return(e.displayName||"Context")+".Provider";case O:return(e._context.displayName||"Context")+".Consumer";case w:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U:return s=e.displayName||null,s!==null?s:r(e.type)||"Memo";case Y:s=e._payload,e=e._init;try{return r(e(s))}catch{}}return null}function n(e){return""+e}function f(e){try{n(e);var s=!1}catch{s=!0}if(s){s=console;var c=s.error,h=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",h),n(e)}}function d(e){if(e===i)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===Y)return"<...>";try{var s=r(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function l(){var e=S.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function x(e){if(p.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function u(e,s){function c(){m||(m=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function v(){var e=r(this.type);return b[e]||(b[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function k(e,s,c,h,L,P,ee,te){return c=P.ref,e={$$typeof:T,type:e,key:s,props:P,_owner:L},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:v}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function g(e,s,c,h,L,P,ee,te){var j=s.children;if(j!==void 0)if(h)if(I(j)){for(h=0;h<j.length;h++)R(j[h]);Object.freeze&&Object.freeze(j)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else R(j);if(p.call(s,"key")){j=r(e);var V=Object.keys(s).filter(function(ke){return ke!=="key"});h=0<V.length?"{key: someKey, "+V.join(": ..., ")+": ...}":"{key: someKey}",G[j+h]||(V=0<V.length?"{"+V.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,h,j,V,j),G[j+h]=!0)}if(j=null,c!==void 0&&(f(c),j=""+c),x(s)&&(f(s.key),j=""+s.key),"key"in s){c={};for(var re in s)re!=="key"&&(c[re]=s[re])}else c=s;return j&&u(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),k(e,j,P,L,l(),c,ee,te)}function R(e){typeof e=="object"&&e!==null&&e.$$typeof===T&&e._store&&(e._store.validated=1)}var y=a,T=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),E=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),S=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,p=Object.prototype.hasOwnProperty,I=Array.isArray,N=console.createTask?console.createTask:function(){return null};y={react_stack_bottom_frame:function(e){return e()}};var m,b={},B=y.react_stack_bottom_frame.bind(y,o)(),q=N(d(o)),G={};J.Fragment=i,J.jsx=function(e,s,c,h,L){var P=1e4>S.recentlyCreatedOwnerStacks++;return g(e,s,c,!1,h,L,P?Error("react-stack-top-frame"):B,P?N(d(e)):q)},J.jsxs=function(e,s,c,h,L){var P=1e4>S.recentlyCreatedOwnerStacks++;return g(e,s,c,!0,h,L,P?Error("react-stack-top-frame"):B,P?N(d(e)):q)}})()),J}var oe;function fe(){return oe||(oe=1,process.env.NODE_ENV==="production"?X.exports=de():X.exports=ue()),X.exports}var t=fe();/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const me=r=>r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),be=r=>r.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,f,d)=>d?d.toUpperCase():f.toLowerCase()),ne=r=>{const n=be(r);return n.charAt(0).toUpperCase()+n.slice(1)},le=(...r)=>r.filter((n,f,d)=>!!n&&n.trim()!==""&&d.indexOf(n)===f).join(" ").trim(),he=r=>{for(const n in r)if(n.startsWith("aria-")||n==="role"||n==="title")return!0};/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var xe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const pe=a.forwardRef(({color:r="currentColor",size:n=24,strokeWidth:f=2,absoluteStrokeWidth:d,className:l="",children:o,iconNode:x,...u},v)=>a.createElement("svg",{ref:v,...xe,width:n,height:n,stroke:r,strokeWidth:d?Number(f)*24/Number(n):f,className:le("lucide",l),...!o&&!he(u)&&{"aria-hidden":"true"},...u},[...x.map(([k,g])=>a.createElement(k,g)),...Array.isArray(o)?o:[o]]));/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const z=(r,n)=>{const f=a.forwardRef(({className:d,...l},o)=>a.createElement(pe,{ref:o,iconNode:n,className:le(`lucide-${me(ne(r))}`,`lucide-${r}`,d),...l}));return f.displayName=ne(r),f};/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Z=z("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ge=z("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const K=z("message-circle",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]);/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const we=z("mic-off",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]]);/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ie=z("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ye=z("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ve=z("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const je=z("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
* @license lucide-react v0.544.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Q=z("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ce=({darkMode:r,title:n,messages:f,isOpen:d,isLoading:l,isTyping:o,typingText:x,inputValue:u,setInputValue:v,inputRef:k,messagesEndRef:g,formatTime:R,handleSendMessage:y,handleKeyPress:T,resetChat:A})=>t.jsxs("div",{className:`
ragbot-chat flex flex-col w-96 h-[500px]
${r?"bg-slate-900/95 border-slate-600/80":"bg-white/95 border-slate-200/80"}
rounded-2xl border backdrop-blur-md shadow-2xl
${d?"animate-in slide-in-from-bottom-4 zoom-in-90":"animate-out slide-out-to-bottom-4 zoom-out-90"}
duration-300 ease-out
`,children:[t.jsxs("div",{className:`
flex items-center justify-between p-4
${r?"bg-slate-800/90 border-slate-600/80":"bg-white/90 border-slate-200/80"}
border-b rounded-t-2xl
`,children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 p-1 rounded-lg bg-gradient-to-br from-blue-500 to-purple-600 text-white flex items-center justify-center",children:t.jsx(K,{size:18})}),t.jsx("span",{className:`font-semibold text-base ${r?"text-slate-100":"text-slate-800"}`,children:n})]}),t.jsx("button",{onClick:A,className:`
p-2 rounded-lg transition-colors
${r?"hover:bg-slate-700 text-slate-400 hover:text-slate-200":"hover:bg-slate-100 text-slate-500 hover:text-slate-700"}
`,children:t.jsx(Q,{size:16})})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[f.map(i=>t.jsxs("div",{className:`flex gap-3 animate-in slide-in-from-bottom-2 duration-300 ${i.isBot?"":"flex-row-reverse"}`,children:[t.jsx("div",{className:`
w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 text-white
${i.isBot?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-green-500 to-cyan-500"}
`,children:i.isBot?t.jsx(Z,{size:16}):t.jsx(ve,{size:16})}),t.jsxs("div",{className:"flex-1 max-w-[calc(100%-40px)]",children:[t.jsx("div",{className:`
px-4 py-3 rounded-xl text-sm leading-relaxed break-words text-left
${i.isBot?r?"bg-slate-800/80 text-slate-200 border border-slate-600/60":"bg-slate-50/80 text-slate-700 border border-slate-200/60":"bg-gradient-to-r from-blue-500 to-purple-600 text-white"}
`,children:i.text}),t.jsx("div",{className:`text-xs mt-1.5 opacity-60 text-left ${r?"text-slate-400":"text-slate-500"}`,children:R(i.timestamp)})]})]},i.id)),l&&t.jsxs("div",{className:"flex gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-blue-500 to-purple-600 text-white flex items-center justify-center",children:t.jsx(Z,{size:16})}),t.jsx("div",{className:`
px-4 py-3 rounded-xl rounded-tl-sm text-left text-sm
${r?"bg-slate-800/80 border border-slate-600/60":"bg-slate-50/80 border border-slate-200/60"}
`,children:"Thinking..."})]}),o&&t.jsxs("div",{className:"flex gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-blue-500 to-purple-600 text-white flex items-center justify-center",children:t.jsx(Z,{size:16})}),t.jsxs("div",{className:`
px-4 py-3 rounded-xl rounded-tl-sm text-sm text-left leading-relaxed
${r?"bg-slate-800/80 text-slate-200 border border-slate-600/60":"bg-slate-50/80 text-slate-700 border border-slate-200/60"}
`,children:[x,t.jsx("span",{className:"inline-block w-0.5 h-3.5 ml-0.5 bg-blue-500 animate-pulse"})]})]}),t.jsx("div",{ref:g})]}),t.jsx("div",{className:`
p-4 border-t
${r?"bg-slate-800/90 border-slate-600/80":"bg-white/90 border-slate-200/80"}
rounded-b-2xl
`,children:t.jsxs("div",{className:"flex gap-3 items-end",children:[t.jsx("textarea",{ref:k,value:u,onChange:i=>v(i.target.value),onKeyDown:T,placeholder:"Type your message...",rows:1,disabled:l||o,className:`
flex-1 resize-none rounded-xl px-4 py-3 text-sm transition-all
max-h-20 min-h-[44px] border text-left
${r?"bg-slate-700/80 border-slate-600/80 text-slate-100 placeholder-slate-400":"bg-white/80 border-slate-200/80 text-slate-700 placeholder-slate-400"}
focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-500
disabled:opacity-50 disabled:cursor-not-allowed
`}),t.jsx("button",{onClick:y,disabled:!u.trim()||l||o,className:`
w-11 h-11 rounded-xl flex items-center justify-center transition-all
${!u.trim()||l||o?r?"bg-slate-700 text-slate-500 cursor-not-allowed":"bg-slate-200 text-slate-400 cursor-not-allowed":"bg-gradient-to-r from-blue-500 to-purple-600 text-white hover:shadow-lg hover:scale-105 active:scale-95"}
`,children:t.jsx(ye,{size:16})})]})})]}),Ne=({backendUrl:r,darkMode:n=!1,title:f="AI Assistant",displayMode:d="float",buttonText:l,className:o=""})=>{const[x,u]=a.useState([{id:1,text:"Hi! I'm here to help answer your questions. What would you like to know?",isBot:!0,timestamp:new Date}]),[v,k]=a.useState(""),[g,R]=a.useState(!1),[y,T]=a.useState(""),[A,i]=a.useState(!1),[_,C]=a.useState(!1),O=a.useRef(null),E=a.useRef(null),w=a.useRef(null);a.useEffect(()=>{O.current?.scrollIntoView({behavior:"smooth"})},[x,A]);const M=p=>{i(!0),T("");let I=0;const N=()=>{I<p.length?(T(p.substring(0,I+1)),I++,w.current=setTimeout(N,30)):(i(!1),u(m=>[...m,{id:Date.now()+1,text:p,isBot:!0,timestamp:new Date}]))};N()},H=()=>{w.current&&(clearTimeout(w.current),w.current=null),i(!1),T("")},U=async()=>{if(!v.trim()||g||A)return;const p={id:Date.now(),text:v,isBot:!1,timestamp:new Date};u(N=>[...N,p]);const I=v;k(""),R(!0);try{const N=await fetch(`${r}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:I})});if(!N.ok)throw new Error("Failed to get response");const b=(await N.json()).answer||"Sorry, I couldn't process your request.";R(!1),M(b)}catch(N){console.error("Error:",N),R(!1),u(m=>[...m,{id:Date.now()+1,text:"Sorry, there was an error processing your request. Please try again.",isBot:!0,timestamp:new Date}])}},Y=p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),U())},W=()=>{H(),u([{id:1,text:"Hi! I'm here to help answer your questions. What would you like to know?",isBot:!0,timestamp:new Date}]),k(""),R(!1),C(!1)},F=p=>p.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),S=n?{background:"bg-gradient-to-r from-slate-700 to-slate-600",shadow:"shadow-slate-900/30"}:{background:"bg-gradient-to-r from-blue-500 to-purple-600",shadow:"shadow-blue-500/30"};return d==="popup"?_?t.jsxs("div",{className:`fixed inset-0 z-50 ${o}`,children:[t.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>C(!1)}),t.jsx("div",{className:"relative z-10 w-full h-full flex items-center justify-center p-4",children:t.jsx(ce,{darkMode:n,title:f,messages:x,isOpen:_,isLoading:g,isTyping:A,typingText:y,inputValue:v,setInputValue:k,inputRef:E,messagesEndRef:O,formatTime:F,handleSendMessage:U,handleKeyPress:Y,resetChat:W})})]}):t.jsx("div",{className:`fixed bottom-6 right-6 z-50 ${o}`,children:t.jsxs("div",{className:"relative flex items-center gap-3",children:[l&&t.jsx("div",{className:`
px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap shadow-lg
${n?"bg-slate-800 text-slate-200 border border-slate-600":"bg-white text-slate-700 border border-slate-200"}
`,children:l}),t.jsx("button",{onClick:()=>C(!0),className:`w-16 h-16 rounded-full text-white flex items-center justify-center ${S.background} shadow-lg ${S.shadow}`,children:t.jsx(K,{size:28})})]})}):t.jsxs("div",{className:`fixed bottom-6 right-6 z-50 ${o}`,children:[_&&t.jsx("div",{className:"absolute bottom-20 right-0 z-10",children:t.jsx(ce,{darkMode:n,title:f,messages:x,isOpen:_,isLoading:g,isTyping:A,typingText:y,inputValue:v,setInputValue:k,inputRef:E,messagesEndRef:O,formatTime:F,handleSendMessage:U,handleKeyPress:Y,resetChat:W})}),t.jsx("div",{className:`fixed bottom-6 right-6 z-50 ${o}`,children:t.jsxs("div",{className:"relative flex items-center gap-3",children:[l&&!_&&t.jsx("div",{className:`
px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap shadow-lg
${n?"bg-slate-800 text-slate-200 border border-slate-600":"bg-white text-slate-700 border border-slate-200"}
`,children:l}),t.jsx("button",{onClick:()=>C(p=>!p),className:`w-16 h-16 rounded-full text-white flex items-center justify-center ${S.background} shadow-lg ${S.shadow}`,children:_?t.jsx(Q,{size:28}):t.jsx(K,{size:28})})]})})]})},_e=({darkMode:r=!1,backendUrl:n,text:f})=>{const[d,l]=a.useState(!1),[o,x]=a.useState(!1),[u,v]=a.useState(!1),[k,g]=a.useState(""),[R,y]=a.useState("Tap to speak"),[T,A]=a.useState(!1),i=a.useRef(null),_=a.useRef([]),C=a.useRef(null),O=a.useRef(null),E=a.useRef(null),w=a.useRef(null);a.useEffect(()=>{(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)&&g("Your browser does not support audio recording")},[]),a.useEffect(()=>{O.current&&O.current.scrollTo({top:O.current.scrollHeight,behavior:"smooth"})},[R]);const M=()=>{i.current&&d&&i.current.stop(),E.current&&(E.current.getTracks().forEach(m=>m.stop()),E.current=null),w.current&&(w.current.pause(),w.current.currentTime=0,w.current.src=""),F(),l(!1),x(!1),v(!1),g(""),y("Tap to speak"),_.current=[],i.current=null},H=async()=>{try{g(""),y("Listening...");const m=await navigator.mediaDevices.getUserMedia({audio:!0});E.current=m,i.current=new MediaRecorder(m,{mimeType:"audio/webm;codecs=opus"}),_.current=[],i.current.ondataavailable=b=>{b.data.size>0&&_.current.push(b.data)},i.current.onstop=()=>{if(_.current.length>0){const b=new Blob(_.current,{type:"audio/webm"});Y(b)}E.current&&(E.current.getTracks().forEach(b=>b.stop()),E.current=null)},i.current.start(),l(!0)}catch(m){g(`Failed to access microphone: ${m.message}`),M()}},U=()=>{i.current&&d&&(i.current.stop(),l(!1),x(!0),y("Processing..."))},Y=async m=>{try{const b=await m.arrayBuffer(),B=await fetch(`${n}/voice`,{method:"POST",headers:{"Content-Type":"audio/webm"},body:b});if(!B.ok)throw new Error("Server error");const{transcription:q,answer:G,audio:e}=await B.json();if(G&&W(G),e&&w.current){const s=new Blob([Uint8Array.from(atob(e),h=>h.charCodeAt(0))],{type:"audio/mpeg"}),c=URL.createObjectURL(s);w.current.src=c,w.current.onloadeddata=()=>{x(!1),v(!0),w.current?.play()},w.current.onended=()=>{v(!1),URL.revokeObjectURL(c)},w.current.onerror=h=>{console.error("Audio playback error:",h),v(!1),URL.revokeObjectURL(c),g("Failed to play audio response")}}else x(!1)}catch(b){g(`Failed to process audio: ${b.message}`),x(!1),y("Tap to speak")}},W=m=>{if(F(),!m||m.length===0){y("Tap to speak");return}y("");let b=0;const B=()=>{b<m.length&&(y(m.substring(0,b+1)),b++,C.current=window.setTimeout(B,50))};B()},F=()=>{C.current&&(window.clearTimeout(C.current),C.current=null)},S=()=>{if(!T){g(""),A(!0);return}d?U():!o&&!u&&H()},p=()=>{u||(M(),A(!1))},I=()=>t.jsx("div",{className:"flex items-center justify-center space-x-1 flex-1",children:[...Array(5)].map((m,b)=>t.jsx("div",{className:`w-1 rounded-full transition-all duration-300 ${r?"bg-blue-400":"bg-blue-500"}`,style:{height:"12px",animation:"waveAnimation 1.5s ease-in-out infinite",animationDelay:`${b*.1}s`}},b))}),N=()=>t.jsxs("div",{className:`ragbot-voice w-full max-w-lg mx-auto rounded-2xl backdrop-blur-lg border transition-all duration-300 ${r?"bg-gray-900/95 border-gray-700/50 text-white":"bg-white/95 border-gray-200/50 text-gray-900"} shadow-2xl`,children:[t.jsxs("div",{className:"flex justify-between items-center p-4 border-b border-gray-200/20",children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Voice Assistant"}),t.jsx("button",{onClick:p,disabled:u,className:`w-8 h-8 rounded-full flex items-center justify-center transition-colors ${u?"opacity-50 cursor-not-allowed":r?"hover:bg-gray-800 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-600 hover:text-gray-900"}`,children:t.jsx(Q,{className:"w-4 h-4"})})]}),t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[t.jsx("button",{className:`flex-shrink-0 flex items-center justify-center w-16 h-16 rounded-full border-2 transition-all duration-200 focus:outline-none focus:ring-4 focus:ring-blue-500/30 ${d?"bg-red-500 border-red-500 hover:bg-red-600 hover:border-red-600 animate-pulse":o||u?"bg-blue-500 border-blue-500 cursor-not-allowed":"bg-blue-500 border-blue-500 hover:bg-blue-600 hover:border-blue-600 hover:scale-105"}`,onClick:S,disabled:o,children:o?t.jsx(ge,{className:"w-6 h-6 text-white animate-spin"}):u?t.jsx(je,{className:"w-6 h-6 text-white"}):d?t.jsx(we,{className:"w-6 h-6 text-white"}):t.jsx(ie,{className:"w-6 h-6 text-white"})}),t.jsx("div",{className:"flex-1 min-w-0",children:d?I():t.jsx("div",{className:"text-base font-medium",children:o||u?"Answering your question...":"Ready to listen"})})]}),t.jsx("div",{className:`h-32 overflow-y-scroll p-4 rounded-lg border text-sm leading-relaxed ${r?"bg-gray-800/50 border-gray-700/50":"bg-gray-50/50 border-gray-200/50"} scrollbar-thin scrollbar-thumb-gray-400 scrollbar-track-transparent`,style:{scrollbarWidth:"thin",scrollbarColor:r?"#6B7280 transparent":"#9CA3AF transparent"},children:t.jsx("div",{ref:O,className:"whitespace-pre-wrap",children:R})})]}),k&&t.jsx("div",{className:`mx-6 mb-6 p-3 rounded-lg border text-sm ${r?"bg-red-900/20 border-red-800/50 text-red-400":"bg-red-50 border-red-200 text-red-700"}`,children:k})]});return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed bottom-6 right-6 z-50",children:t.jsxs("div",{className:"flex items-center gap-3",children:[f&&t.jsx("div",{className:`px-4 py-2 rounded-full backdrop-blur-lg border shadow-lg transition-all duration-200 ${r?"bg-gray-900/90 border-gray-700/50 text-white":"bg-white/90 border-gray-200/50 text-gray-900"}`,children:t.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:f})}),t.jsx("button",{className:`flex items-center justify-center w-14 h-14 rounded-full border-2 transition-all duration-200 focus:outline-none focus:ring-4 focus:ring-blue-500/30 shadow-2xl ${r?"bg-gray-900 border-gray-700 text-white hover:bg-gray-800":"bg-white border-gray-200 text-gray-900 hover:bg-gray-50"} hover:scale-105`,onClick:S,children:t.jsx(ie,{className:"w-6 h-6"})})]})}),T&&t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[t.jsx("style",{children:`
@keyframes waveAnimation {
0%, 100% {
height: 8px;
opacity: 0.6;
}
50% {
height: 24px;
opacity: 1;
}
}
`}),t.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:p}),t.jsx("div",{className:"relative z-10 w-full max-w-lg",children:N()})]}),t.jsx("audio",{ref:w,style:{display:"none"}})]})};D.ChatBot=Ne,D.VoiceBot=_e,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));