@flowengage/react-chatbot 8.0.2 → 8.0.3
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/flowengage-embed.js
CHANGED
|
@@ -648,7 +648,7 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
|
|
|
648
648
|
radial-gradient(circle at 82% 50%, ${r} 0%, ${r}99 35%, transparent 65%),
|
|
649
649
|
radial-gradient(circle at 50% 82%, ${i} 0%, ${i}99 30%, transparent 58%),
|
|
650
650
|
white
|
|
651
|
-
`.replace(/\s+/g,` `).trim()}})}var Ak=()=>(0,A.jsx)(`div`,{style:{display:`flex`,marginBottom:`12px`,justifyContent:`flex-start`},children:(0,A.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,A.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})});function jk({copy:e,orbColors:t,primaryColor:n,chatBgGradient:r,logo:i,quickChatOptions:a,onQuickChatSelect:o,isMobile:s,chatHistory:c,isAiTyping:l,isAgentTyping:u,activeScreen:d,agentName:f,agentHeadshot:p,fallbackAgentName:m,input:h,setInput:g,onSubmit:_,isConversationEnded:v,isLoading:y,isRateLimited:x,rateLimitMessage:ee,selectedFile:S,onFileSelect:C,onRemoveSelectedFile:te,attachmentError:w,isUploadingAttachment:ne,requiresEmail:re,emailInput:ie,setEmailInput:T,emailError:ae,emailCaptureSuccess:oe,replyContext:se,setReplyContext:ce,webRTCError:le,micError:E,setMicError:D,dismissCallError:ue,activeCallId:de,isCallMuted:fe,toggleCallMute:pe,endWebRTCCall:me,formatCallDuration:he,callDurationSeconds:ge,isCallMinimized:_e,onExpand:ve,onCollapse:ye,onStartVoice:be,voiceEnabled:xe,headerBgColor:Se,onNewChat:Ce,showPoweredBy:we,privacyPolicyUrl:Te,getVisitorChatHistory:Ee,resumeChat:De,isSessionRestoring:Oe,isClosing:ke}){let Ae=c.length>0,je=y||x||v,Me=!!de,[Ne,Pe]=(0,b.useState)(!1),[Fe,Ie]=(0,b.useState)(!1),[Le,Re]=(0,b.useState)([]),[ze,Be]=(0,b.useState)(!1),Ve=(0,b.useRef)(null),[He,Ue]=(0,b.useState)(()=>typeof window<`u`?window.visualViewport?.height??window.innerHeight:600),[We,Ge]=(0,b.useState)(0);(0,b.useEffect)(()=>{if(!s)return;let e=window.visualViewport;if(!e)return;let t=()=>{Ue(e.height),Ge(Math.max(0,window.innerHeight-e.offsetTop-e.height))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),t(),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[s]);let Ke=s&&window.innerHeight-He>150,qe=async()=>{Pe(!1),Ie(!0),Be(!0);try{let e=await Ee();e?.data&&Re(e.data)}catch(e){console.error(e)}finally{Be(!1)}},Je=async e=>{Ie(!1),De?.(e.chatId)};return(0,b.useEffect)(()=>{if(!Ne)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Ve.current&&!Ve.current.contains(t)&&Pe(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Ne]),(0,A.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,left:`8px`,right:`8px`,bottom:`${We}px`,height:He>0?`${Math.round(He*.92)}px`:`90dvh`,background:r,borderRadius:`16px 16px 0 0`,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:ke?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:`fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)`}:{"--flowengage-primary":n,"--flowengage-accent":n,width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,background:r,borderRadius:`22px`,boxShadow:`0 24px 64px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08)`,display:`flex`,flexDirection:`column`,overflow:`hidden`,position:`relative`,animation:ke?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:`fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`},children:[(0,A.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`40px minmax(0, 1fr) 40px`,alignItems:`center`,columnGap:`14px`,padding:`16px 10px 14px`,background:Se||`transparent`,flexShrink:0,position:`relative`,zIndex:30},children:[(0,A.jsx)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:(0,A.jsx)(`button`,{onClick:ye,style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},children:(0,A.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,A.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})})}),(()=>{let t=!!i,n=!!e.hasCustomTitle,r=t||n,a=t||!r,o=n||!r,c=a&&o;return(0,A.jsxs)(`div`,{style:{minWidth:0,maxWidth:s?`100%`:`250px`,width:`100%`,justifySelf:`center`,display:`grid`,gridTemplateColumns:c?`minmax(72px, 40%) minmax(0, 60%)`:`1fr`,columnGap:c?`12px`:0,alignItems:`center`,justifyItems:c?`stretch`:`center`},children:[a&&(0,A.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,A.jsx)(Sk,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,A.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,A.jsx)(Ck,{title:e.chatTitle})})}),o&&(0,A.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:c?`flex-start`:`center`},children:(0,A.jsx)(`span`,{style:{fontSize:`15px`,fontWeight:600,color:`#111827`,letterSpacing:`-0.01em`,lineHeight:1.2,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.chatTitle,children:e.chatTitle})})]})})(),(0,A.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:Ve,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>Pe(e=>!e),style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},"aria-label":`Chat options`,children:(0,A.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,A.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,A.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,A.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`})]})}),Ne&&(0,A.jsxs)(`div`,{style:{position:`absolute`,top:`34px`,right:0,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,overflow:`hidden`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,minWidth:`210px`,border:`1px solid rgba(255,255,255,0.07)`,animation:`fe-orb-fade-in 0.18s ease`},children:[xe&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{Pe(!1),be?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,A.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,A.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`}),(0,A.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]}),`Enter Voice Mode`]}),(0,A.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}})]}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{Pe(!1),Ce?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,A.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,A.jsx)(`path`,{d:`M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7`}),(0,A.jsx)(`path`,{d:`M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z`})]}),`Start new chat`]}),Ee&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,A.jsxs)(`button`,{type:`button`,onClick:qe,style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,A.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,A.jsx)(`path`,{d:`M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z`})}),`Chat history`]})]}),(0,A.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{Pe(!1),ye?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`#f87171`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(248,113,113,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,A.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,A.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,A.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,A.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]}),`Close conversation`]})]})]})]}),(0,A.jsx)(JD,{webRTCError:le,micError:E,setMicError:D,dismissCallError:ue,isRateLimited:x,rateLimitMessage:ee}),_e&&(0,A.jsx)(dO,{agentName:f,agentHeadshot:p,fallbackAgentName:m,callDurationSeconds:ge,isCallMuted:fe,formatCallDuration:he,toggleCallMute:pe,endWebRTCCall:me,onExpand:ve,primaryColor:n}),(0,A.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`,position:`relative`},children:[Fe?(0,A.jsxs)(`div`,{style:{position:`absolute`,inset:0,background:`white`,zIndex:20,display:`flex`,flexDirection:`column`,animation:`fe-orb-fade-in 0.2s ease`},children:[(0,A.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px`,borderBottom:`1px solid #f3f4f6`,flexShrink:0},children:(0,A.jsxs)(`button`,{onClick:()=>Ie(!1),style:{background:`none`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,color:`#6b7280`},children:[(0,A.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,A.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),(0,A.jsx)(`span`,{style:{marginLeft:`8px`,fontWeight:500,fontSize:`15px`},children:`Return to Chat`})]})}),(0,A.jsx)(`div`,{style:{flex:1,overflowY:`auto`,position:`relative`},children:ze?(0,A.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading past conversations...`}):Le.length>0?(0,A.jsx)(`div`,{children:Le.map(e=>(0,A.jsxs)(`div`,{onClick:()=>Je(e),style:{padding:`16px 20px`,borderBottom:`1px solid #f3f4f6`,cursor:`pointer`,transition:`background 0.15s ease`},onMouseEnter:e=>e.currentTarget.style.background=`#f9fafb`,onMouseLeave:e=>e.currentTarget.style.background=`white`,children:[(0,A.jsxs)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginBottom:`6px`,fontWeight:500},children:[new Date(e.createdAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),` at `,new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]}),(0,A.jsx)(`div`,{style:{fontSize:`14.5px`,color:`#111827`,opacity:.9,overflow:`hidden`,textOverflow:`ellipsis`,display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,lineHeight:1.4},children:e.message||`Conversation`})]},e.chatId))}):(0,A.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#9ca3af`,fontSize:`14px`},children:`No previous chats found.`})})]}):null,Ae?(0,A.jsx)(KD,{chatHistory:c,isAiTyping:l,isLoading:y,isAgentTyping:u,setReplyContext:ce,TypingDots:Ak,primaryColor:n,agentHeadshot:p,agentDisplayName:f||m,botAvatarNode:(0,A.jsx)(kk,{orbColors:t})}):Oe?(0,A.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`},children:[(0,A.jsx)(`div`,{style:{width:`28px`,height:`28px`,border:`3px solid #f3f4f6`,borderTop:`3px solid ${n}`,borderRadius:`50%`,animation:`spin 1s linear infinite`},children:(0,A.jsx)(`style`,{children:`@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }`})}),(0,A.jsx)(`div`,{style:{color:`#6b7280`,fontSize:`14px`,fontWeight:500,animation:`fe-orb-fade-in 1s infinite alternate`},children:`Loading chat...`})]}):(0,A.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`22px`,padding:`28px 24px`},children:[(0,A.jsx)(Tk,{size:94,orbColors:t}),(0,A.jsx)(`p`,{style:{margin:0,textAlign:`center`,fontSize:`16px`,color:`#374151`,lineHeight:1.55,maxWidth:`270px`},children:e.introGreeting}),a.length>0&&(0,A.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`8px`,justifyContent:`center`,width:`100%`,padding:`0 8px`},children:a.map(e=>(0,A.jsx)(`button`,{onClick:()=>o?.(e),style:{padding:`8px 16px`,borderRadius:`999px`,background:`white`,border:`1.5px solid ${n}33`,color:n||`#374151`,fontSize:`13px`,fontWeight:500,cursor:`pointer`,transition:`all 0.15s ease`,boxShadow:`0 1px 4px rgba(0,0,0,0.06)`},onMouseEnter:e=>{e.currentTarget.style.background=`${n}12`,e.currentTarget.style.borderColor=n},onMouseLeave:e=>{e.currentTarget.style.background=`white`,e.currentTarget.style.borderColor=`${n}33`},children:e.label||e.text},e.id))})]})]}),oe&&(0,A.jsxs)(`div`,{style:{margin:`0 16px 8px`,padding:`9px 14px`,borderRadius:`12px`,background:`#ecfdf5`,border:`1px solid #6ee7b7`,display:`flex`,alignItems:`center`,gap:`8px`,animation:`fe-orb-fade-in 0.2s ease`,flexShrink:0},children:[(0,A.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#10b981`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:(0,A.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),(0,A.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:`#065f46`},children:`Email saved — we'll be in touch!`})]}),(0,A.jsx)(`div`,{style:{background:`transparent`,flexShrink:0,position:`relative`,zIndex:1,padding:re?`6px 0 0`:`12px 0 0`},children:(0,A.jsx)(qD,{input:h,setInput:g,onSubmit:_,isConversationEnded:v,callUiActive:Me,handleToggleVoice:be,showVoiceToggle:d===`agent`,activeScreen:d,inputDisabled:je,replyContext:se,clearReplyContext:()=>ce(null),onFileSelect:C,selectedFile:S,onRemoveSelectedFile:te,attachmentError:w,isUploadingAttachment:ne,requiresEmail:re,emailInput:ie,setEmailInput:T,emailError:ae,inputPlaceholder:e.inputPlaceholder})}),!Ke&&(0,A.jsxs)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`8px 20px`,paddingBottom:`max(12px, env(safe-area-inset-bottom, 12px))`,pointerEvents:`none`},children:[Te&&(0,A.jsxs)(`p`,{style:{margin:`0 0 4px`,fontSize:`10px`,color:`#9ca3af`,lineHeight:1.4,userSelect:`none`,pointerEvents:`auto`},children:[`This conversation is recorded for quality assurance purposes.`,` `,(0,A.jsx)(`a`,{href:Te,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#6b7280`,textDecoration:`underline`},children:`See our privacy policy`})]}),we&&(0,A.jsxs)(`span`,{style:{fontSize:`11px`,color:`#9ca3af`,letterSpacing:`0.01em`,userSelect:`none`},children:[`Powered by `,(0,A.jsx)(`strong`,{style:{fontWeight:600,color:`#6b7280`},children:`FlowEngage`})]})]})]})}function Mk(){let{status:e,runtimeConfig:t,resolvedConfig:n,chatHistory:r,isOpen:i,activeScreen:a,isHumanHandled:o,agentName:s,agentHeadshot:c,visitorEmail:l,isAgentTyping:u,isAiTyping:d,isLoading:f,isRateLimited:p,rateLimitMessage:m,isConversationEnded:h,incomingCall:g,activeCallId:_,callConnectionState:v,callConnectedAt:y,isCallMuted:x,webRTCError:ee,language:S,chatId:C,historyRef:te,onMessageSync:w,sendMessage:ne,uploadChatFile:re,openWidget:ie,captureVisitorEmail:T,setVoiceMode:ae,endConversation:oe,startNewChat:se,acceptCall:ce,rejectCall:le,endWebRTCCall:ue,toggleCallMute:de,dismissCallError:fe,startTyping:pe,stopTyping:me,updateTypingDraft:he,getVisitorChatHistory:ge,resumeChat:_e,isSessionRestoring:ve,openToChatCounter:ye,voiceEndCounter:be}=In();(0,b.useEffect)(()=>{try{mr()}catch{}},[]),(0,b.useEffect)(()=>{ye&&at!==`voice_mode`&&at!==`text_chat`&&at!==`call_screen`&&(ae?.(!1),ot(`text_chat`))},[ye]);let xe=t?.widgetSettings||{},Se=n?.widgetSettings||{},Ce={...xe.branding||{},...Se.branding||{}},we={...xe.theme||{},...Se.theme||{}},Te={...xe.features||{},...Se.features||{}},Ee=Te.voice!==!1,ke=Array.isArray(we.orbColors)&&we.orbColors.length>0?we.orbColors:null,Ae=we.buttonColor||we.primaryColor||ke?.[0]||`#3B82F6`,Me={small:50,medium:64,large:80},Ne=Me[we.orbSize]||Me.small,Fe=we.position||`bottom-right`,Ie=Ce.fallbackAgentName||`Agent`,Le=yk(ke??we.chatBgColors),Re=Ce.logo||Ce.logoUrl||null,ze=S||`en`,Be=xe.recommendations?.[ze]||[],Ve=(Se.recommendations?.[ze]??Be).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),He=Array.isArray(Ce.quickChatOptions)&&Ce.quickChatOptions.length>0?Ce.quickChatOptions:Ve,Ue=Ce.hideWatermark===!0?!1:Ce.showPoweredBy!==!1,We=Ce.headerBgColor||null,Ge=we.bottomPosition==null?`1.5rem`:`${we.bottomPosition}px`,Ke=Ce.privacyPolicyUrl||null,qe=Ce.chatbotEnabled!==!1&&we.chatbotEnabled!==!1,Je=(()=>{let e={...xe.pageVisibility||{},...Se.pageVisibility||{}};return Array.isArray(e.allowedPaths)?e.allowedPaths.filter(Boolean):[]})(),Ye=Je.length===0||Je.some(e=>e===`*`||e===`/*`?!0:e.endsWith(`/*`)?It.startsWith(e.slice(0,-1)):It.replace(/\/$/,``)===e.replace(/\/$/,``)),Xe=xe.greetings?.[S]||Se.greetings?.[S]||Ce.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,Ze={entryPrompt:Ce.entryPrompt||`Do you want to explore in a new way?`,yesLabel:Ce.yesLabel||`Yes`,laterLabel:Ce.laterLabel||`Later`,connectionTitle:Ce.connectionTitle||`How would you like to connect?`,voiceLabel:Ce.voiceLabel||`Voice`,textLabel:Ce.textLabel||`Text`,chatTitle:Ce.headerName||`Chat with FlowEngage`,hasCustomTitle:!!(Ce.headerName&&String(Ce.headerName).trim()),introGreeting:Xe,inputPlaceholder:Ce.inputPlaceholder||`Type your message`,analysingLabel:Ce.analysingLabel||`analysing...`},Qe=Se.elevenLabsAgentId||t?.elevenLabsAgentId||null,$e=t?.siteId||n?.siteId||null,et=t?.apiBaseUrl||``;(0,b.useEffect)(()=>{er(t?.siteType||null)},[t?.siteType]);let tt=(0,b.useMemo)(()=>s&&String(s).trim()||t?.ownerName&&String(t.ownerName).trim()||t?.websiteName&&String(t.websiteName).trim()||`Agent`,[s,t?.ownerName,t?.websiteName]),O=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,nt=r.some(e=>e.sender===`user`),rt=(0,b.useMemo)(()=>{let e=r.findIndex(e=>e.sender===`user`);return e===-1?!1:r.slice(e+1).some(e=>e.sender===`bot`||e.sender===`ai`||e.sender===`agent`)},[r]),it=!!(Se._dashboardLivePreview||xe._dashboardLivePreview),[at,ot]=(0,b.useState)(()=>it?`text_chat`:`entry_prompt`),[st,ct]=(0,b.useState)(``),[lt,ut]=(0,b.useState)(null),[dt,ft]=(0,b.useState)(l||``),[pt,mt]=(0,b.useState)(``),[ht,gt]=(0,b.useState)(!1),[_t,vt]=(0,b.useState)(0),[yt,bt]=(0,b.useState)(null),[xt,St]=(0,b.useState)(null),[Ct,wt]=(0,b.useState)(``),[Tt,Et]=(0,b.useState)(!1),[Dt,Ot]=(0,b.useState)(!1),[kt,At]=(0,b.useState)(!1),jt=(0,b.useRef)(null),Mt=(0,b.useRef)(!1),Nt=!l&&nt&&rt&&at!==`voice_mode`;(0,b.useLayoutEffect)(()=>{if(e!==`ready`||Mt.current)return;if(Mt.current=!0,!Ee){ot(`minimized_orb`);return}let t=!1;try{t=Er().shouldResumeVoice}catch{}let n=je(),r=$e?De($e):null,i=n||!!r?.transcript;if(t){ie?.({notifyChatInitiated:!0}),ae?.(!0),ot(`voice_mode`);return}if(Pe()){ie?.({notifyChatInitiated:!1}),ot(`text_chat`);return}if(i){if((typeof performance<`u`?performance.getEntriesByType?.(`navigation`)?.[0]?.type??`navigate`:`navigate`)===`reload`){ot(`minimized_orb`);return}ie?.({notifyChatInitiated:!0}),ae?.(!0),ot(`voice_mode`);return}if($e)try{Oe($e)}catch{}if(E($e)){ot(`minimized_orb`);return}},[e,r]);let[Pt,Ft]=(0,b.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,b.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>Ft(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[It,Lt]=(0,b.useState)(()=>typeof window<`u`?window.location.pathname:`/`);(0,b.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>Lt(window.location.pathname),t=window.history.pushState.bind(window.history);return window.history.pushState=(...n)=>{t(...n),setTimeout(e,50)},window.addEventListener(`popstate`,e),()=>{window.history.pushState=t,window.removeEventListener(`popstate`,e)}},[]),(0,b.useEffect)(()=>{ft(l||``),l&&mt(``)},[l]);let Rt=(0,b.useCallback)(()=>{St(null),wt(``)},[]),zt=(0,b.useCallback)(e=>{let t=VD(e);if(t){St(null),wt(t);return}St(e),wt(``)},[]);(0,b.useEffect)(()=>{if(!y||v!==`connected`){vt(0);return}let e=()=>{let e=new Date(y).getTime();isNaN(e)||vt(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[y,v]);let Bt=(0,b.useCallback)(()=>{ot(`call_screen`),Ot(!1)},[]),Vt=(0,b.useCallback)(()=>{ot(`text_chat`),Ot(!0)},[]);(0,b.useEffect)(()=>{let e=g?.callId||_||null;if(!e){jt.current=null;return}if(g?.callId||v===`connecting`||v===`connected`){if(at===`minimized_orb`&&Dt&&_&&!g?.callId){jt.current=e;return}!(!i||at===`minimized_orb`||at===`voice_mode`)&&jt.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:at,hasIncomingCall:!!g?.callId,activeCallId:_,callConnectionState:v}),jt.current=e,at===`voice_mode`&&ae?.(!1),ie?.(),Bt())}},[_,v,Bt,g?.callId,i,ie,ae,at]),(0,b.useEffect)(()=>{!g&&!_&&at===`call_screen`&&ot(`text_chat`)},[g,_,at]),(0,b.useEffect)(()=>{!_&&Dt&&Ot(!1)},[_,Dt]),(0,b.useEffect)(()=>{if(!o||h){he?.(``),me?.();return}if(!st.trim()||xt){he?.(``);let e=window.setTimeout(()=>me?.(),100);return()=>window.clearTimeout(e)}pe?.();let e=window.setTimeout(()=>he?.(st),120),t=window.setTimeout(()=>me?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[st,xt,o,h,pe,me,he]);let Ht=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,Ut=async e=>{if(e.preventDefault(),h)return;if(Nt){let e=dt.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){mt(`Please enter a valid email so we can continue helping you.`);return}await T(e),mt(``),gt(!0),setTimeout(()=>gt(!1),3e3);return}let t=Ht(lt);if(!st.trim()&&!xt)return;if(xt){try{Et(!0),wt(``);let e=await re(xt),n=e?.data||e,r=st.trim()||`Shared file: ${UD(xt)}`;ct(``),ut(null),Rt(),await ne(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||xt.name,fileType:n?.fileType||xt.type,fileSize:n?.fileSize||xt.size}})}catch(e){wt(e?.message||`Failed to upload the selected file.`)}finally{Et(!1)}return}let n=st.trim();ct(``),ut(null),await ne(n,``,t)},Wt=(0,b.useCallback)(()=>{r.length!==0&&se?.()},[r.length,se]),Gt=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},Kt=(0,b.useCallback)(async e=>{if(h||f)return;let t=e.message||e.label||e.text||``;t.trim()&&await ne(t.trim(),``)},[h,f,ne]),qt=Pt&&at===`entry_prompt`?{inset:0}:Pt&&at===`text_chat`?{left:0,right:0,bottom:0}:Pt&&at===`call_screen`?{left:0,right:0,bottom:0,height:`90dvh`,overflow:`hidden`,borderRadius:`16px 16px 0 0`}:Pt&&at===`connection_modal`?{left:`12px`,right:`12px`,bottom:`12px`}:at===`call_screen`?{width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,borderRadius:`22px`,overflow:`hidden`,...Fe===`bottom-left`?{left:`1.5rem`,bottom:Ge}:{right:`1.5rem`,bottom:Ge}}:Fe===`bottom-left`?{left:`1.5rem`,bottom:Ge}:{right:`1.5rem`,bottom:Ge},Jt=(0,b.useCallback)(()=>{at!==`minimized_orb`&&(At(!0),setTimeout(()=>{ot(`minimized_orb`),At(!1),_&&Ot(!0)},280))},[_,at]),Yt=()=>ot(`connection_modal`),Xt=()=>{try{let e=window.AudioContext||window.webkitAudioContext;if(e){let t=new e;t.resume().catch(()=>{}),setTimeout(()=>t.close().catch(()=>{}),3e3)}}catch{}ie({notifyChatInitiated:!0}),ae?.(!0),ot(`voice_mode`)},Zt=()=>{ie({notifyChatInitiated:!0}),ae?.(!1),ot(`text_chat`)},Qt=()=>{ae?.(!1),Jt()};return e!==`ready`||!qe||Te.chat===!1||!Ye?null:(0,A.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...qt},onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[at===`entry_prompt`&&(0,A.jsx)(Ek,{copy:Ze,orbColors:ke,primaryColor:Ae,onYes:()=>{D($e),Xt()},onLater:()=>{D($e),Jt()},isMobile:Pt,isClosing:kt}),at===`minimized_orb`&&(0,A.jsxs)(gm.div,{layoutId:`fe-main-orb`,initial:{scale:.4,opacity:0},animate:{scale:1,opacity:1},transition:{type:`spring`,stiffness:280,damping:18},style:{transformOrigin:`bottom right`,display:`inline-flex`,flexDirection:`column`,alignItems:Fe===`bottom-left`?`flex-start`:`flex-end`,gap:`10px`},children:[_&&(0,A.jsxs)(`button`,{type:`button`,onClick:Bt,style:{maxWidth:Pt?`220px`:`240px`,padding:`10px 14px`,borderRadius:`18px`,border:`1px solid rgba(255,255,255,0.7)`,background:`rgba(255,255,255,0.94)`,backdropFilter:`blur(18px)`,WebkitBackdropFilter:`blur(18px)`,boxShadow:`0 10px 26px rgba(15,23,42,0.14)`,display:`flex`,alignItems:`center`,gap:`10px`,cursor:`pointer`,textAlign:`left`},children:[(0,A.jsx)(`span`,{style:{width:`9px`,height:`9px`,borderRadius:`50%`,background:`#22c55e`,boxShadow:`0 0 0 4px rgba(34,197,94,0.16)`,flexShrink:0}}),(0,A.jsxs)(`span`,{style:{minWidth:0},children:[(0,A.jsx)(`span`,{style:{display:`block`,fontSize:`12px`,fontWeight:700,color:`#111827`,lineHeight:1.2},children:v===`connected`?`Call in progress`:`Call is active`}),(0,A.jsx)(`span`,{style:{display:`block`,fontSize:`11px`,color:`#6b7280`,lineHeight:1.3,marginTop:`2px`,whiteSpace:`nowrap`},children:v===`connected`?`${Gt(_t)} with ${tt}`:`Tap to return to ${tt}`})]})]}),(0,A.jsx)(Tk,{size:Ne,orbColors:ke,onClick:_?Bt:Ee?Yt:Zt})]}),at===`connection_modal`&&(0,A.jsx)(Dk,{copy:Ze,orbColors:ke,primaryColor:Ae,onVoice:Xt,onText:Zt,onClose:Jt,isMobile:Pt,isClosing:kt}),at===`voice_mode`&&(0,A.jsx)(Ok,{orbColors:ke,onEnterChat:Zt,onEndChat:Qt,agentId:Qe,siteId:$e,apiBaseUrl:et,chatId:C,historyRef:te,onMessageSync:w,voiceEndCounter:be,websiteName:t?.websiteName},`voice`),at===`call_screen`&&(0,A.jsx)(uO,{incomingCall:g,activeCallId:_,callConnectionState:v,callDurationSeconds:_t,isCallMuted:x,agentName:tt,agentHeadshot:O,fallbackAgentName:Ie,acceptCall:ce,rejectCall:le,endWebRTCCall:ue,toggleCallMute:de,formatCallDuration:Gt,onMinimize:Vt,primaryColor:Ae,orbColors:ke,chatHistory:r}),at===`text_chat`&&(0,A.jsx)(jk,{isClosing:kt,copy:Ze,orbColors:ke,primaryColor:Ae,chatBgGradient:Le,logo:Re,quickChatOptions:He,onQuickChatSelect:Kt,isMobile:Pt,chatHistory:r,isAiTyping:d,isAgentTyping:u,activeScreen:a,agentName:tt,agentHeadshot:O,fallbackAgentName:Ie,input:st,setInput:ct,onSubmit:Ut,isConversationEnded:h,isLoading:f,isRateLimited:p,rateLimitMessage:m,selectedFile:xt,onFileSelect:zt,onRemoveSelectedFile:Rt,attachmentError:Ct,isUploadingAttachment:Tt,requiresEmail:Nt,emailInput:dt,setEmailInput:ft,emailError:pt,emailCaptureSuccess:ht,replyContext:lt,setReplyContext:ut,webRTCError:ee,micError:yt,setMicError:bt,dismissCallError:fe,activeCallId:_,isCallMuted:x,toggleCallMute:de,endWebRTCCall:ue,formatCallDuration:Gt,callDurationSeconds:_t,onCollapse:Jt,onStartVoice:Xt,voiceEnabled:Ee,onNewChat:Wt,onMinimize:Vt,onExpand:Bt,isCallMinimized:!!_,showPoweredBy:Ue,privacyPolicyUrl:Ke,headerBgColor:We,getVisitorChatHistory:ge,resumeChat:_e,isSessionRestoring:ve}),(0,A.jsx)(`style`,{children:`
|
|
651
|
+
`.replace(/\s+/g,` `).trim()}})}var Ak=()=>(0,A.jsx)(`div`,{style:{display:`flex`,marginBottom:`12px`,justifyContent:`flex-start`},children:(0,A.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,A.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})});function jk({copy:e,orbColors:t,primaryColor:n,chatBgGradient:r,logo:i,quickChatOptions:a,onQuickChatSelect:o,isMobile:s,chatHistory:c,isAiTyping:l,isAgentTyping:u,activeScreen:d,agentName:f,agentHeadshot:p,fallbackAgentName:m,input:h,setInput:g,onSubmit:_,isConversationEnded:v,isLoading:y,isRateLimited:x,rateLimitMessage:ee,selectedFile:S,onFileSelect:C,onRemoveSelectedFile:te,attachmentError:w,isUploadingAttachment:ne,requiresEmail:re,emailInput:ie,setEmailInput:T,emailError:ae,emailCaptureSuccess:oe,replyContext:se,setReplyContext:ce,webRTCError:le,micError:E,setMicError:D,dismissCallError:ue,activeCallId:de,isCallMuted:fe,toggleCallMute:pe,endWebRTCCall:me,formatCallDuration:he,callDurationSeconds:ge,isCallMinimized:_e,onExpand:ve,onCollapse:ye,onStartVoice:be,voiceEnabled:xe,headerBgColor:Se,onNewChat:Ce,showPoweredBy:we,privacyPolicyUrl:Te,getVisitorChatHistory:Ee,resumeChat:De,isSessionRestoring:Oe,isClosing:ke}){let Ae=c.length>0,je=y||x||v,Me=!!de,[Ne,Pe]=(0,b.useState)(!1),[Fe,Ie]=(0,b.useState)(!1),[Le,Re]=(0,b.useState)([]),[ze,Be]=(0,b.useState)(!1),Ve=(0,b.useRef)(null),[He,Ue]=(0,b.useState)(()=>typeof window<`u`?window.visualViewport?.height??window.innerHeight:600),[We,Ge]=(0,b.useState)(0);(0,b.useEffect)(()=>{if(!s)return;let e=window.visualViewport;if(!e)return;let t=()=>{Ue(e.height),Ge(Math.max(0,window.innerHeight-e.offsetTop-e.height))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),t(),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[s]);let Ke=s&&window.innerHeight-He>150,qe=async()=>{Pe(!1),Ie(!0),Be(!0);try{let e=await Ee();e?.data&&Re(e.data)}catch(e){console.error(e)}finally{Be(!1)}},Je=async e=>{Ie(!1),De?.(e.chatId)};return(0,b.useEffect)(()=>{if(!Ne)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Ve.current&&!Ve.current.contains(t)&&Pe(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Ne]),(0,A.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,left:`8px`,right:`8px`,bottom:`${We}px`,height:He>0?`${Math.round(He*.92)}px`:`90dvh`,background:r,borderRadius:`16px 16px 0 0`,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:ke?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:`fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)`}:{"--flowengage-primary":n,"--flowengage-accent":n,width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,background:r,borderRadius:`22px`,boxShadow:`0 24px 64px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08)`,display:`flex`,flexDirection:`column`,overflow:`hidden`,position:`relative`,animation:ke?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:`fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`},children:[(0,A.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`40px minmax(0, 1fr) 40px`,alignItems:`center`,columnGap:`14px`,padding:`16px 10px 14px`,background:Se||`transparent`,flexShrink:0,position:`relative`,zIndex:30},children:[(0,A.jsx)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:(0,A.jsx)(`button`,{onClick:ye,style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},children:(0,A.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,A.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})})}),(()=>{let t=!!i,n=!!e.hasCustomTitle,r=t||n,a=t||!r,o=n||!r,c=a&&o;return(0,A.jsxs)(`div`,{style:{minWidth:0,maxWidth:s?`100%`:`250px`,width:`100%`,justifySelf:`center`,display:`grid`,gridTemplateColumns:c?`minmax(72px, 40%) minmax(0, 60%)`:`1fr`,columnGap:c?`12px`:0,alignItems:`center`,justifyItems:c?`stretch`:`center`},children:[a&&(0,A.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,A.jsx)(Sk,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,A.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,A.jsx)(Ck,{title:e.chatTitle})})}),o&&(0,A.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:c?`flex-start`:`center`},children:(0,A.jsx)(`span`,{style:{fontSize:`15px`,fontWeight:600,color:`#111827`,letterSpacing:`-0.01em`,lineHeight:1.2,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.chatTitle,children:e.chatTitle})})]})})(),(0,A.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:Ve,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>Pe(e=>!e),style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},"aria-label":`Chat options`,children:(0,A.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,A.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,A.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,A.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`})]})}),Ne&&(0,A.jsxs)(`div`,{style:{position:`absolute`,top:`34px`,right:0,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,overflow:`hidden`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,minWidth:`210px`,border:`1px solid rgba(255,255,255,0.07)`,animation:`fe-orb-fade-in 0.18s ease`},children:[xe&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{Pe(!1),be?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,A.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,A.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`}),(0,A.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]}),`Enter Voice Mode`]}),(0,A.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}})]}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{Pe(!1),Ce?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,A.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,A.jsx)(`path`,{d:`M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7`}),(0,A.jsx)(`path`,{d:`M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z`})]}),`Start new chat`]}),Ee&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,A.jsxs)(`button`,{type:`button`,onClick:qe,style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,A.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,A.jsx)(`path`,{d:`M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z`})}),`Chat history`]})]}),(0,A.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{Pe(!1),ye?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`#f87171`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(248,113,113,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,A.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,A.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,A.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,A.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]}),`Close conversation`]})]})]})]}),(0,A.jsx)(JD,{webRTCError:le,micError:E,setMicError:D,dismissCallError:ue,isRateLimited:x,rateLimitMessage:ee}),_e&&(0,A.jsx)(dO,{agentName:f,agentHeadshot:p,fallbackAgentName:m,callDurationSeconds:ge,isCallMuted:fe,formatCallDuration:he,toggleCallMute:pe,endWebRTCCall:me,onExpand:ve,primaryColor:n}),(0,A.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`,position:`relative`},children:[Fe?(0,A.jsxs)(`div`,{style:{position:`absolute`,inset:0,background:`white`,zIndex:20,display:`flex`,flexDirection:`column`,animation:`fe-orb-fade-in 0.2s ease`},children:[(0,A.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px`,borderBottom:`1px solid #f3f4f6`,flexShrink:0},children:(0,A.jsxs)(`button`,{onClick:()=>Ie(!1),style:{background:`none`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,color:`#6b7280`},children:[(0,A.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,A.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),(0,A.jsx)(`span`,{style:{marginLeft:`8px`,fontWeight:500,fontSize:`15px`},children:`Return to Chat`})]})}),(0,A.jsx)(`div`,{style:{flex:1,overflowY:`auto`,position:`relative`},children:ze?(0,A.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading past conversations...`}):Le.length>0?(0,A.jsx)(`div`,{children:Le.map(e=>(0,A.jsxs)(`div`,{onClick:()=>Je(e),style:{padding:`16px 20px`,borderBottom:`1px solid #f3f4f6`,cursor:`pointer`,transition:`background 0.15s ease`},onMouseEnter:e=>e.currentTarget.style.background=`#f9fafb`,onMouseLeave:e=>e.currentTarget.style.background=`white`,children:[(0,A.jsxs)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginBottom:`6px`,fontWeight:500},children:[new Date(e.createdAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),` at `,new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]}),(0,A.jsx)(`div`,{style:{fontSize:`14.5px`,color:`#111827`,opacity:.9,overflow:`hidden`,textOverflow:`ellipsis`,display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,lineHeight:1.4},children:e.message||`Conversation`})]},e.chatId))}):(0,A.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#9ca3af`,fontSize:`14px`},children:`No previous chats found.`})})]}):null,Ae?(0,A.jsx)(KD,{chatHistory:c,isAiTyping:l,isLoading:y,isAgentTyping:u,setReplyContext:ce,TypingDots:Ak,primaryColor:n,agentHeadshot:p,agentDisplayName:f||m,botAvatarNode:(0,A.jsx)(kk,{orbColors:t})}):Oe?(0,A.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`},children:[(0,A.jsx)(`div`,{style:{width:`28px`,height:`28px`,border:`3px solid #f3f4f6`,borderTop:`3px solid ${n}`,borderRadius:`50%`,animation:`spin 1s linear infinite`},children:(0,A.jsx)(`style`,{children:`@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }`})}),(0,A.jsx)(`div`,{style:{color:`#6b7280`,fontSize:`14px`,fontWeight:500,animation:`fe-orb-fade-in 1s infinite alternate`},children:`Loading chat...`})]}):(0,A.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`22px`,padding:`28px 24px`},children:[(0,A.jsx)(Tk,{size:94,orbColors:t}),(0,A.jsx)(`p`,{style:{margin:0,textAlign:`center`,fontSize:`16px`,color:`#374151`,lineHeight:1.55,maxWidth:`270px`},children:e.introGreeting}),a.length>0&&(0,A.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`8px`,justifyContent:`center`,width:`100%`,padding:`0 8px`},children:a.map(e=>(0,A.jsx)(`button`,{onClick:()=>o?.(e),style:{padding:`8px 16px`,borderRadius:`999px`,background:`white`,border:`1.5px solid ${n}33`,color:n||`#374151`,fontSize:`13px`,fontWeight:500,cursor:`pointer`,transition:`all 0.15s ease`,boxShadow:`0 1px 4px rgba(0,0,0,0.06)`},onMouseEnter:e=>{e.currentTarget.style.background=`${n}12`,e.currentTarget.style.borderColor=n},onMouseLeave:e=>{e.currentTarget.style.background=`white`,e.currentTarget.style.borderColor=`${n}33`},children:e.label||e.text},e.id))})]})]}),oe&&(0,A.jsxs)(`div`,{style:{margin:`0 16px 8px`,padding:`9px 14px`,borderRadius:`12px`,background:`#ecfdf5`,border:`1px solid #6ee7b7`,display:`flex`,alignItems:`center`,gap:`8px`,animation:`fe-orb-fade-in 0.2s ease`,flexShrink:0},children:[(0,A.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#10b981`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:(0,A.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),(0,A.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:`#065f46`},children:`Email saved — we'll be in touch!`})]}),(0,A.jsx)(`div`,{style:{background:`transparent`,flexShrink:0,position:`relative`,zIndex:1,padding:re?`6px 0 0`:`12px 0 0`},children:(0,A.jsx)(qD,{input:h,setInput:g,onSubmit:_,isConversationEnded:v,callUiActive:Me,handleToggleVoice:be,showVoiceToggle:d===`agent`,activeScreen:d,inputDisabled:je,replyContext:se,clearReplyContext:()=>ce(null),onFileSelect:C,selectedFile:S,onRemoveSelectedFile:te,attachmentError:w,isUploadingAttachment:ne,requiresEmail:re,emailInput:ie,setEmailInput:T,emailError:ae,inputPlaceholder:e.inputPlaceholder})}),!Ke&&(0,A.jsxs)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`8px 20px`,paddingBottom:`max(12px, env(safe-area-inset-bottom, 12px))`,pointerEvents:`none`},children:[Te&&(0,A.jsxs)(`p`,{style:{margin:`0 0 4px`,fontSize:`10px`,color:`#9ca3af`,lineHeight:1.4,userSelect:`none`,pointerEvents:`auto`},children:[`This conversation is recorded for quality assurance purposes.`,` `,(0,A.jsx)(`a`,{href:Te,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#6b7280`,textDecoration:`underline`},children:`See our privacy policy`})]}),we&&(0,A.jsxs)(`span`,{style:{fontSize:`11px`,color:`#9ca3af`,letterSpacing:`0.01em`,userSelect:`none`},children:[`Powered by `,(0,A.jsx)(`strong`,{style:{fontWeight:600,color:`#6b7280`},children:`FlowEngage`})]})]})]})}function Mk(){let{status:e,runtimeConfig:t,resolvedConfig:n,chatHistory:r,isOpen:i,activeScreen:a,isHumanHandled:o,agentName:s,agentHeadshot:c,visitorEmail:l,isAgentTyping:u,isAiTyping:d,isLoading:f,isRateLimited:p,rateLimitMessage:m,isConversationEnded:h,incomingCall:g,activeCallId:_,callConnectionState:v,callConnectedAt:y,isCallMuted:x,webRTCError:ee,language:S,chatId:C,historyRef:te,onMessageSync:w,sendMessage:ne,uploadChatFile:re,openWidget:ie,captureVisitorEmail:T,setVoiceMode:ae,endConversation:oe,startNewChat:se,acceptCall:ce,rejectCall:le,endWebRTCCall:ue,toggleCallMute:de,dismissCallError:fe,startTyping:pe,stopTyping:me,updateTypingDraft:he,getVisitorChatHistory:ge,resumeChat:_e,isSessionRestoring:ve,openToChatCounter:ye,voiceEndCounter:be}=In();(0,b.useEffect)(()=>{try{mr()}catch{}},[]),(0,b.useEffect)(()=>{ye&&st!==`voice_mode`&&st!==`text_chat`&&st!==`call_screen`&&(ae?.(!1),ct(`text_chat`))},[ye]);let xe=t?.widgetSettings||{},Se=n?.widgetSettings||{},Ce={...xe.branding||{},...Se.branding||{}},we={...xe.theme||{},...Se.theme||{}},Te={...xe.features||{},...Se.features||{}},Ee=Te.voice!==!1,ke=Array.isArray(we.orbColors)&&we.orbColors.length>0?we.orbColors:null,Ae=we.buttonColor||we.primaryColor||ke?.[0]||`#3B82F6`,Me={small:50,medium:64,large:80},Ne=Me[we.orbSize]||Me.small,Fe=we.position||`bottom-right`,Ie=Ce.fallbackAgentName||`Agent`,Le=yk(ke??we.chatBgColors),Re=Ce.logo||Ce.logoUrl||null,ze=S||`en`,Be=xe.recommendations?.[ze]||[],Ve=(Se.recommendations?.[ze]??Be).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),He=Array.isArray(Ce.quickChatOptions)&&Ce.quickChatOptions.length>0?Ce.quickChatOptions:Ve,Ue=Ce.hideWatermark===!0?!1:Ce.showPoweredBy!==!1,We=Ce.headerBgColor||null,Ge=we.bottomPosition==null?`1.5rem`:`${we.bottomPosition}px`,Ke=Ce.privacyPolicyUrl||null,qe=Ce.chatbotEnabled!==!1&&we.chatbotEnabled!==!1,[Je,Ye]=(0,b.useState)(()=>typeof window<`u`?window.location.pathname:`/`);(0,b.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>Ye(window.location.pathname),t=window.history.pushState.bind(window.history);return window.history.pushState=(...n)=>{t(...n),setTimeout(e,50)},window.addEventListener(`popstate`,e),()=>{window.history.pushState=t,window.removeEventListener(`popstate`,e)}},[]);let Xe=(()=>{let e={...xe.pageVisibility||{},...Se.pageVisibility||{}};return Array.isArray(e.allowedPaths)?e.allowedPaths.filter(Boolean):[]})(),Ze=Xe.length===0||Xe.some(e=>e===`*`||e===`/*`?!0:e.endsWith(`/*`)?Je.startsWith(e.slice(0,-1)):Je.replace(/\/$/,``)===e.replace(/\/$/,``)),Qe=xe.greetings?.[S]||Se.greetings?.[S]||Ce.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,$e={entryPrompt:Ce.entryPrompt||`Do you want to explore in a new way?`,yesLabel:Ce.yesLabel||`Yes`,laterLabel:Ce.laterLabel||`Later`,connectionTitle:Ce.connectionTitle||`How would you like to connect?`,voiceLabel:Ce.voiceLabel||`Voice`,textLabel:Ce.textLabel||`Text`,chatTitle:Ce.headerName||`Chat with FlowEngage`,hasCustomTitle:!!(Ce.headerName&&String(Ce.headerName).trim()),introGreeting:Qe,inputPlaceholder:Ce.inputPlaceholder||`Type your message`,analysingLabel:Ce.analysingLabel||`analysing...`},et=Se.elevenLabsAgentId||t?.elevenLabsAgentId||null,tt=t?.siteId||n?.siteId||null,O=t?.apiBaseUrl||``;(0,b.useEffect)(()=>{er(t?.siteType||null)},[t?.siteType]);let nt=(0,b.useMemo)(()=>s&&String(s).trim()||t?.ownerName&&String(t.ownerName).trim()||t?.websiteName&&String(t.websiteName).trim()||`Agent`,[s,t?.ownerName,t?.websiteName]),rt=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,it=r.some(e=>e.sender===`user`),at=(0,b.useMemo)(()=>{let e=r.findIndex(e=>e.sender===`user`);return e===-1?!1:r.slice(e+1).some(e=>e.sender===`bot`||e.sender===`ai`||e.sender===`agent`)},[r]),ot=!!(Se._dashboardLivePreview||xe._dashboardLivePreview),[st,ct]=(0,b.useState)(()=>ot?`text_chat`:`entry_prompt`),[lt,ut]=(0,b.useState)(``),[dt,ft]=(0,b.useState)(null),[pt,mt]=(0,b.useState)(l||``),[ht,gt]=(0,b.useState)(``),[_t,vt]=(0,b.useState)(!1),[yt,bt]=(0,b.useState)(0),[xt,St]=(0,b.useState)(null),[Ct,wt]=(0,b.useState)(null),[Tt,Et]=(0,b.useState)(``),[Dt,Ot]=(0,b.useState)(!1),[kt,At]=(0,b.useState)(!1),[jt,Mt]=(0,b.useState)(!1),Nt=(0,b.useRef)(null),Pt=(0,b.useRef)(!1),Ft=!l&&it&&at&&st!==`voice_mode`;(0,b.useLayoutEffect)(()=>{if(e!==`ready`||Pt.current)return;if(Pt.current=!0,!Ee){ct(`minimized_orb`);return}let t=!1;try{t=Er().shouldResumeVoice}catch{}let n=je(),r=tt?De(tt):null,i=n||!!r?.transcript;if(t){ie?.({notifyChatInitiated:!0}),ae?.(!0),ct(`voice_mode`);return}if(Pe()){ie?.({notifyChatInitiated:!1}),ct(`text_chat`);return}if(i){if((typeof performance<`u`?performance.getEntriesByType?.(`navigation`)?.[0]?.type??`navigate`:`navigate`)===`reload`){ct(`minimized_orb`);return}ie?.({notifyChatInitiated:!0}),ae?.(!0),ct(`voice_mode`);return}if(tt)try{Oe(tt)}catch{}if(E(tt)){ct(`minimized_orb`);return}},[e,r]);let[It,Lt]=(0,b.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,b.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>Lt(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,b.useEffect)(()=>{mt(l||``),l&>(``)},[l]);let Rt=(0,b.useCallback)(()=>{wt(null),Et(``)},[]),zt=(0,b.useCallback)(e=>{let t=VD(e);if(t){wt(null),Et(t);return}wt(e),Et(``)},[]);(0,b.useEffect)(()=>{if(!y||v!==`connected`){bt(0);return}let e=()=>{let e=new Date(y).getTime();isNaN(e)||bt(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[y,v]);let Bt=(0,b.useCallback)(()=>{ct(`call_screen`),At(!1)},[]),Vt=(0,b.useCallback)(()=>{ct(`text_chat`),At(!0)},[]);(0,b.useEffect)(()=>{let e=g?.callId||_||null;if(!e){Nt.current=null;return}if(g?.callId||v===`connecting`||v===`connected`){if(st===`minimized_orb`&&kt&&_&&!g?.callId){Nt.current=e;return}!(!i||st===`minimized_orb`||st===`voice_mode`)&&Nt.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:st,hasIncomingCall:!!g?.callId,activeCallId:_,callConnectionState:v}),Nt.current=e,st===`voice_mode`&&ae?.(!1),ie?.(),Bt())}},[_,v,Bt,g?.callId,i,ie,ae,st]),(0,b.useEffect)(()=>{!g&&!_&&st===`call_screen`&&ct(`text_chat`)},[g,_,st]),(0,b.useEffect)(()=>{!_&&kt&&At(!1)},[_,kt]),(0,b.useEffect)(()=>{if(!o||h){he?.(``),me?.();return}if(!lt.trim()||Ct){he?.(``);let e=window.setTimeout(()=>me?.(),100);return()=>window.clearTimeout(e)}pe?.();let e=window.setTimeout(()=>he?.(lt),120),t=window.setTimeout(()=>me?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[lt,Ct,o,h,pe,me,he]);let Ht=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,Ut=async e=>{if(e.preventDefault(),h)return;if(Ft){let e=pt.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){gt(`Please enter a valid email so we can continue helping you.`);return}await T(e),gt(``),vt(!0),setTimeout(()=>vt(!1),3e3);return}let t=Ht(dt);if(!lt.trim()&&!Ct)return;if(Ct){try{Ot(!0),Et(``);let e=await re(Ct),n=e?.data||e,r=lt.trim()||`Shared file: ${UD(Ct)}`;ut(``),ft(null),Rt(),await ne(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||Ct.name,fileType:n?.fileType||Ct.type,fileSize:n?.fileSize||Ct.size}})}catch(e){Et(e?.message||`Failed to upload the selected file.`)}finally{Ot(!1)}return}let n=lt.trim();ut(``),ft(null),await ne(n,``,t)},Wt=(0,b.useCallback)(()=>{r.length!==0&&se?.()},[r.length,se]),Gt=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},Kt=(0,b.useCallback)(async e=>{if(h||f)return;let t=e.message||e.label||e.text||``;t.trim()&&await ne(t.trim(),``)},[h,f,ne]),qt=It&&st===`entry_prompt`?{inset:0}:It&&st===`text_chat`?{left:0,right:0,bottom:0}:It&&st===`call_screen`?{left:0,right:0,bottom:0,height:`90dvh`,overflow:`hidden`,borderRadius:`16px 16px 0 0`}:It&&st===`connection_modal`?{left:`12px`,right:`12px`,bottom:`12px`}:st===`call_screen`?{width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,borderRadius:`22px`,overflow:`hidden`,...Fe===`bottom-left`?{left:`1.5rem`,bottom:Ge}:{right:`1.5rem`,bottom:Ge}}:Fe===`bottom-left`?{left:`1.5rem`,bottom:Ge}:{right:`1.5rem`,bottom:Ge},Jt=(0,b.useCallback)(()=>{st!==`minimized_orb`&&(Mt(!0),setTimeout(()=>{ct(`minimized_orb`),Mt(!1),_&&At(!0)},280))},[_,st]),Yt=()=>ct(`connection_modal`),Xt=()=>{try{let e=window.AudioContext||window.webkitAudioContext;if(e){let t=new e;t.resume().catch(()=>{}),setTimeout(()=>t.close().catch(()=>{}),3e3)}}catch{}ie({notifyChatInitiated:!0}),ae?.(!0),ct(`voice_mode`)},Zt=()=>{ie({notifyChatInitiated:!0}),ae?.(!1),ct(`text_chat`)},Qt=()=>{ae?.(!1),Jt()};return e!==`ready`||!qe||Te.chat===!1||!Ze?null:(0,A.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...qt},onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[st===`entry_prompt`&&(0,A.jsx)(Ek,{copy:$e,orbColors:ke,primaryColor:Ae,onYes:()=>{D(tt),Xt()},onLater:()=>{D(tt),Jt()},isMobile:It,isClosing:jt}),st===`minimized_orb`&&(0,A.jsxs)(gm.div,{layoutId:`fe-main-orb`,initial:{scale:.4,opacity:0},animate:{scale:1,opacity:1},transition:{type:`spring`,stiffness:280,damping:18},style:{transformOrigin:`bottom right`,display:`inline-flex`,flexDirection:`column`,alignItems:Fe===`bottom-left`?`flex-start`:`flex-end`,gap:`10px`},children:[_&&(0,A.jsxs)(`button`,{type:`button`,onClick:Bt,style:{maxWidth:It?`220px`:`240px`,padding:`10px 14px`,borderRadius:`18px`,border:`1px solid rgba(255,255,255,0.7)`,background:`rgba(255,255,255,0.94)`,backdropFilter:`blur(18px)`,WebkitBackdropFilter:`blur(18px)`,boxShadow:`0 10px 26px rgba(15,23,42,0.14)`,display:`flex`,alignItems:`center`,gap:`10px`,cursor:`pointer`,textAlign:`left`},children:[(0,A.jsx)(`span`,{style:{width:`9px`,height:`9px`,borderRadius:`50%`,background:`#22c55e`,boxShadow:`0 0 0 4px rgba(34,197,94,0.16)`,flexShrink:0}}),(0,A.jsxs)(`span`,{style:{minWidth:0},children:[(0,A.jsx)(`span`,{style:{display:`block`,fontSize:`12px`,fontWeight:700,color:`#111827`,lineHeight:1.2},children:v===`connected`?`Call in progress`:`Call is active`}),(0,A.jsx)(`span`,{style:{display:`block`,fontSize:`11px`,color:`#6b7280`,lineHeight:1.3,marginTop:`2px`,whiteSpace:`nowrap`},children:v===`connected`?`${Gt(yt)} with ${nt}`:`Tap to return to ${nt}`})]})]}),(0,A.jsx)(Tk,{size:Ne,orbColors:ke,onClick:_?Bt:Ee?Yt:Zt})]}),st===`connection_modal`&&(0,A.jsx)(Dk,{copy:$e,orbColors:ke,primaryColor:Ae,onVoice:Xt,onText:Zt,onClose:Jt,isMobile:It,isClosing:jt}),st===`voice_mode`&&(0,A.jsx)(Ok,{orbColors:ke,onEnterChat:Zt,onEndChat:Qt,agentId:et,siteId:tt,apiBaseUrl:O,chatId:C,historyRef:te,onMessageSync:w,voiceEndCounter:be,websiteName:t?.websiteName},`voice`),st===`call_screen`&&(0,A.jsx)(uO,{incomingCall:g,activeCallId:_,callConnectionState:v,callDurationSeconds:yt,isCallMuted:x,agentName:nt,agentHeadshot:rt,fallbackAgentName:Ie,acceptCall:ce,rejectCall:le,endWebRTCCall:ue,toggleCallMute:de,formatCallDuration:Gt,onMinimize:Vt,primaryColor:Ae,orbColors:ke,chatHistory:r}),st===`text_chat`&&(0,A.jsx)(jk,{isClosing:jt,copy:$e,orbColors:ke,primaryColor:Ae,chatBgGradient:Le,logo:Re,quickChatOptions:He,onQuickChatSelect:Kt,isMobile:It,chatHistory:r,isAiTyping:d,isAgentTyping:u,activeScreen:a,agentName:nt,agentHeadshot:rt,fallbackAgentName:Ie,input:lt,setInput:ut,onSubmit:Ut,isConversationEnded:h,isLoading:f,isRateLimited:p,rateLimitMessage:m,selectedFile:Ct,onFileSelect:zt,onRemoveSelectedFile:Rt,attachmentError:Tt,isUploadingAttachment:Dt,requiresEmail:Ft,emailInput:pt,setEmailInput:mt,emailError:ht,emailCaptureSuccess:_t,replyContext:dt,setReplyContext:ft,webRTCError:ee,micError:xt,setMicError:St,dismissCallError:fe,activeCallId:_,isCallMuted:x,toggleCallMute:de,endWebRTCCall:ue,formatCallDuration:Gt,callDurationSeconds:yt,onCollapse:Jt,onStartVoice:Xt,voiceEnabled:Ee,onNewChat:Wt,onMinimize:Vt,onExpand:Bt,isCallMinimized:!!_,showPoweredBy:Ue,privacyPolicyUrl:Ke,headerBgColor:We,getVisitorChatHistory:ge,resumeChat:_e,isSessionRestoring:ve}),(0,A.jsx)(`style`,{children:`
|
|
652
652
|
/* Force any SVG (or img) inside LogoSlot to fill the container height
|
|
653
653
|
regardless of whether the component forwards its style prop. */
|
|
654
654
|
.fe-logo-slot svg,
|