@agentman/chat-widget
Version:
Agentman Chat Widget for easy integration with web applications
1 lines • 305 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("AgentmanChatWidget",[],t):"object"==typeof exports?exports.AgentmanChatWidget=t():e.AgentmanChatWidget=t()}("undefined"!=typeof self?self:this,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ChatWidget:()=>$e,OfflineParser:()=>N});var n=function(){function e(e,t){this.enabled=!1,this.logLevel="info",this.timestamps=!0,this.useConsole=!0,this.prefix="[ChatWidget]",this.levels={error:0,warn:1,info:2,debug:3,verbose:4},t&&(this.prefix=t),"boolean"==typeof e?this.enabled=e:e&&(this.enabled=e.enabled,this.logLevel=e.logLevel||"info",this.timestamps=!1!==e.timestamps,this.useConsole=!1!==e.console,this.customLogger=e.logger),e||"undefined"==typeof window||"localhost"===window.location.hostname||(this.logLevel="error")}return e.prototype.shouldLog=function(e){return!!this.enabled&&this.levels[e]<=this.levels[this.logLevel]},e.prototype.formatMessage=function(e,t,n){void 0===n&&(n=!1);var i=[];if(n&&this.useConsole)return i.push(this.prefix),"info"!==e&&i.push("[".concat(e.toUpperCase(),"]")),i.push(t),i.join(" ");if(this.timestamps){var o=new Date;i.push("[".concat(o.toISOString(),"]"))}return i.push(this.prefix),i.push("[".concat(e.toUpperCase(),"]")),i.push(t),i.join(" ")},e.prototype.output=function(e,t,n){if(this.shouldLog(e))if(this.customLogger){var i=this.formatMessage(e,t,!1);this.customLogger(e,i,n)}else if(this.useConsole&&"undefined"!=typeof console){i=this.formatMessage(e,t,!0);var o="error"===e?"error":"warn"===e?"warn":"log";void 0!==n?console[o](i,n):console[o](i)}},e.prototype.error=function(e,t){this.output("error",e,t)},e.prototype.warn=function(e,t){this.output("warn",e,t)},e.prototype.info=function(e,t){this.output("info",e,t)},e.prototype.debug=function(e,t){this.output("debug",e,t)},e.prototype.verbose=function(e,t){this.output("verbose",e,t)},e.prototype.child=function(t){return new e({enabled:this.enabled,logLevel:this.logLevel,timestamps:this.timestamps,console:this.useConsole,logger:this.customLogger},"".concat(this.prefix," ").concat(t))},e.prototype.setConfig=function(e){this.enabled=e.enabled,this.logLevel=e.logLevel||this.logLevel,this.timestamps=!1!==e.timestamps,this.useConsole=!1!==e.console,this.customLogger=e.logger},e.prototype.setEnabled=function(e){this.enabled=e},e.prototype.setLogLevel=function(e){this.logLevel=e},e}(),i=(new n(!1),function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})}),o=function(){function e(e,t,i,o){void 0===i&&(i=!0);var a=this;this.containerId=e,this.stateManager=t,this.enabled=i,this.eventCallbacks=[],this.inMemoryFallback=new Map,this.useInMemoryFallback=!1,this.convKey=function(e){return"chatwidget_".concat(a.containerId,"_conv_").concat(e)},this.logger=new n(o||!1,"[PersistenceManager]"),this.checkStorageAvailability()}return e.prototype.onPersistenceEvent=function(e){this.eventCallbacks.push(e)},e.prototype.emitEvent=function(e,t,n){var i=this,o={type:e,error:t,details:n};this.eventCallbacks.forEach(function(e){try{e(o)}catch(e){i.logger.error("Error in persistence event callback:",e)}})},e.prototype.checkStorageAvailability=function(){try{var e="chatwidget_test_".concat(Date.now());localStorage.setItem(e,"test"),localStorage.removeItem(e),this.useInMemoryFallback=!1}catch(e){this.logger.warn("localStorage not available, using in-memory fallback:",e),this.useInMemoryFallback=!0,this.emitEvent("save_failed",{type:"ACCESS_DENIED",message:"localStorage is not available. Chat history will not persist across sessions.",originalError:e,recoverable:!1})}},Object.defineProperty(e.prototype,"indexKey",{get:function(){return"chatwidget_".concat(this.containerId,"_index")},enumerable:!1,configurable:!0}),e.prototype.getStorageKey=function(){var e=this.getCurrentId();return e?this.convKey(e):this.indexKey},e.prototype.readIndex=function(){try{if(this.useInMemoryFallback){var e=this.inMemoryFallback.get(this.indexKey);return e?JSON.parse(e):{version:2,conversations:[]}}var t=localStorage.getItem(this.indexKey);return t?JSON.parse(t):{version:2,conversations:[]}}catch(e){return this.logger.error("Failed to read index:",e),{version:2,conversations:[]}}},e.prototype.writeIndex=function(e){try{var t=JSON.stringify(e);return this.useInMemoryFallback?(this.inMemoryFallback.set(this.indexKey,t),!0):(localStorage.setItem(this.indexKey,t),!0)}catch(e){return this.handleStorageError(e),!1}},e.prototype.handleStorageError=function(e){var t="UNKNOWN_ERROR",n=!1;"QuotaExceededError"===e.name||e.message.includes("quota")?(t="QUOTA_EXCEEDED",n=!0):"SecurityError"===e.name?t="ACCESS_DENIED":e instanceof SyntaxError&&(t="PARSE_ERROR");var i={type:t,message:this.getErrorMessage(t),originalError:e,recoverable:n};return this.emitEvent("save_failed",i),this.logger.error("Storage error (".concat(t,"):"),e),i},e.prototype.getErrorMessage=function(e){switch(e){case"QUOTA_EXCEEDED":return"Storage quota exceeded. Please clear some chat history to continue saving.";case"ACCESS_DENIED":return"Storage access denied. Chat history will not be saved.";case"PARSE_ERROR":return"Corrupted data detected. Some chat history may be lost.";case"INVALID_STATE":return"Invalid storage state. Please refresh the page.";default:return"An error occurred while saving chat history."}},e.prototype.list=function(){return this.readIndex().conversations.sort(function(e,t){return t.lastUpdated-e.lastUpdated})},e.prototype.getCurrentId=function(){return this.readIndex().currentId},e.prototype.create=function(e){var t=this;void 0===e&&(e="New chat");var n=function(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();var e=Date.now().toString(36),t=Math.random().toString(36).substring(2,10);return"".concat(e,"-").concat(t)}(),i={id:n,title:e,lastUpdated:Date.now()},o=this.readIndex();if(o.conversations.unshift(i),o.conversations.length>10){this.logger.debug("Conversation limit exceeded (".concat(o.conversations.length,"), cleaning up old conversations"));var a=o.conversations.slice(10);o.conversations=o.conversations.slice(0,10),a.forEach(function(e){try{localStorage.removeItem(t.convKey(e.id)),t.logger.debug("Removed old conversation: ".concat(e.id))}catch(n){t.logger.warn("Failed to remove old conversation ".concat(e.id,":"),n)}})}o.currentId=n,this.writeIndex(o);var r={version:2,messages:[],timestamp:Date.now()};try{localStorage.setItem(this.convKey(n),JSON.stringify(r))}catch(e){if(!(e instanceof Error&&"QuotaExceededError"===e.name))throw e;this.logger.warn("Storage quota exceeded, attempting cleanup"),this.clearOldConversations(5);try{localStorage.setItem(this.convKey(n),JSON.stringify(r))}catch(e){throw this.logger.error("Failed to create conversation even after cleanup:",e),e}}return n},e.prototype.switchTo=function(e){this.logger.debug("🔄 switchTo(".concat(e,") called"));var t=this.readIndex();if(!t.conversations.find(function(t){return t.id===e}))throw this.logger.debug("❌ switchTo() failed - unknown conversation id: ".concat(e)),new Error("unknown conversation id");t.currentId=e,this.logger.debug("✅ switchTo() - setting currentId to ".concat(e)),this.writeIndex(t)},e.prototype.delete=function(e){var t;localStorage.removeItem(this.convKey(e));var n=this.readIndex();n.conversations=n.conversations.filter(function(t){return t.id!==e}),n.currentId===e&&(n.currentId=null===(t=n.conversations[0])||void 0===t?void 0:t.id),this.writeIndex(n)},e.prototype.loadMessages=function(){var e=this.getCurrentId();if(!e)return[];try{var t=this.convKey(e),n=localStorage.getItem(t);if(!n)return[];var i=this.parseAndValidatePayload(n);return(null==i?void 0:i.messages)||[]}catch(e){return this.logger.error("Failed to load messages:",e),[]}},e.prototype.loadMetadata=function(){var e=this.getCurrentId();if(!e)return null;try{var t=localStorage.getItem(this.convKey(e));if(!t)return null;var n=this.parseAndValidatePayload(t);return(null==n?void 0:n.metadata)||null}catch(e){return this.logger.error("Failed to load metadata:",e),null}},e.prototype.saveMetadata=function(e){if(this.logger.debug("💾 saveMetadata() called",e),this.enabled){var t=this.getCurrentId();if(t)try{this.saveMetadataAtomic(t,e)}catch(e){this.logger.error("Failed to save metadata:",e)}else this.logger.debug("⏭️ saveMetadata() aborted - no current conversation ID")}else this.logger.debug("⏭️ saveMetadata() aborted - persistence not enabled")},e.prototype.saveMetadataAtomic=function(e,t){var n,i=this.convKey(e),o=localStorage.getItem(i);o?n=this.parseAndValidatePayload(o)||this.createDefaultPayload():(n=this.createDefaultPayload()).messages=this.stateManager.getState().messages,n.metadata=t,n.timestamp=Date.now();var a=JSON.stringify(n);localStorage.setItem(i,a),this.updateIndexMetadata(e,t),this.logger.debug("✅ Metadata saved atomically")},e.prototype.updateIndexMetadata=function(e,t){try{var n=this.readIndex(),i=n.conversations.find(function(t){return t.id===e});i&&(i.metadata=t,this.writeIndex(n))}catch(e){this.logger.error("Failed to update index metadata:",e)}},e.prototype.saveMessages=function(){if(this.logger.debug("📝 saveMessages() called"),!this.enabled)return this.logger.debug("⏭️ saveMessages() aborted - persistence not enabled"),{success:!0};var e=this.getCurrentId();if(!e)return this.logger.debug("⏭️ saveMessages() aborted - no current conversation ID"),{success:!1,error:{type:"INVALID_STATE",message:"No active conversation",recoverable:!0}};var t=this.stateManager.getState().messages;this.logger.debug("📊 Current messages count: ".concat(t.length));var n,i=this.convKey(e),o=(n=this.useInMemoryFallback?this.inMemoryFallback.get(i)||null:localStorage.getItem(i))?JSON.parse(n).messages:[];this.logger.debug("📊 Existing messages count: ".concat(o.length));var a,r=o.length!==t.length;if(!r&&t.length>0)for(var s=0;s<t.length;s++)if(!o[s]||o[s].content!==t[s].content||o[s].sender!==t[s].sender){r=!0;break}if(!r)return this.logger.debug("⏭️ saveMessages() aborted - no changes detected"),{success:!0};if(this.logger.debug("💾 Saving messages - changes detected"),n)try{var c=this.parseAndValidatePayload(n);a=null==c?void 0:c.metadata}catch(e){this.logger.warn("Failed to parse existing metadata, continuing without it:",e)}var l={version:2,messages:t,timestamp:Date.now(),metadata:a};try{var u=JSON.stringify(l);this.useInMemoryFallback?this.inMemoryFallback.set(i,u):localStorage.setItem(i,u)}catch(e){return{success:!1,error:this.handleStorageError(e)}}var h=this.readIndex(),d=h.conversations.find(function(t){return t.id===e});if(d){d.lastUpdated=l.timestamp;var p=t.find(function(e){return"user"===e.sender});if(p){var g=p.content.trim();d.title=g.length>25?g.slice(0,25)+"...":g}else"New chat"===d.title&&t.length>0&&(d.title="Chat with Agentman");this.writeIndex(h)||this.logger.warn("Failed to update conversation index")}return{success:!0}},e.prototype.migrateLegacy=function(){var e="chatwidget_".concat(this.containerId,"_data"),t=localStorage.getItem(e);if(t)try{var n=JSON.parse(t).messages,i=this.create("Imported chat");localStorage.setItem(this.convKey(i),JSON.stringify({version:2,messages:n,timestamp:Date.now()})),localStorage.removeItem(e)}catch(e){this.logger.error("Error migrating legacy data:",e)}},e.prototype.setConversationId=function(e){this.switchTo(e)},e.prototype.getConversationId=function(){return this.getCurrentId()||null},e.prototype.clearStorage=function(){var e=this.getCurrentId();e&&this.delete(e)},e.prototype.parseAndValidatePayload=function(e){try{var t=JSON.parse(e);if("object"!=typeof t||null===t)throw new Error("Invalid payload format");if("number"!=typeof t.version||2!==t.version)throw new Error("Invalid or unsupported payload version");if(!Array.isArray(t.messages))throw new Error("Invalid messages format");if("number"!=typeof t.timestamp)throw new Error("Invalid timestamp format");return t}catch(t){return this.logger.warn("Failed to parse conversation payload:",t),this.emitEvent("corrupted_data",{type:"PARSE_ERROR",message:"Failed to parse conversation payload",originalError:t,recoverable:!0},{rawDataLength:e.length,errorMessage:t.message}),null}},e.prototype.createDefaultPayload=function(){return{version:2,messages:[],timestamp:Date.now()}},e.prototype.getStorageInfo=function(){return i(this,void 0,void 0,function(){var e,t,n,i,o,a,r,s,c;return function(e,t){var n,i,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},r=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return r.next=s(0),r.throw=s(1),r.return=s(2),"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(a=0)),a;)try{if(n=1,i&&(o=2&s[0]?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],i=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,function(l){switch(l.label){case 0:for(l.trys.push([0,5,,6]),e=0,t=0;t<localStorage.length;t++)(n=localStorage.key(t))&&n.startsWith("chatwidget_".concat(this.containerId))&&(i=localStorage.getItem(n))&&(e+=n.length+i.length);if(o=void 0,a=void 0,!("storage"in navigator)||!("estimate"in navigator.storage))return[3,4];l.label=1;case 1:return l.trys.push([1,3,,4]),[4,navigator.storage.estimate()];case 2:return r=l.sent(),o=r.quota,a=r.quota?r.quota-(r.usage||0):void 0,[3,4];case 3:return s=l.sent(),this.logger.debug("Could not estimate storage quota:",s),[3,4];case 4:return[2,{used:e,quota:o,available:a,percentUsed:o?e/o*100:void 0}];case 5:return c=l.sent(),this.logger.error("Failed to get storage info:",c),[2,{used:0}];case 6:return[2]}})})},e.prototype.clearOldConversations=function(e){void 0===e&&(e=5);try{var t=this.list();if(t.length<=e)return{success:!0};for(var n=t.slice(e),i=0,o=0,a=n;o<a.length;o++){var r=a[o];try{this.delete(r.id),i++}catch(e){this.logger.warn("Failed to delete conversation ".concat(r.id,":"),e)}}return this.logger.info("Cleared ".concat(i," old conversations")),{success:!0,data:i}}catch(e){return{success:!1,error:{type:"UNKNOWN_ERROR",message:"Failed to clear old conversations",originalError:e,recoverable:!1}}}},e}(),a='\n<svg id="eGF4vShlzWg1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 482 463" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" project-id="b6a2902621314759b6f55f35963e502f" export-id="3ac2b3de3acd4688a4d0e052043a141a" cached="false">\n <style>\n .main-color {\n fill: var(--chat-toggle-icon-color, --chat-header-text-color, #10b981);\n }\n </style>\n <ellipse rx="195.69139" ry="195.69139" transform="matrix(1.029699 0 0 1.029699 240.53478 231.5)" class="main-color" stroke-width="0"/>\n <path d="M115.170448,367.37098l75.209552-41.95l34.570045,89.914073q-71.559193-7.964036-109.779597-47.964073Z" transform="translate(1.705203 0.000002)" fill="#fff" stroke="#fff" stroke-width="0.964"/>\n <path d="M115.170448,367.37098l75.209552-41.95l34.570045,89.914073q-71.559193-7.964036-109.779597-47.964073Z" transform="matrix(-1 0 0 1 477.488884 0.213954)" fill="#fff" stroke="#fff" stroke-width="0.964"/>\n <path d="" fill="none" stroke="#3f5787" stroke-width="0.964"/>\n <path d="M239.689307,333.842501l-11.989999,12.523368l7.640737,9.115074-9.00527,28.429999l13.354532,21.66l12.169999-21.66-8.276464-28.429999l7.683584-9.115074-11.577119-12.523368Z" transform="translate(.000003-8.207567)" fill="#fff" stroke-width="0.964"/>\n <path d="M277.027489,313.607575c2.10968-2.124145,2.109674-7.294472,2.10968-12.616701.000001-4.924048,3.734359-8.575732,5.993261-11.785502c6.850428-9.734066,17.425154-17.270326,32.509567-28.554392c19.581659-14.648281,38.363352-37.839451,38.363352-75.004322s-15.358165-77.557662-47.326267-97.060908-100.336835-21.863731-138.616835,11.230119q-38.28,33.09385-26.47094,84.615075q2.941471,5.424961-4.109265,16.914925c-7.050736,11.489964-5.790737,10.87-13.400737,20.07q-7.61,9.2,14.77,24.588001q8.081429,8.196065,4.040692,25.931176c-4.040737,17.735111,17.930782,25.351045,58.470045,26.015934c6.315019,0,10.285402,4.016302,9.820182,13.53245c2.318232,3.860567,45.195831,4.173208,63.847265,2.124145Z" transform="translate(-4.731067 2.174968)" fill="#fff" stroke-width="0.964"/>\n <g transform="translate(-1.999999 1)">\n <path d="M245.9733,169.12822c0-15.53699,12.59522-28.13221,28.13221-28.13221s28.13221,12.59522,28.13221,28.13221-12.59522,28.13221-28.13221,28.13221-28.13221-12.59522-28.13221-28.13221Zm28.13221,16.48705c9.10555,0,16.48705-7.3815,16.48705-16.48705s-7.3815-16.48705-16.48705-16.48705-16.48705,7.3815-16.48705,16.48705s7.3815,16.48705,16.48705,16.48705Z" transform="matrix(.869702 0 0 0.869702 29.215138 13.949797)" class="main-color" stroke-width="0"/>\n <ellipse rx="12.075348" ry="12.075348" transform="translate(205.701579 163.375556)" class="main-color" stroke-width="0"/>\n <path d="M181.65805,163.37556c0-13.2238,10.72001-23.94381,23.94382-23.94381c3.66235,0,7.13266.82225,10.23639,2.29221l-1.90827,3.5391c-2.53417-1.16714-5.35513-1.81808-8.32812-1.81808-11.00735,0-19.93057,8.92323-19.93057,19.93059s8.92322,19.93059,19.93057,19.93059c2.7639,0,5.3964-.5626,7.78923-1.57954l2.86146,3.09941c-3.20793,1.59589-6.8245,2.49335-10.65068,2.49335-13.22381,0-23.94382-10.72001-23.94382-23.94381l-.00001-.00001Z" transform="translate(-.294799 0)" class="main-color" stroke-width="0"/>\n <path d="M282.21447,221.07121c10.36489,0,18.76729,8.40244,18.76729,18.76737s-8.4024,18.76737-18.76729,18.76737c-2.06817,0-4.05821-.33454-5.91895-.95246l.40538-3.19396c1.7145.64687,3.5727,1.00082,5.51357,1.00082c8.62762,0,15.62168-6.99411,15.62168-15.62178s-6.99406-15.62178-15.62168-15.62178c-.56983,0-1.13253.03051-1.68657.08999l.4052-3.19253c.42343-.02855.85071-.04306,1.28137-.04306v.00002Z" transform="translate(-.294799 0.000001)" class="main-color" stroke-width="0"/>\n <ellipse rx="12.075348" ry="12.075348" transform="matrix(.818722 0 0 0.818719 201.720047 112.620951)" class="main-color" stroke-width="0"/>\n <ellipse rx="12.075348" ry="12.075348" transform="matrix(.818722 0 0 0.818719 232.659876 121.50729)" class="main-color" stroke-width="0"/>\n <ellipse rx="12.382248" ry="12.382248" transform="matrix(.910778 0 0 0.950271 282.214464 239.661329)" class="main-color" stroke-width="0"/>\n <ellipse rx="14.374568" ry="14.374568" transform="translate(289.307806 110.097611)" class="main-color" stroke-width="0"/>\n <ellipse rx="13.63993" ry="13.63993" transform="translate(323.793572 185.845218)" class="main-color" stroke-width="0"/>\n <ellipse rx="14.309665" ry="14.309665" transform="matrix(.771673 0 0 0.771673 240.96831 199.507461)" fill="#d2dbed" stroke-width="0"/>\n <ellipse rx="14.309665" ry="14.309665" transform="matrix(.771673 0 0 0.771673 240.96831 199.507461)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(1 0 0 0.934365 258.59969 181.205336)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(1 0 0 0.514936 278.399015 177.174522)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(1 0 0 0.386956 319.978123 142.907789)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(1 0 0 0.231676 198.393736 116.13011)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(-.707107 0.707107-.295051-.295051 243.232709 195.973864)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(-.707107 0.707107-.186101-.186101 259.29762 141.857073)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(-.938368-.345637 0.090967-.246966 281.751813 143.498375)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(0 0.999992-.386956 0 249.980637 159.560138)" class="main-color" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(0 0.999992-.319024 0 325.523655 159.560138)" fill="#d2dbed" stroke-width="0"/>\n <rect width="7.630899" height="118.396225" rx="0" ry="0" transform="matrix(0 0.999992-.319024 0 325.523655 159.560138)" class="main-color" stroke-width="0"/>\n </g>\n</svg>\n',r=function(){return r=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},s=function(){function e(e){this.validateConfig(e),this.config=this.mergeWithDefaults(e),this.theme=this.initializeTheme(),this.assets=this.initializeAssets(),this.icons=this.initializeIcons()}return e.prototype.validateConfig=function(e){if(!e.apiUrl)throw new Error("API URL is required");if(!e.agentToken)throw new Error("Agent token is required")},e.prototype.mergeWithDefaults=function(t){return r(r({},t),{title:t.title||"Chat Assistant",position:t.position||"bottom-right",enableAttachments:void 0===t.enableAttachments||t.enableAttachments,theme:r(r({},e.defaultTheme),t.theme)})},e.prototype.initializeTheme=function(){return r(r({},e.defaultTheme),this.config.theme)},e.prototype.initializeAssets=function(){return{logo:this.config.logo||e.defaultAssets.logo,headerLogo:this.config.headerLogo||e.defaultAssets.headerLogo}},e.prototype.initializeIcons=function(){var t=/^(data:image\/|https:\/\/|\/)/i,n={closeIcon:e.defaultIcons.closeIcon,sendIcon:e.defaultIcons.sendIcon,minimizeIcon:e.defaultIcons.minimizeIcon,maximizeIcon:e.defaultIcons.maximizeIcon,expandIcon:e.defaultIcons.expandIcon,reduceIcon:e.defaultIcons.reduceIcon};return this.config.icons&&Object.entries(this.config.icons).forEach(function(e){var i=e[0],o=e[1];o&&t.test(o)&&(n[i]=o)}),n},e.prototype.getConfig=function(){return this.config},e.prototype.getTheme=function(){return this.theme},e.prototype.getAssets=function(){return this.assets},e.prototype.getIcons=function(){return this.icons},e.prototype.getCSSVariables=function(){return{"--chat-text-color":this.theme.textColor,"--chat-background-color":this.theme.backgroundColor,"--chat-button-color":this.theme.buttonColor,"--chat-button-text-color":this.theme.buttonTextColor,"--chat-agent-foreground-color":this.theme.agentForegroundColor,"--chat-user-foreground-color":this.theme.userForegroundColor,"--chat-toggle-background-color":this.theme.toggleBackgroundColor,"--chat-toggle-text-color":this.theme.toggleTextColor,"--chat-toggle-icon-color":this.theme.toggleIconColor}},e.prototype.updateTheme=function(e){this.theme=r(r({},this.theme),e)},e.prototype.updateAssets=function(e){this.assets=this.initializeAssets()},e.prototype.updateIcons=function(e){this.icons=this.initializeIcons()},e.defaultTheme={textColor:"#111827",backgroundColor:"#ffffff",buttonColor:"#2563eb",buttonTextColor:"#ffffff",agentForegroundColor:"#111827",userForegroundColor:"#2563eb",toggleBackgroundColor:"#2563eb",toggleTextColor:"#ffffff",toggleIconColor:"#2563eb"},e.defaultAssets={logo:a,headerLogo:a},e.defaultIcons={closeIcon:"/icons/close-icon.svg",sendIcon:"/icons/send-icon.svg",minimizeIcon:"/icons/minimize-icon.svg",maximizeIcon:"/icons/maximize-icon.svg",expandIcon:"/icons/resize-icon.svg",reduceIcon:"/icons/resize-icon.svg"},e}(),c=function(){return c=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},c.apply(this,arguments)},l=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,a=t.length;o<a;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},u=function(){function e(e){this.state=e||{isOpen:!1,isExpanded:!1,isInitialized:!1,isSending:!1,messages:[],error:void 0,pendingAttachments:[],isUploadingFiles:!1,currentView:"welcome",hasStartedConversation:!1},this.listeners=new Set}return e.prototype.getState=function(){return c({},this.state)},e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){return t.listeners.delete(e)}},e.prototype.setState=function(e){var t=this.state;this.state=c(c({},this.state),e),JSON.stringify(t)!==JSON.stringify(this.state)&&this.notifyListeners()},e.prototype.notifyListeners=function(){var e=this;this.listeners.forEach(function(t){return t(e.getState())})},e.prototype.toggleChat=function(){this.setState({isOpen:!this.state.isOpen})},e.prototype.toggleExpand=function(){this.setState({isExpanded:!this.state.isExpanded})},e.prototype.setOpen=function(e){this.setState({isOpen:e})},e.prototype.setInitialized=function(e){this.setState({isInitialized:e})},e.prototype.setSending=function(e){this.setState({isSending:e})},e.prototype.addMessage=function(e){this.setState({messages:l(l([],this.state.messages,!0),[e],!1)})},e.prototype.setError=function(e){this.setState({error:e})},e.prototype.clearMessages=function(){this.setState(c(c({},this.state),{messages:[]}))},e.prototype.setMessages=function(e){this.setState(c(c({},this.state),{messages:e}))},e.prototype.updateMessage=function(e,t){var n=this.state.messages.map(function(n){return n.id===e?c(c({},n),t):n});this.setState({messages:n})},e.prototype.deleteMessage=function(e){var t=this.state.messages.filter(function(t){return t.id!==e});this.setState({messages:t})},e.prototype.getMessageById=function(e){return this.state.messages.find(function(t){return t.id===e})},e.prototype.getLastMessage=function(){return this.state.messages[this.state.messages.length-1]},e.prototype.getMessageCount=function(){return this.state.messages.length},e.prototype.clearListeners=function(){this.listeners.clear()},e.prototype.addPendingAttachment=function(e){this.setState(c(c({},this.state),{pendingAttachments:l(l([],this.state.pendingAttachments,!0),[e],!1)}))},e.prototype.updatePendingAttachment=function(e,t){this.setState(c(c({},this.state),{pendingAttachments:this.state.pendingAttachments.map(function(n){return n.file_id===e?c(c({},n),t):n})}))},e.prototype.updateAttachmentStatus=function(e,t){var n=this.state.pendingAttachments.map(function(n){return n.file_id===e?c(c({},n),t):n});this.setState({pendingAttachments:n})},e.prototype.removePendingAttachment=function(e){var t=this.state.pendingAttachments.filter(function(t){return t.file_id!==e});this.setState({pendingAttachments:t})},e.prototype.clearPendingAttachments=function(){this.setState({pendingAttachments:[]})},e.prototype.getPendingAttachments=function(){return l([],this.state.pendingAttachments,!0)},e.prototype.setUploadingFiles=function(e){this.setState({isUploadingFiles:e})},e.prototype.getInitialState=function(){return{isOpen:!1,isExpanded:!1,isInitialized:!1,isSending:!1,messages:[],error:void 0,pendingAttachments:[],isUploadingFiles:!1,currentView:"welcome",hasStartedConversation:!1}},e.prototype.updateState=function(e){this.setState(e)},e}(),h='\n :root{\n --am-bg-item-hover:#eef3ff;\n --am-bg-item-active:#dbeafe;\n --am-text-muted:#6b7280;\n --am-bg-badge:#ef4444;\n }\n\n .am-chat-widget {\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Helvetica, Arial, sans-serif;\n z-index: 999999;\n height: 100%;\n display: flex;\n flex-direction: column;\n }\n\n .am-chat-container {\n background: var(--chat-background-color, #FFFFFF);\n flex-direction: column;\n overflow: hidden;\n display: flex;\n width: 480px;\n height: 600px;\n border-radius: 8px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);\n flex: 1;\n z-index: 999999;\n position: relative;\n }\n\n .am-chat-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 16px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n height: 54px;\n background: white !important;\n color: #111827 !important;\n box-sizing: border-box;\n }\n\n .am-chat-header-content {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n gap: 8px;\n }\n\n .am-chat-logo-title {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 16px;\n font-weight: normal;\n color: #111827;\n flex-shrink: 1;\n min-width: 0;\n }\n \n .am-chat-logo-title span {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n /* Hamburger menu button */\n .am-hamburger {\n background: none;\n border: none;\n cursor: pointer;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: inherit;\n margin-right: 4px;\n }\n\n .am-chat-logo {\n width: 28px;\n height: 28px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .am-chat-logo svg {\n width: 100%;\n height: 100%;\n }\n\n .am-chat-header-logo {\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .am-chat-header-logo svg {\n width: 100%;\n height: 100%;\n }\n\n .am-chat-header h3 {\n margin: 0;\n font-size: 16px;\n font-weight: 500;\n color: inherit !important;\n }\n\n .am-chat-header button {\n background: none;\n padding: 4px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0px !important;\n }\n\n .am-chat-header button svg {\n width: 18px;\n height: 18px;\n fill: var(--chat-header-text-color, #FFFFFF);\n }\n\n .am-chat-header button:hover {\n opacity: 0.8;\n }\n\n .am-chat-header-actions {\n display: flex;\n align-items: center;\n gap: 8px !important;\n flex-shrink: 0;\n }\n\n .am-chat-header-button {\n background: none;\n border: none;\n padding: 6px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 0.2s;\n border-radius: 4px;\n color: #6b7280 !important;\n }\n\n .am-chat-header-button:hover {\n background: rgba(0, 0, 0, 0.05) !important;\n color: #374151 !important;\n }\n\n .am-chat-header-button svg {\n width: 18px;\n height: 18px;\n display: block;\n margin: auto;\n }\n\n /* For stroke-based icons (new collection) */\n .am-chat-header-button svg[stroke],\n .am-chat-header-button svg[stroke-width] {\n stroke: #6b7280 !important;\n fill: none !important;\n }\n\n .am-chat-header-button:hover svg[stroke],\n .am-chat-header-button:hover svg[stroke-width] {\n stroke: #374151 !important;\n fill: none !important;\n }\n\n /* For fill-based icons (old collection) */\n .am-chat-header-button svg[fill]:not([fill="none"]) {\n fill: #6b7280 !important;\n }\n\n .am-chat-header-button:hover svg[fill]:not([fill="none"]) {\n fill: #374151 !important;\n }\n\n /* Header button labels */\n .am-button-label {\n margin-left: 4px;\n font-size: 14px;\n font-weight: normal;\n }\n\n .am-header-button-with-text {\n gap: 4px;\n }\n\n\n .am-chat-messages {\n flex: 1 1 auto;\n overflow-y: auto;\n overflow-x: hidden;\n padding: 1rem;\n display: flex;\n flex-direction: column;\n gap: 1rem;\n min-height: 0;\n height: 0;\n background-color: var(--chat-background-color, #ffffff);\n color: var(--chat-text-color, #111827);\n }\n\n /* Style scrollbar to be always visible when content is scrollable */\n .am-chat-messages::-webkit-scrollbar {\n width: 6px;\n }\n\n .am-chat-messages::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.05);\n border-radius: 3px;\n }\n\n .am-chat-messages::-webkit-scrollbar-thumb {\n background: rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n }\n\n .am-chat-messages::-webkit-scrollbar-thumb:hover {\n background: rgba(0, 0, 0, 0.3);\n }\n\n /* Firefox scrollbar styling */\n .am-chat-messages {\n scrollbar-width: thin;\n scrollbar-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.05);\n }\n\n .am-conversation-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n position: relative;\n }\n\n /* Stage-2 conversation drawer */\n .am-drawer {\n position: absolute;\n left: 0;\n top: 0;\n height: 100%;\n width: 240px;\n transform: translateX(-100%);\n transition: transform .2s ease-out;\n background: #f5f5f5;\n box-shadow: 2px 0 6px rgba(0,0,0,.08);\n display: flex;\n flex-direction: column;\n z-index: 3;\n }\n .am-drawer.open {\n transform: translateX(0);\n }\n\n .am-drawer header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-weight: 600;\n padding: .6rem 1rem;\n border-bottom: 1px solid #e5e7eb;\n }\n .am-drawer header button.am-new {\n font-size: 1.1rem;\n line-height: 1;\n border: none;\n background: var(--chat-header-background-color, #2563eb);\n color: var(--chat-header-text-color, #FFFFFF);\n cursor: pointer;\n border-radius: 4px;\n padding: 4px 8px;\n font-weight: bold;\n }\n \n .am-drawer button.am-close {\n width: 100%;\n padding: 8px;\n margin-top: auto;\n border: none;\n background: #f0f0f0;\n cursor: pointer;\n border-top: 1px solid #e5e7eb;\n font-size: 0.9rem;\n text-align: center;\n }\n\n .am-drawer ul {\n list-style: none;\n margin: 0;\n padding: .4rem 0;\n flex: 1;\n overflow-y: auto;\n }\n \n /* drawer list styling */\n .am-drawer li {\n display: flex;\n align-items: center;\n gap: .5rem;\n position: relative;\n padding: .45rem 1rem;\n cursor: pointer;\n }\n \n .am-drawer li:hover {\n background: var(--am-bg-item-hover);\n }\n \n .am-drawer li.active {\n background: var(--am-bg-item-active);\n }\n \n .am-drawer li .title {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n \n .am-drawer li .time {\n font-size: .72rem;\n color: var(--am-text-muted);\n }\n \n .am-drawer li .badge {\n background: var(--am-bg-badge);\n color: #fff;\n border-radius: 9999px;\n font-size: .65rem;\n padding: 0 .4em;\n min-width: 1.2em;\n text-align: center;\n }\n\n /* swipe hint overlay (mobile) */\n @media(max-width:479px){\n .am-drawer{\n touch-action:pan-y;\n }\n }\n \n .am-drawer .am-close {\n border: none;\n background: none;\n padding: .6rem 1rem;\n text-align: left;\n cursor: pointer;\n border-top: 1px solid #e5e7eb;\n }\n\n .am-chat-avatar {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .am-chat-avatar.agent {\n background: var(--chat-header-background-color, #BE185D);\n }\n\n .am-chat-avatar.user {\n background: var(--chat-user-background-color, #F43F5E);\n }\n\n .am-chat-avatar img, .am-chat-avatar svg {\n width: 20px;\n height: 20px;\n }\n\n .am-chat-avatar.agent svg {\n fill: var(--chat-agent-icon-color, #FFFFFF);\n }\n\n .am-chat-avatar.user svg {\n fill: var(--chat-user-icon-color, #FFFFFF);\n }\n\n .am-chat-branding {\n text-align: left;\n font-size: 10px;\n padding: 4px 16px;\n color: #334155;\n background: white;\n }\n\n .am-chat-branding a {\n color: #2563eb;\n text-decoration: none;\n font-weight: 500;\n }\n\n .am-chat-branding a:hover {\n text-decoration: underline;\n }\n\n .am-chat-input-wrapper {\n background: white;\n width: 100%;\n display: flex;\n flex-direction: column;\n }\n\n .am-chat-input-container {\n display: flex;\n align-items: center;\n padding: 8px 16px;\n gap: 8px;\n }\n\n .am-chat-input {\n flex: 1;\n min-height: 44px;\n max-height: 120px;\n padding: 10px 12px 6px 12px;\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: 8px;\n font-size: 14px;\n line-height: 20px;\n resize: none;\n overflow-y: auto;\n background: white;\n box-sizing: border-box;\n }\n\n .am-chat-send {\n margin-left: 8px;\n width: 32px;\n height: 32px;\n padding: 6px;\n background: var(--chat-button-color, #2563eb);\n color: var(--chat-button-text-color, #ffffff);\n border: none;\n border-radius: 4px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: filter 0.2s;\n }\n\n .am-chat-send:not(:disabled):hover {\n background-color: var(--chat-button-color, #2563eb);\n filter: brightness(1.1);\n }\n\n .am-chat-send:disabled {\n cursor: not-allowed;\n opacity: 0.8;\n }\n\n .am-chat-send:disabled:hover {\n background: var(--chat-button-color, #2563eb);\n filter: none;\n opacity: 0.8;\n }\n\n .am-chat-send svg {\n width: 20px;\n height: 20px;\n }\n\n .am-chat-send:disabled svg {\n opacity: 0.8;\n }\n\n .am-chat-initializing {\n padding: 16px;\n text-align: center;\n color: #6B7280;\n }\n\n .desktop-only {\n display: none;\n }\n\n @media (min-width: 768px) {\n .desktop-only {\n display: flex;\n }\n }\n\n .am-chat-toggle {\n position: fixed;\n bottom: 20px;\n right: 20px;\n border: none;\n border-radius: 100px;\n padding: 0;\n cursor: pointer;\n transition: transform 0.2s;\n z-index: 1000;\n }\n\n .am-chat-toggle:hover {\n transform: scale(1.05);\n }\n\n .am-chat-toggle-content {\n display: flex;\n align-items: center;\n gap: 8px;\n background: var(--chat-toggle-background-color, #2563eb);\n color: var(--chat-toggle-text-color, #FFFFFF);\n padding: 8px 16px 8px 8px;\n border-radius: 100px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);\n }\n\n .am-chat-toggle-text {\n font-size: 16px;\n font-weight: 500;\n }\n\n .am-chat-toggle .am-chat-logo {\n color: var(--chat-toggle-icon-color, #FFFFFF);\n }\n\n .am-chat-expanded {\n position: fixed !important;\n top: 12px !important;\n right: 0 !important;\n bottom: 12px !important;\n width: 100vw !important;\n margin: 0 !important;\n border-radius: 0 !important;\n transition: all 0.3s ease-in-out !important;\n display: flex !important;\n justify-content: center !important;\n }\n\n .am-chat-expanded .am-chat-container {\n width: 66.67vw !important;\n max-width: 600px !important;\n height: calc(95vh - 24px) !important;\n border-radius: 8px !important;\n transition: all 0.3s ease-in-out !important;\n }\n\n .am-chat-expanded .am-chat-messages {\n height: calc(95vh - 148px) !important; /* 24px margins + 124px for header and input */\n }\n\n .am-chat-minimize {\n border: none;\n background: none;\n cursor: pointer;\n }\n\n /* Override any external styles that might affect the header text */\n .am-chat-header * {\n color: inherit !important;\n }\n',d='\n .am-message {\n margin-bottom: 12px;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n width: 100%;\n }\n\n .am-message.user {\n margin-top: 0px;\n margin-bottom: 12px;\n }\n\n .am-message-content {\n padding: 0;\n border-radius: 0;\n font-size: 14px;\n width: 100%;\n word-wrap: break-word;\n line-height: 1.6;\n background: none;\n border: none;\n }\n\n .am-message.agent .am-message-content {\n color: var(--chat-agent-foreground-color, var(--chat-text-color, #111827));\n }\n\n .am-message.user .am-message-content {\n color: var(--chat-user-foreground-color, var(--chat-text-color, #111827));\n }\n\n /* Role labels */\n .am-message-role {\n font-size: 12px;\n font-weight: 600;\n color: #6b7280;\n margin-bottom: 8px;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n }\n\n .am-message.agent .am-message-role {\n color: #111827;\n }\n\n .am-message.user .am-message-role {\n color: #2563eb;\n }\n\n // Content formatting - Reduce spacing\n .am-message.agent .am-message-content br {\n content: "";\n display: block;\n margin-top: 0.2em;\n }\n\n .am-message-avatar {\n width: 24px;\n height: 24px;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n margin-top: 4px;\n }\n\n .am-message-avatar img {\n width: 100%;\n height: 100%;\n border-radius: 50%;\n }\n\n .am-message.user .am-message-avatar {\n width: 28px;\n height: 28px;\n margin-top: 16px;\n }\n \n\n /* Typography and spacing */\n .am-message-content p {\n margin: 0 0 8px 0;\n }\n\n .am-message-content p:last-child {\n margin-bottom: 0;\n } \n\n /* Enhanced Lists styling */\n .am-message-content ul,\n .am-message-content ol {\n margin: 4px 0;\n padding-left: 20px;\n list-style-position: outside;\n }\n\n .am-message-content ul {\n list-style-type: disc;\n }\n\n .am-message-content ol {\n list-style-type: decimal;\n }\n\n /* Nested lists */\n .am-message-content ul ul,\n .am-message-content ol ul {\n list-style-type: circle;\n }\n\n .am-message-content ul ul ul,\n .am-message-content ol ul ul {\n list-style-type: square;\n }\n\n .am-message-content ol ol,\n .am-message-content ul ol {\n list-style-type: lower-alpha;\n }\n\n .am-message-content ol ol ol,\n .am-message-content ul ol ol {\n list-style-type: lower-roman;\n }\n\n .am-message-content li {\n margin: 4px 0;\n padding-left: 4px;\n line-height: 1.4;\n display: list-item; /* Ensures list markers are visible */\n }\n\n /* Remove margins for nested lists */\n .am-message-content li > ul,\n .am-message-content li > ol {\n margin: 2px 0;\n }\n\n /* Links styling */\n .am-message-content a {\n color: #2563eb;\n text-decoration: none;\n font-weight: 500;\n }\n\n .am-message.user .am-message-content a {\n color: inherit;\n }\n\n .am-message-content a:hover {\n text-decoration: underline;\n }\n\n /* Strong and emphasis */\n .am-message-content strong {\n font-weight: 600;\n }\n\n .am-message-content em {\n font-style: italic;\n } \n\n .am-message-content h1,\n .am-message-content h2,\n .am-message-content h3,\n .am-message-content h4,\n .am-message-content h5,\n .am-message-content h6 {\n font-weight: 500;\n line-height: 1.3;\n margin: 16px 0 8px 0; \n }\n\n .am-message-content h2,\n .am-message-content h3 {\n margin-top: 24px; /* More space above section headers */\n margin-bottom: 12px; /* More space below before content */\n } \n\n .am-message-content h1 { font-size: 1.4em; }\n .am-message-content h2 { font-size: 1.3em; }\n .am-message-content h3 { font-size: 1.2em; }\n .am-message-content h4 { font-size: 1.1em; }\n .am-message-content h5 { font-size: 1em; }\n .am-message-content h6 { font-size: 0.9em; }\n\n /* Ensure first and last headings don\'t add extra spacing */\n .am-message-content > h1:first-child,\n .am-message-content > h2:first-child,\n .am-message-content > h3:first-child,\n .am-message-content > h4:first-child,\n .am-message-content > h5:first-child,\n .am-message-content > h6:first-child {\n margin-top: 0;\n }\n\n .am-message-content > h1:last-child,\n .am-message-content > h2:last-child,\n .am-message-content > h3:last-child,\n .am-message-content > h4:last-child,\n .am-message-content > h5:last-child,\n .am-message-content > h6:last-child {\n margin-bottom: 0;\n }\n\n /* Add space after paragraphs */\n .am-message-content p + h1,\n .am-message-content p + h2,\n .am-message-content p + h3,\n .am-message-content p + h4,\n .am-message-content p + h5,\n .am-message-content p + h6 {\n margin-top: 24px; /* More space when heading follows paragraph */\n } \n\n /* Adjust list spacing after headers */\n .am-message-content h1 + ul,\n .am-message-content h2 + ul,\n .am-message-content h3 + ul,\n .am-message-content h4 + ul,\n .am-message-content h5 + ul,\n .am-message-content h6 + ul {\n margin-top: 12px;\n }\n\n\n /* Code blocks */\n .am-message-content code {\n background: rgba(0, 0, 0, 0.05);\n padding: 2px 4px;\n border-radius: 4px;\n font-family: monospace;\n font-size: 0.9em;\n }\n\n .am-message-content pre {\n background: rgba(0, 0, 0, 0.05);\n padding: 12px;\n border-radius: 8px;\n overflow-x: auto;\n margin: 8px 0;\n }\n\n .am-message-content pre code {\n background: none;\n padding: 0;\n }\n\n /* Markdown image styling */\n .am-message-image-container {\n margin: 12px 0;\n max-width: 100%;\n text-align: left;\n }\n\n .am-message-image {\n max-width: min(100%, 320px); /* Fluid but capped */\n max-height: 300px;\n width: auto;\n height: auto;\n display: block;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n cursor: pointer;\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n object-fit: contain; /* Better than cover for content visibility */\n }\n\n .am-message-image:hover {\n transform: scale(1.02);\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n\n /* Mobile responsiveness */\n @media (max-width: 480px) {\n .am-message-image {\n max-width: 100%;\n max-height: 250px;\n }\n }\n\n /* Loading state */\n .am-message-image:not([src]), \n .am-message-image[src=""] {\n background: #f3f4f6;\n min-height: 100px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .am-message-image:not([src]):before,\n .am-message-image[src=""]:before {\n content: "Loading image...";\n color: #666;\n font-size: 14px;\n }\n\n /* Fallback for any images not wrapped (safety net) */\n .am-message-content img:not(.am-message-image) {\n max-width: 100%;\n max-height: 300px;\n height: auto;\n display: block;\n margin: 8px 0;\n border-radius: 8px;\n }\n\n /* Blockquotes */\n .am-message-content blockquote {\n border-left: 4px solid #2563eb;\n margin: 8px 0;\n padding: 4px 12px;\n color: #4b5563;\n }\n\n /* Tables */\n .am-message-content table {\n border-collapse: collapse;\n width: 100%;\n margin: 8px 0;\n }\n\n .am-message-content th,\n .am-message-content td {\n border: 1px solid rgba(0, 0, 0, 0.1);\n padding: 8px;\n text-align: left;\n }\n\n .am-message-content th {\n background: rgba(0, 0, 0, 0.05);\n font-weight: 600;\n }\n\n /* Remove margin top from first element */\n .am-message-content > *:first-child {\n margin-top: 0;\n }\n\n /* Remove margin bottom from last element */\n .am-message-content > *:last-child {\n margin-bottom: 0;\n }\n\n\n @media (max-width: 480px) {\n .am-message-content {\n font-size: 13px;\n padding: 10px 14px;\n }\n \n .am-message-content ul,\n .am-message-content ol {\n padding-left: 20px;\n }\n }\n\n /* Input component styles moved to input.ts */\n',p={corner:"\n .am-chat-widget--corner {\n position: fixed;\n bottom: var(--chat-bottom, 12px);\n right: var(--chat-right, 12px);\n z-index: var(--chat-z-index, 999999);\n }\n \n .am-chat-widget--corner .am-chat-container {\n position: fixed;\n bottom: var(--chat-container-bottom, 20px);\n right: var(--chat-container-right, 20px);\n width: var(--chat-container-width, 480px);\n height: var(--chat-container-height, 600px);\n z-index: var(--chat-z-index, 999999);\n }\n\n .am-chat-widget--corner .am-chat-toggle {\n position: fixed !important;\n bottom: var(--chat-toggle-bottom, 12px) !important;\n right: var(--chat-toggle-right, 12px) !important;\n padding: 0 !important;\n border: none !important;\n background: var(--chat-toggle-background-color, var(--chat-header-background-color, #2563eb)) !important;\n cursor: pointer !important;\n z-index: var(--chat-z-index, 999999)\n border-radius: 32px !important;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;\n transition: transform 0.2s !important;\n text-transform: none !important;\n letter-spacing: normal !important;\n line-height: normal !important;\n text-decoration: none !important;\n min-width: auto !important;\n min-height: auto !important;\n max-width: none !important;\n max-height: none !important;\n width: auto !important;\n height: auto !important;\n margin: 0 !important;\n }\n\n .am-chat-widget--corner .am-chat-toggle:hover {\n transform: translateY(-1px) !important;\n background: var(--chat-toggle-background-color,