mind-link-ai-widget
Version:
A react widget for React Web and React-Native Mobile integrations.
10 lines (9 loc) • 21.3 kB
JavaScript
(function(i,b){typeof exports=="object"&&typeof module<"u"?module.exports=b(require("react"),require("react-icons/io5")):typeof define=="function"&&define.amd?define(["react","react-icons/io5"],b):(i=typeof globalThis<"u"?globalThis:i||self,i.BehiveWidget=b(i.React,i.io5))})(this,(function(i,b){"use strict";var z={exports:{}},D={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var $;function me(){if($)return D;$=1;var n=i,a=Symbol.for("react.element"),d=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,N=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,I={key:!0,ref:!0,__self:!0,__source:!0};function w(v,c,f){var p,y={},x=null,o=null;f!==void 0&&(x=""+f),c.key!==void 0&&(x=""+c.key),c.ref!==void 0&&(o=c.ref);for(p in c)r.call(c,p)&&!I.hasOwnProperty(p)&&(y[p]=c[p]);if(v&&v.defaultProps)for(p in c=v.defaultProps,c)y[p]===void 0&&(y[p]=c[p]);return{$$typeof:a,type:v,key:x,ref:o,props:y,_owner:N.current}}return D.Fragment=d,D.jsx=w,D.jsxs=w,D}var ee;function pe(){return ee||(ee=1,z.exports=me()),z.exports}var e=pe();const j=[];for(let n=0;n<256;++n)j.push((n+256).toString(16).slice(1));function fe(n,a=0){return(j[n[a+0]]+j[n[a+1]]+j[n[a+2]]+j[n[a+3]]+"-"+j[n[a+4]]+j[n[a+5]]+"-"+j[n[a+6]]+j[n[a+7]]+"-"+j[n[a+8]]+j[n[a+9]]+"-"+j[n[a+10]]+j[n[a+11]]+j[n[a+12]]+j[n[a+13]]+j[n[a+14]]+j[n[a+15]]).toLowerCase()}let B;const xe=new Uint8Array(16);function be(){if(!B){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");B=crypto.getRandomValues.bind(crypto)}return B(xe)}const te={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ge(n,a,d){if(te.randomUUID&&!n)return te.randomUUID();n=n||{};const r=n.random??n.rng?.()??be();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,fe(r)}const je=k();function k(){return ge()}function we(){const n=new Date().getHours();return n<12?"Good Morning":n<18?"Good Afternoon":"Good Evening"}function V(n,a=1){return n.slice().sort(()=>.5-Math.random()).slice(0,a)}function Ne(n){const a=n.replace(/\D/g,"");return a.length===10?`(${a.slice(0,3)}) ${a.slice(3,6)}-${a.slice(6)}`:a.length===11&&a.startsWith("1")?`+1 (${a.slice(1,4)}) ${a.slice(4,7)}-${a.slice(7)}`:n}function ne(n){return n.replace(/\w\S*/g,a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase())}const H="https://uat.api-az.carelonhealth.com/mindlink/api/v1",F="carelon-bh-mobile",X="2f8c1e7a-4b3d-4e2a-9c6a-8a1f7b2c5d9e";async function ve(n,a){const d=`${H}/behive/intents-and-entities`,r=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${n}`,apikey:X,"sender-app":F,"Content-Type":"application/json",accept:"application/json","x-csid":je},body:JSON.stringify({query:a})});if(!r.ok)throw new Error("Network error");return r.json()}async function se(n,a){const d=`${H}/behive/crediblemind/suggest`,r=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${n}`,apikey:X,"sender-app":F,"Content-Type":"application/json",accept:"application/json"},body:JSON.stringify({query:a})});if(!r.ok)throw new Error("Network error");return r.json()}async function ye(n,a){const d=`${H}/behive/providers/search`,r=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${n}`,apikey:X,"sender-app":F,"Content-Type":"application/json",accept:"application/json"},body:JSON.stringify(a)});if(!r.ok)throw new Error("Network error");return r.json()}const Se=({children:n,className:a})=>e.jsx("span",{className:a,onClick:()=>console.warn("Navigation not supported"),children:n}),ae="var(--carelon-purple)",J=(n=new Date)=>n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),Ie=({showGreeting:n,onStartChat:a,chipToSend:d,onChipSent:r,chips:N=[],selectedChipIdx:I=null,handleChipClick:w,token:v})=>{const[c,f]=i.useState([]),[p,y]=i.useState(""),[x,o]=i.useState(!1),[t,h]=i.useState(!1),[S,l]=i.useState(!1),[_,L]=i.useState(!1),[g,Y]=i.useState([]),[W,G]=i.useState(null),[K,Re]=i.useState([]),[ie,ce]=i.useState(!0),oe=30,Q=i.useRef(null),Ee=i.useRef(null),le=i.useRef(null),re=i.useRef(null),Z=i.useRef(null),O=async s=>{if(!(s||p.trim())||x)return;n&&a(),L(!0);const u=s||p,M={id:k()+"-user",sender:"user",text:u,timestamp:new Date};f(m=>[...m,M]),y(""),o(!0),ce(!0);try{Ee.current=le.current,re.current=Z.current;const m=await ve(v,M.text);le.current=m.intent,Z.current=m.slots.specialty;const R=m?.slots_fulfillment?.status??!0;ce(R);const P=m?.followup?.prompt??null,U=m?.followup?.options??[];Re(U);const ue=m.smalltalk,q=m.hybridtalk;if(R&&m.intent!=="provider_search_intent"&&f(C=>[...C,{id:k()+"-bot-smalltalk",sender:"bot",text:ue||q,timestamp:new Date}]),R&&m.intent==="health_content_intent"&&m.slots.content_query){const C=await se(v,m.slots.content_query);C?.crediblemind?.length?f(A=>[...A,{id:k()+"-bot-healthcontent-richinfo",sender:"bot",crediblemind:C.crediblemind,timestamp:new Date}]):f(A=>[...A,{id:k()+"-bot-smalltalk",sender:"bot",text:"Sorry! There are no health content suggestions for your query.",timestamp:new Date}])}else if(R&&m.intent==="provider_search_intent"){let C=null;re.current!==Z.current&&(C=await se(v,m.query)),C?.crediblemind?.length?f(E=>[...E,{id:k()+"-bot-healthcontent-richinfo-with-text",sender:"bot",text:q,crediblemind:C.crediblemind,timestamp:new Date}]):f(E=>[...E,{id:k()+"-bot-smalltalk",sender:"bot",text:ue||q,timestamp:new Date}]);const A=await ye(v,{gender:m.slots.gender,specialty:m.slots.specialty,provider_type:m.slots.provider_type,location:m.slots.location,language:m.slots.language});A?.providers?.length?f(E=>[...E,{id:k()+"-bot-providersearch-richinfo",sender:"bot",providers:A.providers,timestamp:new Date}]):f(E=>[...E,{id:k()+"-bot-smalltalk",sender:"bot",text:"Sorry! There are no providers available for your search criteria.",timestamp:new Date}])}f(C=>[...C,{id:k()+"-bot-followup",sender:"bot",text:P||void 0,timestamp:new Date}])}catch{f(m=>[...m,{id:k()+"-bot-smalltalk",sender:"bot",text:"Sorry! There was a problem interacting with my system. Please try again in a while.",timestamp:new Date}])}finally{o(!1)}};i.useEffect(()=>{Q.current?.scrollIntoView({behavior:"smooth"})},[c,x]),i.useEffect(()=>{d&&!_&&(O(d),L(!0),n&&a(),typeof r=="function"&&r())},[d]);const[de,he]=i.useState(!1);i.useEffect(()=>{if(!de){if(!n&&c.length>g.length){const s=c[g.length];if(s.sender==="bot"){let u="",M=0;he(!0);const m=typeof s.text=="string"?s.text:"",R=()=>{m&&M<m.length?(u+=m[M],Y(P=>{const U=[...P];return U[U.length-1]={...s,text:u},U}),M++,setTimeout(R,oe)):he(!1)};Y(P=>[...P,{...s,text:""}]),setTimeout(R,oe)}else Y(u=>[...u,s])}Q.current?.scrollIntoView({behavior:"smooth"})}},[c,n,g,g.length,de]);const Te=i.useMemo(()=>"John!",[]),Me=i.useMemo(()=>V(["Hi","Hey","Hello",we()]),[]),Ae=i.useMemo(()=>V(["How can I help you today?","What can I do for you today?"]),[]),De=(()=>{if(!K||K.length===0||g.length===0)return!1;const s=g[g.length-1];return s.sender==="bot"&&s.id.includes("-bot-followup")&&s.text&&c.length===g.length&&c[c.length-1].id===s.id&&c[c.length-1].text===s.text})();return e.jsxs("div",{className:"chat",children:[!W&&e.jsxs("div",{className:"chat-area",children:[e.jsx("div",{className:"chat-header"}),e.jsxs("div",{className:"chat-body",children:[!n&&e.jsx("div",{className:"chat-conversations",children:!n&&!W&&e.jsxs("div",{className:"chat-messages",children:[g.map((s,u)=>e.jsx(i.Fragment,{children:e.jsxs("div",{className:s.sender==="user"?"chat-user-msg":"chat-bot-msg",children:[s.text&&e.jsxs("div",{className:"message-content",children:[e.jsx("div",{className:"message-text",children:s.text}),s.timestamp&&(!s.id.includes("-bot-")||c.length>u&&g.length>u&&c[u].id===s.id&&c[u].text===s.text&&g[u].text===s.text)&&e.jsx("div",{className:"message-timestamp",children:J(new Date(s.timestamp))})]}),ie&&s.crediblemind&&Array.isArray(s.crediblemind)&&s.crediblemind.length>0&&(!s.id.includes("-bot-smalltalk")&&!s.id.includes("-bot-healthcontent-richinfo-with-text")||c.length>u&&g.length>u&&c[u].id===s.id&&c[u].text===s.text&&g[u].text===s.text)&&e.jsxs("div",{className:"crediblemind-cards",children:[e.jsx("div",{className:"cards-header",children:e.jsx("div",{className:"cards-title",children:"📚 Helpful Resources"})}),e.jsx(ke,{items:s.crediblemind,onItemClick:G}),s.timestamp&&e.jsx("div",{className:"message-timestamp message-timestamp-cards",children:J(new Date(s.timestamp))})]}),ie&&s.providers&&Array.isArray(s.providers)&&s.providers.length>0&&(!s.id.includes("-bot-smalltalk")&&!s.id.includes("-bot-healthcontent-richinfo")&&!s.id.includes("-bot-healthcontent-richinfo-with-text")||c.length>u&&g.length>u&&c[u].id===s.id&&c[u].text===s.text&&g[u].text===s.text)&&e.jsxs("div",{className:"provider-cards",children:[e.jsx("div",{className:"cards-header",children:e.jsx("div",{className:"cards-title",children:"👩⚕️ Healthcare Providers"})}),e.jsx(Ce,{providers:s.providers,setIframeUrl:G}),s.timestamp&&e.jsx("div",{className:"message-timestamp message-timestamp-cards",children:J(new Date(s.timestamp))})]})]})},s.id+"-"+u)),De&&e.jsx("div",{className:"chat-suggestion-options",children:e.jsx("div",{className:"followup-suggestion-chips",children:K.map(s=>e.jsx("button",{className:"followup-suggestion-chip",tabIndex:0,onClick:()=>O(s),children:s},s))})}),x&&e.jsxs("div",{className:"chat-bot-msg loading",children:[e.jsx("span",{className:"loader-dot",children:"•"}),e.jsx("span",{className:"loader-dot",children:"•"}),e.jsx("span",{className:"loader-dot",children:"•"})]}),e.jsx("div",{ref:Q})]})}),n&&e.jsxs("div",{className:"chat-greeting-chips",children:[e.jsxs("div",{className:"chat-greeting",children:[e.jsxs("div",{className:"greeting-main",children:[Me,",",e.jsx("span",{className:"greeting-name",children:Te})]}),e.jsx("div",{className:"greeting-sub",children:Ae})]}),e.jsx("div",{className:"chat-suggestion-chips chat-main-chips",children:e.jsx("div",{className:"suggestion-chips",children:N.map((s,u)=>e.jsx("button",{className:`suggestion-chip${I===u?" selected":""}`,tabIndex:0,onClick:()=>w&&w(u),children:s},s))})})]})]}),e.jsx("div",{className:"chat-footer",children:e.jsxs("div",{className:"chat-actions",children:[e.jsxs("div",{className:"chat-input-row",children:[e.jsx("input",{className:"chat-input",type:"text",placeholder:"Ask anything",value:p,onChange:s=>y(s.target.value),onKeyDown:s=>{s.key==="Enter"&&O()},disabled:x,"aria-label":"Type your message"}),e.jsx("button",{className:"chat-mic-btn","aria-label":"Voice input",onClick:()=>{l(!0),h(!1)},disabled:x||n&&!d,children:e.jsx(b.IoMic,{className:"chat-footer-icon"})}),e.jsx("button",{className:"chat-send-btn",onClick:()=>O(),disabled:x||!p.trim()&&n&&!d,"aria-label":"Send message",children:e.jsx(b.IoArrowUp,{className:"chat-footer-icon"})})]}),S&&e.jsx("div",{className:"chat-popup-overlay",tabIndex:-1,"aria-modal":"true",role:"dialog",children:e.jsxs("div",{className:"chat-popup-modal",children:[e.jsx("button",{className:"chat-popup-close",onClick:()=>{l(!1),typeof window.onChatBack=="function"&&window.onChatBack()},"aria-label":"Close",children:"×"}),e.jsx("div",{className:"chat-popup-icon animate-mic",children:e.jsx(b.IoMic,{size:36,color:ae})}),e.jsx("div",{className:"chat-popup-title",children:"Listening..."}),e.jsx("div",{className:"chat-popup-desc",children:"Speak your query and we'll convert it to text. (Animation here)"})]})}),t&&e.jsx("div",{className:"chat-popup-overlay",tabIndex:-1,"aria-modal":"true",role:"dialog",children:e.jsxs("div",{className:"chat-popup-modal",children:[e.jsx("button",{className:"chat-popup-close",onClick:()=>{h(!1),typeof window.onChatBack=="function"&&window.onChatBack()},"aria-label":"Close",children:"×"}),e.jsx("div",{className:"chat-popup-icon animate-attachment",children:e.jsx(b.IoAttach,{size:36,color:ae})}),e.jsx("div",{className:"chat-popup-title",children:"Upload a file or image"}),e.jsx("input",{type:"file",className:"chat-popup-file"}),e.jsx("div",{className:"chat-popup-desc",children:"Choose a file or image to upload. (Animation here)"})]})})]})})]}),e.jsx("div",{className:"chat-ext-links-iframe",children:W&&e.jsx("div",{className:"iframe-modal-overlay",children:e.jsxs("div",{className:"iframe-modal",children:[e.jsx("button",{className:"iframe-modal-close",onClick:()=>{G(null),typeof window.onChatBack=="function"&&window.onChatBack()},children:e.jsx(b.IoClose,{})}),e.jsx("iframe",{src:W,title:"External Content",style:{width:"100%",height:"100vh",border:"none"}})]})})})]})};function ke({items:n,onItemClick:a}){const[d,r]=i.useState(0),[N,I]=i.useState(window.innerWidth<=768),w=i.useRef(null);i.useEffect(()=>{const o=()=>I(window.innerWidth<=768);return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]);const c=(()=>{if(N)return 1;const o=window.innerWidth*.8,h=Math.floor(o/288);return Math.min(h,n.length)})(),f=N?n.length:c>=n.length?1:Math.ceil(n.length/c),p=o=>r(Math.min(o,f-1)),y=i.useRef(0),x=o=>{const t=y.current-o;Math.abs(t)>50&&(t>0&&d<f-1?r(h=>h+1):t<0&&d>0&&r(h=>h-1))};return e.jsxs("div",{className:"cards-carousel",children:[e.jsx("div",{className:"carousel-container",ref:w,onTouchStart:o=>y.current=o.touches[0].clientX,onTouchEnd:o=>x(o.changedTouches[0].clientX),onMouseDown:o=>y.current=o.clientX,onMouseUp:o=>x(o.clientX),children:e.jsx("div",{className:"carousel-track",style:{transform:`translateX(-${d*(N?100:c>=n.length?0:100/c)}%)`},children:n.map(o=>{const t=o.content_type==="Video";return e.jsx("div",{className:"carousel-item",children:e.jsxs("a",{href:o.content_url,className:"crediblemind-card",onClick:h=>{h.preventDefault(),a(o.content_url)},children:[e.jsxs("div",{className:"card-image",children:[e.jsx("img",{src:`${o.image_url}`,alt:""}),e.jsx("div",{className:"card-type-badge",children:o.content_type})]}),e.jsxs("div",{className:`card-content card-content-${o.content_type.toLowerCase()}`,children:[e.jsx("h4",{className:"card-title",children:o.title}),e.jsx("div",{className:"card-action",children:e.jsxs("span",{className:"action-text",children:[t?"Watch":"Read"," →"]})})]})]})},o.entry_id)})})}),f>1&&e.jsx("div",{className:"carousel-indicators",children:Array.from({length:f},(o,t)=>e.jsx("button",{className:`carousel-indicator ${t===d?"active":""}`,onClick:()=>p(t)},t))})]})}function Ce({providers:n,setIframeUrl:a}){const[d,r]=i.useState(0),[N,I]=i.useState(window.innerWidth<=768),[w,v]=i.useState(1),c=i.useRef(null),f=i.useCallback(()=>{if(window.innerWidth<=768)return 1;const t=window.innerWidth*.8,S=Math.floor(t/312);return Math.max(1,Math.min(S,n.length))},[n.length]);i.useEffect(()=>{const t=()=>{I(window.innerWidth<=768),v(f())};return v(f()),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[f]),i.useEffect(()=>{const t=()=>{if(c.current){const S=c.current.querySelectorAll(".provider-card");S.forEach(_=>_.style.height="auto");const l=Math.max(...Array.from(S).map(_=>_.scrollHeight));S.forEach(_=>_.style.height=`${l}px`)}},h=setTimeout(t,100);return window.addEventListener("resize",t),()=>{clearTimeout(h),window.removeEventListener("resize",t)}},[n]);const p=N?n.length:w>=n.length?1:Math.ceil(n.length/w),y=t=>r(Math.min(t,p-1)),x=i.useRef(0),o=t=>{const h=x.current-t;Math.abs(h)>50&&(h>0&&d<p-1?r(S=>S+1):h<0&&d>0&&r(S=>S-1))};return e.jsxs("div",{className:"provider-carousel",children:[e.jsx("div",{className:"carousel-container",ref:c,onTouchStart:t=>x.current=t.touches[0].clientX,onTouchEnd:t=>o(t.changedTouches[0].clientX),onMouseDown:t=>x.current=t.clientX,onMouseUp:t=>o(t.clientX),children:e.jsx("div",{className:"carousel-track",style:{transform:`translateX(-${d*(N?100:w>=n.length?0:100/w)}%)`},children:n.map((t,h)=>{const S=`${t.name.firstName?.[0]||""}${t.name.lastName?.[0]||""}`.toUpperCase();return e.jsx("div",{className:"carousel-item",children:e.jsxs("div",{className:"provider-card",children:[e.jsxs("div",{className:"provider-header-horizontal",children:[e.jsx("span",{className:"provider-logo-circle fixed-width-span",children:S}),e.jsxs("span",{className:"provider-name",children:[t.name.firstName," ",t.name.lastName]}),e.jsx("span",{className:"provider-title right-align",children:t.title})]}),e.jsxs("div",{className:"provider-details",children:[e.jsxs("div",{className:"provider-address",children:[e.jsxs("span",{className:"provider-icon address-icon",children:[e.jsx(b.IoLocationSharp,{})," "]}),e.jsxs("span",{className:"provider-link",onClick:()=>{const l=`${t.contact.address.addr1}, ${t.contact.address.city}, ${t.contact.address.state} ${t.contact.address.zip}`;window.open(`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(l)}`,"_blank")},children:[t.contact.address.addr1,", ",t.contact.address.city,", ",t.contact.address.state," ",t.contact.address.zip]})]}),e.jsxs("div",{className:"provider-contact",children:[t.contact.phone&&t.contact.phone!=="Not Available"&&e.jsxs("span",{children:[e.jsx(b.IoCall,{className:"provider-icon"}),e.jsx("a",{href:`tel:${t.contact.phone}`,target:"_blank",rel:"noopener noreferrer",className:"provider-link",children:Ne(t.contact.phone)})]}),t.contact.officeEmail&&t.contact.officeEmail!=="Not Available"&&e.jsxs("span",{children:[e.jsx(b.IoMail,{className:"provider-icon"}),e.jsx("a",{href:`mailto:${t.contact.officeEmail}`,className:"provider-link-blank",children:t.contact.officeEmail})]}),t.contact.website&&t.contact.website!=="Not Available"&&(t.contact.website.startsWith("/")?e.jsx(Se,{to:t.contact.website,className:"provider-link-blank",children:t.contact.website}):e.jsxs("span",{children:[e.jsx(b.IoGlobe,{className:"provider-icon"}),e.jsx("a",{href:t.contact.website.startsWith("http")?t.contact.website:`https://${t.contact.website}`,className:"provider-link-blank",onClick:l=>{l.preventDefault(),a(t.contact.website.startsWith("http")?t.contact.website:`https://${t.contact.website}`)},children:t.contact.website})]}))]}),t.languages&&t.languages.length>0&&e.jsxs("div",{className:"provider-languages",children:[e.jsx("span",{className:"provider-icon",children:e.jsx(b.IoLanguage,{})}),t.languages.map(l=>ne(l)).join(", ")]}),t.yellowLabels&&t.yellowLabels.length>0&&e.jsx("div",{className:"provider-labels",children:t.yellowLabels.filter(l=>!l.notAvailable).map(l=>l.icon==="accepting-new-patients"?e.jsx(T,{icon:e.jsx(b.IoPersonAdd,{className:"provider-label-icon"}),tooltip:l.label||"Accepting new patients"},l.icon):l.icon==="public-transportation"?e.jsx(T,{icon:e.jsx(b.IoBus,{className:"provider-label-icon"}),tooltip:l.label||"Public transportation available"},l.icon):l.icon==="wheelchair-accessible"?e.jsx(T,{icon:e.jsx(b.IoAccessibility,{className:"provider-label-icon"}),tooltip:l.label||"Wheelchair accessible"},l.icon):l.icon==="telehealth-provider"?e.jsx(T,{icon:e.jsx(b.IoVideocam,{className:"provider-label-icon"}),tooltip:l.label||"Telehealth provider"},l.icon):l.icon==="medicaid-provider"?e.jsx(T,{icon:e.jsx(b.IoMedkit,{className:"provider-label-icon"}),tooltip:l.label||"Medicaid provider"},l.icon):e.jsx(T,{icon:null,tooltip:l.label||l.icon,children:l.label||l.icon},l.icon))})]}),t.onlineAppointmentScheduleFlag==1&&e.jsx("button",{className:"provider-request-appt-btn",onClick:()=>{},children:" Request an appointment"})]})},(t.providerId?t.providerId:`${t.name.firstName}-${t.name.lastName}`)+"-"+h)})})}),p>1&&e.jsx("div",{className:"carousel-indicators",children:Array.from({length:p},(t,h)=>e.jsx("button",{className:`carousel-indicator ${h===d?"active":""}`,onClick:()=>y(h)},h))})]})}function T({icon:n,tooltip:a,children:d}){const[r,N]=i.useState(!1);let I;const w=()=>{N(!0),clearTimeout(I),I=setTimeout(()=>N(!1),5e3)},v=()=>{N(!1),clearTimeout(I)};return e.jsxs("span",{className:"provider-label",onClick:w,onMouseEnter:w,onMouseLeave:v,children:[n,d,r&&e.jsx("span",{className:"provider-label-tooltip",children:ne(a)})]})}function _e({product:n="eap",client:a="bcbsnc",channel:d="mobile",isLoggedIn:r=!1,token:N="",user:I={},config:w={}}){const c=V(["I feel stressed","Tips for anxiety","My benefits","Work-life balance advice","Mindfulness techniques","Dealing with burnout","Healthy habits","Managing emotions","Productivity tips","Positive thinking","Social support","Self care routines","Goal setting","Time management","Sleep hygiene","Stress relief","Mental wellness","Emotional balance","Find providers near me","Find counselors near me","Find therapists near me"],4),[f,p]=i.useState(null),[y,x]=i.useState(!1),[o,t]=i.useState(null),h=i.useRef(null),S=()=>{h.current&&(x(h.current.chatStarted),p(h.current.selectedChipIdx),t(h.current.chipToSend))};i.useEffect(()=>(window.onChatBack=S,()=>{window.onChatBack=void 0}),[]);const l=g=>{p(g),t(c[g]),x(!0)},_=()=>{p(null),t(null)},L=()=>x(!0);return e.jsxs("div",{className:"mind-link-ai-widget theme-light app-root",children:[e.jsx("div",{className:"app-body",children:e.jsx(Ie,{showGreeting:!y,onStartChat:L,chipToSend:o,onChipSent:_,chips:c,selectedChipIdx:f,handleChipClick:l,user:I,product:n,client:a,channel:d,isLoggedIn:r,token:N,config:w})}),e.jsx("footer",{className:"app-footer"})]})}return _e}));