@flowengage/react-chatbot 1.9.7 → 1.9.8

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.
@@ -629,4 +629,4 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
629
629
  @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }
630
630
  @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }
631
631
  `})]})}var zO=`:host{all:initial;box-sizing:border-box!important;color:#111827!important;-webkit-font-smoothing:antialiased!important;z-index:2147483647!important;background:0 0!important;border:none!important;margin:0!important;padding:0!important;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif!important;font-size:16px!important;line-height:1.5!important;display:block!important;position:relative!important}:host *,:host :before,:host :after{box-sizing:border-box}.flowengage-widget-root{-moz-osx-font-smoothing:grayscale;text-rendering:optimizelegibility;color:#111827!important;-webkit-font-smoothing:antialiased!important;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif!important;font-size:16px!important;line-height:1.5!important}.flowengage-widget-root *,.flowengage-widget-root :before,.flowengage-widget-root :after{font-family:inherit!important}.flowengage-widget-root input,.flowengage-widget-root textarea,.flowengage-widget-root button,.flowengage-widget-root select,.flowengage-widget-root optgroup,.flowengage-widget-root option{font-family:inherit!important;font-size:inherit!important;line-height:inherit!important}.flowengage-shell,.flowengage-shell *{font-family:inherit!important}.flowengage-chat-panel{border:none;border-radius:0;outline:none;flex-direction:column;width:100%;height:100%;display:flex;position:relative;overflow:hidden;box-shadow:0 20px 50px #00000026}.flowengage-chat-text-input{margin:0!important}.flowengage-chat-text-input:focus{box-shadow:none!important;border:none!important;outline:none!important}@media (width>=768px){.flowengage-chat-panel{border-radius:24px;width:min(423px,100vw - 40px);height:min(700px,100vh - 120px)}}.flowengage-shell[data-open=true]{inset:0}@media (width>=768px){.flowengage-shell[data-open=true]{inset:auto 1.5rem 1.5rem auto}}.flowengage-logo-fallback{background:conic-gradient(from 180deg, var(--flowengage-primary) 0%, var(--flowengage-accent) 45%, var(--flowengage-primary) 100%)}.fe-bot-message p{margin:0 0 .5em}.fe-bot-message p:last-child{margin-bottom:0}.fe-bot-message ul,.fe-bot-message ol{margin:.4em 0 .4em 1.2em;padding:0}.fe-bot-message li{margin-bottom:.25em}.fe-bot-message strong{font-weight:600}.fe-bot-message a{color:var(--flowengage-primary);text-decoration:underline}.fe-bot-message a:hover{opacity:.8}.incoming-call-overlay{z-index:1000;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:#1a1a2ef2;justify-content:center;align-items:center;transition:all .3s ease-in-out;display:flex;position:absolute;left:0;right:0}.incoming-call-overlay.bottom-mode{border-top:2px solid #ffffff1a;min-height:120px;animation:.4s cubic-bezier(.16,1,.3,1) slideUpBanner;top:auto;bottom:0;box-shadow:0 -10px 30px #00000080}.incoming-call-overlay.header-mode{border-bottom:2px solid #ffffff1a;min-height:80px;animation:.4s cubic-bezier(.16,1,.3,1) slideDownBanner;top:0;bottom:auto;box-shadow:0 10px 30px #00000080}.incoming-call-container{justify-content:space-between;align-items:center;gap:14px;width:100%;padding:14px 16px;display:flex}.incoming-call-container.connected-layout{flex-direction:column;justify-content:center;align-items:stretch;gap:14px}.call-connected-top{justify-content:space-between;align-items:center;gap:16px;width:100%;display:flex}.call-connected-identity{flex:1;align-items:center;gap:14px;min-width:0;display:flex}.call-icon-wrapper{color:#fff;z-index:1;border-radius:9999px;flex-shrink:0;justify-content:center;align-items:center;width:54px;height:54px;margin-right:4px;display:flex;position:relative}.call-icon-wrapper.incoming{background:linear-gradient(135deg,#4caf50,#45a049);animation:1s ease-in-out infinite bounce}.call-icon-wrapper.connecting{background:linear-gradient(135deg,#2196f3,#1976d2)}.call-icon-wrapper.connected{background:linear-gradient(135deg,#4caf50,#45a049)}.call-pulse-animation{z-index:-1;background:#4caf504d;border-radius:50%;width:120px;height:120px;animation:1.5s ease-out infinite pulse;position:absolute}.call-connecting-animation{z-index:-1;border:3px solid #0000;border-top-color:#2196f3;border-radius:50%;width:100px;height:100px;animation:1s linear infinite spin;position:absolute}.call-info-group{flex-direction:column;flex:1;min-width:0;margin-right:8px;display:flex}.call-title{color:#fff;white-space:normal;text-overflow:clip;margin:0;font-size:16px;font-weight:700;line-height:1.2;overflow:visible}.call-subtitle{color:#ffffffb3;white-space:normal;text-overflow:clip;margin:4px 0 0;font-size:12px;line-height:1.35;overflow:visible}.call-timer{text-align:center;color:#fff;flex-shrink:0;min-width:54px;font-size:13px;font-weight:700}.call-actions{flex-shrink:0;align-items:center;gap:8px;display:flex}.call-actions.connected{justify-content:center;width:100%}.flowengage-call-btn{cursor:pointer;color:#fff;border:none;border-radius:8px;justify-content:center;align-items:center;gap:6px;min-width:92px;padding:8px 12px;font-size:12px;font-weight:600;line-height:1;transition:transform .2s,box-shadow .2s,background .2s;display:flex}.flowengage-call-btn svg{flex-shrink:0;display:block}.flowengage-call-btn span{justify-content:center;align-items:center;line-height:1;display:flex}.flowengage-call-btn.icon-only{border-radius:9999px;width:46px;min-width:46px;height:46px;padding:0}.flowengage-call-btn-accept{background:linear-gradient(135deg,#4caf50,#45a049);box-shadow:0 8px 24px #4caf5066}.flowengage-call-btn-reject,.flowengage-call-btn-end{background:linear-gradient(135deg,#f44336,#d32f2f);box-shadow:0 4px 12px #f4433666}.flowengage-call-btn-mute{background:#ffffff1a;border:2px solid #fff3}.flowengage-call-btn-mute.active{background:#f443364d;border-color:#f44336}.flowengage-call-btn:hover:not(:disabled){transform:scale(1.05)}.incoming-call-overlay.header-mode .flowengage-call-btn{border-radius:9999px!important;width:36px!important;min-width:36px!important;height:36px!important;padding:0!important}.incoming-call-overlay.header-mode .flowengage-call-btn span{display:none!important}.incoming-call-overlay.header-mode .call-icon-wrapper{width:40px;height:40px;margin-right:0}.incoming-call-overlay.header-mode .call-info-group{min-width:0}.incoming-call-overlay.header-mode .call-title,.incoming-call-overlay.header-mode .call-subtitle{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=640px){.incoming-call-container{align-items:flex-start;gap:10px;padding:12px 14px}.incoming-call-container.connected-layout{align-items:stretch}.call-connected-top{flex-direction:column;align-items:flex-start;gap:10px}.call-connected-identity{width:100%}.call-info-group{margin-right:0}.call-actions{flex-wrap:wrap;align-self:stretch;gap:6px}.call-actions.connected{justify-content:stretch}.call-actions.connected .flowengage-call-btn{flex:1}.flowengage-call-btn{min-width:78px;padding:8px 10px}}@keyframes slideUpBanner{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes slideDownBanner{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-10px)}}@keyframes pulse{0%{opacity:1;transform:scale(.8)}to{opacity:0;transform:scale(2)}}@keyframes spin{to{transform:rotate(360deg)}}.fe-screen-fade-in{animation:.4s cubic-bezier(.16,1,.3,1) forwards feFadeIn}@keyframes feFadeIn{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.flowengage-initial-bg{background-color:#fff;position:relative;overflow:hidden}.flowengage-initial-bg:before{content:"";background:linear-gradient(to bottom, var(--flowengage-primary) 0%, var(--flowengage-accent) 55%, white 82%);opacity:0;pointer-events:none;z-index:0;transition:opacity .6s cubic-bezier(.4,0,.2,1);position:absolute;inset:0}.flowengage-initial-bg.is-initial:before{opacity:1}.flowengage-content-wrapper{z-index:1;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}`,BO=(()=>{try{return window.top!==window.self}catch{return!0}})(),VO=`https://be-flowengage-stage.oslabs.app`,HO=`${VO}/agent-shell.html`,UO=`flowengage-voice-iframe`,WO=null,GO=!1;function KO(){let e=document.createElement(`div`);e.id=`flowengage-root`;let t=e.attachShadow({mode:`open`}),n=document.createElement(`style`);n.textContent=zO,t.appendChild(n);let r=document.createElement(`div`);return r.setAttribute(`data-flowengage-mount`,`true`),r.className=`flowengage-widget-root`,t.appendChild(r),{host:e,mount:r}}function qO(e){if(document.body){e();return}let t=new MutationObserver(()=>{document.body&&(t.disconnect(),e())});t.observe(document.documentElement,{childList:!0})}function JO({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r,config:i={}}){if(GO)return;if(!e){console.error(`[FlowEngage] siteId is required.`);return}if(!document.body){qO(()=>JO({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r,config:i}));return}if(document.getElementById(`flowengage-root`))return;let{host:a,mount:o}=KO();document.body.appendChild(a),WO=(0,x.createRoot)(o);let s={widgetSettings:n,...r&&{apiBaseUrl:r},...i};WO.render(b.createElement(jn,{siteId:e,language:t,config:s},b.createElement(RO))),GO=!0}if(BO){let e=new URLSearchParams(location.search),t=e.get(`siteId`)||``,n=e.get(`clientOrigin`)||``;if(n&&typeof window<`u`&&window.fetch){let e=window.fetch.bind(window);window.fetch=(t,r={})=>{try{let e=(r.method||`GET`).toUpperCase(),i=(r.headers?.[`Content-Type`]||r.headers?.[`content-type`]||``).toLowerCase();if(e!==`GET`&&i.includes(`application/json`)&&r.body)try{let e=JSON.parse(r.body);e.clientOrigin||(r={...r,body:JSON.stringify({...e,clientOrigin:n})})}catch{}if(e===`GET`)try{let e=new URL(typeof t==`string`?t:t.url,window.location.href);e.searchParams.has(`clientOrigin`)||(e.searchParams.set(`clientOrigin`,n),t=typeof t==`string`?e.toString():new Request(e.toString(),t))}catch{}}catch{}return e(t,r)}}if(t){let e={siteId:t,...n&&{config:{clientOrigin:n}}};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>qO(()=>JO(e))):qO(()=>JO(e))}else console.error(`[FlowEngage] agent-shell.html loaded without ?siteId= param.`)}if(!BO){function e(e){try{return!!e.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root, #`+UO)}catch{return!1}}function t(e){let t=e.ownerDocument||document,n=e.getAttribute(`aria-labelledby`);if(n){let e=n.trim().split(/\s+/).filter(Boolean).map(e=>{try{return t.getElementById(e)?.textContent?.trim()}catch{return null}}).filter(Boolean);if(e.length)return e.join(` `).replace(/\s*\*+\s*$/,``).trim()}if(e.labels?.length)return e.labels[0].textContent.replace(/\s*\*+\s*$/,``).trim();if(e.id){try{let n=t.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(n)return n.textContent.replace(/\s*\*+\s*$/,``).trim()}catch{}let n=t.querySelector(`label[for="${e.id.replace(/"/g,`\\"`)}"]`);if(n)return n.textContent.replace(/\s*\*+\s*$/,``).trim()}let r=e.parentElement;for(let e=0;e<5&&r;e++){if(r.tagName===`LABEL`)return r.textContent.replace(/\s*\*+\s*$/,``).trim();r=r.parentElement}return e.getAttribute(`aria-label`)||null}function n(){let n=[],r=[],i=0;function a(a){Array.from(a.querySelectorAll(`input, select, textarea`)).forEach(a=>{if(e(a))return;let o=(a.type||``).toLowerCase();if(![`hidden`,`submit`,`button`,`image`].includes(o)&&!(a.disabled||a.readOnly)){try{let e=(a.ownerDocument?.defaultView||window).getComputedStyle(a);if(e.display===`none`||e.visibility===`hidden`)return}catch{}n.push({index:i,tag:a.tagName,type:a.type||`text`,name:a.name||null,id:a.id||null,placeholder:a.placeholder||null,label:t(a),ariaLabel:a.getAttribute(`aria-label`),title:a.getAttribute(`title`),datatestid:a.getAttribute(`data-testid`),autocomplete:a.getAttribute(`autocomplete`)}),r.push(a),i++}})}return a(document),Array.from(document.querySelectorAll(`iframe`)).forEach(e=>{if(e.id!==UO)try{let t=e.contentDocument;t&&a(t)}catch{}}),{fields:n,elements:r}}function r(){let t=[],n=[],r=0;function i(i){Array.from(i.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).forEach(i=>{if(e(i)||i.disabled)return;try{let e=(i.ownerDocument?.defaultView||window).getComputedStyle(i);if(e.display===`none`||e.visibility===`hidden`)return}catch{}let a=(i.textContent||i.value||``).replace(/\s+/g,` `).trim().slice(0,120);t.push({index:r,text:a||null,ariaLabel:i.getAttribute(`aria-label`),type:i.type||i.tagName}),n.push(i),r++})}return i(document),Array.from(document.querySelectorAll(`iframe`)).forEach(e=>{if(e.id!==UO)try{let t=e.contentDocument;t&&i(t)}catch{}}),{buttons:t.slice(0,60),elements:n.slice(0,60)}}function i(e,t){let n=t.toLowerCase().replace(/\s*\*+\s*$/u,``).replace(/\s+/g,` `).trim();if(!n)return 0;let r=[e.name,e.id,e.placeholder,e.label,e.ariaLabel,e.title,e.datatestid,e.autocomplete].filter(Boolean).map(e=>String(e).toLowerCase().trim()),i=0;for(let e of r){if(e===n||e.includes(n)||n.includes(e)){i=Math.max(i,100);continue}let t=n.split(/\s+/).filter(e=>e.length>1);if(!t.length)continue;let r=0;for(let n of t)e.includes(n)&&r++;i=Math.max(i,r/t.length*88)}return i}function a(e,t){try{e.scrollIntoView({block:`center`,inline:`nearest`})}catch{}try{e.focus({preventScroll:!0})}catch{}let n=e.tagName,r=(e.type||``).toLowerCase();if(n===`SELECT`){e.value=String(t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r===`checkbox`||r===`radio`){e.checked=[`1`,`true`,`yes`,`on`].includes(String(t).toLowerCase()),e.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let i=String(t),a=e.ownerDocument?.defaultView||window,o=n===`TEXTAREA`?a.HTMLTextAreaElement?.prototype:a.HTMLInputElement?.prototype,s=o&&Object.getOwnPropertyDescriptor(o,`value`);s?.set?s.set.call(e,i):e.value=i;let c={bubbles:!0,cancelable:!0};try{e.dispatchEvent(new InputEvent(`input`,{...c,inputType:`insertText`,data:i}))}catch{e.dispatchEvent(new Event(`input`,c))}e.dispatchEvent(new Event(`change`,c))}let o=null,s=null;function c(t){if(l(),!t)return`Missing section text.`;let n=t.toLowerCase().trim(),r=n.split(/\s+/).filter(e=>e.length>2),i=null,a=0,c=Array.from(document.querySelectorAll(`h1,h2,h3,h4,h5,h6,[data-section],p,li,section,article`)).filter(t=>!e(t));for(let e of c){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(!t)continue;let o=0;if(t===n)o=200;else if(t.startsWith(n)||t.endsWith(n))o=150;else if(t.includes(n))o=100;else if(n.includes(t)&&t.length>3)o=80;else if(r.length>0){let e=0;for(let n of r)t.includes(n)&&e++;let n=e/r.length;n>=.6&&(o=n*70)}o>0&&/^H[1-6]$/i.test(e.tagName)&&(o+=50),o>0&&t.length<200&&(o+=10),o>a&&(a=o,i=e)}if(!i||a<30)return`Could not find that section on the page.`;try{i.scrollIntoView({behavior:`smooth`,block:`center`})}catch{}return o=i,i.setAttribute(`data-fe-parent-hl`,`1`),Object.assign(i.style,{outline:`3px solid #2563eb`,outlineOffset:`8px`,background:`rgba(37,99,235,0.08)`,borderRadius:`8px`,transition:`all 0.4s ease`,position:`relative`,zIndex:`9999`}),s=document.createElement(`div`),s.style.cssText=`position:fixed;inset:0;background:rgba(0,0,0,0.35);z-index:9998;pointer-events:none;opacity:0;transition:opacity 0.4s ease;`,document.body.appendChild(s),s.offsetHeight,s.style.opacity=`1`,setTimeout(l,6e4),`Highlighted the section.`}function l(){if(o&&=(o.removeAttribute(`data-fe-parent-hl`),[`outline`,`outlineOffset`,`background`,`borderRadius`,`transition`,`position`,`zIndex`].forEach(e=>{o.style[e]=``}),null),s){s.style.opacity=`0`;let e=s;setTimeout(()=>e.parentNode?.removeChild(e),400),s=null}document.querySelectorAll(`[data-fe-parent-hl]`).forEach(e=>{e.removeAttribute(`data-fe-parent-hl`),[`outline`,`outlineOffset`,`background`,`borderRadius`,`transition`,`position`,`zIndex`].forEach(t=>{e.style[t]=``})})}function u(t){if(t){let n=t.toLowerCase().trim(),r=Array.from(document.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).find(t=>!e(t)&&t.textContent.toLowerCase().trim().includes(n));if(r){let e=[r.textContent.trim()],t=r.nextElementSibling;for(;t&&!/^H[1-3]$/i.test(t.tagName);){let n=t.textContent.trim();n&&e.push(n),t=t.nextElementSibling}let n=e.join(`
632
- `);return n.length>8e3?n.slice(0,8e3)+`… (truncated)`:n||`No content found.`}}let n=(document.querySelector(`main`)||document.querySelector(`article`)||document.body).cloneNode(!0);n.querySelectorAll(`nav,footer,header,aside,script,style,noscript`).forEach(e=>e.remove());let r=n.textContent.replace(/\s+/g,` `).trim();return r.length>8e3?r.slice(0,8e3)+`… (truncated)`:r||`No readable content.`}function d(e,t){function o(n,r){try{t.contentWindow.postMessage({type:`FE_DOM_RESPONSE`,id:e.id,result:n,error:r||void 0},VO)}catch{}}try{switch(e.type){case`FE_DOM_GET_URL`:o(window.location.href);break;case`FE_DOM_NAVIGATE`:try{let t=new URL(e.url,window.location.href),n=window.next?.router,r=window.__NEXT_ROUTER__;if(n?.push)n.push(t.pathname+t.search+t.hash);else if(r?.push)r.push(t.pathname+t.search+t.hash);else if(t.hash&&t.pathname===window.location.pathname){let e=document.getElementById(t.hash.slice(1));e?e.scrollIntoView({behavior:`smooth`}):window.location.assign(t.href)}else window.location.assign(t.href)}catch{window.location.href=e.url}o(`ok`);break;case`FE_DOM_LIST_FORMS`:{let{fields:e}=n(),{buttons:t}=r();o(JSON.stringify({fields:e,buttons:t,hint:`Use field_key matching label, placeholder, name, or id. Buttons are indexed by visible text.`}));break}case`FE_DOM_FILL_FORM`:{let{fields:t,elements:r}=n(),s=[];for(let{field_key:n,value:o}of e.fields||[]){if(n==null||o==null)continue;let e=-1,c=0;for(let r of t){let t=i(r,String(n));t>c&&(c=t,e=r.index)}e>=0&&c>=28&&r[e]&&(a(r[e],o),s.push(String(n)))}o(s.length?`OK_FILLED: ${s.join(`, `)}`:`Could not match any fields.`);break}case`FE_DOM_CLICK_BUTTON`:{let{buttons:t,elements:n}=r(),i=(e.text||``).toLowerCase().trim(),a=-1,s=0;for(let e of t){let t=[e.text,e.ariaLabel].filter(Boolean).join(` `).toLowerCase(),n=t.includes(i)?100:0;if(!n){let e=i.split(/\s+/).filter(e=>e.length>1);if(e.length){let r=0;for(let n of e)t.includes(n)&&r++;n=r/e.length*92}}n>s&&(s=n,a=e.index)}if(a<0||s<36||!n[a]){o(`Could not find button "${e.text}".`);break}try{let e=n[a];try{e.scrollIntoView({block:`center`})}catch{}e.focus?.(),e.click(),o(`OK_CLICK ${(e.textContent||e.value||``).trim().slice(0,80)||`button`}`)}catch(e){o(`Click failed: ${e.message}`)}break}case`FE_DOM_HIGHLIGHT`:o(c(e.sectionText));break;case`FE_DOM_CLEAR_HIGHLIGHT`:l(),o(`ok`);break;case`FE_DOM_READ_CONTENT`:o(u(e.sectionText));break;default:o(null,`Unknown command: ${e.type}`)}}catch(e){o(null,e.message)}}function f(){let e=document.getElementById(UO);if(e?.contentWindow)try{e.contentWindow.postMessage({type:`PARENT_URL_CHANGE`,url:window.location.href},VO)}catch{}}function p(e){if(!e)return;if(!document.body){qO(()=>p(e));return}if(document.getElementById(UO))return;let t=document.createElement(`iframe`);t.id=UO;let n=typeof window<`u`?window.location.origin:``;t.src=`${HO}?siteId=${encodeURIComponent(e)}&clientOrigin=${encodeURIComponent(n)}`,t.setAttribute(`allow`,`microphone`),t.style.cssText=[`position:fixed`,`bottom:24px`,`right:24px`,`width:80px`,`height:80px`,`border:none`,`background:transparent`,`z-index:2147483647`,`border-radius:50%`,`transition:all 0.3s ease`].join(`;`),document.body.appendChild(t),t.addEventListener(`load`,f),window.addEventListener(`popstate`,f),window.addEventListener(`hashchange`,f),window.addEventListener(`message`,function(e){if(e.origin!==VO)return;let t=document.getElementById(UO);if(t){if(e.data?.type?.startsWith(`FE_DOM_`)){d(e.data,t);return}e.data?.type===`WIDGET_OPEN`&&(t.style.width=`390px`,t.style.height=`640px`,t.style.borderRadius=`16px`),e.data?.type===`WIDGET_MINIMIZED`&&(t.style.width=`80px`,t.style.height=`80px`,t.style.borderRadius=`50%`),e.data?.type===`AGENT_EXPAND`&&(t.style.width=`380px`,t.style.height=`520px`,t.style.borderRadius=`16px`),e.data?.type===`AGENT_COLLAPSE`&&(t.style.width=`80px`,t.style.height=`80px`,t.style.borderRadius=`50%`)}})}try{(()=>{let e=document.currentScript;e?.getAttribute(`data-site-id`)||(e=document.querySelector(`script[data-site-id]`));let t=e?.getAttribute(`data-site-id`);t&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>qO(()=>p(t))):qO(()=>p(t)))})()}catch{}try{typeof window<`u`&&(window.FlowEngage={init({siteId:e}={}){try{document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>qO(()=>p(e))):qO(()=>p(e))}catch{}},destroy(){let e=document.getElementById(UO);e&&e.remove()}})}catch{}}})();
632
+ `);return n.length>8e3?n.slice(0,8e3)+`… (truncated)`:n||`No content found.`}}let n=(document.querySelector(`main`)||document.querySelector(`article`)||document.body).cloneNode(!0);n.querySelectorAll(`nav,footer,header,aside,script,style,noscript`).forEach(e=>e.remove());let r=n.textContent.replace(/\s+/g,` `).trim();return r.length>8e3?r.slice(0,8e3)+`… (truncated)`:r||`No readable content.`}function d(e,t){function o(n,r){try{t.contentWindow.postMessage({type:`FE_DOM_RESPONSE`,id:e.id,result:n,error:r||void 0},VO)}catch{}}try{switch(e.type){case`FE_DOM_GET_URL`:o(window.location.href);break;case`FE_DOM_NAVIGATE`:try{let t=new URL(e.url,window.location.href),n=window.next?.router,r=window.__NEXT_ROUTER__;if(n?.push)n.push(t.pathname+t.search+t.hash);else if(r?.push)r.push(t.pathname+t.search+t.hash);else if(t.hash&&t.pathname===window.location.pathname){let e=document.getElementById(t.hash.slice(1));e?e.scrollIntoView({behavior:`smooth`}):window.location.assign(t.href)}else t.origin===window.location.origin?(window.history.pushState(null,``,t.pathname+t.search+t.hash),window.dispatchEvent(new PopStateEvent(`popstate`,{state:null})),setTimeout(f,150)):window.location.assign(t.href)}catch{window.location.href=e.url}o(`ok`);break;case`FE_DOM_LIST_FORMS`:{let{fields:e}=n(),{buttons:t}=r();o(JSON.stringify({fields:e,buttons:t,hint:`Use field_key matching label, placeholder, name, or id. Buttons are indexed by visible text.`}));break}case`FE_DOM_FILL_FORM`:{let{fields:t,elements:r}=n(),s=[];for(let{field_key:n,value:o}of e.fields||[]){if(n==null||o==null)continue;let e=-1,c=0;for(let r of t){let t=i(r,String(n));t>c&&(c=t,e=r.index)}e>=0&&c>=28&&r[e]&&(a(r[e],o),s.push(String(n)))}o(s.length?`OK_FILLED: ${s.join(`, `)}`:`Could not match any fields.`);break}case`FE_DOM_CLICK_BUTTON`:{let{buttons:t,elements:n}=r(),i=(e.text||``).toLowerCase().trim(),a=-1,s=0;for(let e of t){let t=[e.text,e.ariaLabel].filter(Boolean).join(` `).toLowerCase(),n=t.includes(i)?100:0;if(!n){let e=i.split(/\s+/).filter(e=>e.length>1);if(e.length){let r=0;for(let n of e)t.includes(n)&&r++;n=r/e.length*92}}n>s&&(s=n,a=e.index)}if(a<0||s<36||!n[a]){o(`Could not find button "${e.text}".`);break}try{let e=n[a];try{e.scrollIntoView({block:`center`})}catch{}e.focus?.(),e.click(),o(`OK_CLICK ${(e.textContent||e.value||``).trim().slice(0,80)||`button`}`)}catch(e){o(`Click failed: ${e.message}`)}break}case`FE_DOM_HIGHLIGHT`:o(c(e.sectionText));break;case`FE_DOM_CLEAR_HIGHLIGHT`:l(),o(`ok`);break;case`FE_DOM_READ_CONTENT`:o(u(e.sectionText));break;default:o(null,`Unknown command: ${e.type}`)}}catch(e){o(null,e.message)}}function f(){let e=document.getElementById(UO);if(e?.contentWindow)try{e.contentWindow.postMessage({type:`PARENT_URL_CHANGE`,url:window.location.href},VO)}catch{}}function p(e){if(!e)return;if(!document.body){qO(()=>p(e));return}if(document.getElementById(UO))return;let t=document.createElement(`iframe`);t.id=UO;let n=typeof window<`u`?window.location.origin:``;t.src=`${HO}?siteId=${encodeURIComponent(e)}&clientOrigin=${encodeURIComponent(n)}`,t.setAttribute(`allow`,`microphone`),t.style.cssText=[`position:fixed`,`bottom:24px`,`right:24px`,`width:80px`,`height:80px`,`border:none`,`background:transparent`,`z-index:2147483647`,`border-radius:50%`,`transition:all 0.3s ease`].join(`;`),document.body.appendChild(t),t.addEventListener(`load`,f),window.addEventListener(`popstate`,f),window.addEventListener(`hashchange`,f),window.addEventListener(`message`,function(e){if(e.origin!==VO)return;let t=document.getElementById(UO);if(t){if(e.data?.type?.startsWith(`FE_DOM_`)){d(e.data,t);return}e.data?.type===`WIDGET_OPEN`&&(t.style.width=`390px`,t.style.height=`640px`,t.style.borderRadius=`16px`),e.data?.type===`WIDGET_MINIMIZED`&&(t.style.width=`80px`,t.style.height=`80px`,t.style.borderRadius=`50%`),e.data?.type===`AGENT_EXPAND`&&(t.style.width=`380px`,t.style.height=`520px`,t.style.borderRadius=`16px`),e.data?.type===`AGENT_COLLAPSE`&&(t.style.width=`80px`,t.style.height=`80px`,t.style.borderRadius=`50%`)}})}try{(()=>{let e=document.currentScript;e?.getAttribute(`data-site-id`)||(e=document.querySelector(`script[data-site-id]`));let t=e?.getAttribute(`data-site-id`);t&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>qO(()=>p(t))):qO(()=>p(t)))})()}catch{}try{typeof window<`u`&&(window.FlowEngage={init({siteId:e}={}){try{document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>qO(()=>p(e))):qO(()=>p(e))}catch{}},destroy(){let e=document.getElementById(UO);e&&e.remove()}})}catch{}}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "1.9.7",
3
+ "version": "1.9.8",
4
4
  "description": "Embeddable AI chat widget for React — powered by FlowEngage. Drop it in with a single siteId.",
5
5
  "keywords": [
6
6
  "chatbot",