UNPKG

chatnest

Version:

A lightweight, customizable, and responsive chat widget for modern web applications.

2 lines 210 kB
/*! For license information please see chat-widget.min.js.LICENSE.txt */ !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.EasyChatWidget=n():t.EasyChatWidget=n()}(this,(()=>{return t={877:t=>{function n(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,i)}return e}function e(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(Object(o),!0).forEach((function(n){i(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(o,n))}))}return t}function i(t,n,e){return(n=w(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function a(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var i,o,a,r,s=[],c=!0,l=!1;try{if(a=(e=e.call(t)).next,0===n){if(Object(e)!==e)return;c=!1}else for(;!(c=(i=a.call(e)).done)&&(s.push(i.value),s.length!==n);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=e.return&&(r=e.return(),Object(r)!==r))return}finally{if(l)throw o}}return s}}(t,n)||function(t,n){if(t){if("string"==typeof t)return r(t,n);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?r(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,i=Array(n);e<n;e++)i[e]=t[e];return i}function s(){"use strict";var t=h(),n=t.m(s),e=(Object.getPrototypeOf?Object.getPrototypeOf(n):n.__proto__).constructor;function i(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===e||"GeneratorFunction"===(n.displayName||n.name))}var o={throw:1,return:2,break:3,continue:3};function a(t){var n,e;return function(i){n||(n={stop:function(){return e(i.a,2)},catch:function(){return i.v},abrupt:function(t,n){return e(i.a,o[t],n)},delegateYield:function(t,o,a){return n.resultName=o,e(i.d,c(t),a)},finish:function(t){return e(i.f,t)}},e=function(t,e,o){i.p=n.prev,i.n=n.next;try{return t(e,o)}finally{n.next=i.n}}),n.resultName&&(n[n.resultName]=i.v,n.resultName=void 0),n.sent=i.v,n.next=i.n;try{return t.call(this,n)}finally{i.p=n.prev,i.n=n.next}}}return(s=function(){return{wrap:function(n,e,i,o){return t.w(a(n),e,i,o&&o.reverse())},isGeneratorFunction:i,mark:t.m,awrap:function(t,n){return new g(t,n)},AsyncIterator:d,async:function(t,n,e,o,r){return(i(n)?p:u)(a(t),n,e,o,r)},keys:l,values:c}})()}function c(t){if(null!=t){var n=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],e=0;if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}}}throw new TypeError(o(t)+" is not iterable")}function l(t){var n=Object(t),e=[];for(var i in n)e.unshift(i);return function t(){for(;e.length;)if((i=e.pop())in n)return t.value=i,t.done=!1,t;return t.done=!0,t}}function u(t,n,e,i,o){var a=p(t,n,e,i,o);return a.next().then((function(t){return t.done?t.value:a.next()}))}function p(t,n,e,i,o){return new d(h().w(t,n,e,i),o||Promise)}function d(t,n){function e(i,o,a,r){try{var s=t[i](o),c=s.value;return c instanceof g?n.resolve(c.v).then((function(t){e("next",t,a,r)}),(function(t){e("throw",t,a,r)})):n.resolve(c).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,r)}))}catch(t){r(t)}}var i;this.next||(m(d.prototype),m(d.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",(function(){return this}))),m(this,"_invoke",(function(t,o,a){function r(){return new n((function(n,i){e(t,a,n,i)}))}return i=i?i.then(r,r):r()}),!0)}function h(){var t,n,e="function"==typeof Symbol?Symbol:{},i=e.iterator||"@@iterator",o=e.toStringTag||"@@toStringTag";function a(e,i,o,a){var c=i&&i.prototype instanceof s?i:s,l=Object.create(c.prototype);return m(l,"_invoke",function(e,i,o){var a,s,c,l=0,u=o||[],p=!1,d={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(n,e){return a=n,s=0,c=t,d.n=e,r}};function h(e,i){for(s=e,c=i,n=0;!p&&l&&!o&&n<u.length;n++){var o,a=u[n],h=d.p,m=a[2];e>3?(o=m===i)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=h&&((o=e<2&&h<a[1])?(s=0,d.v=i,d.n=a[1]):h<m&&(o=e<3||a[0]>i||i>m)&&(a[4]=e,a[5]=i,d.n=m,s=0))}if(o||e>1)return r;throw p=!0,i}return function(o,u,m){if(l>1)throw TypeError("Generator is already running");for(p&&1===u&&h(u,m),s=u,c=m;(n=s<2?t:c)||!p;){a||(s?s<3?(s>1&&(d.n=-1),h(s,c)):d.n=c:d.v=c);try{if(l=2,a){if(s||(o="next"),n=a[o]){if(!(n=n.call(a,c)))throw TypeError("iterator result is not an object");if(!n.done)return n;c=n.value,s<2&&(s=0)}else 1===s&&(n=a.return)&&n.call(a),s<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),s=1);a=t}else if((n=(p=d.n<0)?c:e.call(i,d))!==r)break}catch(n){a=t,s=1,c=n}finally{l=1}}return{value:n,done:p}}}(e,o,a),!0),l}var r={};function s(){}function c(){}function l(){}n=Object.getPrototypeOf;var u=[][i]?n(n([][i]())):(m(n={},i,(function(){return this})),n),p=l.prototype=s.prototype=Object.create(u);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,m(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=l,m(p,"constructor",l),m(l,"constructor",c),c.displayName="GeneratorFunction",m(l,o,"GeneratorFunction"),m(p),m(p,o,"Generator"),m(p,i,(function(){return this})),m(p,"toString",(function(){return"[object Generator]"})),(h=function(){return{w:a,m:d}})()}function m(t,n,e,i){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}m=function(t,n,e,i){if(n)o?o(t,n,{value:e,enumerable:!i,configurable:!i,writable:!i}):t[n]=e;else{var a=function(n,e){m(t,n,(function(t){return this._invoke(n,e,t)}))};a("next",0),a("throw",1),a("return",2)}},m(t,n,e,i)}function g(t,n){this.v=t,this.k=n}function f(t,n,e,i,o,a,r){try{var s=t[a](r),c=s.value}catch(t){return void e(t)}s.done?n(c):Promise.resolve(c).then(i,o)}function v(t){return function(){var n=this,e=arguments;return new Promise((function(i,o){var a=t.apply(n,e);function r(t){f(a,i,o,r,s,"next",t)}function s(t){f(a,i,o,r,s,"throw",t)}r(void 0)}))}}function b(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function y(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,w(i.key),i)}}function x(t,n,e){return n&&y(t.prototype,n),e&&y(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function w(t){var n=function(t,n){if("object"!=o(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,n||"default");if("object"!=o(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==o(n)?n:n+""}var D=function(){return x((function t(){var n=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};b(this,t),this.isWaitingForResponse=!1,this.initConfig(e),this.userManager=new k(this.config),this.storageManager=new E(this.userManager,this.config),this.ensureDependencies().then((function(){n.initializeWidget(),n.setupEventListeners(),n.storageManager.setWidget(n),n.loadChatHistory(),n.setupEraseButton()})),this.activeForm=null,C[this.config.position]||(console.warn('Invalid position "'.concat(this.config.position,'". Falling back to bottom-right.')),this.config.position="bottom-right")}),[{key:"hexToRgb",value:function(t){if(!t)return"0, 132, 255";if(t.includes("linear-gradient")||t.includes("radial-gradient")){var n=t.match(/#[a-fA-F0-9]{6}|#[a-fA-F0-9]{3}/);if(n){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n[0]);return e?"".concat(parseInt(e[1],16),", ").concat(parseInt(e[2],16),", ").concat(parseInt(e[3],16)):"0, 132, 255"}return"0, 132, 255"}var i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return i?"".concat(parseInt(i[1],16),", ").concat(parseInt(i[2],16),", ").concat(parseInt(i[3],16)):"0, 132, 255"}},{key:"isGradient",value:function(t){return t&&(t.includes("linear-gradient")||t.includes("radial-gradient"))}},{key:"getCurrentTheme",value:function(){return"system"===this.config.theme?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":this.config.theme}},{key:"getThemeColor",value:function(t){var n,e={light:{bg:"#ffffff",text:"#333333",border:"#e1e5e9",inputBg:"#ffffff",messageBg:"#ffffff",headerBg:"#ffffff",headerText:"#333333"},dark:{bg:"#1a1a1a",text:"#ffffff",border:"#404040",inputBg:"#2d2d2d",messageBg:"#2d2d2d",headerBg:"#2d2d2d",headerText:"#ffffff"}};return(null===(n=e[this.getCurrentTheme()])||void 0===n?void 0:n[t])||e.light[t]}},{key:"applyTheme",value:function(){var t=this,n=this.getCurrentTheme();this.widget&&(this.widget.className="chat-widget ".concat(n,"-theme")),"system"===this.config.theme&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(function(){t.loadStyles()}))}},{key:"generateAiAvatar",value:function(){if(!this.config.showAiAvatar)return"";var t=this.config.aiAvatar;return t?this.isEmoji(t)?'\n <div class="ai-avatar">\n <div class="ai-avatar-icon emoji-avatar">'.concat(t,'</div>\n <div class="ai-name">').concat(this.config.botName,"</div>\n </div>\n "):this.isImageUrl(t)?'\n <div class="ai-avatar">\n <div class="ai-avatar-icon image-avatar">\n <img src="'.concat(t,'" alt="').concat(this.config.botName,'" \n onerror="this.style.display=\'none\'; this.parentNode.innerHTML=\'🤖\';" \n onload="this.style.display=\'block\';" />\n </div>\n <div class="ai-name">').concat(this.config.botName,"</div>\n </div>\n "):this.isSvg(t)?'\n <div class="ai-avatar">\n <div class="ai-avatar-icon svg-avatar">\n '.concat(this.sanitizeSvg(t),'\n </div>\n <div class="ai-name">').concat(this.config.botName,"</div>\n </div>\n "):t.length<=10?'\n <div class="ai-avatar">\n <div class="ai-avatar-icon text-avatar">'.concat(t,'</div>\n <div class="ai-name">').concat(this.config.botName,"</div>\n </div>\n "):'\n <div class="ai-avatar">\n <div class="ai-avatar-icon">🤖</div>\n <div class="ai-name">'.concat(this.config.botName,"</div>\n </div>\n "):'\n <div class="ai-avatar">\n <div class="ai-avatar-icon">🤖</div>\n <div class="ai-name">'.concat(this.config.botName,"</div>\n </div>\n ")}},{key:"isEmoji",value:function(t){if(!t||t.length>20)return!1;var n=/(?:\uD83C[\uDFFB-\uDFFF])|\u200D|\uFE0F/.test(t);return/^(?:\uD83D[\uDE00-\uDE4F])|(?:\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])|(?:\uD83D[\uDE80-\uDEFF])|(?:\uD83C[\uDDE0-\uDDFF])|[\u2600-\u26FF]|[\u2700-\u27BF]|(?:\uD83E[\uDD00-\uDDFF])|(?:\uD83C[\uDC18-\uDE70])|[\u238C-\u2454]|[\u20D0-\u20FF]|\uFE0F|\u200D|(?:\uDB40[\uDC20-\uDC7F])/.test(t)||n||/(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEDC-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9\uDEF0-\uDEF8])/.test(t)}},{key:"isImageUrl",value:function(t){return!(!t||"string"!=typeof t)&&([/^https?:\/\/.+\.(jpg|jpeg|png|gif|svg|webp|bmp|ico)(\?.*)?$/i,/^data:image\/.+;base64,/i,/^\/.*\.(jpg|jpeg|png|gif|svg|webp|bmp|ico)(\?.*)?$/i,/^\.\.?\/.*\.(jpg|jpeg|png|gif|svg|webp|bmp|ico)(\?.*)?$/i].some((function(n){return n.test(t.trim())}))||t.startsWith("http")||t.startsWith("data:image")||t.startsWith("/")||t.includes("://"))}},{key:"isSvg",value:function(t){if(!t||"string"!=typeof t)return!1;var n=t.trim();return n.startsWith("<svg")&&n.includes("</svg>")}},{key:"sanitizeSvg",value:function(t){var n=t.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/on\w+="[^"]*"/gi,"").replace(/on\w+='[^']*'/gi,"").replace(/javascript:/gi,"").replace(/vbscript:/gi,"").replace(/data:/gi,"");return!n.includes("viewBox")&&n.includes("<svg")&&(n=n.replace("<svg",'<svg viewBox="0 0 24 24"')),n}},{key:"generateGreetingAvatar",value:function(){var t=this.config.aiAvatar;return t?this.isEmoji(t)?'\n <div class="ai-avatar">\n <div class="ai-avatar-icon emoji-avatar">'.concat(t,'</div>\n <div class="ai-name">').concat(this.config.botName,"</div>\n </div>\n "):this.isImageUrl(t)?'\n <div class="ai-avatar">\n <div class="ai-avatar-icon image-avatar">\n <img src="'.concat(t,'" alt="').concat(this.config.botName,'"\n onerror="this.style.display=\'none\'; this.parentNode.innerHTML=\'🤖\';" \n onload="this.style.display=\'block\';" />\n </div>\n <div class="ai-name">').concat(this.config.botName,"</div>\n </div>\n "):this.isSvg(t)?'\n <div class="ai-avatar">\n <div class="ai-avatar-icon svg-avatar">\n '.concat(this.sanitizeSvg(t),'\n </div>\n <div class="ai-name">').concat(this.config.botName,"</div>\n </div>\n "):t.length<=10?'\n <div class="ai-avatar">\n <div class="ai-avatar-icon text-avatar">'.concat(t,'</div>\n <div class="ai-name">').concat(this.config.botName,"</div>\n </div>\n "):'\n <div class="ai-avatar">\n <div class="ai-avatar-icon">🤖</div>\n <div class="ai-name">'.concat(this.config.botName,"</div>\n </div>\n "):'\n <div class="ai-avatar">\n <div class="ai-avatar-icon">🤖</div>\n <div class="ai-name">'.concat(this.config.botName,"</div>\n </div>\n ")}},{key:"initConfig",value:function(t){var n,e,i,o,a=function(t,n,e){var i=parseInt(t);return"".concat(Math.min(Math.max(i,n),e),"px")},r=function(t){return t?t.startsWith("//")?"".concat(window.location.protocol).concat(t):t.startsWith("/")?"".concat(window.location.origin).concat(t):t.startsWith("http")?t:"http://".concat(t):"http://localhost:7000/chat"};this.config={botName:t.botName||"Chat Assistant",botImage:t.botImage||"https://cdn-icons-png.flaticon.com/512/1786/1786548.png",greeting:t.greeting||"Hello! How can I help you today?",placeholder:t.placeholder||"Type your message here...",primaryColor:t.primaryColor||"#0084ff",fontSize:function(t){var n;n="string"==typeof t?parseInt(t.replace("px","")):"number"==typeof t?t:14;var e=Math.min(Math.max(14,n),25);return"".concat(e,"px")}(t.fontSize||14),width:a(t.width||"400px",300,600),height:a(t.height||"600px",400,800),showTimestamp:t.showTimestamp||!1,enableTypingIndicator:!1!==t.enableTypingIndicator,enableMarkdown:!1!==t.enableMarkdown,enableHistory:!1!==t.enableHistory,maxHistoryLength:t.maxHistoryLength||100,enableTypewriter:!1!==t.enableTypewriter,typewriterSpeed:t.typewriterSpeed||{min:30,max:70},typewritewithscroll:void 0!==t.typewritewithscroll&&t.typewritewithscroll,chips:t.chips||[],customStyles:t.customStyles||{},onInit:t.onInit||null,onMessage:t.onMessage||null,onError:t.onError||null,apiEndpoint:r(t.apiEndpoint),apiKey:t.apiKey||"",apiHeaders:t.apiHeaders||{"Content-Type":"application/json"},apiRequestFormat:t.apiRequestFormat||{query:"query",userId:"userId",domain:"domain"},apiResponseFormat:t.apiResponseFormat||{response:"response"},apiMethod:t.apiMethod||"POST",apiTimeout:t.apiTimeout||3e4,enableBackendHistory:!1!==t.enableBackendHistory,backendHistoryEndpoint:r(t.backendHistoryEndpoint),deleteEndpoint:r(t.deleteEndpoint)||"".concat(r(t.apiEndpoint).replace(/\/chat$/,""),"/delete-history"),separateSubpageHistory:t.separateSubpageHistory||!1,feedbackEndpoint:r(t.feedbackEndpoint)||"".concat(this.config.apiEndpoint,"/feedback"),hubspot:{enabled:(null===(n=t.hubspot)||void 0===n?void 0:n.enabled)||!1,portalId:(null===(e=t.hubspot)||void 0===e?void 0:e.portalId)||"",formGuid:(null===(i=t.hubspot)||void 0===i?void 0:i.formGuid)||"",triggerKeywords:(null===(o=t.hubspot)||void 0===o?void 0:o.triggerKeywords)||["pricing","demo","contact","quote","help","support"],formShownToUsers:new Set,formSubmittedUsers:new Set},position:t.position||"bottom-right",enableServerHistoryDelete:void 0!==t.enableServerHistoryDelete&&t.enableServerHistoryDelete,enableFileUpload:!1!==t.enableFileUpload,enableDeleteButton:!1!==t.enableDeleteButton,useMultipartFormData:!1!==t.useMultipartFormData,apiDataFormat:t.apiDataFormat||"json",typingIndicatorColor:t.typingIndicatorColor||"#666",showTypingText:!1,toggleButtonIcon:t.toggleButtonIcon||null,chatBackgroundImage:t.chatBackgroundImage||null,chatBackgroundColor:t.chatBackgroundColor||"#ffffff",sendButtonIconSize:t.sendButtonIconSize||24,enableEnhancedMobileInput:!1!==t.enableEnhancedMobileInput,aiAvatar:t.aiAvatar||null,showAiAvatar:!1!==t.showAiAvatar,botSubname:t.botSubname||null,showBotSubname:!1!==t.showBotSubname,showFormOnStart:!1!==t.showFormOnStart,useEmailAsUserId:!1!==t.useEmailAsUserId,formTitle:t.formTitle||"Give Your Details",formSubtitle:t.formSubtitle||"Please provide your information to start chatting.",theme:t.theme||"light",showBranding:!1!==t.showBranding,brandingText:t.brandingText||"Powered by NeuroBrain",brandingUrl:t.brandingUrl||"https://neurobrains.co/",showMessageActions:!1!==t.showMessageActions,showTextBox:!1!==t.showTextBox,textBoxMessage:t.textBoxMessage||"Hi there! If you need any assistance, I am always here.",textBoxSubMessage:t.textBoxSubMessage||"💬 24/7 Live Chat Support",showTextBoxCloseButton:!1!==t.showTextBoxCloseButton,toggleButtonAnimation:void 0!==t.toggleButtonAnimation?Math.max(0,Math.min(5,parseInt(t.toggleButtonAnimation)||0)):4,toggleButtonSize:t.toggleButtonSize?Math.max(40,Math.min(80,parseInt(t.toggleButtonSize))):60,toggleButtonBottomMargin:t.toggleButtonBottomMargin?Math.max(10,Math.min(50,parseInt(t.toggleButtonBottomMargin))):50,toggleButtonRightMargin:t.toggleButtonRightMargin?Math.max(10,Math.min(100,parseInt(t.toggleButtonRightMargin))):30,websiteBottomSpacing:t.websiteBottomSpacing?Math.max(0,Math.min(100,parseInt(t.websiteBottomSpacing))):0,textBoxSpacingFromToggle:void 0!==t.textBoxSpacingFromToggle?Math.max(0,Math.min(30,parseInt(t.textBoxSpacingFromToggle))):0,textBoxTextColor:t.textBoxTextColor||"primary"}}},{key:"updateFontSize",value:function(t){this.config.fontSize=t,document.documentElement.style.setProperty("--chat-message-font-size",t)}},{key:"ensureDependencies",value:(p=v(s().mark((function t(){return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(window.marked||!this.config.enableMarkdown){t.next=3;break}return t.next=3,this.loadScript("https://cdn.jsdelivr.net/npm/marked/marked.min.js");case 3:this.loadStyles();case 4:case"end":return t.stop()}}),t,this)}))),function(){return p.apply(this,arguments)})},{key:"loadScript",value:function(t){return new Promise((function(n,e){var i=document.createElement("script");i.src=t,i.async=!0,i.onload=n,i.onerror=e,document.head.appendChild(i)}))}},{key:"loadStyles",value:function(){this.applyTheme();var t=document.createElement("style");t.textContent="\n :root {\n --chat-primary-color: ".concat(this.config.primaryColor,";\n --chat-primary-color-gradient: ").concat((this.isGradient(this.config.primaryColor),this.config.primaryColor),";\n --chat-message-font-size: ").concat(this.config.fontSize,";\n --chat-width: ").concat(this.config.width,";\n --chat-height: ").concat(this.config.height,";\n --chat-toggle-size: ").concat(this.config.toggleButtonSize,"px;\n --chat-toggle-bottom-margin: ").concat(this.config.toggleButtonBottomMargin,"px;\n --chat-toggle-right-margin: ").concat(this.config.toggleButtonRightMargin,"px;\n --website-bottom-spacing: ").concat(this.config.websiteBottomSpacing,"px;\n --text-box-spacing-from-toggle: ").concat(this.config.textBoxSpacingFromToggle,"px;\n --text-box-text-color: ").concat("primary"===this.config.textBoxTextColor?this.config.primaryColor:"default"===this.config.textBoxTextColor?"#374151":this.config.textBoxTextColor,";\n --text-box-submessage-color: ").concat("primary"===this.config.textBoxTextColor?this.config.primaryColor:"default"===this.config.textBoxTextColor?"#6b7280":this.config.textBoxTextColor,";\n --text-box-submessage-opacity: ").concat("primary"===this.config.textBoxTextColor?"0.8":"1",";\n --text-box-is-gradient: ").concat("primary"===this.config.textBoxTextColor&&this.isGradient(this.config.primaryColor)?"true":"false",";\n --chat-border-radius: 16px;\n --chat-shadow: 0 5px 40px rgba(0,0,0,0.16);\n --typing-dot-color: ").concat(this.config.typingIndicatorColor,";\n --chat-primary-color-rgb: ").concat(this.hexToRgb(this.config.primaryColor),";\n --send-button-icon-size: ").concat(this.config.sendButtonIconSize,"px;\n \n /* Theme variables */\n --chat-bg-color: ").concat(this.getThemeColor("bg"),";\n --chat-text-color: ").concat(this.getThemeColor("text"),";\n --chat-border-color: ").concat(this.getThemeColor("border"),";\n --chat-input-bg: ").concat(this.getThemeColor("inputBg"),";\n --chat-message-bg: ").concat(this.getThemeColor("messageBg"),";\n --chat-header-bg: ").concat(this.getThemeColor("headerBg"),";\n --chat-header-text: ").concat(this.getThemeColor("headerText"),';\n }\n\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n }\n\n body {\n background-color: #f5f5f5;\n min-height: 100vh;\n }\n\n /* Main Website Content */\n .website-content {\n padding: 2rem;\n max-width: 1200px;\n margin: 0 auto;\n }\n\n /* Chat Widget Container */\n .chat-widget {\n position: fixed;\n bottom: 20px;\n right: 20px;\n z-index: 2147483647;\n }\n\n .chat-widget.left .chat-toggle {\n left: 20px;\n right: auto;\n }\n\n .chat-widget.left .chat-window {\n left: 20px;\n right: auto;\n }\n\n /* Chat Toggle Button - Positioned above chat window */\n .chat-toggle {\n width: var(--chat-toggle-size);\n height: var(--chat-toggle-size);\n border-radius: 50%;\n background: var(--chat-primary-color-gradient);\n box-shadow: 0 2px 12px rgba(0,0,0,0.15);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 0.3s ease;\n z-index: 2147483650; /* Higher than chat window (2147483647) to appear in front */\n position: fixed;\n text-align: center;\n }\n\n .chat-toggle:hover {\n transform: scale(1.1);\n }\n\n .chat-toggle img {\n width: 30px;\n height: 30px;\n display: block;\n margin: 0 auto;\n }\n\n .chat-toggle span {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-size: 24px;\n line-height: 1;\n }\n\n /* Toggle Button Animations - Enhanced for production compatibility */\n .chat-toggle.animation-1 {\n animation: pulseAnimation 2s infinite !important;\n -webkit-animation: pulseAnimation 2s infinite !important;\n }\n\n .chat-toggle.animation-2 {\n animation: bounceAnimation 2s infinite !important;\n -webkit-animation: bounceAnimation 2s infinite !important;\n }\n\n .chat-toggle.animation-3 {\n animation: shakeAnimation 3s infinite !important;\n -webkit-animation: shakeAnimation 3s infinite !important;\n }\n\n .chat-toggle.animation-4 {\n animation: infinityAnimation 3s infinite !important;\n -webkit-animation: infinityAnimation 3s infinite !important;\n }\n\n .chat-toggle.animation-5 {\n animation: rotateAnimation 4s infinite linear !important;\n -webkit-animation: rotateAnimation 4s infinite linear !important;\n }\n\n /* Keyframe Animations - Enhanced with vendor prefixes for production compatibility */\n @keyframes pulseAnimation {\n 0%, 100% { \n transform: scale(1); \n -webkit-transform: scale(1);\n }\n 50% { \n transform: scale(1.15); \n -webkit-transform: scale(1.15);\n }\n }\n\n @-webkit-keyframes pulseAnimation {\n 0%, 100% { -webkit-transform: scale(1); }\n 50% { -webkit-transform: scale(1.15); }\n }\n\n @keyframes bounceAnimation {\n 0%, 20%, 50%, 80%, 100% { \n transform: translateY(0); \n -webkit-transform: translateY(0);\n }\n 40% { \n transform: translateY(-10px); \n -webkit-transform: translateY(-10px);\n }\n 60% { \n transform: translateY(-5px); \n -webkit-transform: translateY(-5px);\n }\n }\n\n @-webkit-keyframes bounceAnimation {\n 0%, 20%, 50%, 80%, 100% { -webkit-transform: translateY(0); }\n 40% { -webkit-transform: translateY(-10px); }\n 60% { -webkit-transform: translateY(-5px); }\n }\n\n @keyframes shakeAnimation {\n 0%, 100% { \n transform: translateX(0); \n -webkit-transform: translateX(0);\n }\n 10%, 30%, 50%, 70%, 90% { \n transform: translateX(-5px); \n -webkit-transform: translateX(-5px);\n }\n 20%, 40%, 60%, 80% { \n transform: translateX(5px); \n -webkit-transform: translateX(5px);\n }\n }\n\n @-webkit-keyframes shakeAnimation {\n 0%, 100% { -webkit-transform: translateX(0); }\n 10%, 30%, 50%, 70%, 90% { -webkit-transform: translateX(-5px); }\n 20%, 40%, 60%, 80% { -webkit-transform: translateX(5px); }\n }\n\n @keyframes infinityAnimation {\n 0%, 100% { \n transform: scale(1); \n -webkit-transform: scale(1);\n }\n 25% { \n transform: scale(1.2); \n -webkit-transform: scale(1.2);\n }\n 50% { \n transform: scale(1); \n -webkit-transform: scale(1);\n }\n 75% { \n transform: scale(1.2); \n -webkit-transform: scale(1.2);\n }\n }\n\n @-webkit-keyframes infinityAnimation {\n 0%, 100% { -webkit-transform: scale(1); }\n 25% { -webkit-transform: scale(1.2); }\n 50% { -webkit-transform: scale(1); }\n 75% { -webkit-transform: scale(1.2); }\n }\n\n @keyframes rotateAnimation {\n from { \n transform: rotate(0deg); \n -webkit-transform: rotate(0deg);\n }\n to { \n transform: rotate(360deg); \n -webkit-transform: rotate(360deg);\n }\n }\n\n @-webkit-keyframes rotateAnimation {\n from { -webkit-transform: rotate(0deg); }\n to { -webkit-transform: rotate(360deg); }\n }\n\n /* Text Box Styles - Positioned below chat window for better visibility */\n .chat-text-box {\n z-index: 2147483640; /* Lower than chat window (2147483647) to not block branding */\n max-width: min(280px, calc(100vw - 40px)); /* Responsive max-width with proper margins */\n pointer-events: auto;\n box-sizing: border-box;\n position: fixed; /* Ensure proper stacking context */\n opacity: 1;\n /* No transitions for direct show/hide */\n /* Spacing is now handled by CSS variables in position-specific rules */\n }\n\n .chat-text-box-content {\n background: white;\n border-radius: 12px;\n padding: 16px;\n box-shadow: 0 4px 20px rgba(0,0,0,0.15);\n border: 1px solid #e5e7eb;\n position: relative;\n animation: slideInUp 0.3s ease-out;\n }\n\n .chat-text-box-close {\n position: absolute;\n top: 10px;\n right: 10px;\n background: var(--chat-primary-color-gradient);\n border: none;\n cursor: pointer;\n padding: 8px;\n border-radius: 50%;\n color: white;\n width: 34px;\n height: 34px;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n z-index: 10;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n }\n\n .chat-text-box-close:hover {\n filter: brightness(0.9);\n transform: scale(1.15) rotate(90deg);\n box-shadow: 0 4px 12px rgba(0,0,0,0.3);\n }\n\n .chat-text-box-close svg {\n width: 18px;\n height: 18px;\n stroke-width: 2.5;\n }\n\n .chat-text-box-message {\n font-size: 16px;\n line-height: 1.5;\n margin-bottom: 14px;\n font-weight: 600;\n padding-right: 35px;\n }\n \n /* Gradient text support for text box message */\n .chat-text-box-message {\n background: var(--text-box-text-color);\n background-clip: text;\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n color: var(--text-box-text-color); /* Fallback for non-webkit browsers */\n }\n \n /* Non-gradient text fallback */\n .chat-text-box-message:not([data-gradient="true"]) {\n background: none;\n background-clip: unset;\n -webkit-background-clip: unset;\n -webkit-text-fill-color: unset;\n color: var(--text-box-text-color);\n }\n\n .chat-text-box-separator {\n height: 1px;\n background: #e5e7eb;\n margin: 0 -4px 14px -4px;\n }\n\n .chat-text-box-submessage {\n font-size: 15px;\n font-weight: 600;\n display: flex;\n align-items: center;\n gap: 8px;\n opacity: var(--text-box-submessage-opacity);\n }\n \n /* Gradient text support for text box submessage */\n .chat-text-box-submessage {\n background: var(--text-box-submessage-color);\n background-clip: text;\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n color: var(--text-box-submessage-color); /* Fallback for non-webkit browsers */\n }\n \n /* Non-gradient text fallback */\n .chat-text-box-submessage:not([data-gradient="true"]) {\n background: none;\n background-clip: unset;\n -webkit-background-clip: unset;\n -webkit-text-fill-color: unset;\n color: var(--text-box-submessage-color);\n }\n\n .chat-text-box-submessage::before {\n content: \'\';\n width: 8px;\n height: 8px;\n background: #10b981;\n border-radius: 50%;\n flex-shrink: 0;\n }\n\n /* Text Box Animation */\n @keyframes slideInUp {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes slideOutDown {\n from {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n to {\n opacity: 0;\n transform: translateY(-10px) scale(0.95);\n }\n }\n\n /* Dark theme styles for text box */\n .chat-widget.dark .chat-text-box-content {\n background: #374151;\n border-color: #4b5563;\n }\n\n .chat-widget.dark .chat-text-box-message {\n color: var(--text-box-text-color);\n }\n\n .chat-widget.dark .chat-text-box-submessage {\n color: var(--text-box-submessage-color);\n opacity: var(--text-box-submessage-opacity);\n }\n\n .chat-widget.dark .chat-text-box-separator {\n background: #4b5563;\n }\n\n .chat-widget.dark .chat-text-box-close {\n color: #9ca3af;\n }\n\n .chat-widget.dark .chat-text-box-close:hover {\n background: #4b5563;\n color: #d1d5db;\n }\n\n /* Chat Window */\n .chat-window {\n position: fixed;\n bottom: 100px;\n right: 20px;\n width: var(--chat-width);\n height: var(--chat-height);\n background: var(--chat-bg-color);\n border-radius: var(--chat-border-radius);\n box-shadow: var(--chat-shadow);\n display: none;\n flex-direction: column;\n overflow: hidden;\n transition: transform 0.3s ease, opacity 0.3s ease;\n transform: translateY(20px);\n opacity: 0;\n font-size: var(--chat-font-size);\n min-width: 300px;\n max-width: 600px;\n min-height: 400px;\n max-height: 800px;\n padding: 0;\n box-sizing: border-box;\n overscroll-behavior: contain;\n -webkit-overflow-scrolling: touch;\n }\n\n .chat-window.active {\n display: flex;\n transform: translateY(0);\n opacity: 1;\n border-radius: var(--chat-border-radius);\n overflow: hidden;\n }\n\n /* Chat Header */\n .chat-header {\n background: var(--chat-primary-color);\n color: white;\n padding: 1rem;\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n box-sizing: border-box;\n position: relative;\n margin: 0;\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n border-bottom: 1px solid var(--chat-primary-color);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n }\n\n /* Fix for header background extending to edges */\n .chat-header::before {\n content: \'\';\n position: absolute;\n top: 0;\n left: -1px;\n right: -1px;\n bottom: 0;\n background: var(--chat-primary-color);\n z-index: -1;\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n .chat-header-title {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n position: relative;\n z-index: 1;\n }\n \n .chat-header-text {\n display: flex;\n flex-direction: column;\n gap: 0.1rem;\n }\n \n .chat-header-subname {\n font-size: 0.8em;\n opacity: 0.8;\n font-weight: 400;\n line-height: 1.2;\n }\n\n .chat-header-avatar {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n background: white;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .chat-header-avatar img {\n width: 33px;\n height: 33px;\n border-radius: 50%;\n }\n\n .chat-header-actions {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n position: relative;\n z-index: 1;\n }\n\n .erase-chat, .close-chat {\n background: none;\n border: none;\n color: white;\n cursor: pointer;\n padding: 0.5rem;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: all 0.2s ease;\n width: 40px;\n height: 40px;\n }\n\n .erase-chat:hover, .close-chat:hover {\n background: rgba(255, 255, 255, 0.1);\n transform: scale(1.05);\n }\n\n .erase-chat:active, .close-chat:active {\n background: var(--chat-primary-color) !important;\n transform: scale(0.95);\n }\n\n /* Enhanced mobile touch support for header buttons */\n @media (max-width: 768px) {\n .erase-chat, .close-chat {\n width: 44px;\n height: 44px;\n -webkit-tap-highlight-color: transparent;\n touch-action: manipulation;\n }\n \n .erase-chat:active, .close-chat:active {\n background: var(--chat-primary-color) !important;\n transform: scale(0.9);\n }\n }\n\n .erase-chat img, .close-chat img {\n width: 20px;\n height: 20px;\n pointer-events: none;\n }\n\n /* Chat Messages - Normal bottom flow */\n .chat-messages {\n flex: 1;\n overflow-y: auto;\n padding: 1rem;\n display: flex;\n flex-direction: column;\n gap: 1rem;\n overscroll-behavior: contain;\n -webkit-overflow-scrolling: touch;\n scroll-behavior: smooth;\n scrollbar-width: thin;\n scrollbar-color: rgba(0, 0, 0, 0.2) transparent;\n background: var(--chat-message-bg);\n ').concat(this.config.chatBackgroundImage?"\n background-image: url('".concat(this.config.chatBackgroundImage,"');\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n background-attachment: fixed;\n "):"\n background: var(--chat-message-bg);\n ","\n }\n\n .chat-messages::-webkit-scrollbar {\n width: 6px;\n }\n\n .chat-messages::-webkit-scrollbar-track {\n background: transparent;\n }\n\n .chat-messages::-webkit-scrollbar-thumb {\n background-color: rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n }\n\n /* Prevent iOS rubber-band effect */\n @supports (-webkit-touch-callout: none) {\n .chat-window {\n height: -webkit-fill-available;\n }\n \n .chat-messages {\n height: -webkit-fill-available;\n }\n }\n\n /* Dark theme styles */\n .chat-widget.dark-theme .chat-window {\n background: var(--chat-bg-color);\n border: 1px solid var(--chat-border-color);\n }\n\n .chat-widget.dark-theme .chat-header {\n background: var(--chat-primary-color);\n color: white;\n }\n\n .chat-widget.dark-theme .chat-input input,\n .chat-widget.dark-theme .chat-input .chat-textarea {\n background: var(--chat-input-bg);\n color: var(--chat-text-color);\n border-color: var(--chat-border-color);\n }\n\n .chat-widget.dark-theme .chat-input input::placeholder,\n .chat-widget.dark-theme .chat-input .chat-textarea::placeholder {\n color: #888888;\n }\n\n .chat-widget.dark-theme .bot-message {\n background: var(--chat-message-bg);\n color: var(--chat-text-color);\n border: 1px solid var(--chat-border-color);\n }\n\n .chat-widget.dark-theme .user-message {\n background: var(--chat-primary-color);\n color: white;\n }\n\n .chat-widget.dark-theme .typing-indicator {\n background: var(--chat-message-bg);\n border: 1px solid var(--chat-border-color);\n }\n\n .chat-widget.dark-theme .chip {\n background: var(--chat-message-bg);\n color: var(--chat-text-color);\n border: 1px solid var(--chat-border-color);\n }\n\n .chat-widget.dark-theme .chip:hover {\n background: var(--chat-border-color);\n }\n\n .message {\n max-width: 80%;\n padding: 0.8rem 1rem;\n border-radius: 1rem;\n margin: 0.25rem 0;\n font-size: calc(var(--chat-font-size) * 0.8);\n transition: max-width 0.3s ease, padding 0.3s ease;\n }\n\n .message-row {\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n }\n\n /* Chat spacer to ensure new messages and responses are visible */\n .chat-spacer {\n height: 20px;\n min-height: 20px;\n flex-shrink: 0;\n pointer-events: none;\n }\n\n /* Bot Message Styling */\n .bot-message {\n max-width: 80%;\n padding: 1rem;\n background: #f0f2f5;\n border-radius: 1rem;\n border-top-left-radius: 0;\n font-size: 14px;\n line-height: 1.5;\n color: #000000;\n box-shadow: none !important;\n ").concat(this.config.chatBackgroundImage?"\n background: rgba(240, 242, 245, 0.95) !important;\n box-shadow: none !important;\n ":"",'\n }\n \n /* Ensure bot message has no shadow */\n .chat-widget .bot-message,\n .chat-widget .ai-message {\n box-shadow: none !important;\n background: #f0f2f5 !important;\n }\n\n .bot-message img {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n margin: 8px 0;\n transition: min-height 0.3s ease;\n }\n\n .bot-message img[src=""] {\n display: none;\n }\n\n .bot-message a {\n color: #0084ff;\n text-decoration: none;\n }\n\n .bot-message a:hover {\n text-decoration: underline;\n }\n\n /* User Message */\n .user-message {\n margin-left: auto;\n background: var(--chat-primary-color);\n color: white;\n border-top-right-radius: 0;\n text-align: left;\n ').concat(this.config.chatBackgroundImage?"\n background: rgba(var(--chat-primary-color-rgb, 0, 132, 255), 0.95);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n ":"","\n }\n\n /* Markdown Content Styles */\n .bot-message h1, .bot-message h2, .bot-message h3 {\n margin: 16px 0 8px 0;\n }\n\n .bot-message p {\n margin: 8px 0;\n }\n\n .bot-message ul, .bot-message ol {\n margin: 8px 0;\n padding-left: 20px;\n }\n\n .bot-message code {\n background: rgba(0, 0, 0, 0.05);\n padding: 2px 4px;\n border-radius: 4px;\n font-family: monospace;\n }\n\n .bot-message pre {\n background: rgba(0, 0, 0, 0.05);\n padding: 12px;\n border-radius: 4px;\n overflow-x: auto;\n }\n\n .bot-message blockquote {\n border-left: 4px solid #0084ff;\n margin: 8px 0;\n padding-left: 12px;\n color: #666;\n }\n \n /* COMPREHENSIVE GREETING WIDTH FIX - Force identical width to o