@ihoomanai/chat-widget 3.0.9 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +106 -46
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +106 -46
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.umd.js +106 -46
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/widget.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/widget.ts +111 -45
package/dist/index.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="https://api.ihooman.ai",t={serverUrl:e,theme:"light",position:"bottom-right",title:"Chat Support",subtitle:"We typically reply within minutes",welcomeMessage:"Hi there! 👋 How can we help you today?",placeholder:"Type a message...",primaryColor:"#00aeff",gradientFrom:"#00aeff",gradientTo:"#0066ff",showTimestamps:!0,showTypingIndicator:!0,enableSounds:!0,enableFileUpload:!0,startOpen:!1,persistSession:!0,zIndex:9999,width:380,height:560,buttonSize:60,borderRadius:16,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',avatarUrl:"",poweredBy:!0,presetQuestions:[],proactiveMessages:[],surveyConfig:null,locale:"en",allowLocalhost:!0},o={chat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>',close:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',send:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>',attach:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>',minimize:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"></line></svg>',bot:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="10" rx="2"></rect><circle cx="12" cy="5" r="2"></circle><path d="M12 7v4"></path></svg>',agent:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>',ticket:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>',history:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>',plus:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>',star:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"></path></svg>',starEmpty:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"></path></svg>',thumbUp:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"></path></svg>',thumbDown:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"></path></svg>'};let n={widgetId:"",...t},i={isOpen:!1,isConnected:!1,messages:[],pendingMessages:[],sessionId:null,visitorId:null,unreadCount:0,view:"chat",connectionStatus:"disconnected",typingIndicator:!1,soundMuted:!1,escalationStatus:null,userInfo:null},a="chat",s=!1,r=[],c={},d=null,l=[],p={};const u={};let h=null,m=null,g=0;let f=!1,b=null,y=null;function v(e=""){return e+Math.random().toString(36).slice(2,14)+Date.now().toString(36)}function x(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function w(e,t){const o="ihooman_chat_"+e;try{if(void 0===t){const e=localStorage.getItem(o);return e?JSON.parse(e):null}return null===t?(localStorage.removeItem(o),null):(localStorage.setItem(o,JSON.stringify(t)),t)}catch{return null}}function k(e,t){(u[e]||[]).forEach(o=>{try{o(t)}catch(t){console.error(`Error in ${e} handler:`,t)}});const o=`on${e.charAt(0).toUpperCase()}${e.slice(1)}`,i=n[o];if("function"==typeof i)try{i(t)}catch(e){console.error(`Error in ${o}:`,e)}}function V(){const e=window.scrollY||document.documentElement.scrollTop,t=document.documentElement.scrollHeight-window.innerHeight;return t>0?Math.round(e/t*100):0}function A(e){try{return new RegExp(e.replace(/\*/g,".*")).test(window.location.href)}catch{return window.location.href.includes(e)}}function $(){const e=document.createElement("style");e.id="ihooman-widget-styles",e.textContent=function(){const{primaryColor:e,gradientFrom:t,gradientTo:o,fontFamily:i,borderRadius:a,zIndex:s,width:r,height:c,buttonSize:d}=n,l="dark"===n.theme,p=l?"#1a1a2e":"#ffffff",u=l?"#e4e4e7":"#1f2937",h=l?"#71717a":"#6b7280",m=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",g=l?"#16162a":"#f9fafb",f=`linear-gradient(135deg, ${t}, ${o})`,b=l?"#252542":"#f1f5f9",y=n.position?.includes("right")??!0,v=n.position?.includes("bottom")??!0;return`\n .ihooman-widget * { box-sizing: border-box !important; margin: 0; padding: 0; }\n .ihooman-widget { font-family: ${i}; font-size: 14px; line-height: 1.5; color: ${u}; -webkit-font-smoothing: antialiased; }\n .ihooman-widget button { box-sizing: border-box !important; cursor: pointer !important; font-family: inherit !important; appearance: none !important; -webkit-appearance: none !important; outline: none !important; }\n .ihooman-toggle { position: fixed !important; ${y?"right: 20px":"left: 20px"}; ${v?"bottom: 20px":"top: 20px"}; width: ${d}px !important; height: ${d}px !important; border-radius: 50% !important; background: linear-gradient(135deg, ${t}, ${o}) !important; border: none !important; cursor: pointer; z-index: ${s}; display: flex !important; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(0, 174, 255, 0.35); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; }\n .ihooman-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0, 174, 255, 0.45); }\n .ihooman-toggle:active { transform: scale(0.95); }\n .ihooman-toggle::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent); border-radius: 50%; }\n .ihooman-toggle svg { width: 26px; height: 26px; color: white; transition: transform 0.3s ease, opacity 0.2s ease; position: relative; z-index: 1; }\n .ihooman-toggle .chat-icon { display: flex; align-items: center; justify-content: center; transition: transform 0.3s ease, opacity 0.2s ease; }\n .ihooman-toggle .close-icon { position: absolute; display: flex; align-items: center; justify-content: center; transform: rotate(-90deg) scale(0); opacity: 0; transition: transform 0.3s ease, opacity 0.2s ease; }\n .ihooman-toggle.open .chat-icon { transform: rotate(90deg) scale(0); opacity: 0; }\n .ihooman-toggle.open .close-icon { transform: rotate(0) scale(1); opacity: 1; }\n .ihooman-pulse { position: absolute; inset: 0; border-radius: 50%; background: ${e}; animation: ihooman-pulse 2s ease-out infinite; }\n @keyframes ihooman-pulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.6); opacity: 0; } }\n .ihooman-toggle.open .ihooman-pulse { display: none; }\n .ihooman-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; background: #ef4444; color: white; font-size: 11px; font-weight: 600; border-radius: 10px; display: flex; align-items: center; justify-content: center; z-index: 2; }\n .ihooman-badge:empty { display: none; }\n .ihooman-window { position: fixed; ${y?"right: 20px":"left: 20px"}; ${v?"bottom: 90px":"top: 90px"}; width: ${r}px; height: ${c}px; min-height: ${c}px; max-height: ${c}px; z-index: ${(s??9999)-1}; display: flex; flex-direction: column; opacity: 0; visibility: hidden; transform: translateY(20px) scale(0.95); transition: opacity 0.3s, visibility 0.3s, transform 0.3s; overscroll-behavior: contain; }\n .ihooman-window.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }\n .ihooman-container { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; border-radius: ${a}px; overflow: hidden; flex-shrink: 0; }\n .ihooman-container::before { content: ''; position: absolute; inset: 0; background: ${p}; opacity: 0.97; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: ${a}px; border: 1px solid ${m}; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }\n .ihooman-container > * { position: relative; z-index: 1; }\n .ihooman-header { padding: 16px 20px; background: linear-gradient(135deg, ${t}, ${o}); color: white; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }\n .ihooman-header-avatar { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }\n .ihooman-header-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }\n .ihooman-header-avatar svg { width: 22px; height: 22px; }\n .ihooman-header-info { flex: 1; min-width: 0; }\n .ihooman-header-title { font-size: 16px; font-weight: 600; margin-bottom: 2px; }\n .ihooman-header-status { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.9; }\n .ihooman-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }\n .ihooman-status-dot.offline { background: #f59e0b; }\n .ihooman-header-actions { display: flex; gap: 8px; }\n .ihooman-header-btn { width: 28px; height: 28px; border-radius: 6px; background: rgba(255,255,255,0.15); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: white; transition: background 0.2s; }\n .ihooman-header-btn:hover { background: rgba(255,255,255,0.25); }\n .ihooman-header-btn svg { width: 14px; height: 14px; }\n .ihooman-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: ${p}; overscroll-behavior: contain; min-height: 0; }\n .ihooman-messages::-webkit-scrollbar { width: 6px; }\n .ihooman-messages::-webkit-scrollbar-track { background: transparent; }\n .ihooman-messages::-webkit-scrollbar-thumb { background: ${m}; border-radius: 3px; }\n .ihooman-message { display: flex; flex-direction: column; max-width: 85%; animation: ihooman-fadeIn 0.3s ease; }\n @keyframes ihooman-fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }\n .ihooman-message.user { align-self: flex-end; align-items: flex-end; }\n .ihooman-message.bot { align-self: flex-start; align-items: flex-start; }\n .ihooman-message-content { padding: 12px 16px; border-radius: 16px; word-wrap: break-word; }\n .ihooman-message.user .ihooman-message-content { background: ${f}; color: white; border-bottom-right-radius: 4px; }\n .ihooman-message.bot .ihooman-message-content { background: ${b}; color: ${u}; border-bottom-left-radius: 4px; }\n .ihooman-message-content code { background: rgba(0,0,0,0.1); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }\n .ihooman-message-time { font-size: 11px; color: ${h}; margin-top: 4px; padding: 0 4px; }\n .ihooman-typing { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: ${b}; border-radius: 16px; border-bottom-left-radius: 4px; max-width: 80px; align-self: flex-start; }\n .ihooman-typing-dots { display: flex; gap: 4px; }\n .ihooman-typing-dot { width: 8px; height: 8px; background: ${h}; border-radius: 50%; animation: ihooman-typing 1.4s infinite; }\n .ihooman-typing-dot:nth-child(2) { animation-delay: 0.2s; }\n .ihooman-typing-dot:nth-child(3) { animation-delay: 0.4s; }\n @keyframes ihooman-typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }\n .ihooman-input-area { padding: 12px 16px; background: ${p}; border-top: 1px solid ${m}; flex-shrink: 0; }\n .ihooman-input-wrapper { display: flex; align-items: flex-end; gap: 8px; background: ${g}; border: 1px solid ${m}; border-radius: 12px; padding: 8px 12px; transition: border-color 0.2s, box-shadow 0.2s; }\n .ihooman-input-wrapper:focus-within { border-color: ${e}; box-shadow: 0 0 0 3px rgba(0, 174, 255, 0.1); }\n .ihooman-input { flex: 1; border: none; background: transparent; font-family: inherit; font-size: 14px; color: ${u}; resize: none; max-height: 100px; outline: none; line-height: 1.4; }\n .ihooman-input::placeholder { color: ${h}; }\n .ihooman-input-btn { width: 32px; height: 32px; border-radius: 8px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; background: transparent; color: ${h}; }\n .ihooman-input-btn:hover { background: ${m}; color: ${u}; }\n .ihooman-input-btn.send { background: linear-gradient(135deg, ${t}, ${o}); color: white; }\n .ihooman-input-btn.send:hover { opacity: 0.9; }\n .ihooman-input-btn.send:disabled { opacity: 0.5; cursor: not-allowed; }\n .ihooman-input-btn svg { width: 16px; height: 16px; }\n .ihooman-file-input { display: none; }\n .ihooman-powered { text-align: center; padding: 8px; font-size: 11px; color: ${h}; background: ${p}; }\n .ihooman-powered a { color: ${e}; text-decoration: none; }\n .ihooman-escalation-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }\n .ihooman-widget .ihooman-escalation-btn { cursor: pointer !important; font-family: inherit !important; transition: all 0.2s ease !important; }\n .ihooman-widget .ihooman-escalation-btn svg { width: 14px !important; height: 14px !important; flex-shrink: 0 !important; }\n .ihooman-status-bar { padding: 10px 16px; text-align: center; font-size: 13px; display: none; }\n .ihooman-status-bar.show { display: block; }\n .ihooman-status-bar.waiting { background: #fef3c7; color: #92400e; }\n .ihooman-status-bar.connected { background: #dcfce7; color: #166534; }\n .ihooman-chat-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }\n .ihooman-chat-view.hidden { display: none; }\n .ihooman-ticket-view { display: none; flex-direction: column; padding: 20px; gap: 16px; background: ${p}; flex: 1; overflow-y: auto; min-height: 0; }\n .ihooman-ticket-view.show { display: flex; }\n .ihooman-ticket-title { font-size: 18px; font-weight: 600; color: ${u}; margin: 0; }\n .ihooman-ticket-subtitle { font-size: 13px; color: ${h}; margin: 0; }\n .ihooman-ticket-input { padding: 12px 14px; border: 1px solid ${m}; border-radius: 10px; font-size: 14px; font-family: inherit; background: ${g}; color: ${u}; outline: none; transition: border-color 0.2s; }\n .ihooman-ticket-input:focus { border-color: ${e}; }\n .ihooman-ticket-input::placeholder { color: ${h}; }\n .ihooman-ticket-textarea { min-height: 100px; resize: vertical; }\n .ihooman-ticket-submit { display: flex; align-items: center; justify-content: center; padding: 12px; background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; line-height: 1.4; }\n .ihooman-ticket-submit:hover { opacity: 0.9; }\n .ihooman-ticket-submit:disabled { opacity: 0.5; cursor: not-allowed; }\n .ihooman-ticket-back { display: flex; align-items: center; justify-content: center; padding: 10px; background: transparent; color: ${h}; border: 1px solid ${m}; border-radius: 8px; font-size: 13px; cursor: pointer; transition: all 0.2s; line-height: 1.4; }\n .ihooman-ticket-back:hover { background: ${l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.03)"}; }\n .ihooman-history-view { display: none; flex-direction: column; flex: 1; overflow: hidden; background: ${p}; }\n .ihooman-history-view.show { display: flex; }\n .ihooman-history-header { padding: 12px 16px; border-bottom: 1px solid ${m}; display: flex; justify-content: space-between; align-items: center; }\n .ihooman-history-title { font-size: 14px; font-weight: 600; color: ${u}; margin: 0; }\n .ihooman-history-new { display: inline-flex; align-items: center; justify-content: center; gap: 4px; background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s; line-height: 1.4; }\n .ihooman-history-new:hover { opacity: 0.9; }\n .ihooman-history-new svg { width: 12px; height: 12px; flex-shrink: 0; }\n .ihooman-history-list { flex: 1; overflow-y: auto; padding: 8px; overscroll-behavior: contain; }\n .ihooman-history-item { padding: 12px; border: 1px solid ${m}; border-radius: 8px; margin-bottom: 6px; cursor: pointer; transition: all 0.2s; background: ${p}; }\n .ihooman-history-item:hover { background: ${l?"rgba(255,255,255,0.05)":"#f8fafc"}; }\n .ihooman-history-item.active { background: ${l?"rgba(0, 174, 255, 0.1)":"#eff6ff"}; border-color: ${e}; }\n .ihooman-history-preview { font-size: 13px; color: ${u}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .ihooman-history-meta { font-size: 11px; color: ${h}; margin-top: 4px; display: flex; justify-content: space-between; }\n .ihooman-history-empty { padding: 40px; text-align: center; color: ${h}; font-size: 14px; }\n .ihooman-preset-questions { padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 6px; background: ${p}; border-top: 1px solid ${m}; }\n .ihooman-preset-questions:empty { display: none; }\n .ihooman-preset-questions.hidden { display: none !important; }\n .ihooman-widget .ihooman-preset-btn { cursor: pointer !important; font-family: inherit !important; transition: all 0.2s !important; }\n .ihooman-proactive-toast { position: fixed; ${y?"right: 20px":"left: 20px"}; ${v?"bottom: 90px":"top: 90px"}; max-width: 300px; padding: 16px; background: ${p}; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); z-index: ${(s??9999)-2}; opacity: 0; visibility: hidden; transform: translateY(10px); transition: all 0.3s ease; border: 1px solid ${m}; }\n .ihooman-proactive-toast.show { opacity: 1; visibility: visible; transform: translateY(0); }\n .ihooman-proactive-toast-content { font-size: 14px; color: ${u}; margin-bottom: 12px; }\n .ihooman-proactive-toast-actions { display: flex; gap: 8px; }\n .ihooman-proactive-toast-btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; line-height: 1.4; }\n .ihooman-proactive-toast-btn.primary { background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; }\n .ihooman-proactive-toast-btn.primary:hover { opacity: 0.9; }\n .ihooman-proactive-toast-btn.secondary { background: transparent; color: ${h}; border: 1px solid ${m}; }\n .ihooman-proactive-toast-btn.secondary:hover { background: ${l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.03)"}; }\n .ihooman-survey-view { display: none; flex-direction: column; padding: 20px; gap: 16px; background: ${p}; flex: 1; align-items: center; justify-content: center; }\n .ihooman-survey-view.show { display: flex; }\n .ihooman-survey-question { font-size: 16px; font-weight: 600; color: ${u}; text-align: center; }\n .ihooman-survey-stars { display: flex; gap: 8px; }\n .ihooman-survey-star { width: 40px; height: 40px; cursor: pointer; color: ${h}; transition: all 0.2s; }\n .ihooman-survey-star:hover, .ihooman-survey-star.active { color: #fbbf24; transform: scale(1.1); }\n .ihooman-survey-star svg { width: 100%; height: 100%; }\n .ihooman-survey-comment { width: 100%; padding: 12px; border: 1px solid ${m}; border-radius: 8px; font-size: 14px; resize: none; min-height: 80px; background: ${g}; color: ${u}; }\n .ihooman-survey-submit { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; line-height: 1.4; }\n .ihooman-survey-submit:hover { opacity: 0.9; }\n .ihooman-survey-skip { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; background: transparent; color: ${h}; border: none; font-size: 12px; cursor: pointer; line-height: 1.4; }\n .ihooman-survey-skip:hover { color: ${u}; }\n .ihooman-feedback-btns { display: flex; gap: 6px; margin-top: 6px; }\n .ihooman-widget .ihooman-feedback-btn { cursor: pointer !important; transition: all 0.2s !important; }\n .ihooman-widget .ihooman-feedback-btn svg { width: 12px !important; height: 12px !important; }\n .ihooman-carousel { display: flex; gap: 12px; overflow-x: auto; padding: 8px 0; scroll-snap-type: x mandatory; }\n .ihooman-carousel::-webkit-scrollbar { height: 4px; }\n .ihooman-carousel-card { min-width: 200px; max-width: 250px; border: 1px solid ${m}; border-radius: 12px; overflow: hidden; scroll-snap-align: start; background: ${p}; }\n .ihooman-carousel-card img { width: 100%; height: 120px; object-fit: cover; }\n .ihooman-carousel-card-content { padding: 12px; }\n .ihooman-carousel-card-title { font-size: 14px; font-weight: 600; color: ${u}; margin-bottom: 4px; }\n .ihooman-carousel-card-desc { font-size: 12px; color: ${h}; margin-bottom: 8px; }\n .ihooman-carousel-card-btns { display: flex; flex-direction: column; gap: 6px; }\n .ihooman-widget .ihooman-carousel-card-btn { cursor: pointer !important; transition: all 0.2s !important; }\n .ihooman-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }\n .ihooman-widget .ihooman-quick-reply { cursor: pointer !important; transition: all 0.2s !important; }\n @media (max-width: 480px) { .ihooman-window { width: calc(100vw - 20px); height: calc(100vh - 100px); min-height: 400px; max-height: calc(100vh - 100px); left: 10px; right: 10px; bottom: 80px; } .ihooman-toggle { ${y?"right: 16px":"left: 16px"}; bottom: 16px; } .ihooman-proactive-toast { left: 10px; right: 10px; max-width: none; } }\n `}(),document.head.appendChild(e);const t=document.createElement("div");t.className="ihooman-widget",t.innerHTML=`\n <button class="ihooman-toggle" aria-label="Open chat">\n <span class="ihooman-pulse"></span>\n <span class="ihooman-badge"></span>\n <span class="chat-icon">${o.chat}</span>\n <span class="close-icon">${o.close}</span>\n </button>\n <div class="ihooman-proactive-toast">\n <div class="ihooman-proactive-toast-content"></div>\n <div class="ihooman-proactive-toast-actions">\n <button class="ihooman-proactive-toast-btn primary">Chat Now</button>\n <button class="ihooman-proactive-toast-btn secondary">Dismiss</button>\n </div>\n </div>\n <div class="ihooman-window" role="dialog" aria-label="Chat window">\n <div class="ihooman-container">\n <div class="ihooman-header">\n <div class="ihooman-header-avatar">${n.avatarUrl?`<img src="${x(n.avatarUrl)}" alt="Support">`:o.bot}</div>\n <div class="ihooman-header-info">\n <div class="ihooman-header-title">${x(n.title||"Chat Support")}</div>\n <div class="ihooman-header-status"><span class="ihooman-status-dot"></span><span class="ihooman-status-text">Online</span></div>\n </div>\n <div class="ihooman-header-actions">\n <button class="ihooman-header-btn" data-action="history" title="Chat history">${o.history}</button>\n <button class="ihooman-header-btn" data-action="refresh" title="New conversation">${o.plus}</button>\n <button class="ihooman-header-btn" data-action="minimize" title="Minimize">${o.minimize}</button>\n </div>\n </div>\n <div class="ihooman-chat-view">\n <div class="ihooman-status-bar"></div>\n <div class="ihooman-messages" role="log" aria-live="polite"></div>\n <div class="ihooman-preset-questions"></div>\n <div class="ihooman-input-area">\n <div class="ihooman-input-wrapper">\n ${n.enableFileUpload?`<button class="ihooman-input-btn attach" title="Attach file">${o.attach}</button><input type="file" class="ihooman-file-input">`:""}\n <textarea class="ihooman-input" placeholder="${x(n.placeholder||"Type a message...")}" rows="1" aria-label="Message input"></textarea>\n <button class="ihooman-input-btn send" title="Send message" disabled>${o.send}</button>\n </div>\n </div>\n </div>\n <div class="ihooman-ticket-view">\n <h4 class="ihooman-ticket-title">📝 Submit a Ticket</h4>\n <p class="ihooman-ticket-subtitle">We'll get back to you via email</p>\n <input class="ihooman-ticket-input" id="ihooman-ticket-name" placeholder="Your name" required>\n <input class="ihooman-ticket-input" id="ihooman-ticket-email" type="email" placeholder="Your email" required>\n <textarea class="ihooman-ticket-input ihooman-ticket-textarea" id="ihooman-ticket-issue" placeholder="Describe your issue..."></textarea>\n <button class="ihooman-ticket-submit" id="ihooman-ticket-submit">Submit Ticket</button>\n <button class="ihooman-ticket-back" id="ihooman-ticket-back">← Back to Chat</button>\n </div>\n <div class="ihooman-history-view">\n <div class="ihooman-history-header">\n <span class="ihooman-history-title">Your Conversations</span>\n <button class="ihooman-history-new">${o.plus} New Chat</button>\n </div>\n <div class="ihooman-history-list"></div>\n </div>\n <div class="ihooman-survey-view">\n <div class="ihooman-survey-question">${n.surveyConfig?.question||"How was your experience?"}</div>\n <div class="ihooman-survey-stars"></div>\n <textarea class="ihooman-survey-comment" placeholder="Any additional feedback? (optional)"></textarea>\n <button class="ihooman-survey-submit">Submit Feedback</button>\n <button class="ihooman-survey-skip">Skip</button>\n </div>\n ${n.poweredBy?'<div class="ihooman-powered">Powered by <a href="https://ihooman.ai" target="_blank" rel="noopener">Ihooman AI</a></div>':""}\n </div>\n </div>\n `,document.body.appendChild(t),p={widget:t,toggle:t.querySelector(".ihooman-toggle"),badge:t.querySelector(".ihooman-badge"),window:t.querySelector(".ihooman-window"),chatView:t.querySelector(".ihooman-chat-view"),ticketView:t.querySelector(".ihooman-ticket-view"),historyView:t.querySelector(".ihooman-history-view"),surveyView:t.querySelector(".ihooman-survey-view"),historyList:t.querySelector(".ihooman-history-list"),messages:t.querySelector(".ihooman-messages"),presetQuestions:t.querySelector(".ihooman-preset-questions"),input:t.querySelector(".ihooman-input"),sendBtn:t.querySelector(".ihooman-input-btn.send"),attachBtn:t.querySelector(".ihooman-input-btn.attach"),fileInput:t.querySelector(".ihooman-file-input"),statusDot:t.querySelector(".ihooman-status-dot"),statusText:t.querySelector(".ihooman-status-text"),statusBar:t.querySelector(".ihooman-status-bar"),ticketName:t.querySelector("#ihooman-ticket-name"),ticketEmail:t.querySelector("#ihooman-ticket-email"),ticketIssue:t.querySelector("#ihooman-ticket-issue"),ticketSubmitBtn:t.querySelector("#ihooman-ticket-submit"),ticketBackBtn:t.querySelector("#ihooman-ticket-back"),proactiveToast:t.querySelector(".ihooman-proactive-toast")},function(){if(!p.toggle||!p.sendBtn||!p.input)return;p.toggle.addEventListener("click",X),p.sendBtn.addEventListener("click",j),p.input.addEventListener("input",()=>{p.sendBtn&&(p.sendBtn.disabled=!p.input?.value.trim()),p.input&&(p.input.style.height="auto",p.input.style.height=Math.min(p.input.scrollHeight,100)+"px")}),p.input.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),p.sendBtn?.disabled||j())}),p.attachBtn&&p.fileInput&&(p.attachBtn.addEventListener("click",()=>p.fileInput?.click()),p.fileInput.addEventListener("change",N));p.widget?.querySelector('[data-action="refresh"]')?.addEventListener("click",ee),p.widget?.querySelector('[data-action="minimize"]')?.addEventListener("click",Z),p.widget?.querySelector('[data-action="history"]')?.addEventListener("click",q),p.ticketSubmitBtn&&p.ticketSubmitBtn.addEventListener("click",T);p.ticketBackBtn&&p.ticketBackBtn.addEventListener("click",()=>L("chat"));const e=p.widget?.querySelector(".ihooman-history-new");e&&e.addEventListener("click",()=>{ee(),L("chat")});const t=p.proactiveToast?.querySelector(".ihooman-proactive-toast-btn.primary"),n=p.proactiveToast?.querySelector(".ihooman-proactive-toast-btn.secondary");t&&t.addEventListener("click",()=>{F(),K(),k("proactive:clicked")});n&&n.addEventListener("click",()=>{F()});const i=p.surveyView?.querySelector(".ihooman-survey-submit"),a=p.surveyView?.querySelector(".ihooman-survey-skip");i&&i.addEventListener("click",B);a&&a.addEventListener("click",()=>L("chat"));!function(){const e=p.surveyView?.querySelector(".ihooman-survey-stars");if(!e)return;let t=0;e.innerHTML="";for(let n=1;n<=5;n++){const i=document.createElement("div");i.className="ihooman-survey-star",i.innerHTML=o.starEmpty,i.dataset.rating=String(n),i.addEventListener("click",()=>{t=n,S(e,n)}),i.addEventListener("mouseenter",()=>S(e,n)),i.addEventListener("mouseleave",()=>S(e,t)),e.appendChild(i)}}()}()}function S(e,t){e.querySelectorAll(".ihooman-survey-star").forEach((e,n)=>{const i=e;n<t?(i.innerHTML=o.star,i.classList.add("active")):(i.innerHTML=o.starEmpty,i.classList.remove("active"))})}function _(e,t="bot",a={}){const s={id:v("msg_"),content:e,sender:t,timestamp:new Date,metadata:a};if(i.messages.push(s),!p.messages)return s;const r=document.createElement("div");r.className=`ihooman-message ${t}`;const c="bot"===t&&!0===a?.escalation_offered;let d="";c&&(d=`\n <div class="ihooman-escalation-actions">\n <button class="ihooman-escalation-btn primary" data-action="live-agent">${o.agent}<span>Talk to Agent</span></button>\n <button class="ihooman-escalation-btn secondary" data-action="create-ticket">${o.ticket}<span>Create Ticket</span></button>\n </div>\n `);let l="";a?.quick_replies&&a.quick_replies.length>0&&(l=`<div class="ihooman-quick-replies">${a.quick_replies.map(e=>`<button class="ihooman-quick-reply" data-text="${x(e.text)}">${x(e.text)}</button>`).join("")}</div>`);let u="";var h,m;"bot"!==t||a?.is_system_message||(u=`\n <div class="ihooman-feedback-btns">\n <button class="ihooman-feedback-btn" data-feedback="up" title="Helpful">${o.thumbUp}</button>\n <button class="ihooman-feedback-btn" data-feedback="down" title="Not helpful">${o.thumbDown}</button>\n </div>\n `),r.innerHTML=`\n <div class="ihooman-message-content">${m=e,m?x(m).replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`(.*?)`/g,"<code>$1</code>").replace(/\[(.*?)\]\((.*?)\)/g,'<a href="$2" target="_blank" rel="noopener">$1</a>').replace(/\n/g,"<br>"):""}</div>\n ${d}\n ${l}\n ${u}\n ${n.showTimestamps?`<div class="ihooman-message-time">${h=s.timestamp,new Date(h).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}</div>`:""}\n `,c&&(r.querySelector('[data-action="live-agent"]')?.addEventListener("click",()=>I("live-agent")),r.querySelector('[data-action="create-ticket"]')?.addEventListener("click",()=>I("create-ticket"))),r.querySelectorAll(".ihooman-quick-reply").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.text;t&&(H(),_(t,"user"),U(),W(t))})}),r.querySelectorAll(".ihooman-feedback-btn").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.feedback;r.querySelectorAll(".ihooman-feedback-btn").forEach(e=>e.classList.remove("active")),e.classList.add("active"),async function(e,t){try{await fetch(`${n.serverUrl}/api/widget/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:n.widgetId,message_id:e,session_id:i.sessionId,feedback_type:t})})}catch(e){console.error("Error submitting feedback:",e)}}(s.id,"up"===t?"positive":"negative")})});const g=p.messages.querySelector(".ihooman-typing");return g&&g.remove(),p.messages.appendChild(r),p.messages.scrollTop=p.messages.scrollHeight,"bot"!==t||i.isOpen||(i.unreadCount++,p.badge&&(p.badge.textContent=String(i.unreadCount)),n.enableSounds&&function(){try{const e=new Audio("data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4Ljc2LjEwMAAAAAAAAAAAAAAA//tQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU4LjEzAAAAAAAAAAAAAAAAJAAAAAAAAAAAAYYNBrP/AAAAAAAAAAAAAAAAAAAAAP/7UMQAA8AAAaQAAAAgAAA0gAAABExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tQxBKDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=");e.volume=.3,e.play().catch(()=>{})}catch{}}()),k("message",s),s}function C(){console.debug("[IhoomanChat] Rendering preset questions:",l.length),p.presetQuestions&&0!==l.length?(p.presetQuestions.innerHTML=l.map(e=>`\n <button class="ihooman-preset-btn" data-question-id="${x(e.id)}" data-question-text="${x(e.text)}">\n ${e.icon||e.emoji?`<span class="icon">${x(e.icon||e.emoji||"")}</span>`:""}\n <span>${x(e.text)}</span>\n </button>\n `).join(""),p.presetQuestions.querySelectorAll(".ihooman-preset-btn").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.questionText;t&&function(e){H(),_(e,"user"),U(),W(e)}(t)})})):p.presetQuestions&&(p.presetQuestions.innerHTML="")}function I(e){document.querySelectorAll(".ihooman-escalation-btn").forEach(e=>e.disabled=!0),"live-agent"===e?async function(){if(!i.sessionId)return void _("Please send a message first to start a conversation.","bot",{is_system_message:!0});try{const e=await fetch(`${n.serverUrl}/api/widget/live-agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:n.widgetId,session_id:i.sessionId,visitor_id:i.visitorId})}),t=await e.json();s=!0,i.escalationStatus={active:!0,type:"live_agent",queuePosition:t.position_in_queue},t.position_in_queue&&t.position_in_queue>1?z("waiting",`⏳ Waiting for agent (Position: #${t.position_in_queue})`):z("waiting","⏳ Connecting to live support..."),E(),k("escalation:start",{type:"live_agent"})}catch(e){console.error("Error requesting live agent:",e),_("❌ Unable to connect to live support. Please try again.","bot",{is_system_message:!0})}}():"create-ticket"===e&&L("ticket")}function L(e){a=e,i.view=e,p.chatView&&p.chatView.classList.toggle("hidden","chat"!==e),p.ticketView&&p.ticketView.classList.toggle("show","ticket"===e),p.historyView&&p.historyView.classList.toggle("show","history"===e),p.surveyView&&p.surveyView.classList.toggle("show","survey"===e),"history"===e&&async function(){if(!p.historyList||!i.visitorId)return;p.historyList.innerHTML='<div class="ihooman-history-empty">Loading...</div>';try{const e=await fetch(`${n.serverUrl}/api/widget/conversations?widget_id=${n.widgetId}&visitor_id=${i.visitorId}&limit=20`);if(!e.ok)throw new Error("Failed to load history");const t=await e.json();if(!t.length)return void(p.historyList.innerHTML='<div class="ihooman-history-empty">No conversations yet</div>');p.historyList.innerHTML=t.map(e=>`\n <div class="ihooman-history-item ${e.session_id===i.sessionId?"active":""}" data-session-id="${e.session_id}">\n <div class="ihooman-history-preview">${x(e.preview||"New conversation")}</div>\n <div class="ihooman-history-meta">\n <span>${e.message_count} msgs</span>\n <span>${"pending"===e.status?"🟡 Pending":"closed"===e.status?"✓ Closed":""} ${function(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"now":t<36e5?Math.floor(t/6e4)+"m":t<864e5?Math.floor(t/36e5)+"h":Math.floor(t/864e5)+"d"}(e.updated_at)}</span>\n </div>\n </div>\n `).join(""),p.historyList.querySelectorAll(".ihooman-history-item").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.sessionId;t&&async function(e){i.sessionId=e,n.persistSession&&w("session_id",e);p.messages&&(p.messages.innerHTML="");s=!1,M(),z("hidden"),f=!0,h&&(h.close(),h=null);R(),L("chat"),await async function(e){try{const t=await fetch(`${n.serverUrl}/api/widget/transcript/${e}?widget_id=${n.widgetId}`);if(!t.ok)throw new Error("Failed to load messages");const o=await t.json();p.messages&&(p.messages.innerHTML=""),o.messages&&o.messages.length>0?o.messages.forEach(e=>{const t="user"===e.sender_type?"user":"bot";_(e.content,t,e.extra_data||{})}):n.welcomeMessage&&_(n.welcomeMessage,"bot"),"pending"===o.status&&(s=!0,E(),z("waiting","⏳ Waiting for agent..."))}catch(e){console.error("Error loading conversation messages:",e),n.welcomeMessage&&_(n.welcomeMessage,"bot")}}(e)}(t)})})}catch(e){console.error("Error loading conversation history:",e),p.historyList.innerHTML='<div class="ihooman-history-empty">Failed to load history</div>'}}()}function q(){L("history"===a?"chat":"history")}function z(e,t){p.statusBar&&("hidden"!==e?(p.statusBar.classList.add("show"),p.statusBar.classList.remove("waiting","connected"),p.statusBar.classList.add(e),t&&(p.statusBar.textContent=t)):p.statusBar.classList.remove("show"))}async function T(){const e=p.ticketName?.value.trim(),t=p.ticketEmail?.value.trim(),o=p.ticketIssue?.value.trim();if(e&&t){p.ticketSubmitBtn&&(p.ticketSubmitBtn.disabled=!0,p.ticketSubmitBtn.textContent="Submitting...");try{const a=await fetch(`${n.serverUrl}/api/widget/submit-ticket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:n.widgetId,session_id:i.sessionId,user_name:e,user_email:t,issue:o||"No description provided"})}),s=await a.json();p.ticketName&&(p.ticketName.value=""),p.ticketEmail&&(p.ticketEmail.value=""),p.ticketIssue&&(p.ticketIssue.value=""),L("chat");_(`✅ Ticket submitted! We'll contact you at ${t}. Reference: #${s.ticket_id?s.ticket_id.slice(0,8):"submitted"}`,"bot",{is_system_message:!0})}catch(e){console.error("Error submitting ticket:",e),_("❌ Error submitting ticket. Please try again.","bot",{is_system_message:!0})}p.ticketSubmitBtn&&(p.ticketSubmitBtn.disabled=!1,p.ticketSubmitBtn.textContent="Submit Ticket")}else alert("Please fill in your name and email")}function E(){y||(y=setInterval(async()=>{if(i.sessionId&&s)try{const e=await fetch(`${n.serverUrl}/api/widget/escalation-status/${i.sessionId}?widget_id=${n.widgetId}`);if(e.ok){const t=await e.json();t.escalated&&("in_progress"===t.ticket_status?z("connected","🟢 Connected to live agent"):"open"===t.ticket_status?z("waiting",t.position_in_queue>1?`⏳ Waiting for agent (Position: #${t.position_in_queue})`:"⏳ Waiting for agent..."):"closed"!==t.ticket_status&&"resolved"!==t.ticket_status||(s=!1,M(),z("hidden"),_("This conversation has been closed. Thank you for contacting us!","bot",{is_system_message:!0}),k("escalation:end",{type:"live_agent"})))}}catch{}else M()},3e3))}function M(){y&&(clearInterval(y),y=null)}async function B(){const e=p.surveyView?.querySelector(".ihooman-survey-stars"),t=e?.querySelectorAll(".ihooman-survey-star.active"),o=t?.length||0,a=p.surveyView?.querySelector(".ihooman-survey-comment")?.value;if(0!==o)try{await fetch(`${n.serverUrl}/api/widget/survey-response`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:n.widgetId,survey_id:n.surveyConfig?.id,session_id:i.sessionId,rating:o,comment:a})}),w("survey_completed_"+i.sessionId,!0),k("survey:submitted",{rating:o,comment:a}),_(n.surveyConfig?.thankYouMessage||"Thank you for your feedback!","bot",{is_system_message:!0}),L("chat")}catch(e){console.error("Error submitting survey:",e)}else alert("Please select a rating")}function U(){if(!n.showTypingIndicator||!p.messages)return;if(p.messages.querySelector(".ihooman-typing"))return;const e=document.createElement("div");e.className="ihooman-typing",e.innerHTML='<div class="ihooman-typing-dots"><span class="ihooman-typing-dot"></span><span class="ihooman-typing-dot"></span><span class="ihooman-typing-dot"></span></div>',p.messages.appendChild(e),p.messages.scrollTop=p.messages.scrollHeight}function O(){const e=p.messages?.querySelector(".ihooman-typing");e&&e.remove()}function j(){const e=p.input?.value.trim();e&&(H(),p.input&&(p.input.value="",p.input.style.height="auto"),p.sendBtn&&(p.sendBtn.disabled=!0),_(e,"user"),U(),W(e))}function H(){p.presetQuestions&&p.presetQuestions.classList.add("hidden")}async function W(e){if(h&&h.readyState===WebSocket.OPEN)h.send(JSON.stringify({type:"message",content:e}));else try{const t=await fetch(`${n.serverUrl}/api/v1/public/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,session_id:i.sessionId,visitor_id:i.visitorId,widget_id:n.widgetId})}),o=await t.json();O(),o.session_id&&(i.sessionId=o.session_id,n.persistSession&&w("session_id",i.sessionId)),o.response&&_(o.response,"bot",{sources:o.sources,confidence:o.confidence,escalation_offered:o.escalation_offered,quick_replies:o.quick_replies})}catch(e){O(),_("Sorry, something went wrong. Please try again.","bot"),k("error",e)}}function N(e){const t=e.target,o=t.files?.[0];if(!o)return;_(`📎 Uploading: ${o.name}...`,"user"),U();const a=new FormData;a.append("file",o),a.append("session_id",i.sessionId||""),a.append("visitor_id",i.visitorId||""),a.append("widget_id",n.widgetId),fetch(`${n.serverUrl}/api/upload`,{method:"POST",body:a}).then(e=>e.json()).then(e=>{O(),e.message&&_(e.message,"bot")}).catch(()=>{O(),_("Failed to upload file.","bot")}),t.value=""}function D(){n.proactiveMessages&&0!==n.proactiveMessages.length?(console.debug("[IhoomanChat] Initializing proactive messages:",n.proactiveMessages.length),r=w("shown_proactive")||[],c=w("proactive_cooldowns")||{},d=setInterval(P,5e3),window.addEventListener("scroll",P),document.addEventListener("mouseout",e=>{e.clientY<=0&&function(){if(i.isOpen||!n.proactiveMessages)return;const e=n.proactiveMessages.filter(e=>"exit_intent"===e.trigger.type&&!r.includes(e.id));e.length>0&&Q(e[0])}()})):console.debug("[IhoomanChat] No proactive messages configured")}function P(){if(i.isOpen||!n.proactiveMessages)return;const e=Date.now();for(const t of n.proactiveMessages){if(r.includes(t.id))continue;const o=c[t.id];if(o&&e-o<60*t.cooldownMinutes*1e3)continue;if(t.startDate&&new Date(t.startDate)>new Date)continue;if(t.endDate&&new Date(t.endDate)<new Date)continue;let n=!1;switch(t.trigger.type){case"time":const o="number"==typeof t.trigger.value?t.trigger.value:parseInt(String(t.trigger.value),10);e-(w("page_load_time")||e)>=1e3*o&&(n=!0);break;case"scroll":const i="number"==typeof t.trigger.value?t.trigger.value:parseInt(String(t.trigger.value),10);V()>=i&&(n=!0);break;case"url_pattern":A(String(t.trigger.value))&&(n=!0)}if(n){Q(t);break}}}function Q(e){if(r.push(e.id),c[e.id]=Date.now(),w("shown_proactive",r),w("proactive_cooldowns",c),p.proactiveToast){const t=p.proactiveToast.querySelector(".ihooman-proactive-toast-content");t&&(t.textContent=e.message),p.proactiveToast.classList.add("show"),k("proactive:shown",e),e.autoOpen&&setTimeout(()=>{F(),K()},3e3)}}function F(){p.proactiveToast&&p.proactiveToast.classList.remove("show")}function R(e){if(!n.serverUrl&&!e)return;let t;if(n.widgetId){const e=n.serverUrl?.replace(/^http/,"ws"),o=new URLSearchParams({widget_id:n.widgetId});i.visitorId&&o.append("visitor_id",i.visitorId),i.sessionId&&o.append("session_id",i.sessionId),t=`${e}/public/ws?${o.toString()}`}else t=e||n.serverUrl?.replace(/^http/,"ws")+"/ws";try{Y(),h=new WebSocket(t),h.onopen=()=>{i.isConnected=!0,i.connectionStatus="connected",g=0,G(!0),k("connected"),Y(),b=setInterval(()=>{if(h&&h.readyState===WebSocket.OPEN)try{h.send(JSON.stringify({type:"ping"}))}catch{}},25e3)},h.onclose=t=>{if(i.isConnected=!1,i.connectionStatus="disconnected",G(!1),Y(),k("disconnected"),f)f=!1;else if(i.isOpen)if(g<5){g++;const t=Math.min(1e3*Math.pow(2,g),3e4);setTimeout(()=>R(e),t)}else J()},h.onerror=e=>{console.error("WebSocket error:",e)},h.onmessage=e=>{try{const t=JSON.parse(e.data);if("connected"===t.type)t.session_id&&(i.sessionId=t.session_id,n.persistSession&&w("session_id",i.sessionId)),t.visitor_id&&(i.visitorId=t.visitor_id,n.persistSession&&w("visitor_id",i.visitorId)),t.welcome_message&&0===i.messages.length&&_(t.welcome_message,"bot");else if("message"===t.type){O();const e="user"===t.sender?"user":"bot";_(t.content,e,{confidence:t.confidence,agent_name:t.agent_name,escalation_offered:t.escalation_offered,escalated:t.escalated,quick_replies:t.quick_replies})}else"typing"===t.type?t.is_typing?U():O():"pong"===t.type||"error"===t.type&&(console.error("WebSocket server error:",t.message),k("error",{message:t.message}))}catch{}}}catch{J()}}function Y(){b&&(clearInterval(b),b=null)}function J(){m||(m=setInterval(async()=>{if(i.sessionId)try{const e=await fetch(`${n.serverUrl}/api/messages?session_id=${i.sessionId}&since=${Date.now()-5e3}&widget_id=${n.widgetId}`),t=await e.json();t.messages&&t.messages.forEach(e=>{i.messages.find(t=>t.id===e.id)||_(e.content,e.sender_type,e.metadata)})}catch{}},5e3))}function G(e){p.statusDot&&p.statusDot.classList.toggle("offline",!e),p.statusText&&(p.statusText.textContent=e?"Online":"Offline")}function K(){i.isOpen||(i.isOpen=!0,i.unreadCount=0,p.badge&&(p.badge.textContent=""),p.toggle&&p.toggle.classList.add("open"),p.window&&p.window.classList.add("open"),F(),setTimeout(()=>p.input?.focus(),300),k("open"))}function Z(){if(i.isOpen){if(i.isOpen=!1,p.toggle&&p.toggle.classList.remove("open"),p.window&&p.window.classList.remove("open"),n.surveyConfig&&i.messages.length>=4){i.sessionId&&w("survey_completed_"+i.sessionId)||setTimeout(()=>{i.isOpen||(n.surveyConfig&&(i.sessionId&&w("survey_completed_"+i.sessionId)||i.messages.length<4||(L("survey"),k("survey:shown",n.surveyConfig))),K())},500)}k("close")}}function X(){i.isOpen?Z():K()}function ee(){i.sessionId=null,i.visitorId=null,i.messages=[],s=!1,w("session_id",null),i.visitorId=v("v_"),w("visitor_id",i.visitorId),p.messages&&(p.messages.innerHTML=""),z("hidden"),M(),g=0,h&&(f=!0,h.close(),h=null),R(),n.welcomeMessage&&_(n.welcomeMessage,"bot"),p.presetQuestions&&p.presetQuestions.classList.remove("hidden"),C(),k("newConversation")}const te={backgroundColor:"#00aeff",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:8,paddingVertical:8,paddingHorizontal:16,fontSize:13,fontWeight:"medium"},oe={backgroundColor:"transparent",textColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:1,borderRadius:8,paddingVertical:8,paddingHorizontal:16,fontSize:13,fontWeight:"medium"},ne={backgroundColor:"rgba(0, 174, 255, 0.1)",textColor:"#00aeff",borderColor:"rgba(0, 174, 255, 0.2)",borderWidth:1,borderRadius:20,paddingVertical:6,paddingHorizontal:12,fontSize:12,fontWeight:"medium"},ie={backgroundColor:"#f3f4f6",textColor:"#374151",borderColor:"#e5e7eb",borderWidth:1,borderRadius:16,paddingVertical:5,paddingHorizontal:10,fontSize:11,fontWeight:"medium"},ae={backgroundColor:"transparent",textColor:"#9ca3af",borderColor:"#e5e7eb",borderWidth:1,borderRadius:6,paddingVertical:4,paddingHorizontal:8,fontSize:12,fontWeight:"medium"},se={backgroundColor:"rgba(255, 255, 255, 0.1)",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:6,paddingVertical:6,paddingHorizontal:6,fontSize:14,fontWeight:"medium"},re={backgroundColor:"#00aeff",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:8,paddingVertical:8,paddingHorizontal:14,fontSize:12,fontWeight:"medium"},ce={backgroundColor:"#00aeff",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:6,paddingVertical:6,paddingHorizontal:12,fontSize:12,fontWeight:"medium"};function de(e){const t="ihooman-button-styling";let o=document.getElementById(t);o||(o=document.createElement("style"),o.id=t,document.head.appendChild(o));const n={primary:{...te,...e?.primary||{}},secondary:{...oe,...e?.secondary||{}},presetQuestions:{...ne,...e?.presetQuestions||{}},quickReplies:{...ie,...e?.quickReplies||{}},feedback:{...ae,...e?.feedback||{}},headerActions:{...se,...e?.headerActions||{}},escalation:{...re,...e?.escalation||{}},cardActions:{...ce,...e?.cardActions||{}}},i=(e,t)=>{const o=t.backgroundColor,n=t.textColor,i=t.borderColor;return`\n .ihooman-widget ${e},\n html body .ihooman-widget ${e} {\n background: ${o} !important;\n color: ${n} !important;\n border: ${t.borderWidth}px solid ${i} !important;\n border-radius: ${t.borderRadius}px !important;\n padding: ${t.paddingVertical}px ${t.paddingHorizontal}px !important;\n font-size: ${t.fontSize}px !important;\n font-weight: ${function(e){switch(e){case"normal":return 400;case"medium":default:return 500;case"semibold":return 600;case"bold":return 700}}(t.fontWeight)} !important;\n min-width: auto !important;\n min-height: auto !important;\n width: auto !important;\n height: auto !important;\n max-width: none !important;\n max-height: none !important;\n display: inline-flex !important;\n align-items: center !important;\n justify-content: center !important;\n gap: 6px !important;\n line-height: 1.4 !important;\n text-transform: none !important;\n letter-spacing: normal !important;\n box-shadow: none !important;\n text-decoration: none !important;\n white-space: nowrap !important;\n flex-shrink: 0 !important;\n flex-grow: 0 !important;\n box-sizing: border-box !important;\n appearance: none !important;\n -webkit-appearance: none !important;\n }\n `};let a="";a+=i(".ihooman-input-btn.send",n.primary),a+=i(".ihooman-proactive-toast-btn.primary",n.primary),a+=i(".ihooman-survey-submit",n.primary),a+=i(".ihooman-ticket-submit",n.primary),a+=i(".ihooman-history-new",n.primary),a+=i(".ihooman-proactive-toast-btn.secondary",n.secondary),a+=i(".ihooman-survey-skip",n.secondary),a+=i(".ihooman-ticket-back",n.secondary),a+=i(".ihooman-preset-btn",n.presetQuestions),a+=i(".ihooman-quick-reply",n.quickReplies),a+=i(".ihooman-feedback-btn",n.feedback),a+=i(".ihooman-header-btn",n.headerActions),a+=i(".ihooman-escalation-btn",n.escalation),a+=i(".ihooman-escalation-btn.primary",n.escalation),a+=i(".ihooman-escalation-btn.secondary",n.secondary),a+=i(".ihooman-carousel-card-btn",n.cardActions),console.debug("[IhoomanChat] Applied button styling CSS:",a.length,"chars"),o.textContent=a}async function le(o){if(!o.widgetId)return console.error("IhoomanChat: widgetId is required"),null;n={...t,...o},i.visitorId=w("visitor_id")||v("v_"),w("visitor_id",i.visitorId),n.persistSession&&(i.sessionId=w("session_id")),w("page_load_time")||w("page_load_time",Date.now());const a=n.serverUrl||e,s=await async function(e,t){try{const o=await fetch(`${t}/api/widget/config?widget_id=${encodeURIComponent(e)}`);return o.ok?await o.json():{success:!1,error:(await o.json().catch(()=>({}))).error||`HTTP ${o.status}`}}catch(e){return{success:!1,error:"Unable to connect. Please check your internet connection."}}}(n.widgetId,a);let r;var c;return s.success&&s.config?(c=s.config,n.title=c.title||n.title,n.subtitle=c.subtitle||n.subtitle,n.welcomeMessage=c.welcomeMessage||n.welcomeMessage,n.placeholder=c.placeholder||n.placeholder,n.position=c.position||n.position,c.theme&&(n.primaryColor=c.theme.primaryColor||n.primaryColor,n.gradientFrom=c.theme.gradientFrom||n.gradientFrom,n.gradientTo=c.theme.gradientTo||n.gradientTo,n.fontFamily=c.theme.fontFamily||n.fontFamily,c.theme.borderRadius&&(n.borderRadius=parseInt(c.theme.borderRadius,10)||n.borderRadius)),c.behavior&&(n.startOpen=c.behavior.startOpen??n.startOpen,n.showTypingIndicator=c.behavior.showTypingIndicator??n.showTypingIndicator,n.showTimestamps=c.behavior.showTimestamps??n.showTimestamps,n.enableSounds=c.behavior.enableSounds??n.enableSounds,n.enableFileUpload=c.behavior.enableFileUpload??n.enableFileUpload,n.persistSession=c.behavior.persistSession??n.persistSession),c.branding&&(n.avatarUrl=c.branding.avatarUrl||n.avatarUrl,n.logoUrl=c.branding.logoUrl||n.logoUrl,n.poweredBy=c.branding.poweredBy??n.poweredBy,n.customCss=c.branding.customCss||n.customCss),c.size&&(n.width=c.size.width||n.width,n.height=c.size.height||n.height,n.buttonSize=c.size.buttonSize||n.buttonSize),c.presetQuestions&&Array.isArray(c.presetQuestions)&&(console.debug("[IhoomanChat] Server config presetQuestions:",c.presetQuestions.length),l=c.presetQuestions.map(e=>({id:e.id,text:e.text,icon:e.icon,emoji:e.icon})),n.presetQuestions=l),c.proactiveMessages&&Array.isArray(c.proactiveMessages)&&(console.debug("[IhoomanChat] Server config proactiveMessages:",c.proactiveMessages.length),n.proactiveMessages=c.proactiveMessages.filter(e=>!1!==e.isActive).map(e=>({id:e.id,message:e.message,trigger:{type:e.trigger.type,value:"time"===e.trigger.type||"scroll"===e.trigger.type?parseInt(e.trigger.value,10)||30:e.trigger.value},autoOpen:e.autoOpen||!1,cooldownMinutes:e.cooldownMinutes||60}))),c.surveyConfig&&!1!==c.surveyConfig.isActive&&(console.debug("[IhoomanChat] Server config surveyConfig:",c.surveyConfig.id),n.surveyConfig={id:c.surveyConfig.id,type:c.surveyConfig.type,question:c.surveyConfig.question,followUpQuestion:c.surveyConfig.followUpQuestion,thankYouMessage:c.surveyConfig.thankYouMessage}),c.buttonStyling&&(console.debug("[IhoomanChat] Server config buttonStyling:",Object.keys(c.buttonStyling)),n.buttonStyling=c.buttonStyling,de(c.buttonStyling)),r=s.chatEndpoint):s.error&&(console.warn("IhoomanChat: Could not fetch server config:",s.error),"Widget not authorized for this domain"===s.error&&console.error("IhoomanChat: Widget configuration error. Please contact support.")),$(),de(n.buttonStyling),C(),i.messages.forEach(e=>_(e.content,"user"===e.sender?"user":"bot",e.metadata)),0===i.messages.length&&n.welcomeMessage&&_(n.welcomeMessage,"bot"),R(r),D(),n.startOpen&&setTimeout(K,500),k("ready"),pe}const pe={init:le,open:K,close:Z,toggle:X,isOpen:function(){return i.isOpen},destroy:function(){Y(),M(),d&&(clearInterval(d),d=null),window.removeEventListener("scroll",P),f=!0,h&&(h.close(),h=null),m&&(clearInterval(m),m=null),p.widget&&p.widget.remove();const e=document.getElementById("ihooman-widget-styles");e&&e.remove(),i={isOpen:!1,isConnected:!1,messages:[],sessionId:null,visitorId:null,unreadCount:0},p={},g=0,f=!1},sendMessage:function(e){e.trim()&&(p.input&&(p.input.value=e),j())},setUser:function(e){i.userInfo=e,e.name&&w("user_name",e.name),e.email&&w("user_email",e.email),e.metadata&&w("user_metadata",e.metadata)},clearUser:function(){i.userInfo=null,w("user_name",null),w("user_email",null),w("user_metadata",null)},clearHistory:function(){ee()},on:function(e,t){u[e]||(u[e]=[]),u[e].push(t)},off:function(e,t){u[e]&&(u[e]=u[e].filter(e=>e!==t))},getState:function(){return{...i}},getConfig:function(){return{...n}},showSurvey:function(){n.surveyConfig?(L("survey"),k("survey:shown",n.surveyConfig)):console.warn("[IhoomanChat] No survey configured")},resetProactiveMessages:function(){r=[],c={},w("shown_proactive",null),w("proactive_cooldowns",null),console.debug("[IhoomanChat] Proactive message history reset")},version:"3.0.9"},ue=pe;function he(){return{...pe}}!function(){if("undefined"==typeof document)return;let e=document.currentScript;if(!e){const t=document.getElementsByTagName("script");for(let o=0;o<t.length;o++)if(t[o].src&&t[o].src.includes("ihooman")){e=t[o];break}}if(!e)return;const t=e.getAttribute("data-widget-id");if(t){const o={widgetId:t},n=e.getAttribute("data-server-url");n&&(o.serverUrl=n);const i=e.getAttribute("data-theme");"light"!==i&&"dark"!==i||(o.theme=i);const a=e.getAttribute("data-position");a&&(o.position=a);"true"===e.getAttribute("data-start-open")&&(o.startOpen=!0),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>le(o)):le(o)}}(),"undefined"!=typeof window&&(window.IhoomanChat=ue);export{ue as IhoomanChat,he as createWidgetInstance,ue as default};
|
|
1
|
+
const e="https://api.ihooman.ai",t={serverUrl:e,theme:"light",position:"bottom-right",title:"Chat Support",subtitle:"We typically reply within minutes",welcomeMessage:"Hi there! 👋 How can we help you today?",placeholder:"Type a message...",primaryColor:"#00aeff",gradientFrom:"#00aeff",gradientTo:"#0066ff",showTimestamps:!0,showTypingIndicator:!0,enableSounds:!0,enableFileUpload:!0,startOpen:!1,persistSession:!0,zIndex:9999,width:380,height:560,buttonSize:60,borderRadius:16,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',avatarUrl:"",poweredBy:!0,presetQuestions:[],proactiveMessages:[],surveyConfig:null,locale:"en",allowLocalhost:!0},o={chat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>',close:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',send:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>',attach:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>',minimize:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"></line></svg>',bot:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="10" rx="2"></rect><circle cx="12" cy="5" r="2"></circle><path d="M12 7v4"></path></svg>',agent:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>',ticket:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>',history:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>',plus:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>',star:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"></path></svg>',starEmpty:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"></path></svg>',thumbUp:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"></path></svg>',thumbDown:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"></path></svg>'};let n={widgetId:"",...t},i={isOpen:!1,isConnected:!1,messages:[],pendingMessages:[],sessionId:null,visitorId:null,unreadCount:0,view:"chat",connectionStatus:"disconnected",typingIndicator:!1,soundMuted:!1,escalationStatus:null,userInfo:null},a="chat",s=!1,r=[],c={},d=null,l=[],p={};const u={};let h=null,m=null,g=0;let f=!1,b=null,y=null;function v(e=""){return e+Math.random().toString(36).slice(2,14)+Date.now().toString(36)}function x(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function w(e,t){const o="ihooman_chat_"+e;try{if(void 0===t){const e=localStorage.getItem(o);return e?JSON.parse(e):null}return null===t?(localStorage.removeItem(o),null):(localStorage.setItem(o,JSON.stringify(t)),t)}catch{return null}}function k(e,t){(u[e]||[]).forEach(o=>{try{o(t)}catch(t){console.error(`Error in ${e} handler:`,t)}});const o=`on${e.charAt(0).toUpperCase()}${e.slice(1)}`,i=n[o];if("function"==typeof i)try{i(t)}catch(e){console.error(`Error in ${o}:`,e)}}function V(){const e=window.scrollY||document.documentElement.scrollTop,t=document.documentElement.scrollHeight-window.innerHeight;return t>0?Math.round(e/t*100):0}function A(e){try{return new RegExp(e.replace(/\*/g,".*")).test(window.location.href)}catch{return window.location.href.includes(e)}}let $=null;function S(){const e=document.createElement("div");e.id="ihooman-chat-widget-host",e.style.cssText="all: initial !important; position: fixed !important; z-index: 2147483647 !important; pointer-events: none !important;",document.body.appendChild(e),$=e.attachShadow({mode:"open"});const t=document.createElement("style");t.id="ihooman-widget-styles",t.textContent=function(){const{primaryColor:e,gradientFrom:t,gradientTo:o,fontFamily:i,borderRadius:a,zIndex:s,width:r,height:c,buttonSize:d}=n,l="dark"===n.theme,p=l?"#1a1a2e":"#ffffff",u=l?"#e4e4e7":"#1f2937",h=l?"#71717a":"#6b7280",m=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",g=l?"#16162a":"#f9fafb",f=`linear-gradient(135deg, ${t}, ${o})`,b=l?"#252542":"#f1f5f9",y=n.position?.includes("right")??!0,v=n.position?.includes("bottom")??!0;return`\n *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }\n :host { all: initial; }\n .ihooman-widget { font-family: ${i}; font-size: 14px; line-height: 1.5; color: ${u}; -webkit-font-smoothing: antialiased; }\n button { \n font-family: inherit;\n font-size: 100%;\n line-height: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n background: transparent;\n border: none;\n cursor: pointer;\n outline: none;\n }\n .ihooman-toggle { position: fixed !important; ${y?"right: 20px":"left: 20px"}; ${v?"bottom: 20px":"top: 20px"}; width: ${d}px !important; height: ${d}px !important; border-radius: 50% !important; background: linear-gradient(135deg, ${t}, ${o}) !important; border: none !important; cursor: pointer; z-index: ${s}; display: flex !important; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(0, 174, 255, 0.35); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; }\n .ihooman-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0, 174, 255, 0.45); }\n .ihooman-toggle:active { transform: scale(0.95); }\n .ihooman-toggle::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent); border-radius: 50%; }\n .ihooman-toggle svg { width: 26px; height: 26px; color: white; transition: transform 0.3s ease, opacity 0.2s ease; position: relative; z-index: 1; }\n .ihooman-toggle .chat-icon { display: flex; align-items: center; justify-content: center; transition: transform 0.3s ease, opacity 0.2s ease; }\n .ihooman-toggle .close-icon { position: absolute; display: flex; align-items: center; justify-content: center; transform: rotate(-90deg) scale(0); opacity: 0; transition: transform 0.3s ease, opacity 0.2s ease; }\n .ihooman-toggle.open .chat-icon { transform: rotate(90deg) scale(0); opacity: 0; }\n .ihooman-toggle.open .close-icon { transform: rotate(0) scale(1); opacity: 1; }\n .ihooman-pulse { position: absolute; inset: 0; border-radius: 50%; background: ${e}; animation: ihooman-pulse 2s ease-out infinite; }\n @keyframes ihooman-pulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.6); opacity: 0; } }\n .ihooman-toggle.open .ihooman-pulse { display: none; }\n .ihooman-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; background: #ef4444; color: white; font-size: 11px; font-weight: 600; border-radius: 10px; display: flex; align-items: center; justify-content: center; z-index: 2; }\n .ihooman-badge:empty { display: none; }\n .ihooman-window { position: fixed; ${y?"right: 20px":"left: 20px"}; ${v?"bottom: 90px":"top: 90px"}; width: ${r}px; height: ${c}px; min-height: ${c}px; max-height: ${c}px; z-index: ${(s??9999)-1}; display: flex; flex-direction: column; opacity: 0; visibility: hidden; transform: translateY(20px) scale(0.95); transition: opacity 0.3s, visibility 0.3s, transform 0.3s; overscroll-behavior: contain; }\n .ihooman-window.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }\n .ihooman-container { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; border-radius: ${a}px; overflow: hidden; flex-shrink: 0; }\n .ihooman-container::before { content: ''; position: absolute; inset: 0; background: ${p}; opacity: 0.97; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: ${a}px; border: 1px solid ${m}; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }\n .ihooman-container > * { position: relative; z-index: 1; }\n .ihooman-header { padding: 16px 20px; background: linear-gradient(135deg, ${t}, ${o}); color: white; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }\n .ihooman-header-avatar { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }\n .ihooman-header-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }\n .ihooman-header-avatar svg { width: 22px; height: 22px; }\n .ihooman-header-info { flex: 1; min-width: 0; }\n .ihooman-header-title { font-size: 16px; font-weight: 600; margin-bottom: 2px; }\n .ihooman-header-status { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.9; }\n .ihooman-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }\n .ihooman-status-dot.offline { background: #f59e0b; }\n .ihooman-header-actions { display: flex; gap: 8px; }\n .ihooman-header-btn { width: 28px; height: 28px; border-radius: 6px; background: rgba(255,255,255,0.15); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: white; transition: background 0.2s; }\n .ihooman-header-btn:hover { background: rgba(255,255,255,0.25); }\n .ihooman-header-btn svg { width: 14px; height: 14px; }\n .ihooman-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: ${p}; overscroll-behavior: contain; min-height: 0; }\n .ihooman-messages::-webkit-scrollbar { width: 6px; }\n .ihooman-messages::-webkit-scrollbar-track { background: transparent; }\n .ihooman-messages::-webkit-scrollbar-thumb { background: ${m}; border-radius: 3px; }\n .ihooman-message { display: flex; flex-direction: column; max-width: 85%; animation: ihooman-fadeIn 0.3s ease; }\n @keyframes ihooman-fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }\n .ihooman-message.user { align-self: flex-end; align-items: flex-end; }\n .ihooman-message.bot { align-self: flex-start; align-items: flex-start; }\n .ihooman-message-content { padding: 12px 16px; border-radius: 16px; word-wrap: break-word; }\n .ihooman-message.user .ihooman-message-content { background: ${f}; color: white; border-bottom-right-radius: 4px; }\n .ihooman-message.bot .ihooman-message-content { background: ${b}; color: ${u}; border-bottom-left-radius: 4px; }\n .ihooman-message-content code { background: rgba(0,0,0,0.1); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }\n .ihooman-message-time { font-size: 11px; color: ${h}; margin-top: 4px; padding: 0 4px; }\n .ihooman-typing { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: ${b}; border-radius: 16px; border-bottom-left-radius: 4px; max-width: 80px; align-self: flex-start; }\n .ihooman-typing-dots { display: flex; gap: 4px; }\n .ihooman-typing-dot { width: 8px; height: 8px; background: ${h}; border-radius: 50%; animation: ihooman-typing 1.4s infinite; }\n .ihooman-typing-dot:nth-child(2) { animation-delay: 0.2s; }\n .ihooman-typing-dot:nth-child(3) { animation-delay: 0.4s; }\n @keyframes ihooman-typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }\n .ihooman-input-area { padding: 12px 16px; background: ${p}; border-top: 1px solid ${m}; flex-shrink: 0; }\n .ihooman-input-wrapper { display: flex; align-items: flex-end; gap: 8px; background: ${g}; border: 1px solid ${m}; border-radius: 12px; padding: 8px 12px; transition: border-color 0.2s, box-shadow 0.2s; }\n .ihooman-input-wrapper:focus-within { border-color: ${e}; box-shadow: 0 0 0 3px rgba(0, 174, 255, 0.1); }\n .ihooman-input { flex: 1; border: none; background: transparent; font-family: inherit; font-size: 14px; color: ${u}; resize: none; max-height: 100px; outline: none; line-height: 1.4; }\n .ihooman-input::placeholder { color: ${h}; }\n .ihooman-input-btn { width: 32px; height: 32px; border-radius: 8px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; background: transparent; color: ${h}; }\n .ihooman-input-btn:hover { background: ${m}; color: ${u}; }\n .ihooman-input-btn.send { background: linear-gradient(135deg, ${t}, ${o}); color: white; }\n .ihooman-input-btn.send:hover { opacity: 0.9; }\n .ihooman-input-btn.send:disabled { opacity: 0.5; cursor: not-allowed; }\n .ihooman-input-btn svg { width: 16px; height: 16px; }\n .ihooman-file-input { display: none; }\n .ihooman-powered { text-align: center; padding: 8px; font-size: 11px; color: ${h}; background: ${p}; }\n .ihooman-powered a { color: ${e}; text-decoration: none; }\n .ihooman-escalation-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }\n .ihooman-escalation-btn svg { width: 14px; height: 14px; flex-shrink: 0; }\n .ihooman-status-bar { padding: 10px 16px; text-align: center; font-size: 13px; display: none; }\n .ihooman-status-bar.show { display: block; }\n .ihooman-status-bar.waiting { background: #fef3c7; color: #92400e; }\n .ihooman-status-bar.connected { background: #dcfce7; color: #166534; }\n .ihooman-chat-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }\n .ihooman-chat-view.hidden { display: none; }\n .ihooman-ticket-view { display: none; flex-direction: column; padding: 20px; gap: 16px; background: ${p}; flex: 1; overflow-y: auto; min-height: 0; }\n .ihooman-ticket-view.show { display: flex; }\n .ihooman-ticket-title { font-size: 18px; font-weight: 600; color: ${u}; margin: 0; }\n .ihooman-ticket-subtitle { font-size: 13px; color: ${h}; margin: 0; }\n .ihooman-ticket-input { padding: 12px 14px; border: 1px solid ${m}; border-radius: 10px; font-size: 14px; font-family: inherit; background: ${g}; color: ${u}; outline: none; transition: border-color 0.2s; }\n .ihooman-ticket-input:focus { border-color: ${e}; }\n .ihooman-ticket-input::placeholder { color: ${h}; }\n .ihooman-ticket-textarea { min-height: 100px; resize: vertical; }\n .ihooman-ticket-submit { display: flex; align-items: center; justify-content: center; padding: 12px; background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; line-height: 1.4; }\n .ihooman-ticket-submit:hover { opacity: 0.9; }\n .ihooman-ticket-submit:disabled { opacity: 0.5; cursor: not-allowed; }\n .ihooman-ticket-back { display: flex; align-items: center; justify-content: center; padding: 10px; background: transparent; color: ${h}; border: 1px solid ${m}; border-radius: 8px; font-size: 13px; cursor: pointer; transition: all 0.2s; line-height: 1.4; }\n .ihooman-ticket-back:hover { background: ${l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.03)"}; }\n .ihooman-history-view { display: none; flex-direction: column; flex: 1; overflow: hidden; background: ${p}; }\n .ihooman-history-view.show { display: flex; }\n .ihooman-history-header { padding: 12px 16px; border-bottom: 1px solid ${m}; display: flex; justify-content: space-between; align-items: center; }\n .ihooman-history-title { font-size: 14px; font-weight: 600; color: ${u}; margin: 0; }\n .ihooman-history-new { display: inline-flex; align-items: center; justify-content: center; gap: 4px; background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s; line-height: 1.4; }\n .ihooman-history-new:hover { opacity: 0.9; }\n .ihooman-history-new svg { width: 12px; height: 12px; flex-shrink: 0; }\n .ihooman-history-list { flex: 1; overflow-y: auto; padding: 8px; overscroll-behavior: contain; }\n .ihooman-history-item { padding: 12px; border: 1px solid ${m}; border-radius: 8px; margin-bottom: 6px; cursor: pointer; transition: all 0.2s; background: ${p}; }\n .ihooman-history-item:hover { background: ${l?"rgba(255,255,255,0.05)":"#f8fafc"}; }\n .ihooman-history-item.active { background: ${l?"rgba(0, 174, 255, 0.1)":"#eff6ff"}; border-color: ${e}; }\n .ihooman-history-preview { font-size: 13px; color: ${u}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .ihooman-history-meta { font-size: 11px; color: ${h}; margin-top: 4px; display: flex; justify-content: space-between; }\n .ihooman-history-empty { padding: 40px; text-align: center; color: ${h}; font-size: 14px; }\n .ihooman-preset-questions { padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 6px; background: ${p}; border-top: 1px solid ${m}; }\n .ihooman-preset-questions:empty { display: none; }\n .ihooman-preset-questions.hidden { display: none; }\n .ihooman-proactive-toast { position: fixed; ${y?"right: 20px":"left: 20px"}; ${v?"bottom: 90px":"top: 90px"}; max-width: 300px; padding: 16px; background: ${p}; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); z-index: ${(s??9999)-2}; opacity: 0; visibility: hidden; transform: translateY(10px); transition: all 0.3s ease; border: 1px solid ${m}; }\n .ihooman-proactive-toast.show { opacity: 1; visibility: visible; transform: translateY(0); }\n .ihooman-proactive-toast-content { font-size: 14px; color: ${u}; margin-bottom: 12px; }\n .ihooman-proactive-toast-actions { display: flex; gap: 8px; }\n .ihooman-proactive-toast-btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; line-height: 1.4; }\n .ihooman-proactive-toast-btn.primary { background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; }\n .ihooman-proactive-toast-btn.primary:hover { opacity: 0.9; }\n .ihooman-proactive-toast-btn.secondary { background: transparent; color: ${h}; border: 1px solid ${m}; }\n .ihooman-proactive-toast-btn.secondary:hover { background: ${l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.03)"}; }\n .ihooman-survey-view { display: none; flex-direction: column; padding: 20px; gap: 16px; background: ${p}; flex: 1; align-items: center; justify-content: center; }\n .ihooman-survey-view.show { display: flex; }\n .ihooman-survey-question { font-size: 16px; font-weight: 600; color: ${u}; text-align: center; }\n .ihooman-survey-stars { display: flex; gap: 8px; }\n .ihooman-survey-star { width: 40px; height: 40px; cursor: pointer; color: ${h}; transition: all 0.2s; }\n .ihooman-survey-star:hover, .ihooman-survey-star.active { color: #fbbf24; transform: scale(1.1); }\n .ihooman-survey-star svg { width: 100%; height: 100%; }\n .ihooman-survey-comment { width: 100%; padding: 12px; border: 1px solid ${m}; border-radius: 8px; font-size: 14px; resize: none; min-height: 80px; background: ${g}; color: ${u}; }\n .ihooman-survey-submit { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; line-height: 1.4; }\n .ihooman-survey-submit:hover { opacity: 0.9; }\n .ihooman-survey-skip { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; background: transparent; color: ${h}; border: none; font-size: 12px; cursor: pointer; line-height: 1.4; }\n .ihooman-survey-skip:hover { color: ${u}; }\n .ihooman-feedback-btns { display: flex; gap: 6px; margin-top: 6px; }\n .ihooman-feedback-btn svg { width: 12px; height: 12px; }\n .ihooman-carousel { display: flex; gap: 12px; overflow-x: auto; padding: 8px 0; scroll-snap-type: x mandatory; }\n .ihooman-carousel::-webkit-scrollbar { height: 4px; }\n .ihooman-carousel-card { min-width: 200px; max-width: 250px; border: 1px solid ${m}; border-radius: 12px; overflow: hidden; scroll-snap-align: start; background: ${p}; }\n .ihooman-carousel-card img { width: 100%; height: 120px; object-fit: cover; }\n .ihooman-carousel-card-content { padding: 12px; }\n .ihooman-carousel-card-title { font-size: 14px; font-weight: 600; color: ${u}; margin-bottom: 4px; }\n .ihooman-carousel-card-desc { font-size: 12px; color: ${h}; margin-bottom: 8px; }\n .ihooman-carousel-card-btns { display: flex; flex-direction: column; gap: 6px; }\n .ihooman-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }\n @media (max-width: 480px) { .ihooman-window { width: calc(100vw - 20px); height: calc(100vh - 100px); min-height: 400px; max-height: calc(100vh - 100px); left: 10px; right: 10px; bottom: 80px; } .ihooman-toggle { ${y?"right: 16px":"left: 16px"}; bottom: 16px; } .ihooman-proactive-toast { left: 10px; right: 10px; max-width: none; } }\n `}(),$.appendChild(t);const i=document.createElement("div");i.className="ihooman-widget",i.style.cssText="pointer-events: auto;",i.innerHTML=`\n <button class="ihooman-toggle" aria-label="Open chat">\n <span class="ihooman-pulse"></span>\n <span class="ihooman-badge"></span>\n <span class="chat-icon">${o.chat}</span>\n <span class="close-icon">${o.close}</span>\n </button>\n <div class="ihooman-proactive-toast">\n <div class="ihooman-proactive-toast-content"></div>\n <div class="ihooman-proactive-toast-actions">\n <button class="ihooman-proactive-toast-btn primary">Chat Now</button>\n <button class="ihooman-proactive-toast-btn secondary">Dismiss</button>\n </div>\n </div>\n <div class="ihooman-window" role="dialog" aria-label="Chat window">\n <div class="ihooman-container">\n <div class="ihooman-header">\n <div class="ihooman-header-avatar">${n.avatarUrl?`<img src="${x(n.avatarUrl)}" alt="Support">`:o.bot}</div>\n <div class="ihooman-header-info">\n <div class="ihooman-header-title">${x(n.title||"Chat Support")}</div>\n <div class="ihooman-header-status"><span class="ihooman-status-dot"></span><span class="ihooman-status-text">Online</span></div>\n </div>\n <div class="ihooman-header-actions">\n <button class="ihooman-header-btn" data-action="history" title="Chat history">${o.history}</button>\n <button class="ihooman-header-btn" data-action="refresh" title="New conversation">${o.plus}</button>\n <button class="ihooman-header-btn" data-action="minimize" title="Minimize">${o.minimize}</button>\n </div>\n </div>\n <div class="ihooman-chat-view">\n <div class="ihooman-status-bar"></div>\n <div class="ihooman-messages" role="log" aria-live="polite"></div>\n <div class="ihooman-preset-questions"></div>\n <div class="ihooman-input-area">\n <div class="ihooman-input-wrapper">\n ${n.enableFileUpload?`<button class="ihooman-input-btn attach" title="Attach file">${o.attach}</button><input type="file" class="ihooman-file-input">`:""}\n <textarea class="ihooman-input" placeholder="${x(n.placeholder||"Type a message...")}" rows="1" aria-label="Message input"></textarea>\n <button class="ihooman-input-btn send" title="Send message" disabled>${o.send}</button>\n </div>\n </div>\n </div>\n <div class="ihooman-ticket-view">\n <h4 class="ihooman-ticket-title">📝 Submit a Ticket</h4>\n <p class="ihooman-ticket-subtitle">We'll get back to you via email</p>\n <input class="ihooman-ticket-input" id="ihooman-ticket-name" placeholder="Your name" required>\n <input class="ihooman-ticket-input" id="ihooman-ticket-email" type="email" placeholder="Your email" required>\n <textarea class="ihooman-ticket-input ihooman-ticket-textarea" id="ihooman-ticket-issue" placeholder="Describe your issue..."></textarea>\n <button class="ihooman-ticket-submit" id="ihooman-ticket-submit">Submit Ticket</button>\n <button class="ihooman-ticket-back" id="ihooman-ticket-back">← Back to Chat</button>\n </div>\n <div class="ihooman-history-view">\n <div class="ihooman-history-header">\n <span class="ihooman-history-title">Your Conversations</span>\n <button class="ihooman-history-new">${o.plus} New Chat</button>\n </div>\n <div class="ihooman-history-list"></div>\n </div>\n <div class="ihooman-survey-view">\n <div class="ihooman-survey-question">${n.surveyConfig?.question||"How was your experience?"}</div>\n <div class="ihooman-survey-stars"></div>\n <textarea class="ihooman-survey-comment" placeholder="Any additional feedback? (optional)"></textarea>\n <button class="ihooman-survey-submit">Submit Feedback</button>\n <button class="ihooman-survey-skip">Skip</button>\n </div>\n ${n.poweredBy?'<div class="ihooman-powered">Powered by <a href="https://ihooman.ai" target="_blank" rel="noopener">Ihooman AI</a></div>':""}\n </div>\n </div>\n `,$.appendChild(i),p={widget:i,toggle:i.querySelector(".ihooman-toggle"),badge:i.querySelector(".ihooman-badge"),window:i.querySelector(".ihooman-window"),chatView:i.querySelector(".ihooman-chat-view"),ticketView:i.querySelector(".ihooman-ticket-view"),historyView:i.querySelector(".ihooman-history-view"),surveyView:i.querySelector(".ihooman-survey-view"),historyList:i.querySelector(".ihooman-history-list"),messages:i.querySelector(".ihooman-messages"),presetQuestions:i.querySelector(".ihooman-preset-questions"),input:i.querySelector(".ihooman-input"),sendBtn:i.querySelector(".ihooman-input-btn.send"),attachBtn:i.querySelector(".ihooman-input-btn.attach"),fileInput:i.querySelector(".ihooman-file-input"),statusDot:i.querySelector(".ihooman-status-dot"),statusText:i.querySelector(".ihooman-status-text"),statusBar:i.querySelector(".ihooman-status-bar"),ticketName:i.querySelector("#ihooman-ticket-name"),ticketEmail:i.querySelector("#ihooman-ticket-email"),ticketIssue:i.querySelector("#ihooman-ticket-issue"),ticketSubmitBtn:i.querySelector("#ihooman-ticket-submit"),ticketBackBtn:i.querySelector("#ihooman-ticket-back"),proactiveToast:i.querySelector(".ihooman-proactive-toast")},function(){if(!p.toggle||!p.sendBtn||!p.input)return;p.toggle.addEventListener("click",ee),p.sendBtn.addEventListener("click",H),p.input.addEventListener("input",()=>{p.sendBtn&&(p.sendBtn.disabled=!p.input?.value.trim()),p.input&&(p.input.style.height="auto",p.input.style.height=Math.min(p.input.scrollHeight,100)+"px")}),p.input.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),p.sendBtn?.disabled||H())}),p.attachBtn&&p.fileInput&&(p.attachBtn.addEventListener("click",()=>p.fileInput?.click()),p.fileInput.addEventListener("change",D));p.widget?.querySelector('[data-action="refresh"]')?.addEventListener("click",te),p.widget?.querySelector('[data-action="minimize"]')?.addEventListener("click",X),p.widget?.querySelector('[data-action="history"]')?.addEventListener("click",q),p.ticketSubmitBtn&&p.ticketSubmitBtn.addEventListener("click",E);p.ticketBackBtn&&p.ticketBackBtn.addEventListener("click",()=>L("chat"));const e=p.widget?.querySelector(".ihooman-history-new");e&&e.addEventListener("click",()=>{te(),L("chat")});const t=p.proactiveToast?.querySelector(".ihooman-proactive-toast-btn.primary"),n=p.proactiveToast?.querySelector(".ihooman-proactive-toast-btn.secondary");t&&t.addEventListener("click",()=>{F(),Z(),k("proactive:clicked")});n&&n.addEventListener("click",()=>{F()});const i=p.surveyView?.querySelector(".ihooman-survey-submit"),a=p.surveyView?.querySelector(".ihooman-survey-skip");i&&i.addEventListener("click",U);a&&a.addEventListener("click",()=>L("chat"));!function(){const e=p.surveyView?.querySelector(".ihooman-survey-stars");if(!e)return;let t=0;e.innerHTML="";for(let n=1;n<=5;n++){const i=document.createElement("div");i.className="ihooman-survey-star",i.innerHTML=o.starEmpty,i.dataset.rating=String(n),i.addEventListener("click",()=>{t=n,C(e,n)}),i.addEventListener("mouseenter",()=>C(e,n)),i.addEventListener("mouseleave",()=>C(e,t)),e.appendChild(i)}}()}()}function C(e,t){e.querySelectorAll(".ihooman-survey-star").forEach((e,n)=>{const i=e;n<t?(i.innerHTML=o.star,i.classList.add("active")):(i.innerHTML=o.starEmpty,i.classList.remove("active"))})}function _(e,t="bot",a={}){const s={id:v("msg_"),content:e,sender:t,timestamp:new Date,metadata:a};if(i.messages.push(s),!p.messages)return s;const r=document.createElement("div");r.className=`ihooman-message ${t}`;const c="bot"===t&&!0===a?.escalation_offered;let d="";c&&(d=`\n <div class="ihooman-escalation-actions">\n <button class="ihooman-escalation-btn primary" data-action="live-agent">${o.agent}<span>Talk to Agent</span></button>\n <button class="ihooman-escalation-btn secondary" data-action="create-ticket">${o.ticket}<span>Create Ticket</span></button>\n </div>\n `);let l="";a?.quick_replies&&a.quick_replies.length>0&&(l=`<div class="ihooman-quick-replies">${a.quick_replies.map(e=>`<button class="ihooman-quick-reply" data-text="${x(e.text)}">${x(e.text)}</button>`).join("")}</div>`);let u="";var h,m;"bot"!==t||a?.is_system_message||(u=`\n <div class="ihooman-feedback-btns">\n <button class="ihooman-feedback-btn" data-feedback="up" title="Helpful">${o.thumbUp}</button>\n <button class="ihooman-feedback-btn" data-feedback="down" title="Not helpful">${o.thumbDown}</button>\n </div>\n `),r.innerHTML=`\n <div class="ihooman-message-content">${m=e,m?x(m).replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`(.*?)`/g,"<code>$1</code>").replace(/\[(.*?)\]\((.*?)\)/g,'<a href="$2" target="_blank" rel="noopener">$1</a>').replace(/\n/g,"<br>"):""}</div>\n ${d}\n ${l}\n ${u}\n ${n.showTimestamps?`<div class="ihooman-message-time">${h=s.timestamp,new Date(h).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}</div>`:""}\n `,c&&(r.querySelector('[data-action="live-agent"]')?.addEventListener("click",()=>z("live-agent")),r.querySelector('[data-action="create-ticket"]')?.addEventListener("click",()=>z("create-ticket"))),r.querySelectorAll(".ihooman-quick-reply").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.text;t&&(W(),_(t,"user"),O(),N(t))})}),r.querySelectorAll(".ihooman-feedback-btn").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.feedback;r.querySelectorAll(".ihooman-feedback-btn").forEach(e=>e.classList.remove("active")),e.classList.add("active"),async function(e,t){try{await fetch(`${n.serverUrl}/api/widget/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:n.widgetId,message_id:e,session_id:i.sessionId,feedback_type:t})})}catch(e){console.error("Error submitting feedback:",e)}}(s.id,"up"===t?"positive":"negative")})});const g=p.messages.querySelector(".ihooman-typing");return g&&g.remove(),p.messages.appendChild(r),p.messages.scrollTop=p.messages.scrollHeight,"bot"!==t||i.isOpen||(i.unreadCount++,p.badge&&(p.badge.textContent=String(i.unreadCount)),n.enableSounds&&function(){try{const e=new Audio("data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4Ljc2LjEwMAAAAAAAAAAAAAAA//tQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU4LjEzAAAAAAAAAAAAAAAAJAAAAAAAAAAAAYYNBrP/AAAAAAAAAAAAAAAAAAAAAP/7UMQAA8AAAaQAAAAgAAA0gAAABExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tQxBKDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=");e.volume=.3,e.play().catch(()=>{})}catch{}}()),k("message",s),s}function I(){console.debug("[IhoomanChat] Rendering preset questions:",l.length),p.presetQuestions&&0!==l.length?(p.presetQuestions.innerHTML=l.map(e=>`\n <button class="ihooman-preset-btn" data-question-id="${x(e.id)}" data-question-text="${x(e.text)}">\n ${e.icon||e.emoji?`<span class="icon">${x(e.icon||e.emoji||"")}</span>`:""}\n <span>${x(e.text)}</span>\n </button>\n `).join(""),p.presetQuestions.querySelectorAll(".ihooman-preset-btn").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.questionText;t&&function(e){W(),_(e,"user"),O(),N(e)}(t)})})):p.presetQuestions&&(p.presetQuestions.innerHTML="")}function z(e){document.querySelectorAll(".ihooman-escalation-btn").forEach(e=>e.disabled=!0),"live-agent"===e?async function(){if(!i.sessionId)return void _("Please send a message first to start a conversation.","bot",{is_system_message:!0});try{const e=await fetch(`${n.serverUrl}/api/widget/live-agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:n.widgetId,session_id:i.sessionId,visitor_id:i.visitorId})}),t=await e.json();s=!0,i.escalationStatus={active:!0,type:"live_agent",queuePosition:t.position_in_queue},t.position_in_queue&&t.position_in_queue>1?T("waiting",`⏳ Waiting for agent (Position: #${t.position_in_queue})`):T("waiting","⏳ Connecting to live support..."),M(),k("escalation:start",{type:"live_agent"})}catch(e){console.error("Error requesting live agent:",e),_("❌ Unable to connect to live support. Please try again.","bot",{is_system_message:!0})}}():"create-ticket"===e&&L("ticket")}function L(e){a=e,i.view=e,p.chatView&&p.chatView.classList.toggle("hidden","chat"!==e),p.ticketView&&p.ticketView.classList.toggle("show","ticket"===e),p.historyView&&p.historyView.classList.toggle("show","history"===e),p.surveyView&&p.surveyView.classList.toggle("show","survey"===e),"history"===e&&async function(){if(!p.historyList||!i.visitorId)return;p.historyList.innerHTML='<div class="ihooman-history-empty">Loading...</div>';try{const e=await fetch(`${n.serverUrl}/api/widget/conversations?widget_id=${n.widgetId}&visitor_id=${i.visitorId}&limit=20`);if(!e.ok)throw new Error("Failed to load history");const t=await e.json();if(!t.length)return void(p.historyList.innerHTML='<div class="ihooman-history-empty">No conversations yet</div>');p.historyList.innerHTML=t.map(e=>`\n <div class="ihooman-history-item ${e.session_id===i.sessionId?"active":""}" data-session-id="${e.session_id}">\n <div class="ihooman-history-preview">${x(e.preview||"New conversation")}</div>\n <div class="ihooman-history-meta">\n <span>${e.message_count} msgs</span>\n <span>${"pending"===e.status?"🟡 Pending":"closed"===e.status?"✓ Closed":""} ${function(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"now":t<36e5?Math.floor(t/6e4)+"m":t<864e5?Math.floor(t/36e5)+"h":Math.floor(t/864e5)+"d"}(e.updated_at)}</span>\n </div>\n </div>\n `).join(""),p.historyList.querySelectorAll(".ihooman-history-item").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.sessionId;t&&async function(e){i.sessionId=e,n.persistSession&&w("session_id",e);p.messages&&(p.messages.innerHTML="");s=!1,B(),T("hidden"),f=!0,h&&(h.close(),h=null);Y(),L("chat"),await async function(e){try{const t=await fetch(`${n.serverUrl}/api/widget/transcript/${e}?widget_id=${n.widgetId}`);if(!t.ok)throw new Error("Failed to load messages");const o=await t.json();p.messages&&(p.messages.innerHTML=""),o.messages&&o.messages.length>0?o.messages.forEach(e=>{const t="user"===e.sender_type?"user":"bot";_(e.content,t,e.extra_data||{})}):n.welcomeMessage&&_(n.welcomeMessage,"bot"),"pending"===o.status&&(s=!0,M(),T("waiting","⏳ Waiting for agent..."))}catch(e){console.error("Error loading conversation messages:",e),n.welcomeMessage&&_(n.welcomeMessage,"bot")}}(e)}(t)})})}catch(e){console.error("Error loading conversation history:",e),p.historyList.innerHTML='<div class="ihooman-history-empty">Failed to load history</div>'}}()}function q(){L("history"===a?"chat":"history")}function T(e,t){p.statusBar&&("hidden"!==e?(p.statusBar.classList.add("show"),p.statusBar.classList.remove("waiting","connected"),p.statusBar.classList.add(e),t&&(p.statusBar.textContent=t)):p.statusBar.classList.remove("show"))}async function E(){const e=p.ticketName?.value.trim(),t=p.ticketEmail?.value.trim(),o=p.ticketIssue?.value.trim();if(e&&t){p.ticketSubmitBtn&&(p.ticketSubmitBtn.disabled=!0,p.ticketSubmitBtn.textContent="Submitting...");try{const a=await fetch(`${n.serverUrl}/api/widget/submit-ticket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:n.widgetId,session_id:i.sessionId,user_name:e,user_email:t,issue:o||"No description provided"})}),s=await a.json();p.ticketName&&(p.ticketName.value=""),p.ticketEmail&&(p.ticketEmail.value=""),p.ticketIssue&&(p.ticketIssue.value=""),L("chat");_(`✅ Ticket submitted! We'll contact you at ${t}. Reference: #${s.ticket_id?s.ticket_id.slice(0,8):"submitted"}`,"bot",{is_system_message:!0})}catch(e){console.error("Error submitting ticket:",e),_("❌ Error submitting ticket. Please try again.","bot",{is_system_message:!0})}p.ticketSubmitBtn&&(p.ticketSubmitBtn.disabled=!1,p.ticketSubmitBtn.textContent="Submit Ticket")}else alert("Please fill in your name and email")}function M(){y||(y=setInterval(async()=>{if(i.sessionId&&s)try{const e=await fetch(`${n.serverUrl}/api/widget/escalation-status/${i.sessionId}?widget_id=${n.widgetId}`);if(e.ok){const t=await e.json();t.escalated&&("in_progress"===t.ticket_status?T("connected","🟢 Connected to live agent"):"open"===t.ticket_status?T("waiting",t.position_in_queue>1?`⏳ Waiting for agent (Position: #${t.position_in_queue})`:"⏳ Waiting for agent..."):"closed"!==t.ticket_status&&"resolved"!==t.ticket_status||(s=!1,B(),T("hidden"),_("This conversation has been closed. Thank you for contacting us!","bot",{is_system_message:!0}),k("escalation:end",{type:"live_agent"})))}}catch{}else B()},3e3))}function B(){y&&(clearInterval(y),y=null)}async function U(){const e=p.surveyView?.querySelector(".ihooman-survey-stars"),t=e?.querySelectorAll(".ihooman-survey-star.active"),o=t?.length||0,a=p.surveyView?.querySelector(".ihooman-survey-comment")?.value;if(0!==o)try{await fetch(`${n.serverUrl}/api/widget/survey-response`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:n.widgetId,survey_id:n.surveyConfig?.id,session_id:i.sessionId,rating:o,comment:a})}),w("survey_completed_"+i.sessionId,!0),k("survey:submitted",{rating:o,comment:a}),_(n.surveyConfig?.thankYouMessage||"Thank you for your feedback!","bot",{is_system_message:!0}),L("chat")}catch(e){console.error("Error submitting survey:",e)}else alert("Please select a rating")}function O(){if(!n.showTypingIndicator||!p.messages)return;if(p.messages.querySelector(".ihooman-typing"))return;const e=document.createElement("div");e.className="ihooman-typing",e.innerHTML='<div class="ihooman-typing-dots"><span class="ihooman-typing-dot"></span><span class="ihooman-typing-dot"></span><span class="ihooman-typing-dot"></span></div>',p.messages.appendChild(e),p.messages.scrollTop=p.messages.scrollHeight}function j(){const e=p.messages?.querySelector(".ihooman-typing");e&&e.remove()}function H(){const e=p.input?.value.trim();e&&(W(),p.input&&(p.input.value="",p.input.style.height="auto"),p.sendBtn&&(p.sendBtn.disabled=!0),_(e,"user"),O(),N(e))}function W(){p.presetQuestions&&p.presetQuestions.classList.add("hidden")}async function N(e){if(h&&h.readyState===WebSocket.OPEN)h.send(JSON.stringify({type:"message",content:e}));else try{const t=await fetch(`${n.serverUrl}/api/v1/public/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,session_id:i.sessionId,visitor_id:i.visitorId,widget_id:n.widgetId})}),o=await t.json();j(),o.session_id&&(i.sessionId=o.session_id,n.persistSession&&w("session_id",i.sessionId)),o.response&&_(o.response,"bot",{sources:o.sources,confidence:o.confidence,escalation_offered:o.escalation_offered,quick_replies:o.quick_replies})}catch(e){j(),_("Sorry, something went wrong. Please try again.","bot"),k("error",e)}}function D(e){const t=e.target,o=t.files?.[0];if(!o)return;_(`📎 Uploading: ${o.name}...`,"user"),O();const a=new FormData;a.append("file",o),a.append("session_id",i.sessionId||""),a.append("visitor_id",i.visitorId||""),a.append("widget_id",n.widgetId),fetch(`${n.serverUrl}/api/upload`,{method:"POST",body:a}).then(e=>e.json()).then(e=>{j(),e.message&&_(e.message,"bot")}).catch(()=>{j(),_("Failed to upload file.","bot")}),t.value=""}function P(){n.proactiveMessages&&0!==n.proactiveMessages.length?(console.debug("[IhoomanChat] Initializing proactive messages:",n.proactiveMessages.length),r=w("shown_proactive")||[],c=w("proactive_cooldowns")||{},d=setInterval(R,5e3),window.addEventListener("scroll",R),document.addEventListener("mouseout",e=>{e.clientY<=0&&function(){if(i.isOpen||!n.proactiveMessages)return;const e=n.proactiveMessages.filter(e=>"exit_intent"===e.trigger.type&&!r.includes(e.id));e.length>0&&Q(e[0])}()})):console.debug("[IhoomanChat] No proactive messages configured")}function R(){if(i.isOpen||!n.proactiveMessages)return;const e=Date.now();for(const t of n.proactiveMessages){if(r.includes(t.id))continue;const o=c[t.id];if(o&&e-o<60*t.cooldownMinutes*1e3)continue;if(t.startDate&&new Date(t.startDate)>new Date)continue;if(t.endDate&&new Date(t.endDate)<new Date)continue;let n=!1;switch(t.trigger.type){case"time":const o="number"==typeof t.trigger.value?t.trigger.value:parseInt(String(t.trigger.value),10);e-(w("page_load_time")||e)>=1e3*o&&(n=!0);break;case"scroll":const i="number"==typeof t.trigger.value?t.trigger.value:parseInt(String(t.trigger.value),10);V()>=i&&(n=!0);break;case"url_pattern":A(String(t.trigger.value))&&(n=!0)}if(n){Q(t);break}}}function Q(e){if(r.push(e.id),c[e.id]=Date.now(),w("shown_proactive",r),w("proactive_cooldowns",c),p.proactiveToast){const t=p.proactiveToast.querySelector(".ihooman-proactive-toast-content");t&&(t.textContent=e.message),p.proactiveToast.classList.add("show"),k("proactive:shown",e),e.autoOpen&&setTimeout(()=>{F(),Z()},3e3)}}function F(){p.proactiveToast&&p.proactiveToast.classList.remove("show")}function Y(e){if(!n.serverUrl&&!e)return;let t;if(n.widgetId){const e=n.serverUrl?.replace(/^http/,"ws"),o=new URLSearchParams({widget_id:n.widgetId});i.visitorId&&o.append("visitor_id",i.visitorId),i.sessionId&&o.append("session_id",i.sessionId),t=`${e}/public/ws?${o.toString()}`}else t=e||n.serverUrl?.replace(/^http/,"ws")+"/ws";try{J(),h=new WebSocket(t),h.onopen=()=>{i.isConnected=!0,i.connectionStatus="connected",g=0,K(!0),k("connected"),J(),b=setInterval(()=>{if(h&&h.readyState===WebSocket.OPEN)try{h.send(JSON.stringify({type:"ping"}))}catch{}},25e3)},h.onclose=t=>{if(i.isConnected=!1,i.connectionStatus="disconnected",K(!1),J(),k("disconnected"),f)f=!1;else if(i.isOpen)if(g<5){g++;const t=Math.min(1e3*Math.pow(2,g),3e4);setTimeout(()=>Y(e),t)}else G()},h.onerror=e=>{console.error("WebSocket error:",e)},h.onmessage=e=>{try{const t=JSON.parse(e.data);if("connected"===t.type)t.session_id&&(i.sessionId=t.session_id,n.persistSession&&w("session_id",i.sessionId)),t.visitor_id&&(i.visitorId=t.visitor_id,n.persistSession&&w("visitor_id",i.visitorId)),t.welcome_message&&0===i.messages.length&&_(t.welcome_message,"bot");else if("message"===t.type){j();const e="user"===t.sender?"user":"bot";_(t.content,e,{confidence:t.confidence,agent_name:t.agent_name,escalation_offered:t.escalation_offered,escalated:t.escalated,quick_replies:t.quick_replies})}else"typing"===t.type?t.is_typing?O():j():"pong"===t.type||"error"===t.type&&(console.error("WebSocket server error:",t.message),k("error",{message:t.message}))}catch{}}}catch{G()}}function J(){b&&(clearInterval(b),b=null)}function G(){m||(m=setInterval(async()=>{if(i.sessionId)try{const e=await fetch(`${n.serverUrl}/api/messages?session_id=${i.sessionId}&since=${Date.now()-5e3}&widget_id=${n.widgetId}`),t=await e.json();t.messages&&t.messages.forEach(e=>{i.messages.find(t=>t.id===e.id)||_(e.content,e.sender_type,e.metadata)})}catch{}},5e3))}function K(e){p.statusDot&&p.statusDot.classList.toggle("offline",!e),p.statusText&&(p.statusText.textContent=e?"Online":"Offline")}function Z(){i.isOpen||(i.isOpen=!0,i.unreadCount=0,p.badge&&(p.badge.textContent=""),p.toggle&&p.toggle.classList.add("open"),p.window&&p.window.classList.add("open"),F(),setTimeout(()=>p.input?.focus(),300),k("open"))}function X(){if(i.isOpen){if(i.isOpen=!1,p.toggle&&p.toggle.classList.remove("open"),p.window&&p.window.classList.remove("open"),n.surveyConfig&&i.messages.length>=4){i.sessionId&&w("survey_completed_"+i.sessionId)||setTimeout(()=>{i.isOpen||(n.surveyConfig&&(i.sessionId&&w("survey_completed_"+i.sessionId)||i.messages.length<4||(L("survey"),k("survey:shown",n.surveyConfig))),Z())},500)}k("close")}}function ee(){i.isOpen?X():Z()}function te(){i.sessionId=null,i.visitorId=null,i.messages=[],s=!1,w("session_id",null),i.visitorId=v("v_"),w("visitor_id",i.visitorId),p.messages&&(p.messages.innerHTML=""),T("hidden"),B(),g=0,h&&(f=!0,h.close(),h=null),Y(),n.welcomeMessage&&_(n.welcomeMessage,"bot"),p.presetQuestions&&p.presetQuestions.classList.remove("hidden"),I(),k("newConversation")}const oe={backgroundColor:"#00aeff",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:8,paddingVertical:8,paddingHorizontal:16,fontSize:13,fontWeight:"medium"},ne={backgroundColor:"transparent",textColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:1,borderRadius:8,paddingVertical:8,paddingHorizontal:16,fontSize:13,fontWeight:"medium"},ie={backgroundColor:"rgba(0, 174, 255, 0.1)",textColor:"#00aeff",borderColor:"rgba(0, 174, 255, 0.2)",borderWidth:1,borderRadius:20,paddingVertical:6,paddingHorizontal:12,fontSize:12,fontWeight:"medium"},ae={backgroundColor:"#f3f4f6",textColor:"#374151",borderColor:"#e5e7eb",borderWidth:1,borderRadius:16,paddingVertical:5,paddingHorizontal:10,fontSize:11,fontWeight:"medium"},se={backgroundColor:"transparent",textColor:"#9ca3af",borderColor:"#e5e7eb",borderWidth:1,borderRadius:6,paddingVertical:4,paddingHorizontal:8,fontSize:12,fontWeight:"medium"},re={backgroundColor:"rgba(255, 255, 255, 0.1)",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:6,paddingVertical:6,paddingHorizontal:6,fontSize:14,fontWeight:"medium"},ce={backgroundColor:"#00aeff",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:8,paddingVertical:8,paddingHorizontal:14,fontSize:12,fontWeight:"medium"},de={backgroundColor:"#00aeff",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:6,paddingVertical:6,paddingHorizontal:12,fontSize:12,fontWeight:"medium"},le={backgroundColor:"#00aeff",textColor:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:30,paddingVertical:0,paddingHorizontal:0,fontSize:14,fontWeight:"medium"},pe={backgroundColor:"transparent",textColor:"#6b7280",borderColor:"transparent",borderWidth:0,borderRadius:8,paddingVertical:6,paddingHorizontal:6,fontSize:14,fontWeight:"medium"};function ue(e){const t="ihooman-button-styling",o=$||document.head;let n=o.querySelector(`#${t}`);n||(n=document.createElement("style"),n.id=t,o.appendChild(n));const i={primary:{...oe,...e?.primary||{}},secondary:{...ne,...e?.secondary||{}},presetQuestions:{...ie,...e?.presetQuestions||{}},quickReplies:{...ae,...e?.quickReplies||{}},feedback:{...se,...e?.feedback||{}},headerActions:{...re,...e?.headerActions||{}},escalation:{...ce,...e?.escalation||{}},cardActions:{...de,...e?.cardActions||{}},toggleButton:{...le,...e?.toggleButton||{}},attachButton:{...pe,...e?.attachButton||{}}},a=(e,t)=>{const o=t.backgroundColor,n=t.textColor,i=t.borderColor;return`\n ${e} {\n background: ${o};\n color: ${n};\n border: ${t.borderWidth}px solid ${i};\n border-radius: ${t.borderRadius}px;\n padding: ${t.paddingVertical}px ${t.paddingHorizontal}px;\n margin: 0;\n font-family: inherit;\n font-size: ${t.fontSize}px;\n font-weight: ${function(e){switch(e){case"normal":return 400;case"medium":default:return 500;case"semibold":return 600;case"bold":return 700}}(t.fontWeight)};\n min-width: unset;\n min-height: unset;\n width: auto;\n height: auto;\n max-width: none;\n max-height: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n line-height: 1.4;\n text-transform: none;\n letter-spacing: normal;\n box-shadow: none;\n text-decoration: none;\n white-space: nowrap;\n box-sizing: border-box;\n cursor: pointer;\n transition: all 0.2s ease;\n }\n `};let s="";s+=a(".ihooman-input-btn.send",i.primary),s+=a(".ihooman-proactive-toast-btn.primary",i.primary),s+=a(".ihooman-survey-submit",i.primary),s+=a(".ihooman-ticket-submit",i.primary),s+=a(".ihooman-history-new",i.primary),s+=a(".ihooman-proactive-toast-btn.secondary",i.secondary),s+=a(".ihooman-survey-skip",i.secondary),s+=a(".ihooman-ticket-back",i.secondary),s+=a(".ihooman-preset-btn",i.presetQuestions),s+=a(".ihooman-quick-reply",i.quickReplies),s+=a(".ihooman-feedback-btn",i.feedback),s+=a(".ihooman-header-btn",i.headerActions),s+=a(".ihooman-escalation-btn",i.escalation),s+=a(".ihooman-escalation-btn.primary",i.escalation),s+=a(".ihooman-escalation-btn.secondary",i.secondary),s+=a(".ihooman-carousel-card-btn",i.cardActions);const r=i.toggleButton,c=r.backgroundColor,d=r.textColor,l=r.borderColor;s+=`\n .ihooman-toggle {\n background: linear-gradient(135deg, ${c}, ${c}) !important;\n color: ${d};\n border: ${r.borderWidth}px solid ${l};\n border-radius: ${r.borderRadius}px;\n }\n `,s+=a(".ihooman-input-btn.attach",i.attachButton),console.debug("[IhoomanChat] Applied button styling CSS:",s.length,"chars"),n.textContent=s}async function he(o){if(!o.widgetId)return console.error("IhoomanChat: widgetId is required"),null;n={...t,...o},i.visitorId=w("visitor_id")||v("v_"),w("visitor_id",i.visitorId),n.persistSession&&(i.sessionId=w("session_id")),w("page_load_time")||w("page_load_time",Date.now());const a=n.serverUrl||e,s=await async function(e,t){try{const o=await fetch(`${t}/api/widget/config?widget_id=${encodeURIComponent(e)}`);return o.ok?await o.json():{success:!1,error:(await o.json().catch(()=>({}))).error||`HTTP ${o.status}`}}catch(e){return{success:!1,error:"Unable to connect. Please check your internet connection."}}}(n.widgetId,a);let r;var c;return s.success&&s.config?(c=s.config,n.title=c.title||n.title,n.subtitle=c.subtitle||n.subtitle,n.welcomeMessage=c.welcomeMessage||n.welcomeMessage,n.placeholder=c.placeholder||n.placeholder,n.position=c.position||n.position,c.theme&&(n.primaryColor=c.theme.primaryColor||n.primaryColor,n.gradientFrom=c.theme.gradientFrom||n.gradientFrom,n.gradientTo=c.theme.gradientTo||n.gradientTo,n.fontFamily=c.theme.fontFamily||n.fontFamily,c.theme.borderRadius&&(n.borderRadius=parseInt(c.theme.borderRadius,10)||n.borderRadius)),c.behavior&&(n.startOpen=c.behavior.startOpen??n.startOpen,n.showTypingIndicator=c.behavior.showTypingIndicator??n.showTypingIndicator,n.showTimestamps=c.behavior.showTimestamps??n.showTimestamps,n.enableSounds=c.behavior.enableSounds??n.enableSounds,n.enableFileUpload=c.behavior.enableFileUpload??n.enableFileUpload,n.persistSession=c.behavior.persistSession??n.persistSession),c.branding&&(n.avatarUrl=c.branding.avatarUrl||n.avatarUrl,n.logoUrl=c.branding.logoUrl||n.logoUrl,n.poweredBy=c.branding.poweredBy??n.poweredBy,n.customCss=c.branding.customCss||n.customCss),c.size&&(n.width=c.size.width||n.width,n.height=c.size.height||n.height,n.buttonSize=c.size.buttonSize||n.buttonSize),c.presetQuestions&&Array.isArray(c.presetQuestions)&&(console.debug("[IhoomanChat] Server config presetQuestions:",c.presetQuestions.length),l=c.presetQuestions.map(e=>({id:e.id,text:e.text,icon:e.icon,emoji:e.icon})),n.presetQuestions=l),c.proactiveMessages&&Array.isArray(c.proactiveMessages)&&(console.debug("[IhoomanChat] Server config proactiveMessages:",c.proactiveMessages.length),n.proactiveMessages=c.proactiveMessages.filter(e=>!1!==e.isActive).map(e=>({id:e.id,message:e.message,trigger:{type:e.trigger.type,value:"time"===e.trigger.type||"scroll"===e.trigger.type?parseInt(e.trigger.value,10)||30:e.trigger.value},autoOpen:e.autoOpen||!1,cooldownMinutes:e.cooldownMinutes||60}))),c.surveyConfig&&!1!==c.surveyConfig.isActive&&(console.debug("[IhoomanChat] Server config surveyConfig:",c.surveyConfig.id),n.surveyConfig={id:c.surveyConfig.id,type:c.surveyConfig.type,question:c.surveyConfig.question,followUpQuestion:c.surveyConfig.followUpQuestion,thankYouMessage:c.surveyConfig.thankYouMessage}),c.buttonStyling&&(console.debug("[IhoomanChat] Server config buttonStyling:",Object.keys(c.buttonStyling)),n.buttonStyling=c.buttonStyling,ue(c.buttonStyling)),r=s.chatEndpoint):s.error&&(console.warn("IhoomanChat: Could not fetch server config:",s.error),"Widget not authorized for this domain"===s.error&&console.error("IhoomanChat: Widget configuration error. Please contact support.")),S(),ue(n.buttonStyling),I(),i.messages.forEach(e=>_(e.content,"user"===e.sender?"user":"bot",e.metadata)),0===i.messages.length&&n.welcomeMessage&&_(n.welcomeMessage,"bot"),Y(r),P(),n.startOpen&&setTimeout(Z,500),k("ready"),me}const me={init:he,open:Z,close:X,toggle:ee,isOpen:function(){return i.isOpen},destroy:function(){J(),B(),d&&(clearInterval(d),d=null),window.removeEventListener("scroll",R),f=!0,h&&(h.close(),h=null),m&&(clearInterval(m),m=null),p.widget&&p.widget.remove();const e=document.getElementById("ihooman-widget-styles");e&&e.remove(),i={isOpen:!1,isConnected:!1,messages:[],sessionId:null,visitorId:null,unreadCount:0},p={},g=0,f=!1},sendMessage:function(e){e.trim()&&(p.input&&(p.input.value=e),H())},setUser:function(e){i.userInfo=e,e.name&&w("user_name",e.name),e.email&&w("user_email",e.email),e.metadata&&w("user_metadata",e.metadata)},clearUser:function(){i.userInfo=null,w("user_name",null),w("user_email",null),w("user_metadata",null)},clearHistory:function(){te()},on:function(e,t){u[e]||(u[e]=[]),u[e].push(t)},off:function(e,t){u[e]&&(u[e]=u[e].filter(e=>e!==t))},getState:function(){return{...i}},getConfig:function(){return{...n}},showSurvey:function(){n.surveyConfig?(L("survey"),k("survey:shown",n.surveyConfig)):console.warn("[IhoomanChat] No survey configured")},resetProactiveMessages:function(){r=[],c={},w("shown_proactive",null),w("proactive_cooldowns",null),console.debug("[IhoomanChat] Proactive message history reset")},version:"3.0.11"},ge=me;function fe(){return{...me}}!function(){if("undefined"==typeof document)return;let e=document.currentScript;if(!e){const t=document.getElementsByTagName("script");for(let o=0;o<t.length;o++)if(t[o].src&&t[o].src.includes("ihooman")){e=t[o];break}}if(!e)return;const t=e.getAttribute("data-widget-id");if(t){const o={widgetId:t},n=e.getAttribute("data-server-url");n&&(o.serverUrl=n);const i=e.getAttribute("data-theme");"light"!==i&&"dark"!==i||(o.theme=i);const a=e.getAttribute("data-position");a&&(o.position=a);"true"===e.getAttribute("data-start-open")&&(o.startOpen=!0),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>he(o)):he(o)}}(),"undefined"!=typeof window&&(window.IhoomanChat=ge);export{ge as IhoomanChat,fe as createWidgetInstance,ge as default};
|
|
2
2
|
//# sourceMappingURL=index.esm.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.min.js","sources":["../src/widget.ts"],"sourcesContent":[null],"names":["DEFAULT_SERVER_URL","defaultConfig","serverUrl","theme","position","title","subtitle","welcomeMessage","placeholder","primaryColor","gradientFrom","gradientTo","showTimestamps","showTypingIndicator","enableSounds","enableFileUpload","startOpen","persistSession","zIndex","width","height","buttonSize","borderRadius","fontFamily","avatarUrl","poweredBy","presetQuestions","proactiveMessages","surveyConfig","locale","allowLocalhost","icons","chat","close","send","attach","minimize","bot","agent","ticket","history","plus","star","starEmpty","thumbUp","thumbDown","config","widgetId","state","isOpen","isConnected","messages","pendingMessages","sessionId","visitorId","unreadCount","view","connectionStatus","typingIndicator","soundMuted","escalationStatus","userInfo","currentView","isLiveAgentMode","shownProactiveIds","proactiveCooldowns","proactiveCheckInterval","elements","eventListeners","ws","pollInterval","reconnectAttempts","intentionalDisconnect","heartbeatInterval","liveAgentPollInterval","generateId","prefix","Math","random","toString","slice","Date","now","escapeHtml","text","div","document","createElement","textContent","innerHTML","storage","key","value","fullKey","undefined","item","localStorage","getItem","JSON","parse","removeItem","setItem","stringify","emit","event","data","forEach","fn","e","console","error","callbackName","charAt","toUpperCase","callback","getCurrentScrollDepth","scrollTop","window","scrollY","documentElement","scrollHeight","innerHeight","round","matchUrlPattern","pattern","RegExp","replace","test","location","href","includes","createWidget","styleEl","id","isDark","bgColor","textColor","mutedColor","borderColor","inputBg","messageBgUser","messageBgBot","positionRight","positionBottom","generateStyles","head","appendChild","widget","className","question","body","toggle","querySelector","badge","chatView","ticketView","historyView","surveyView","historyList","input","sendBtn","attachBtn","fileInput","statusDot","statusText","statusBar","ticketName","ticketEmail","ticketIssue","ticketSubmitBtn","ticketBackBtn","proactiveToast","addEventListener","handleSendClick","disabled","trim","style","min","shiftKey","preventDefault","click","handleFileSelect","startNewConversation","toggleHistoryView","handleSubmitTicket","showView","historyNewBtn","proactivePrimaryBtn","proactiveSecondaryBtn","hideProactiveToast","open","surveySubmitBtn","surveySkipBtn","handleSurveySubmit","starsContainer","selectedRating","i","dataset","rating","String","updateStars","initializeSurveyStars","setupEventListeners","container","querySelectorAll","index","starEl","classList","add","remove","addMessage","content","sender","metadata","message","timestamp","push","el","showEscalationButtons","escalation_offered","escalationButtonsHtml","quickRepliesHtml","quick_replies","length","map","qr","join","feedbackHtml","date","is_system_message","toLocaleTimeString","hour","minute","handleEscalationAction","btn","hidePresetQuestions","showTyping","sendMessageToServer","feedback","b","async","messageId","feedbackType","fetch","method","headers","widget_id","message_id","session_id","feedback_type","submitFeedback","typing","audio","Audio","volume","play","catch","playSound","renderPresetQuestions","debug","q","icon","emoji","questionText","handlePresetQuestionClick","action","response","visitor_id","json","active","type","queuePosition","position_in_queue","updateStatusBar","startLiveAgentPolling","handleRequestLiveAgent","ok","Error","conversations","conv","preview","message_count","status","diff","getTime","floor","timeAgo","updated_at","stopLiveAgentPolling","connectWebSocket","msg","sender_type","extra_data","loadConversationMessages","switchToConversation","loadConversationHistory","name","email","issue","user_name","user_email","ticket_id","alert","setInterval","escalated","ticket_status","clearInterval","activeStars","comment","survey_id","thankYouMessage","hideTyping","readyState","WebSocket","OPEN","sources","confidence","target","file","files","formData","FormData","append","then","r","initializeProactiveMessages","checkProactiveTriggers","clientY","exitIntentMessages","filter","pm","trigger","showProactiveMessage","checkExitIntentTrigger","lastShown","cooldownMinutes","startDate","endDate","triggered","timeValue","parseInt","scrollValue","autoOpen","setTimeout","chatEndpoint","wsUrl","baseWsUrl","params","URLSearchParams","stopHeartbeat","onopen","updateStatus","onclose","_event","delay","pow","startPolling","onerror","onmessage","welcome_message","agent_name","is_typing","find","m","online","focus","DEFAULT_BUTTON_STYLES","backgroundColor","borderWidth","paddingVertical","paddingHorizontal","fontSize","fontWeight","applyButtonStyling","buttonStyling","styleId","getElementById","mergedStyles","primary","secondary","quickReplies","headerActions","escalation","cardActions","generateButtonCSS","selector","bg","color","weight","getFontWeightValue","css","init","userConfig","configResponse","encodeURIComponent","success","fetchWidgetConfig","serverConfig","behavior","branding","logoUrl","customCss","size","Array","isArray","isActive","followUpQuestion","Object","keys","warn","publicAPI","destroy","removeEventListener","styles","sendMessage","setUser","user","clearUser","clearHistory","on","off","getState","getConfig","showSurvey","resetProactiveMessages","version","IhoomanChat","createWidgetInstance","script","currentScript","scripts","getElementsByTagName","src","getAttribute","autoConfig"],"mappings":"AAmBA,MAEMA,EAAqB,yBAErBC,EAAuC,CAC3CC,UAAWF,EACXG,MAAO,QACPC,SAAU,eACVC,MAAO,eACPC,SAAU,oCACVC,eAAgB,0CAChBC,YAAa,oBACbC,aAAc,UACdC,aAAc,UACdC,WAAY,UACZC,gBAAgB,EAChBC,qBAAqB,EACrBC,cAAc,EACdC,kBAAkB,EAClBC,WAAW,EACXC,gBAAgB,EAChBC,OAAQ,KACRC,MAAO,IACPC,OAAQ,IACRC,WAAY,GACZC,aAAc,GACdC,WAAY,oEACZC,UAAW,GACXC,WAAW,EACXC,gBAAiB,GACjBC,kBAAmB,GACnBC,aAAc,KACdC,OAAQ,KACRC,gBAAgB,GAGZC,EAAQ,CACZC,KAAM,oKACNC,MAAO,2KACPC,KAAM,uLACNC,OAAQ,wNACRC,SAAU,iIACVC,IAAK,4MACLC,MAAO,sLACPC,OAAQ,yNACRC,QAAS,4KACTC,KAAM,6KACNC,KAAM,oKACNC,UAAW,mMACXC,QAAS,0NACTC,UAAW,6OAKb,IAAIC,EAAuB,CAAEC,SAAU,MAAO9C,GAC1C+C,EAAqB,CACvBC,QAAQ,EACRC,aAAa,EACbC,SAAU,GACVC,gBAAiB,GACjBC,UAAW,KACXC,UAAW,KACXC,YAAa,EACbC,KAAM,OACNC,iBAAkB,eAClBC,iBAAiB,EACjBC,YAAY,EACZC,iBAAkB,KAClBC,SAAU,MAGRC,EAA0B,OAC1BC,GAAkB,EAClBC,EAA8B,GAC9BC,EAA6C,CAAA,EAC7CC,EAAgE,KAChExC,EAAoC,GA+BpCyC,EAA2B,CAAA,EAC/B,MAAMC,EAAkD,CAAA,EAC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MmY,EAA2D,CAAEnY,YAE7D7C,EAAY0a,EAAOK,aAAa,mBAClC/a,IAAWgb,EAAWhb,UAAYA,GAEtC,MAAMC,EAAQya,EAAOK,aAAa,cACpB,UAAV9a,GAA+B,SAAVA,IAAkB+a,EAAW/a,MAAQA,GAE9D,MAAMC,EAAWwa,EAAOK,aAAa,iBACjC7a,IAAU8a,EAAW9a,SAAWA,GAGlB,SADAwa,EAAOK,aAAa,qBACZC,EAAWla,WAAY,GAErB,YAAxBsE,SAASkO,WACXlO,SAASsF,iBAAiB,mBAAoB,IAAM2N,GAAK2C,IAEzD3C,GAAK2C,EAET,CACD,CAvCD,GAyCsB,oBAAX7T,SACRA,OAA8CqT,YAAcA"}
|
|
1
|
+
{"version":3,"file":"index.esm.min.js","sources":["../src/widget.ts"],"sourcesContent":[null],"names":["DEFAULT_SERVER_URL","defaultConfig","serverUrl","theme","position","title","subtitle","welcomeMessage","placeholder","primaryColor","gradientFrom","gradientTo","showTimestamps","showTypingIndicator","enableSounds","enableFileUpload","startOpen","persistSession","zIndex","width","height","buttonSize","borderRadius","fontFamily","avatarUrl","poweredBy","presetQuestions","proactiveMessages","surveyConfig","locale","allowLocalhost","icons","chat","close","send","attach","minimize","bot","agent","ticket","history","plus","star","starEmpty","thumbUp","thumbDown","config","widgetId","state","isOpen","isConnected","messages","pendingMessages","sessionId","visitorId","unreadCount","view","connectionStatus","typingIndicator","soundMuted","escalationStatus","userInfo","currentView","isLiveAgentMode","shownProactiveIds","proactiveCooldowns","proactiveCheckInterval","elements","eventListeners","ws","pollInterval","reconnectAttempts","intentionalDisconnect","heartbeatInterval","liveAgentPollInterval","generateId","prefix","Math","random","toString","slice","Date","now","escapeHtml","text","div","document","createElement","textContent","innerHTML","storage","key","value","fullKey","undefined","item","localStorage","getItem","JSON","parse","removeItem","setItem","stringify","emit","event","data","forEach","fn","e","console","error","callbackName","charAt","toUpperCase","callback","getCurrentScrollDepth","scrollTop","window","scrollY","documentElement","scrollHeight","innerHeight","round","matchUrlPattern","pattern","RegExp","replace","test","location","href","includes","shadowRoot","createWidget","host","id","style","cssText","body","appendChild","attachShadow","mode","styleEl","isDark","bgColor","textColor","mutedColor","borderColor","inputBg","messageBgUser","messageBgBot","positionRight","positionBottom","generateStyles","widget","className","question","toggle","querySelector","badge","chatView","ticketView","historyView","surveyView","historyList","input","sendBtn","attachBtn","fileInput","statusDot","statusText","statusBar","ticketName","ticketEmail","ticketIssue","ticketSubmitBtn","ticketBackBtn","proactiveToast","addEventListener","handleSendClick","disabled","trim","min","shiftKey","preventDefault","click","handleFileSelect","startNewConversation","toggleHistoryView","handleSubmitTicket","showView","historyNewBtn","proactivePrimaryBtn","proactiveSecondaryBtn","hideProactiveToast","open","surveySubmitBtn","surveySkipBtn","handleSurveySubmit","starsContainer","selectedRating","i","dataset","rating","String","updateStars","initializeSurveyStars","setupEventListeners","container","querySelectorAll","index","starEl","classList","add","remove","addMessage","content","sender","metadata","message","timestamp","push","el","showEscalationButtons","escalation_offered","escalationButtonsHtml","quickRepliesHtml","quick_replies","length","map","qr","join","feedbackHtml","date","is_system_message","toLocaleTimeString","hour","minute","handleEscalationAction","btn","hidePresetQuestions","showTyping","sendMessageToServer","feedback","b","async","messageId","feedbackType","fetch","method","headers","widget_id","message_id","session_id","feedback_type","submitFeedback","typing","audio","Audio","volume","play","catch","playSound","renderPresetQuestions","debug","q","icon","emoji","questionText","handlePresetQuestionClick","action","response","visitor_id","json","active","type","queuePosition","position_in_queue","updateStatusBar","startLiveAgentPolling","handleRequestLiveAgent","ok","Error","conversations","conv","preview","message_count","status","diff","getTime","floor","timeAgo","updated_at","stopLiveAgentPolling","connectWebSocket","msg","sender_type","extra_data","loadConversationMessages","switchToConversation","loadConversationHistory","name","email","issue","user_name","user_email","ticket_id","alert","setInterval","escalated","ticket_status","clearInterval","activeStars","comment","survey_id","thankYouMessage","hideTyping","readyState","WebSocket","OPEN","sources","confidence","target","file","files","formData","FormData","append","then","r","initializeProactiveMessages","checkProactiveTriggers","clientY","exitIntentMessages","filter","pm","trigger","showProactiveMessage","checkExitIntentTrigger","lastShown","cooldownMinutes","startDate","endDate","triggered","timeValue","parseInt","scrollValue","autoOpen","setTimeout","chatEndpoint","wsUrl","baseWsUrl","params","URLSearchParams","stopHeartbeat","onopen","updateStatus","onclose","_event","delay","pow","startPolling","onerror","onmessage","welcome_message","agent_name","is_typing","find","m","online","focus","DEFAULT_BUTTON_STYLES","backgroundColor","borderWidth","paddingVertical","paddingHorizontal","fontSize","fontWeight","applyButtonStyling","buttonStyling","styleId","styleContainer","head","mergedStyles","primary","secondary","quickReplies","headerActions","escalation","cardActions","toggleButton","attachButton","generateButtonCSS","selector","bg","color","weight","getFontWeightValue","css","toggleStyle","toggleBg","toggleColor","toggleBorderColor","init","userConfig","configResponse","encodeURIComponent","success","fetchWidgetConfig","serverConfig","behavior","branding","logoUrl","customCss","size","Array","isArray","isActive","followUpQuestion","Object","keys","warn","publicAPI","destroy","removeEventListener","styles","getElementById","sendMessage","setUser","user","clearUser","clearHistory","on","off","getState","getConfig","showSurvey","resetProactiveMessages","version","IhoomanChat","createWidgetInstance","script","currentScript","scripts","getElementsByTagName","src","getAttribute","autoConfig"],"mappings":"AAmBA,MAEMA,EAAqB,yBAErBC,EAAuC,CAC3CC,UAAWF,EACXG,MAAO,QACPC,SAAU,eACVC,MAAO,eACPC,SAAU,oCACVC,eAAgB,0CAChBC,YAAa,oBACbC,aAAc,UACdC,aAAc,UACdC,WAAY,UACZC,gBAAgB,EAChBC,qBAAqB,EACrBC,cAAc,EACdC,kBAAkB,EAClBC,WAAW,EACXC,gBAAgB,EAChBC,OAAQ,KACRC,MAAO,IACPC,OAAQ,IACRC,WAAY,GACZC,aAAc,GACdC,WAAY,oEACZC,UAAW,GACXC,WAAW,EACXC,gBAAiB,GACjBC,kBAAmB,GACnBC,aAAc,KACdC,OAAQ,KACRC,gBAAgB,GAGZC,EAAQ,CACZC,KAAM,oKACNC,MAAO,2KACPC,KAAM,uLACNC,OAAQ,wN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