@accurix/centrinfo-widget 5.1.1 → 5.2.0
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/README.md +83 -8
- package/dist/cdn/centrinfo-widget.js +80 -52
- package/dist/cdn/manifest.json +6 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/runtime.cjs +2 -2
- package/dist/runtime.d.cts +45 -8
- package/dist/runtime.d.mts +42 -5
- package/dist/runtime.mjs +2 -2
- package/dist/styles-BNPs-1he.mjs +3539 -0
- package/dist/styles-Bp-0ZpvF.cjs +3539 -0
- package/dist/{types-D0VIOagk.d.cts → types-CCk7I1fM.d.cts} +117 -16
- package/dist/{types-k3nQBQjf.d.mts → types-CmLbqY23.d.mts} +122 -19
- package/package.json +2 -2
- package/dist/styles-CvzR5bT8.cjs +0 -3516
- package/dist/styles-mW_qo6Ed.mjs +0 -3516
package/dist/cdn/manifest.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "@accurix/centrinfo-widget",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"fileName": "centrinfo-widget.js",
|
|
5
|
-
"cdnPath": "centrinfo/js/sdk-centrinfo-widget-v5.
|
|
6
|
-
"bytes":
|
|
7
|
-
"gzipBytes":
|
|
8
|
-
"sha256": "
|
|
9
|
-
"sri": "sha256-
|
|
5
|
+
"cdnPath": "centrinfo/js/sdk-centrinfo-widget-v5.2.0/centrinfo-widget.js",
|
|
6
|
+
"bytes": 407975,
|
|
7
|
+
"gzipBytes": 118595,
|
|
8
|
+
"sha256": "be2161ad97328714704f65a8a28cf4207123dc8f417e1056bf3f9e0689d438c3",
|
|
9
|
+
"sri": "sha256-viFhrZcyhxRwT2Woooz0IHEj3I9BfhBWvz+eBonUOMM=",
|
|
10
10
|
"chunks": [
|
|
11
11
|
{
|
|
12
12
|
"fileName": "centrinfo-widget-charts.js",
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./styles-CvzR5bT8.cjs`);let t=require(`preact`),n=require(`preact/hooks`),r=require(`preact/jsx-runtime`);const i=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom();n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},a=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,o=({state:t,onClose:i})=>{let o=e.V(),s=(0,n.useRef)(null);(0,n.useEffect)(()=>{s.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),i())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i]);let c=t.status===`ready`?a(t.mimeType):`other`;return(0,r.jsx)(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":e.B(o.attachPreviewTitle,{name:t.name}),onClick:e=>{e.target===e.currentTarget&&i()},children:(0,r.jsxs)(`div`,{class:`cf-preview__frame`,children:[(0,r.jsxs)(`div`,{class:`cf-preview__bar`,children:[(0,r.jsx)(`span`,{class:`cf-preview__name`,title:t.name,children:t.name}),t.status===`ready`&&(0,r.jsx)(`a`,{class:`cf-preview__btn`,href:t.url,download:t.name,children:o.attachDownload}),(0,r.jsx)(`button`,{ref:s,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":o.attachPreviewClose,onClick:i,children:`✕`})]}),(0,r.jsxs)(`div`,{class:`cf-preview__body`,children:[t.status===`loading`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewLoading}),t.status===`error`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewFailed}),t.status===`ready`&&c===`image`&&(0,r.jsx)(`img`,{class:`cf-preview__image`,src:t.url,alt:t.name}),t.status===`ready`&&c===`pdf`&&(0,r.jsx)(`iframe`,{class:`cf-preview__pdf`,src:t.url,title:t.name}),t.status===`ready`&&c===`other`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewUnsupported})]})]})})},s=({name:t,greeting:n})=>{let i=e.V();return(0,r.jsxs)(`section`,{class:`cf-empty-welcome`,"aria-label":e.B(i.welcomeLabel,{name:t}),children:[(0,r.jsx)(`span`,{class:`cf-empty-welcome__eyebrow`,children:i.welcomeEyebrow}),(0,r.jsx)(`h2`,{children:t}),(0,r.jsx)(`p`,{children:n||i.welcomePrompt})]})},c=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],c=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),c.focus()):!e.shiftKey&&(o===c||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},l=new Map,ee=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},te=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(l.has(n))return l.get(n);let r=ee(e),i=ee(t)??[255,255,255,1];if(!r){l.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,c=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return l.set(n,c),c},ne=e=>{let[t,r]=(0,n.useState)(`light`);return(0,n.useEffect)(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>r(t.matches?`dark`:`light`);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),e===`auto`?t:e},u=6e4,d=90,re={end:`end the call`,mute:`mute your microphone`,minimize:`minimize the chat`,expand:`expand the view`,shrink:`exit the expanded view`},ie=e=>e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/\s+/g,` `).trim(),ae=[{action:`shrink`,re:/\b(?:exit|leave|quit|close)\b[\s\w]*\b(?:full ?screen|expanded|theat(?:er|re))\b|\bshrink\b|\bsmaller view\b/},{action:`end`,re:/\b(?:end|close|stop|finish|hang ?up|quit|exit)\b[\s\w]*\b(?:call|chat|conversation|convo|session|talking)\b|\bhang ?up\b|\bgood ?bye\b|^bye(?: bye)?$/},{action:`mute`,re:/\bmute\b|\bstop listening\b/},{action:`minimize`,re:/\bminimi[sz]e\b|\bhide\b[\s\w]*\b(?:chat|call|window|widget)\b/},{action:`expand`,re:/\bexpand\b|\bmaximi[sz]e\b|\bfull ?screen\b|\btheat(?:er|re) mode\b|\bbigger view\b/}],oe=/^(?:yes|yeah|yep|yup|sure|correct|confirm|affirmative|go ahead|do it|please do|ok(?:ay)?)\b/,se=/^(?:no|nope|nah|cancel|never ?mind|don'?t|stop)\b/,ce=/^(?:end|close|stop|finish|hang ?up|quit|exit|bye|good ?bye)\b/,le=e=>{let t=ie(e);if(!t)return null;for(let{action:e,re:n}of ae)if(n.test(t)){let n=t.split(` `).length;return{action:e,confident:e===`end`?n<=10:n<=6}}return null},ue=e=>`I didn't catch yes or no. Say yes to ${re[e]}, or no to keep talking.`,f=({transport:t,config:a,bindControls:l,composerDraftStore:ee})=>{let u=a.strings,[d,ae]=(0,n.useState)(a.openByDefault),{persona:f,messages:p,sending:m,assistantSpeaking:h,visitor:de,hasEmail:fe,liveMode:g,assignedAgentName:pe,agentTypingName:me,starters:he,featuredLinks:ge,send:_,sendGif:_e,notifyTyping:ve,stop:ye,amend:be,hold:xe,resumeHeld:Se,duckSpeaking:Ce,retry:we,rateMessage:Te,rateExplanation:Ee,explanationTransport:De,injectAssistant:Oe,reconnectSupport:ke,appendUserDraft:Ae,patchMessage:v,removeMessage:je,submitCsat:Me,submitForm:Ne,confirmHostedBooking:Pe,transcribe:Fe,uploadAttachment:Ie,loadAttachment:Le,searchGifs:Re,demoSlots:ze,gifEnabled:Be,identify:Ve,ended:y,endConversation:He,startNew:Ue,history:We,viewingSessionId:Ge,viewMessages:Ke,openConversation:qe,closeHistoryView:Je,shutdown:Ye,stopSpeaking:b,speakAssistantText:Xe}=e.a(t,a,d),Ze=e.i(p,g),[Qe,$e]=(0,n.useState)(null),et=(0,n.useRef)(0),tt=(0,n.useCallback)((e,t,n)=>{n===et.current&&$e({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),nt=(0,n.useCallback)((e,t,n)=>{let r=t.name,i=++et.current;$e({status:`loading`,name:r}),Le(e,t,n).then(e=>tt(e,r,i),()=>{i===et.current&&$e({status:`error`,name:r})})},[Le,tt]),rt=(0,n.useCallback)((e,t)=>tt(e,t,++et.current),[tt]),it=(0,n.useCallback)(()=>{et.current+=1,$e(null)},[]);(0,n.useEffect)(()=>()=>{Qe?.status===`ready`&&URL.revokeObjectURL(Qe.url)},[Qe]);let at=!!e.r(f?.actions),[x,ot]=(0,n.useState)(0),[S,st]=(0,n.useState)({mic:`off`,processing:!1}),[ct,lt]=(0,n.useState)(null),[ut,dt]=(0,n.useState)(!1),[C,ft]=(0,n.useState)(!1),[pt,mt]=(0,n.useState)(!1),[ht,gt]=(0,n.useState)(!1),[_t,vt]=(0,n.useState)(0),[w,T]=(0,n.useState)(!1),[yt,E]=(0,n.useState)(null),[bt,xt]=(0,n.useState)(null),[St,Ct]=(0,n.useState)([]),[wt,Tt]=(0,n.useState)(``),[Et,Dt]=(0,n.useState)(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),Ot=ne(a.theme),kt=f?.soundEnabled??!0;(0,n.useEffect)(()=>{e.d(a.sound&&kt&&!Et)},[a.sound,kt,Et]);let At=(0,n.useCallback)(()=>{Dt(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),D=(0,n.useRef)(null),jt=(0,n.useRef)(null),Mt=(0,n.useRef)(null),Nt=(0,n.useRef)(0),O=(0,n.useRef)(!1),k=(0,n.useRef)(!1),A=(0,n.useRef)(null),j=(0,n.useRef)(0),Pt=(0,n.useRef)(void 0),Ft=(0,n.useRef)(0),It=(0,n.useRef)(null),M=(0,n.useRef)(!1),N=(0,n.useRef)(null),P=(0,n.useRef)(``),Lt=(0,n.useRef)(()=>{}),Rt=(0,n.useRef)(``),zt=(0,n.useRef)(m),Bt=(0,n.useRef)(_);Bt.current=_;let Vt=(0,n.useRef)(be);Vt.current=be;let Ht=(0,n.useRef)(Fe);Ht.current=Fe;let F=(0,n.useRef)(!1),I=(0,n.useRef)(!1),Ut=(0,n.useRef)(``);Ut.current=[...p].reverse().find(e=>e.role===`assistant`)?.content??``;let Wt=(0,n.useRef)(h);zt.current=m,Wt.current=h;let L=C?ut?`timeout`:ht||S.mic===`muted`?`muted`:S.mic===`unavailable`?S.reason===`permission-denied`||S.reason===`unsupported`?`denied`:`unavailable`:S.mic===`off`||S.mic===`starting`?`connecting`:S.mic===`hearing`?`hearing`:h?`speaking`:ct??(S.processing||m?`processing`:`listening`):`idle`,[Gt,Kt]=(0,n.useState)(!0),[qt,R]=(0,n.useState)(!1),Jt=(0,n.useRef)(0),[z,B]=(0,n.useState)(!1),[V,H]=(0,n.useState)(!1),Yt=(0,n.useRef)(null),[U,W]=(0,n.useState)(!1),Xt=(0,n.useRef)({value:``}),Zt=ee??Xt.current,Qt=(0,n.useRef)({confirmEnd:z,confirmClear:V,showHistory:U});Qt.current={confirmEnd:z,confirmClear:V,showHistory:U};let[$t,en]=(0,n.useState)(!1),G=!!Ge,tn=G?Ke:p,nn=tn.find(e=>e.id===yt&&e.visualization)?.visualization,rn=tn.find(e=>e.id===bt&&e.visualization);(0,n.useEffect)(()=>{!bt||rn||(xt(null),T(!1))},[bt,rn]),(0,n.useEffect)(()=>{!yt||nn||(E(null),T(!1))},[nn,yt]);let K=(0,n.useCallback)(()=>{ae(!0),ot(0),e.u(`open`),a.onOpen?.(),a.onShow?.()},[a]),q=(0,n.useCallback)(()=>{ae(!1),T(!1),E(null),a.onClose?.(),a.onHide?.(),jt.current?.focus()},[a]),J=(0,n.useCallback)(()=>d?q():K(),[d,K,q]),an=(0,n.useCallback)(()=>B(!0),[]),on=(0,n.useCallback)(()=>{He(),B(!1)},[He]),sn=(0,n.useCallback)(()=>{Ue(),R(!1),Kt(!0)},[Ue]);(0,n.useEffect)(()=>{z&&Yt.current?.focus()},[z]),(0,n.useEffect)(()=>{l({open:K,close:q,toggle:J,identify:Ve,startNew:Ue,endConversation:He,shutdown:Ye})},[l,K,q,J,Ve,Ue,He,Ye]),(0,n.useEffect)(()=>{let e=p.filter(e=>e.role===`assistant`&&!e.pending).length;if(d){Nt.current=e;return}e>Nt.current&&ot(e-Nt.current)},[p,d]),(0,n.useEffect)(()=>{a.onUnreadChange?.(x)},[x,a]),(0,n.useEffect)(()=>{let e=a.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>Ye(),e*60*1e3);return()=>clearTimeout(t)},[a.sessionDurationMinutes,p,d,Ye]),(0,n.useEffect)(()=>{let e=a.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),J()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[a.customLauncherSelector,J]);let cn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let e=a.proactiveMessage?.trim();if(!e||cn.current)return;let t=a.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${a.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(d||y||p.some(e=>e.role===`user`))){cn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}Oe(e),K()}},Math.max(0,a.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[a.proactiveMessage]),(0,n.useEffect)(()=>{let e=Mt.current;if(!d||!e)return;let t=p[p.length-1],n=Date.now()<Jt.current;t?.role===`user`||Gt||n?(requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),R(!1),n&&Kt(!0)):R(!0)},[p,d,m,Gt]);let ln=(0,n.useRef)(!0);ln.current=Gt,(0,n.useEffect)(()=>{let e=Mt.current;if(!(!d||!e))return i(e,{isAtBottom:()=>ln.current,onUnseen:()=>R(!0)})},[d,G]);let un=(0,n.useCallback)(()=>{let e=Mt.current;if(!e)return;if(O.current&&!G){Kt(!0),R(!1);return}let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;Kt(t),t&&R(!1)},[G]),Y=(0,n.useCallback)(()=>{let e=Mt.current;e&&(e.scrollTop=e.scrollHeight),R(!1),Kt(!0)},[]),dn=(0,n.useCallback)(()=>{Jt.current=Date.now()+3e3,requestAnimationFrame(Y)},[Y]);(0,n.useEffect)(()=>{if(!d||G||!C||L===`connecting`)return;Jt.current=Date.now()+6e4,Y();let e=requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)}),t=[80,180,360].map(e=>window.setTimeout(Y,e));return()=>{cancelAnimationFrame(e),t.forEach(e=>window.clearTimeout(e))}},[h,p,d,Y,m,C,G,L]);let fn=(0,n.useCallback)(()=>{D.current?.querySelector(`.cf-textarea`)?.focus()},[]),pn=(0,n.useCallback)((e,t)=>{lt(e),Pt.current&&window.clearTimeout(Pt.current),Pt.current=window.setTimeout(()=>lt(null),3e3),t&&!k.current&&Xe(t)},[Xe]),mn=(0,n.useCallback)(e=>{let t=N.current;if(t)return t;dn();let n=Ae(e);return N.current=n,v(n,{content:P.current||e,pending:!0,streaming:!1}),n},[Ae,dn,v]),X=(0,n.useCallback)(()=>{let e=N.current;if(e){if(P.current){v(e,{content:P.current,pending:!0});return}N.current=null,je(e)}},[v,je]),Z=(0,n.useCallback)(()=>{I.current&&(I.current=!1,Ce(!1)),F.current&&(F.current=!1,Se())},[Ce,Se]),Q=(0,n.useCallback)(()=>{O.current=!1,A.current?.stop(`call-ended`),A.current=null,F.current=!1,I.current=!1,k.current=!1,It.current=null,M.current=!1;let e=N.current;N.current=null,P.current=``,e&&je(e),Pt.current&&window.clearTimeout(Pt.current),lt(null),dt(!1),st({mic:`off`,processing:!1}),vt(0),ft(!1),mt(!1),gt(!1),T(!1),E(null),b()},[je,b]),hn=(0,n.useCallback)(()=>{w&&E(null),T(!w)},[w]),gn=(0,n.useCallback)(e=>{E(e),T(!0)},[]),_n=(0,n.useCallback)(e=>{xt(e),T(!0)},[]),vn=(0,n.useCallback)(()=>{let e=yt,t=bt;E(null),xt(null),T(!1),window.requestAnimationFrame(()=>{(t?D.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(D.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[yt,bt]),yn=(0,n.useCallback)(()=>{E(null),xt(null),T(!1)},[]),bn=(0,n.useCallback)((e,t,n=!1)=>{if(dn(),t&&(v(t,{content:e,pending:!1,streaming:!1}),N.current===t&&(N.current=null)),P.current=``,n){b(),Vt.current(e,{forceVoicePlayback:!0,userMessageId:t});return}O.current&&(xe()?Vt.current(e,{forceVoicePlayback:!0,userMessageId:t}):Bt.current(e,{forceVoicePlayback:!0,userMessageId:t}))},[dn,xe,v,b]),$=(0,n.useCallback)(e=>{Oe(e),Xe(e)},[Oe,Xe]),xn=(0,n.useCallback)(()=>{if(j.current=Date.now(),lt(null),Wt.current){I.current=!0,Ce(!0);return}F.current||(F.current=xe()),mn(`Listening...`)},[Ce,mn,xe]),Sn=(0,n.useCallback)(e=>{let t=N.current;!t||I.current||v(t,{content:`${[P.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[v]),Cn=(0,n.useCallback)(t=>{j.current=Date.now();let n=[P.current,t.text].map(e=>e.trim()).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();if((I.current||t.overlappedOutput)&&e.U(t.text,Ut.current)){X(),Z();return}if(!n||e.p(n)||e.m(n)){let e=I.current||F.current;X(),Z(),e||pn(`misunderstood`);return}I.current&&(I.current=!1,ye(),b());let r=It.current;if(r){P.current=``,X();let e=ie(n);if(oe.test(e)||r===`end`&&ce.test(e)){It.current=null,Lt.current(r);return}if(se.test(e)){It.current=null,$(`Okay, never mind — what would you like to know?`);return}$(ue(r));return}let i=le(n);if(i){if(P.current=``,X(),Z(),i.confident){Lt.current(i.action);return}It.current=i.action,$(`Just to confirm — you want me to ${re[i.action]}? Please say yes or no.`);return}let a=mn(n);v(a,{content:n,pending:!0});let o=F.current;F.current=!1,bn(n,a,o)},[mn,v,Z,bn,X,pn,$,ye,b]),wn=(0,n.useCallback)(e=>{j.current=Date.now();let t=I.current||F.current;if(X(),Z(),!(t||e.overlappedOutput||e.reason===`too-short`)){if(e.reason===`transcribe-failed`){pn(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`);return}pn(`noise`)}},[Z,X,pn]),Tn=(0,n.useRef)({speechStart:xn,partial:Sn,turn:Cn,noise:wn});Tn.current={speechStart:xn,partial:Sn,turn:Cn,noise:wn};let En=(0,n.useCallback)(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{Ct(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||`Microphone ${t+1}`})))}).catch(()=>{})},[]),Dn=(0,n.useCallback)(()=>{if(O.current){Q();return}if(fn(),!f?.allowVoiceInput||!f.talkbackMode||f.talkbackMode===`text`||zt.current||y||G)return;j.current=Date.now(),k.current=!1,O.current=!0,gt(!1),ft(!0),mt(!1),dt(!1);let t=!1,n=new e.H({deviceId:Rt.current||void 0,transcribe:async({audio:t,mimeType:n,durationSeconds:r})=>{let i=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return e.h(await Ht.current(t,n,i,r))},listener:{state:e=>{st(e),e.mic!==`starting`&&e.mic!==`off`&&mt(!0),!t&&e.mic===`listening`&&(t=!0,En())},speechStart:()=>Tn.current.speechStart(),partial:({text:e})=>Tn.current.partial(e),turn:e=>Tn.current.turn(e),noise:e=>Tn.current.noise(e),level:e=>{let t=performance.now();t-Ft.current<90||(Ft.current=t,vt(e))}}});A.current=n,n.setOutputActive(Wt.current),n.start()},[Q,y,fn,f,En,G]),On=(0,n.useCallback)(()=>{let e=!k.current;k.current=e,gt(e),A.current?.setMuted(e),e?(P.current=``,X(),Z()):j.current=Date.now()},[Z,X]),kn=(0,n.useCallback)(e=>{switch(j.current=Date.now(),e){case`end`:M.current=!0,$(`Okay — ending our call now. Goodbye!`),window.setTimeout(()=>{M.current&&(M.current=!1,Q())},2e3);break;case`mute`:k.current||On(),$(`Muted. Tap the mic button when you want me to listen again.`);break;case`minimize`:q(),$(`Minimized — I'm still listening. Tap the call pill to bring the chat back.`);break;case`expand`:T(!0),$(`Sure — expanding the view.`);break;case`shrink`:E(null),T(!1),$(`Okay — back to the smaller view.`);break}},[q,Q,$,On]);(0,n.useEffect)(()=>{Lt.current=kn},[kn]);let An=(0,n.useRef)(!1);(0,n.useEffect)(()=>{An.current&&!h&&M.current&&(M.current=!1,Q()),An.current=h},[h,Q]);let jn=(0,n.useCallback)(e=>{Rt.current=e,Tt(e),A.current?.selectDevice(e||void 0)},[]),Mn=(0,n.useCallback)(()=>{!O.current||k.current||(I.current=!1,F.current=!1,ye(),b(),j.current=Date.now())},[ye,b]);(0,n.useEffect)(()=>{A.current?.setOutputActive(h),j.current=Date.now()},[h]),(0,n.useEffect)(()=>{if(L!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,L]),(0,n.useEffect)(()=>{if(!C)return;let e=window.setInterval(()=>{let e=A.current;!e||k.current||zt.current||Wt.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-j.current<6e4||(A.current?.log.add(`call-timeout`),dt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,C]);let Nn=C&&!ht&&(m||h);(0,n.useEffect)(()=>()=>Q(),[Q]);let[Pn,Fn]=(0,n.useState)(``),In=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(In.current&&!m){let e=[...p].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&Fn(e.content)}In.current=m},[m,p]),(0,n.useLayoutEffect)(()=>{if(!d)return;let e=D.current,t=z||V?e?.querySelector(`.cf-confirm__card`):U?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[V,z,d,U]),(0,n.useEffect)(()=>{if(!d)return;let e=D.current,t=z||V?e?.querySelector(`.cf-confirm__card`):U?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Qt.current;if(t.confirmEnd){B(!1);return}if(t.confirmClear){H(!1);return}if(t.showHistory){W(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;q();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[d,q,z,V,U]),(0,n.useEffect)(()=>{let e=D.current;e&&(d?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[d]);let Ln=a.accentColor??a.themeTokens?.accent??f?.accentColor,Rn=a.themeTokens?.accentText??te(Ln,a.themeTokens?.background??(Ot===`dark`?`#0f1c27`:`#ffffff`)),zn={zIndex:a.zIndex,"--cf-h-pad":`${a.horizontalPadding}px`,"--cf-v-pad":`${a.verticalPadding}px`,...Rn?{"--cf-accent-ink":Rn}:{},...a.themeTokens?.accentStrong?{"--cf-accent-2":a.themeTokens.accentStrong}:{},...a.themeTokens?.background?{"--cf-bg":a.themeTokens.background}:{},...a.themeTokens?.surface?{"--cf-surface":a.themeTokens.surface}:{},...a.themeTokens?.surfaceMuted?{"--cf-surface-2":a.themeTokens.surfaceMuted}:{},...a.themeTokens?.text?{"--cf-text":a.themeTokens.text}:{},...a.themeTokens?.mutedText?{"--cf-muted":a.themeTokens.mutedText}:{},...a.themeTokens?.border?{"--cf-border":a.themeTokens.border}:{},...a.themeTokens?.shadow?{"--cf-shadow":a.themeTokens.shadow}:{},...a.themeTokens?.radius?{"--cf-radius":a.themeTokens.radius}:{},...a.themeTokens?.fontFamily?{"--cf-font":a.themeTokens.fontFamily}:{},...a.themeTokens?.success?{"--cf-success":a.themeTokens.success}:{},...a.themeTokens?.warning?{"--cf-warning":a.themeTokens.warning}:{},...a.themeTokens?.danger?{"--cf-danger":a.themeTokens.danger}:{},...Ln?{"--cf-accent":Ln,"--cf-accent-2":a.themeTokens?.accentStrong??`color-mix(in oklab, ${Ln} 76%, #14141f)`}:{}},Bn=e=>_(e),Vn=[...p].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,Hn=p.some(e=>e.role===`user`),Un=!!(f?.allowVoiceInput&&f?.talkbackMode&&f.talkbackMode!==`text`),Wn=Un,Gn=!G&&Wn&&!Hn?tn.filter((e,t)=>!(t===0&&e.role===`assistant`)):tn,Kn=g===`human`&&pe?pe:f?.agentName??u.chatName,qn=g===`human`?u.liveSupport:g===`queued`?u.waitingForTeam:f?.offline?u.statusOffline:u.statusOnline,Jn=!y&&!G?f?.availableActions:void 0,Yn=!y&&!G?f?.actions:void 0,Xn=C&&!pt&&L===`connecting`&&!G;return(0,r.jsx)(e.z,{value:u,children:(0,r.jsx)(e.R,{value:a.locale,children:(0,r.jsxs)(`div`,{class:`cf-root`,dir:a.dir,"data-theme":Ot,"data-align":a.alignment,"data-display":`floating`,style:zn,children:[w&&d&&(0,r.jsx)(`div`,{class:`cf-theater-backdrop`,onClick:yn}),(0,r.jsxs)(`div`,{ref:D,class:`cf-panel ${d?`is-open`:``} ${C?`cf-panel--call`:``} ${Xn?`cf-panel--voice-connecting`:``} ${w&&d?`cf-panel--theater`:``} ${nn||rn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${u.chatName}: ${f?.agentName??u.assistantName}`,"aria-hidden":!d,children:[Qe&&d&&(0,r.jsx)(o,{state:Qe,onClose:it}),(0,r.jsxs)(`div`,{class:`cf-header`,children:[(0,r.jsx)(e.v,{persona:f,hideWhenMissing:!0}),(0,r.jsxs)(`div`,{class:`cf-header__meta`,children:[(0,r.jsx)(`div`,{class:`cf-header__name`,children:Kn}),(0,r.jsx)(`div`,{class:`cf-header__status ${g===`ai`&&f?.offline?`cf-header__status--offline`:``}`,children:(0,r.jsx)(`span`,{class:`cf-header__status-text`,children:qn})})]}),(0,r.jsxs)(`div`,{class:`cf-header__actions`,children:[We.length>0&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.pastConversations,title:u.pastConversations,"aria-pressed":U,onClick:()=>W(e=>!e),children:(0,r.jsx)(e.M,{})}),Hn&&!y&&!G&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.endChat,title:u.endChat,onClick:an,children:(0,r.jsx)(e.j,{})}),a.sound&&kt&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":Et?u.unmuteSounds:u.muteSounds,"aria-pressed":Et,onClick:At,children:Et?(0,r.jsx)(e.N,{}):(0,r.jsx)(e.P,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":u.closeChat,onClick:q,children:(0,r.jsx)(e.A,{})})]})]}),(0,r.jsx)(`div`,{class:`cf-panel__video`,children:nn?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:(0,r.jsx)(e.E,{visualization:nn,expanded:!0,onFollowUp:e=>{vn(),_(e)},onClose:vn})}):rn?.visualization?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:(0,r.jsx)(e.T,{visualization:rn.visualization,onClose:vn,onFollowUp:e=>{vn(),_(e)},onFeedback:G?void 0:Ee,transport:G?void 0:De(`widget`),onOpenSource:a.onOpenAnalyticsSource})}):!G&&Wn?(0,r.jsx)(e.y,{persona:f,starters:[],onPick:_,onFocusComposer:Dn,speaking:h,voiceState:L,replyPending:C&&m&&!h,pinned:!0,muted:ht,onToggleMute:On,onEndCall:Q,onTalkNow:Mn,showTalkNow:Nn,micLevel:_t,theaterMode:w,onToggleTheater:hn,onMinimize:q,audioDevices:St,selectedAudioDeviceId:wt,onSelectAudioDevice:jn,connectingOnly:Xn}):null}),!Xn&&(0,r.jsxs)(`div`,{class:`cf-panel__chat`,children:[a.preview&&(0,r.jsx)(`div`,{class:`cf-preview-banner`,children:u.previewBanner}),G&&(0,r.jsx)(`div`,{class:`cf-viewing-banner`,children:u.viewingPast}),(0,r.jsxs)(`div`,{class:`cf-body`,ref:Mt,role:`log`,onScroll:un,children:[Gn.map((t,n)=>(0,r.jsx)(e.C,{msg:t,persona:f,isLast:!G&&n===Gn.length-1,visitor:de,hasEmail:fe,lastQuestion:Vn,showActions:!G&&n===Gn.length-1&&!!(t.handoffOffered||t.selectedAction),onPickReply:Bn,onSubmitForm:Ne,onDemoSlots:ze,onConfirmHostedBooking:Pe,onRetry:we,ratable:!G&&Gn.slice(0,n).some(e=>e.role===`user`),onRate:Te,onExplanationFeedback:G?void 0:Ee,explanationTransport:G?void 0:De(`widget`),onOpenAnalyticsSource:a.onOpenAnalyticsSource,onExpandVisualization:G?void 0:gn,onExpandExplanation:G?void 0:_n,onOpenAttachment:nt,onReconnect:!G&&!y&&at&&t.id===Ze?ke:void 0},t.id)),!Hn&&!G&&(0,r.jsxs)(r.Fragment,{children:[Gn.length===0&&(0,r.jsx)(s,{name:f?.agentName??u.assistantName,greeting:f?.greeting}),(0,r.jsx)(e.w,{items:he,onPick:_}),(0,r.jsx)(e.x,{items:ge})]}),qt&&(0,r.jsxs)(`button`,{type:`button`,class:`cf-newmsg`,onClick:Y,children:[(0,r.jsx)(e.O,{}),u.newMessages]})]}),(0,r.jsx)(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:Pn}),m&&!y&&!G&&(0,r.jsx)(`div`,{class:`cf-stopbar`,children:(0,r.jsxs)(`button`,{type:`button`,class:`cf-stop`,onClick:ye,children:[(0,r.jsx)(e.F,{}),u.stop]})}),G?(0,r.jsx)(`div`,{class:`cf-ended`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Je,children:u.backToChat})}):y?(0,r.jsxs)(`div`,{class:`cf-ended`,children:[(0,r.jsx)(`p`,{class:`cf-ended__text`,children:u.conversationEnded}),a.csat&&Hn?$t?(0,r.jsx)(`p`,{class:`cf-ended__text`,children:u.feedbackThanks}):(0,r.jsxs)(`div`,{class:`cf-csat`,children:[(0,r.jsx)(`span`,{class:`cf-csat__q`,children:u.csatPrompt}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackHelpful,onClick:()=>{Me(`up`),en(!0)},children:(0,r.jsx)(e.L,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackNotHelpful,onClick:()=>{Me(`down`),en(!0)},children:(0,r.jsx)(e.I,{})})]}):null,(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:sn,children:u.startNewChat})]}):(0,r.jsxs)(r.Fragment,{children:[me?(0,r.jsx)(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:e.B(u.agentTyping,{name:me})}):null,Jn&&Jn.length>0&&(0,r.jsx)(`div`,{class:`cf-footer-actions`,children:(0,r.jsx)(e._,{actions:Jn,descriptors:Yn,visitor:de,onSubmitForm:Ne,onDemoSlots:ze,onConfirmHostedBooking:Pe,scheduler:f?.scheduler,translations:a.actionTranslations})},`footer-actions`),(0,r.jsx)(e.b,{draftStore:Zt,onSend:_,onSendGif:_e,onTyping:ve,disabled:m,allowVoice:Un,onTranscribe:Fe,gifEnabled:Be,onSearchGifs:Re,allowAttach:a.attachments,analyzeAttachments:!0,onUpload:Ie,onPreviewAttachment:rt},`composer`)]}),!y&&f?.disclaimerText&&(0,r.jsx)(`div`,{class:`cf-disclaimer`,children:f.disclaimerText}),(0,r.jsxs)(`div`,{class:`cf-footer`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":u.clearDeviceData,onClick:()=>H(!0),children:u.privacyAndData}),(0,r.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),u.poweredBy,` `,(0,r.jsx)(`a`,{href:`https://accurix.tech/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),z&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>B(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>B(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:u.endChatConfirm}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:u.endChatConfirmBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{ref:Yt,type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>B(!1),children:u.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:on,children:u.endConfirmCta})]})]})},`confirm-end`),U&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>W(!1),children:(0,r.jsxs)(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":u.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>W(!1)),children:[(0,r.jsxs)(`div`,{class:`cf-history__head`,children:[(0,r.jsx)(`span`,{children:u.pastConversations}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.closeHistory,onClick:()=>W(!1),children:(0,r.jsx)(e.A,{})})]}),(0,r.jsx)(`div`,{class:`cf-history__list`,children:We.map(e=>(0,r.jsxs)(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===Ge?`is-active`:``}`,onClick:()=>{qe(e.sessionId),W(!1)},children:[(0,r.jsx)(`span`,{class:`cf-history__title`,children:e.title}),(0,r.jsxs)(`span`,{class:`cf-history__meta`,children:[new Date(e.ts).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),e.ended?` · ${u.historyEnded}`:``]})]},e.sessionId))}),(0,r.jsx)(`div`,{class:`cf-history__footer`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{W(!1),H(!0)},children:u.clearDeviceData})})]})},`history`),V&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>H(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>H(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:u.clearDeviceData}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:u.clearDeviceDataBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>H(!1),children:u.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{H(!1),Ye()},children:u.clearDeviceDataCta})]})]})},`confirm-clear`)]}),C&&!d?(0,r.jsx)(e.S,{persona:f,voiceState:L,muted:ht,onToggleMute:On,onEndCall:Q,micLevel:_t,onExpand:K}):w&&d?null:!a.hideDefaultLauncher&&(0,r.jsxs)(`button`,{ref:jt,type:`button`,class:`cf-launcher`,"aria-label":d?u.closeChat:x>0?`${u.openChat}. ${x===1?u.unreadMessage:e.B(u.unreadMessages,{count:String(x)})}`:u.openChat,"aria-expanded":d,onClick:J,children:[a.launcherIcon?(0,r.jsx)(`img`,{class:`cf-launcher__img`,src:a.launcherIcon,alt:``}):(0,r.jsx)(e.k,{}),!d&&x>0&&(0,r.jsx)(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:x>99?`99+`:x})]})]})})})},p=`centrinfo-widget`;var m=class extends HTMLElement{constructor(...t){super(...t),e.Z(this,`controls`,null),e.Z(this,`composerDraftStore`,{value:``})}mountWith(n){let i=e.n(n),a=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(i.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let t=new CSSStyleSheet;t.replaceSync(e.t),a.adoptedStyleSheets=[t]}else{let t=document.createElement(`style`);i.styleNonce&&(t.nonce=i.styleNonce),t.textContent=e.t,a.appendChild(t)}(0,t.render)((0,r.jsx)(f,{transport:e.X(i),config:i,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore}),a)}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.shadowRoot&&(0,t.render)(null,this.shadowRoot)}};typeof customElements<`u`&&!customElements.get(p)&&customElements.define(p,m);const h=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(p);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),destroy:()=>{n.unmount(),n.remove()}}},de=e=>h(e);let fe=null;const g=e=>{fe?.destroy();let t=de(e);return fe=t,t},pe={init:g,createWidget:de};exports.Centrinfo=pe,exports.createWidget=de,exports.init=g;
|
|
1
|
+
const e=require(`./styles-Bp-0ZpvF.cjs`);let t=require(`preact`),n=require(`preact/hooks`),r=require(`preact/jsx-runtime`);const i=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom();n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},a=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,o=({state:t,onClose:i})=>{let o=e.q(),s=(0,n.useRef)(null);(0,n.useEffect)(()=>{s.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),i())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i]);let c=t.status===`ready`?a(t.mimeType):`other`;return(0,r.jsx)(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":e.K(o.attachPreviewTitle,{name:t.name}),onClick:e=>{e.target===e.currentTarget&&i()},children:(0,r.jsxs)(`div`,{class:`cf-preview__frame`,children:[(0,r.jsxs)(`div`,{class:`cf-preview__bar`,children:[(0,r.jsx)(`span`,{class:`cf-preview__name`,title:t.name,children:t.name}),t.status===`ready`&&(0,r.jsx)(`a`,{class:`cf-preview__btn`,href:t.url,download:t.name,children:o.attachDownload}),(0,r.jsx)(`button`,{ref:s,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":o.attachPreviewClose,onClick:i,children:`✕`})]}),(0,r.jsxs)(`div`,{class:`cf-preview__body`,children:[t.status===`loading`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewLoading}),t.status===`error`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewFailed}),t.status===`ready`&&c===`image`&&(0,r.jsx)(`img`,{class:`cf-preview__image`,src:t.url,alt:t.name}),t.status===`ready`&&c===`pdf`&&(0,r.jsx)(`iframe`,{class:`cf-preview__pdf`,src:t.url,title:t.name}),t.status===`ready`&&c===`other`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewUnsupported})]})]})})},s=({name:t,greeting:n})=>{let i=e.q();return(0,r.jsxs)(`section`,{class:`cf-empty-welcome`,"aria-label":e.K(i.welcomeLabel,{name:t}),children:[(0,r.jsx)(`span`,{class:`cf-empty-welcome__eyebrow`,children:i.welcomeEyebrow}),(0,r.jsx)(`h2`,{children:t}),(0,r.jsx)(`p`,{children:n||i.welcomePrompt})]})},c=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],c=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),c.focus()):!e.shiftKey&&(o===c||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},l=new Map,ee=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},te=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(l.has(n))return l.get(n);let r=ee(e),i=ee(t)??[255,255,255,1];if(!r){l.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,c=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return l.set(n,c),c},ne=e=>{let[t,r]=(0,n.useState)(`light`);return(0,n.useEffect)(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>r(t.matches?`dark`:`light`);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),e===`auto`?t:e},u=6e4,d=90,re={end:`end the call`,mute:`mute your microphone`,minimize:`minimize the chat`,expand:`expand the view`,shrink:`exit the expanded view`},ie=e=>e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/\s+/g,` `).trim(),ae=[{action:`shrink`,re:/\b(?:exit|leave|quit|close)\b[\s\w]*\b(?:full ?screen|expanded|theat(?:er|re))\b|\bshrink\b|\bsmaller view\b/},{action:`end`,re:/\b(?:end|close|stop|finish|hang ?up|quit|exit)\b[\s\w]*\b(?:call|chat|conversation|convo|session|talking)\b|\bhang ?up\b|\bgood ?bye\b|^bye(?: bye)?$/},{action:`mute`,re:/\bmute\b|\bstop listening\b/},{action:`minimize`,re:/\bminimi[sz]e\b|\bhide\b[\s\w]*\b(?:chat|call|window|widget)\b/},{action:`expand`,re:/\bexpand\b|\bmaximi[sz]e\b|\bfull ?screen\b|\btheat(?:er|re) mode\b|\bbigger view\b/}],oe=/^(?:yes|yeah|yep|yup|sure|correct|confirm|affirmative|go ahead|do it|please do|ok(?:ay)?)\b/,se=/^(?:no|nope|nah|cancel|never ?mind|don'?t|stop)\b/,ce=/^(?:end|close|stop|finish|hang ?up|quit|exit|bye|good ?bye)\b/,le=e=>{let t=ie(e);if(!t)return null;for(let{action:e,re:n}of ae)if(n.test(t)){let n=t.split(` `).length;return{action:e,confident:e===`end`?n<=10:n<=6}}return null},ue=e=>`I didn't catch yes or no. Say yes to ${re[e]}, or no to keep talking.`,f=({transport:t,config:a,bindControls:l,composerDraftStore:ee})=>{let u=a.strings,[d,ae]=(0,n.useState)(a.openByDefault),{persona:f,messages:p,sending:m,assistantSpeaking:h,visitor:de,hasEmail:fe,liveMode:g,assignedAgentName:pe,agentTypingName:me,starters:he,featuredLinks:ge,send:_,sendGif:_e,notifyTyping:ve,stop:ye,amend:be,hold:xe,resumeHeld:Se,duckSpeaking:Ce,retry:we,rateMessage:Te,doubleCheckResponse:Ee,retryResponse:De,rateExplanation:Oe,explanationTransport:ke,injectAssistant:Ae,reconnectSupport:je,appendUserDraft:Me,patchMessage:v,removeMessage:Ne,submitCsat:Pe,submitForm:Fe,confirmHostedBooking:Ie,transcribe:Le,uploadAttachment:Re,loadAttachment:ze,searchGifs:Be,demoSlots:Ve,gifEnabled:He,identify:Ue,ended:y,endConversation:We,startNew:Ge,history:Ke,viewingSessionId:qe,viewMessages:Je,openConversation:Ye,closeHistoryView:Xe,shutdown:Ze,stopSpeaking:b,speakAssistantText:Qe,analyticsModels:$e,analyticsModelId:et,selectAnalyticsModel:tt}=e.o(t,a,d),nt=e.a(p,g),[rt,it]=(0,n.useState)(null),at=(0,n.useRef)(0),ot=(0,n.useCallback)((e,t,n)=>{n===at.current&&it({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),st=(0,n.useCallback)((e,t,n)=>{let r=t.name,i=++at.current;it({status:`loading`,name:r}),ze(e,t,n).then(e=>ot(e,r,i),()=>{i===at.current&&it({status:`error`,name:r})})},[ze,ot]),ct=(0,n.useCallback)((e,t)=>ot(e,t,++at.current),[ot]),lt=(0,n.useCallback)(()=>{at.current+=1,it(null)},[]);(0,n.useEffect)(()=>()=>{rt?.status===`ready`&&URL.revokeObjectURL(rt.url)},[rt]);let ut=!!e.i(f?.actions),[x,dt]=(0,n.useState)(0),[S,ft]=(0,n.useState)({mic:`off`,processing:!1}),[pt,mt]=(0,n.useState)(null),[ht,gt]=(0,n.useState)(!1),[C,_t]=(0,n.useState)(!1),[vt,yt]=(0,n.useState)(!1),[bt,xt]=(0,n.useState)(!1),[St,Ct]=(0,n.useState)(0),[w,T]=(0,n.useState)(!1),[wt,E]=(0,n.useState)(null),[Tt,Et]=(0,n.useState)(null),[Dt,Ot]=(0,n.useState)([]),[kt,At]=(0,n.useState)(``),[jt,Mt]=(0,n.useState)(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),Nt=ne(a.theme),Pt=f?.soundEnabled??!0;(0,n.useEffect)(()=>{e.f(a.sound&&Pt&&!jt)},[a.sound,Pt,jt]);let Ft=(0,n.useCallback)(()=>{Mt(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),D=(0,n.useRef)(null),It=(0,n.useRef)(null),Lt=(0,n.useRef)(null),Rt=(0,n.useRef)(0),O=(0,n.useRef)(!1),k=(0,n.useRef)(!1),A=(0,n.useRef)(null),j=(0,n.useRef)(0),zt=(0,n.useRef)(void 0),Bt=(0,n.useRef)(0),Vt=(0,n.useRef)(null),M=(0,n.useRef)(!1),N=(0,n.useRef)(null),P=(0,n.useRef)(``),Ht=(0,n.useRef)(()=>{}),Ut=(0,n.useRef)(``),Wt=(0,n.useRef)(m),Gt=(0,n.useRef)(_);Gt.current=_;let Kt=(0,n.useRef)(be);Kt.current=be;let qt=(0,n.useRef)(Le);qt.current=Le;let F=(0,n.useRef)(!1),I=(0,n.useRef)(!1),Jt=(0,n.useRef)(``);Jt.current=[...p].reverse().find(e=>e.role===`assistant`)?.content??``;let Yt=(0,n.useRef)(h);Wt.current=m,Yt.current=h;let L=C?ht?`timeout`:bt||S.mic===`muted`?`muted`:S.mic===`unavailable`?S.reason===`permission-denied`||S.reason===`unsupported`?`denied`:`unavailable`:S.mic===`off`||S.mic===`starting`?`connecting`:S.mic===`hearing`?`hearing`:h?`speaking`:pt??(S.processing||m?`processing`:`listening`):`idle`,[Xt,Zt]=(0,n.useState)(!0),[Qt,R]=(0,n.useState)(!1),$t=(0,n.useRef)(0),[z,B]=(0,n.useState)(!1),[V,H]=(0,n.useState)(!1),en=(0,n.useRef)(null),[U,W]=(0,n.useState)(!1),tn=(0,n.useRef)({value:``}),nn=ee??tn.current,rn=(0,n.useRef)({confirmEnd:z,confirmClear:V,showHistory:U});rn.current={confirmEnd:z,confirmClear:V,showHistory:U};let[an,on]=(0,n.useState)(!1),G=!!qe,sn=G?Je:p,cn=sn.find(e=>e.id===wt&&e.visualization)?.visualization,ln=sn.find(e=>e.id===Tt&&e.visualization);(0,n.useEffect)(()=>{!Tt||ln||(Et(null),T(!1))},[Tt,ln]),(0,n.useEffect)(()=>{!wt||cn||(E(null),T(!1))},[cn,wt]);let K=(0,n.useCallback)(()=>{ae(!0),dt(0),e.d(`open`),a.onOpen?.(),a.onShow?.()},[a]),q=(0,n.useCallback)(()=>{ae(!1),T(!1),E(null),a.onClose?.(),a.onHide?.(),It.current?.focus()},[a]),J=(0,n.useCallback)(()=>d?q():K(),[d,K,q]),un=(0,n.useCallback)(()=>B(!0),[]),dn=(0,n.useCallback)(()=>{We(),B(!1)},[We]),fn=(0,n.useCallback)(()=>{Ge(),R(!1),Zt(!0)},[Ge]);(0,n.useEffect)(()=>{z&&en.current?.focus()},[z]),(0,n.useEffect)(()=>{l({open:K,close:q,toggle:J,identify:Ue,startNew:Ge,endConversation:We,shutdown:Ze})},[l,K,q,J,Ue,Ge,We,Ze]),(0,n.useEffect)(()=>{let e=p.filter(e=>e.role===`assistant`&&!e.pending).length;if(d){Rt.current=e;return}e>Rt.current&&dt(e-Rt.current)},[p,d]),(0,n.useEffect)(()=>{a.onUnreadChange?.(x)},[x,a]),(0,n.useEffect)(()=>{let e=a.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>Ze(),e*60*1e3);return()=>clearTimeout(t)},[a.sessionDurationMinutes,p,d,Ze]),(0,n.useEffect)(()=>{let e=a.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),J()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[a.customLauncherSelector,J]);let pn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let e=a.proactiveMessage?.trim();if(!e||pn.current)return;let t=a.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${a.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(d||y||p.some(e=>e.role===`user`))){pn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}Ae(e),K()}},Math.max(0,a.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[a.proactiveMessage]),(0,n.useEffect)(()=>{let e=Lt.current;if(!d||!e)return;let t=p[p.length-1],n=Date.now()<$t.current;t?.role===`user`||Xt||n?(requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),R(!1),n&&Zt(!0)):R(!0)},[p,d,m,Xt]);let mn=(0,n.useRef)(!0);mn.current=Xt,(0,n.useEffect)(()=>{let e=Lt.current;if(!(!d||!e))return i(e,{isAtBottom:()=>mn.current,onUnseen:()=>R(!0)})},[d,G]);let hn=(0,n.useCallback)(()=>{let e=Lt.current;if(!e)return;if(O.current&&!G){Zt(!0),R(!1);return}let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;Zt(t),t&&R(!1)},[G]),Y=(0,n.useCallback)(()=>{let e=Lt.current;e&&(e.scrollTop=e.scrollHeight),R(!1),Zt(!0)},[]),gn=(0,n.useCallback)(()=>{$t.current=Date.now()+3e3,requestAnimationFrame(Y)},[Y]);(0,n.useEffect)(()=>{if(!d||G||!C||L===`connecting`)return;$t.current=Date.now()+6e4,Y();let e=requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)}),t=[80,180,360].map(e=>window.setTimeout(Y,e));return()=>{cancelAnimationFrame(e),t.forEach(e=>window.clearTimeout(e))}},[h,p,d,Y,m,C,G,L]);let _n=(0,n.useCallback)(()=>{D.current?.querySelector(`.cf-textarea`)?.focus()},[]),vn=(0,n.useCallback)((e,t)=>{mt(e),zt.current&&window.clearTimeout(zt.current),zt.current=window.setTimeout(()=>mt(null),3e3),t&&!k.current&&Qe(t)},[Qe]),yn=(0,n.useCallback)(e=>{let t=N.current;if(t)return t;gn();let n=Me(e);return N.current=n,v(n,{content:P.current||e,pending:!0,streaming:!1}),n},[Me,gn,v]),X=(0,n.useCallback)(()=>{let e=N.current;if(e){if(P.current){v(e,{content:P.current,pending:!0});return}N.current=null,Ne(e)}},[v,Ne]),Z=(0,n.useCallback)(()=>{I.current&&(I.current=!1,Ce(!1)),F.current&&(F.current=!1,Se())},[Ce,Se]),Q=(0,n.useCallback)(()=>{O.current=!1,A.current?.stop(`call-ended`),A.current=null,F.current=!1,I.current=!1,k.current=!1,Vt.current=null,M.current=!1;let e=N.current;N.current=null,P.current=``,e&&Ne(e),zt.current&&window.clearTimeout(zt.current),mt(null),gt(!1),ft({mic:`off`,processing:!1}),Ct(0),_t(!1),yt(!1),xt(!1),T(!1),E(null),b()},[Ne,b]),bn=(0,n.useCallback)(()=>{w&&E(null),T(!w)},[w]),xn=(0,n.useCallback)(e=>{E(e),T(!0)},[]),Sn=(0,n.useCallback)(e=>{Et(e),T(!0)},[]),Cn=(0,n.useCallback)(()=>{let e=wt,t=Tt;E(null),Et(null),T(!1),window.requestAnimationFrame(()=>{(t?D.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(D.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[wt,Tt]),wn=(0,n.useCallback)(()=>{E(null),Et(null),T(!1)},[]),Tn=(0,n.useCallback)((e,t,n=!1)=>{if(gn(),t&&(v(t,{content:e,pending:!1,streaming:!1}),N.current===t&&(N.current=null)),P.current=``,n){b(),Kt.current(e,{forceVoicePlayback:!0,userMessageId:t});return}O.current&&(xe()?Kt.current(e,{forceVoicePlayback:!0,userMessageId:t}):Gt.current(e,{forceVoicePlayback:!0,userMessageId:t}))},[gn,xe,v,b]),$=(0,n.useCallback)(e=>{Ae(e),Qe(e)},[Ae,Qe]),En=(0,n.useCallback)(()=>{if(j.current=Date.now(),mt(null),Yt.current){I.current=!0,Ce(!0);return}F.current||(F.current=xe()),yn(`Listening...`)},[Ce,yn,xe]),Dn=(0,n.useCallback)(e=>{let t=N.current;!t||I.current||v(t,{content:`${[P.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[v]),On=(0,n.useCallback)(t=>{j.current=Date.now();let n=[P.current,t.text].map(e=>e.trim()).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();if((I.current||t.overlappedOutput)&&e.V(t.text,Jt.current)){X(),Z();return}if(!n||e.m(n)||e.h(n)){let e=I.current||F.current;X(),Z(),e||vn(`misunderstood`);return}I.current&&(I.current=!1,ye(),b());let r=Vt.current;if(r){P.current=``,X();let e=ie(n);if(oe.test(e)||r===`end`&&ce.test(e)){Vt.current=null,Ht.current(r);return}if(se.test(e)){Vt.current=null,$(`Okay, never mind — what would you like to know?`);return}$(ue(r));return}let i=le(n);if(i){if(P.current=``,X(),Z(),i.confident){Ht.current(i.action);return}Vt.current=i.action,$(`Just to confirm — you want me to ${re[i.action]}? Please say yes or no.`);return}let a=yn(n);v(a,{content:n,pending:!0});let o=F.current;F.current=!1,Tn(n,a,o)},[yn,v,Z,Tn,X,vn,$,ye,b]),kn=(0,n.useCallback)(e=>{j.current=Date.now();let t=I.current||F.current;if(X(),Z(),!(t||e.overlappedOutput||e.reason===`too-short`)){if(e.reason===`transcribe-failed`){vn(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`);return}vn(`noise`)}},[Z,X,vn]),An=(0,n.useRef)({speechStart:En,partial:Dn,turn:On,noise:kn});An.current={speechStart:En,partial:Dn,turn:On,noise:kn};let jn=(0,n.useCallback)(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{Ot(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||`Microphone ${t+1}`})))}).catch(()=>{})},[]),Mn=(0,n.useCallback)(()=>{if(O.current){Q();return}if(_n(),!f?.allowVoiceInput||!f.talkbackMode||f.talkbackMode===`text`||Wt.current||y||G)return;j.current=Date.now(),k.current=!1,O.current=!0,xt(!1),_t(!0),yt(!1),gt(!1);let t=!1,n=new e.B({deviceId:Ut.current||void 0,transcribe:async({audio:t,mimeType:n,durationSeconds:r})=>{let i=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return e.g(await qt.current(t,n,i,r))},listener:{state:e=>{ft(e),e.mic!==`starting`&&e.mic!==`off`&&yt(!0),!t&&e.mic===`listening`&&(t=!0,jn())},speechStart:()=>An.current.speechStart(),partial:({text:e})=>An.current.partial(e),turn:e=>An.current.turn(e),noise:e=>An.current.noise(e),level:e=>{let t=performance.now();t-Bt.current<90||(Bt.current=t,Ct(e))}}});A.current=n,n.setOutputActive(Yt.current),n.start()},[Q,y,_n,f,jn,G]),Nn=(0,n.useCallback)(()=>{let e=!k.current;k.current=e,xt(e),A.current?.setMuted(e),e?(P.current=``,X(),Z()):j.current=Date.now()},[Z,X]),Pn=(0,n.useCallback)(e=>{switch(j.current=Date.now(),e){case`end`:M.current=!0,$(`Okay — ending our call now. Goodbye!`),window.setTimeout(()=>{M.current&&(M.current=!1,Q())},2e3);break;case`mute`:k.current||Nn(),$(`Muted. Tap the mic button when you want me to listen again.`);break;case`minimize`:q(),$(`Minimized — I'm still listening. Tap the call pill to bring the chat back.`);break;case`expand`:T(!0),$(`Sure — expanding the view.`);break;case`shrink`:E(null),T(!1),$(`Okay — back to the smaller view.`);break}},[q,Q,$,Nn]);(0,n.useEffect)(()=>{Ht.current=Pn},[Pn]);let Fn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Fn.current&&!h&&M.current&&(M.current=!1,Q()),Fn.current=h},[h,Q]);let In=(0,n.useCallback)(e=>{Ut.current=e,At(e),A.current?.selectDevice(e||void 0)},[]),Ln=(0,n.useCallback)(()=>{!O.current||k.current||(I.current=!1,F.current=!1,ye(),b(),j.current=Date.now())},[ye,b]);(0,n.useEffect)(()=>{A.current?.setOutputActive(h),j.current=Date.now()},[h]),(0,n.useEffect)(()=>{if(L!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,L]),(0,n.useEffect)(()=>{if(!C)return;let e=window.setInterval(()=>{let e=A.current;!e||k.current||Wt.current||Yt.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-j.current<6e4||(A.current?.log.add(`call-timeout`),gt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,C]);let Rn=C&&!bt&&(m||h);(0,n.useEffect)(()=>()=>Q(),[Q]);let[zn,Bn]=(0,n.useState)(``),Vn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(Vn.current&&!m){let e=[...p].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&Bn(e.content)}Vn.current=m},[m,p]),(0,n.useLayoutEffect)(()=>{if(!d)return;let e=D.current,t=z||V?e?.querySelector(`.cf-confirm__card`):U?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[V,z,d,U]),(0,n.useEffect)(()=>{if(!d)return;let e=D.current,t=z||V?e?.querySelector(`.cf-confirm__card`):U?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=rn.current;if(t.confirmEnd){B(!1);return}if(t.confirmClear){H(!1);return}if(t.showHistory){W(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;q();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[d,q,z,V,U]),(0,n.useEffect)(()=>{let e=D.current;e&&(d?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[d]);let Hn=a.accentColor??a.themeTokens?.accent??f?.accentColor,Un=a.themeTokens?.accentText??te(Hn,a.themeTokens?.background??(Nt===`dark`?`#0f1c27`:`#ffffff`)),Wn={zIndex:a.zIndex,"--cf-h-pad":`${a.horizontalPadding}px`,"--cf-v-pad":`${a.verticalPadding}px`,...Un?{"--cf-accent-ink":Un}:{},...a.themeTokens?.accentStrong?{"--cf-accent-2":a.themeTokens.accentStrong}:{},...a.themeTokens?.background?{"--cf-bg":a.themeTokens.background}:{},...a.themeTokens?.surface?{"--cf-surface":a.themeTokens.surface}:{},...a.themeTokens?.surfaceMuted?{"--cf-surface-2":a.themeTokens.surfaceMuted}:{},...a.themeTokens?.text?{"--cf-text":a.themeTokens.text}:{},...a.themeTokens?.mutedText?{"--cf-muted":a.themeTokens.mutedText}:{},...a.themeTokens?.border?{"--cf-border":a.themeTokens.border}:{},...a.themeTokens?.shadow?{"--cf-shadow":a.themeTokens.shadow}:{},...a.themeTokens?.radius?{"--cf-radius":a.themeTokens.radius}:{},...a.themeTokens?.fontFamily?{"--cf-font":a.themeTokens.fontFamily}:{},...a.themeTokens?.success?{"--cf-success":a.themeTokens.success}:{},...a.themeTokens?.warning?{"--cf-warning":a.themeTokens.warning}:{},...a.themeTokens?.danger?{"--cf-danger":a.themeTokens.danger}:{},...Hn?{"--cf-accent":Hn,"--cf-accent-2":a.themeTokens?.accentStrong??`color-mix(in oklab, ${Hn} 76%, #14141f)`}:{}},Gn=e=>_(e),Kn=[...p].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,qn=p.some(e=>e.role===`user`),Jn=!!(f?.allowVoiceInput&&f?.talkbackMode&&f.talkbackMode!==`text`),Yn=Jn,Xn=!G&&Yn&&!qn?sn.filter((e,t)=>!(t===0&&e.role===`assistant`)):sn,Zn=g===`human`&&pe?pe:f?.agentName??u.chatName,Qn=g===`human`?u.liveSupport:g===`queued`?u.waitingForTeam:f?.offline?u.statusOffline:u.statusOnline,$n=!y&&!G?f?.availableActions:void 0,er=!y&&!G?f?.actions:void 0,tr=C&&!vt&&L===`connecting`&&!G;return(0,r.jsx)(e.G,{value:u,children:(0,r.jsx)(e.W,{value:a.locale,children:(0,r.jsxs)(`div`,{class:`cf-root`,dir:a.dir,"data-theme":Nt,"data-align":a.alignment,"data-display":`floating`,style:Wn,children:[w&&d&&(0,r.jsx)(`div`,{class:`cf-theater-backdrop`,onClick:wn}),(0,r.jsxs)(`div`,{ref:D,class:`cf-panel ${d?`is-open`:``} ${C?`cf-panel--call`:``} ${tr?`cf-panel--voice-connecting`:``} ${w&&d?`cf-panel--theater`:``} ${cn||ln?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${u.chatName}: ${f?.agentName??u.assistantName}`,"aria-hidden":!d,children:[rt&&d&&(0,r.jsx)(o,{state:rt,onClose:lt}),(0,r.jsxs)(`div`,{class:`cf-header`,children:[(0,r.jsx)(e.y,{persona:f,hideWhenMissing:!0}),(0,r.jsxs)(`div`,{class:`cf-header__meta`,children:[(0,r.jsx)(`div`,{class:`cf-header__name`,children:Zn}),a.token.startsWith(`pub_test_`)?(0,r.jsx)(`small`,{role:`status`,children:u.testMode}):null,(0,r.jsx)(`div`,{class:`cf-header__status ${g===`ai`&&f?.offline?`cf-header__status--offline`:``}`,children:(0,r.jsx)(`span`,{class:`cf-header__status-text`,children:Qn})})]}),(0,r.jsxs)(`div`,{class:`cf-header__actions`,children:[Ke.length>0&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.pastConversations,title:u.pastConversations,"aria-pressed":U,onClick:()=>W(e=>!e),children:(0,r.jsx)(e.N,{})}),qn&&!y&&!G&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.endChat,title:u.endChat,onClick:un,children:(0,r.jsx)(e.M,{})}),a.sound&&Pt&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":jt?u.unmuteSounds:u.muteSounds,"aria-pressed":jt,onClick:Ft,children:jt?(0,r.jsx)(e.P,{}):(0,r.jsx)(e.F,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":u.closeChat,onClick:q,children:(0,r.jsx)(e.j,{})})]})]}),(0,r.jsx)(`div`,{class:`cf-panel__video`,children:cn?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:(0,r.jsx)(e.D,{visualization:cn,expanded:!0,onFollowUp:e=>{Cn(),_(e)},onClose:Cn})}):ln?.visualization?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:(0,r.jsx)(e.E,{visualization:ln.visualization,onClose:Cn,onFollowUp:e=>{Cn(),_(e)},onFeedback:G?void 0:Oe,transport:G?void 0:ke(`widget`),onOpenSource:a.onOpenAnalyticsSource})}):!G&&Yn?(0,r.jsx)(e.b,{persona:f,starters:[],onPick:_,onFocusComposer:Mn,speaking:h,voiceState:L,replyPending:C&&m&&!h,pinned:!0,muted:bt,onToggleMute:Nn,onEndCall:Q,onTalkNow:Ln,showTalkNow:Rn,micLevel:St,theaterMode:w,onToggleTheater:bn,onMinimize:q,audioDevices:Dt,selectedAudioDeviceId:kt,onSelectAudioDevice:In,connectingOnly:tr}):null}),!tr&&(0,r.jsxs)(`div`,{class:`cf-panel__chat`,children:[a.preview&&(0,r.jsx)(`div`,{class:`cf-preview-banner`,children:u.previewBanner}),G&&(0,r.jsx)(`div`,{class:`cf-viewing-banner`,children:u.viewingPast}),(0,r.jsxs)(`div`,{class:`cf-body`,ref:Lt,role:`log`,onScroll:hn,children:[Xn.map((t,n)=>(0,r.jsx)(e.w,{msg:t,persona:f,isLast:!G&&n===Xn.length-1,visitor:de,hasEmail:fe,lastQuestion:Kn,showActions:!G&&n===Xn.length-1&&!!(t.handoffOffered||t.selectedAction),onPickReply:Gn,onSubmitForm:Fe,onDemoSlots:Ve,onConfirmHostedBooking:Ie,onRetry:we,ratable:!G&&Xn.slice(0,n).some(e=>e.role===`user`),onRate:Te,onDoubleCheck:G||y?void 0:Ee,onRetryResponse:G||y||g!==`ai`?void 0:De,doubleCheckDisabled:m,onExplanationFeedback:G?void 0:Oe,explanationTransport:G?void 0:ke(`widget`),onOpenAnalyticsSource:a.onOpenAnalyticsSource,onExpandVisualization:G?void 0:xn,onExpandExplanation:G?void 0:Sn,onOpenAttachment:st,onReconnect:!G&&!y&&ut&&t.id===nt?je:void 0},t.id)),!qn&&!G&&(0,r.jsxs)(r.Fragment,{children:[Xn.length===0&&(0,r.jsx)(s,{name:f?.agentName??u.assistantName,greeting:f?.greeting}),(0,r.jsx)(e.T,{items:he,onPick:_}),(0,r.jsx)(e.S,{items:ge})]}),Qt&&(0,r.jsxs)(`button`,{type:`button`,class:`cf-newmsg`,onClick:Y,children:[(0,r.jsx)(e.k,{}),u.newMessages]})]}),(0,r.jsx)(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:zn}),m&&!y&&!G&&(0,r.jsx)(`div`,{class:`cf-stopbar`,children:(0,r.jsxs)(`button`,{type:`button`,class:`cf-stop`,onClick:ye,children:[(0,r.jsx)(e.I,{}),u.stop]})}),G?(0,r.jsx)(`div`,{class:`cf-ended`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Xe,children:u.backToChat})}):y?(0,r.jsxs)(`div`,{class:`cf-ended`,children:[(0,r.jsx)(`p`,{class:`cf-ended__text`,children:u.conversationEnded}),a.csat&&qn?an?(0,r.jsx)(`p`,{class:`cf-ended__text`,children:u.feedbackThanks}):(0,r.jsxs)(`div`,{class:`cf-csat`,children:[(0,r.jsx)(`span`,{class:`cf-csat__q`,children:u.csatPrompt}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackHelpful,onClick:()=>{Pe(`up`),on(!0)},children:(0,r.jsx)(e.R,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackNotHelpful,onClick:()=>{Pe(`down`),on(!0)},children:(0,r.jsx)(e.L,{})})]}):null,(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:fn,children:u.startNewChat})]}):(0,r.jsxs)(r.Fragment,{children:[me?(0,r.jsx)(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:e.K(u.agentTyping,{name:me})}):null,$n&&$n.length>0&&(0,r.jsx)(`div`,{class:`cf-footer-actions`,children:(0,r.jsx)(e.v,{actions:$n,descriptors:er,visitor:de,onSubmitForm:Fe,onDemoSlots:Ve,onConfirmHostedBooking:Ie,scheduler:f?.scheduler,translations:a.actionTranslations})},`footer-actions`),(0,r.jsx)(e.x,{toolbarContent:a.showAnalyticsModelSelector?(0,r.jsx)(e.U,{models:$e,value:et,onChange:tt,disabled:m}):null,draftStore:nn,onSend:_,onSendGif:_e,onTyping:ve,disabled:m,allowVoice:Jn&&a.composer?.voice!==!1,onTranscribe:Le,gifEnabled:He,onSearchGifs:Be,allowAttach:a.attachments,analyzeAttachments:!0,onUpload:Re,onPreviewAttachment:ct},`composer`)]}),!y&&f?.disclaimerText&&(0,r.jsx)(`div`,{class:`cf-disclaimer`,children:f.disclaimerText}),(0,r.jsxs)(`div`,{class:`cf-footer`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":u.clearDeviceData,onClick:()=>H(!0),children:u.privacyAndData}),(0,r.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),u.poweredBy,` `,(0,r.jsx)(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),z&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>B(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>B(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:u.endChatConfirm}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:u.endChatConfirmBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{ref:en,type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>B(!1),children:u.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:dn,children:u.endConfirmCta})]})]})},`confirm-end`),U&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>W(!1),children:(0,r.jsxs)(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":u.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>W(!1)),children:[(0,r.jsxs)(`div`,{class:`cf-history__head`,children:[(0,r.jsx)(`span`,{children:u.pastConversations}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.closeHistory,onClick:()=>W(!1),children:(0,r.jsx)(e.j,{})})]}),(0,r.jsx)(`div`,{class:`cf-history__list`,children:Ke.map(e=>(0,r.jsxs)(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===qe?`is-active`:``}`,onClick:()=>{Ye(e.sessionId),W(!1)},children:[(0,r.jsx)(`span`,{class:`cf-history__title`,children:e.title}),(0,r.jsxs)(`span`,{class:`cf-history__meta`,children:[new Date(e.ts).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),e.ended?` · ${u.historyEnded}`:``]})]},e.sessionId))}),(0,r.jsx)(`div`,{class:`cf-history__footer`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{W(!1),H(!0)},children:u.clearDeviceData})})]})},`history`),V&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>H(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>H(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:u.clearDeviceData}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:u.clearDeviceDataBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>H(!1),children:u.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{H(!1),Ze()},children:u.clearDeviceDataCta})]})]})},`confirm-clear`)]}),C&&!d?(0,r.jsx)(e.C,{persona:f,voiceState:L,muted:bt,onToggleMute:Nn,onEndCall:Q,micLevel:St,onExpand:K}):w&&d?null:!a.hideDefaultLauncher&&(0,r.jsxs)(`button`,{ref:It,type:`button`,class:`cf-launcher`,"aria-label":d?u.closeChat:x>0?`${u.openChat}. ${x===1?u.unreadMessage:e.K(u.unreadMessages,{count:String(x)})}`:u.openChat,"aria-expanded":d,onClick:J,children:[a.launcherIcon?(0,r.jsx)(`img`,{class:`cf-launcher__img`,src:a.launcherIcon,alt:``}):(0,r.jsx)(e.A,{}),!d&&x>0&&(0,r.jsx)(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:x>99?`99+`:x})]})]})})})},p=`centrinfo-widget`;var m=class extends HTMLElement{constructor(...t){super(...t),e.tt(this,`controls`,null),e.tt(this,`composerDraftStore`,{value:``})}mountWith(n){let i=e.n(n),a=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(i.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let t=new CSSStyleSheet;t.replaceSync(e.t),a.adoptedStyleSheets=[t]}else{let t=document.createElement(`style`);i.styleNonce&&(t.nonce=i.styleNonce),t.textContent=e.t,a.appendChild(t)}(0,t.render)((0,r.jsx)(f,{transport:e.et(i),config:i,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore}),a)}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.shadowRoot&&(0,t.render)(null,this.shadowRoot)}};typeof customElements<`u`&&!customElements.get(p)&&customElements.define(p,m);const h=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(p);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),destroy:()=>{n.unmount(),n.remove()}}},de=e=>h(e);let fe=null;const g=e=>{fe?.destroy();let t=de(e);return fe=t,t},pe={init:g,createWidget:de};exports.Centrinfo=pe,exports.createWidget=de,exports.init=g;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig
|
|
1
|
+
import { T as WidgetStrings, d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig } from "./types-CCk7I1fM.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mount.d.ts
|
|
4
4
|
/** Create + mount the floating public messenger. */
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig
|
|
1
|
+
import { T as WidgetStrings, d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig } from "./types-CmLbqY23.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mount.d.ts
|
|
4
4
|
/** Create + mount the floating public messenger. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig
|
|
1
|
+
import { T as WidgetStrings, d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig } from "./types-CmLbqY23.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mount.d.ts
|
|
4
4
|
/** Create + mount the floating public messenger. */
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,E as r,F as i,H as a,I as o,L as s,M as ee,N as te,O as ne,P as re,R as ie,S as ae,T as oe,U as se,V as ce,X as c,Z as le,_ as ue,a as de,b as fe,d as pe,h as me,i as he,j as ge,k as _e,m as ve,n as ye,p as be,r as xe,t as l,u as Se,v as Ce,w as we,x as Te,y as Ee,z as De}from"./styles-mW_qo6Ed.mjs";import{render as u}from"preact";import{useCallback as d,useEffect as f,useLayoutEffect as Oe,useRef as p,useState as m}from"preact/hooks";import{Fragment as ke,jsx as h,jsxs as g}from"preact/jsx-runtime";const Ae=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom();n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},je=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,Me=({state:e,onClose:n})=>{let r=ce(),i=p(null);f(()=>{i.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[n]);let a=e.status===`ready`?je(e.mimeType):`other`;return h(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":t(r.attachPreviewTitle,{name:e.name}),onClick:e=>{e.target===e.currentTarget&&n()},children:g(`div`,{class:`cf-preview__frame`,children:[g(`div`,{class:`cf-preview__bar`,children:[h(`span`,{class:`cf-preview__name`,title:e.name,children:e.name}),e.status===`ready`&&h(`a`,{class:`cf-preview__btn`,href:e.url,download:e.name,children:r.attachDownload}),h(`button`,{ref:i,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":r.attachPreviewClose,onClick:n,children:`✕`})]}),g(`div`,{class:`cf-preview__body`,children:[e.status===`loading`&&h(`p`,{class:`cf-preview__note`,children:r.attachPreviewLoading}),e.status===`error`&&h(`p`,{class:`cf-preview__note`,children:r.attachPreviewFailed}),e.status===`ready`&&a===`image`&&h(`img`,{class:`cf-preview__image`,src:e.url,alt:e.name}),e.status===`ready`&&a===`pdf`&&h(`iframe`,{class:`cf-preview__pdf`,src:e.url,title:e.name}),e.status===`ready`&&a===`other`&&h(`p`,{class:`cf-preview__note`,children:r.attachPreviewUnsupported})]})]})})},Ne=({name:e,greeting:n})=>{let r=ce();return g(`section`,{class:`cf-empty-welcome`,"aria-label":t(r.welcomeLabel,{name:e}),children:[h(`span`,{class:`cf-empty-welcome__eyebrow`,children:r.welcomeEyebrow}),h(`h2`,{children:e}),h(`p`,{children:n||r.welcomePrompt})]})},Pe=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],ee=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),ee.focus()):!e.shiftKey&&(o===ee||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},_=new Map,v=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},Fe=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(_.has(n))return _.get(n);let r=v(e),i=v(t)??[255,255,255,1];if(!r){_.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,ee=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return _.set(n,ee),ee},Ie=e=>{let[t,n]=m(`light`);return f(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),r=()=>n(t.matches?`dark`:`light`);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`auto`?t:e},Le={end:`end the call`,mute:`mute your microphone`,minimize:`minimize the chat`,expand:`expand the view`,shrink:`exit the expanded view`},Re=e=>e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/\s+/g,` `).trim(),y=[{action:`shrink`,re:/\b(?:exit|leave|quit|close)\b[\s\w]*\b(?:full ?screen|expanded|theat(?:er|re))\b|\bshrink\b|\bsmaller view\b/},{action:`end`,re:/\b(?:end|close|stop|finish|hang ?up|quit|exit)\b[\s\w]*\b(?:call|chat|conversation|convo|session|talking)\b|\bhang ?up\b|\bgood ?bye\b|^bye(?: bye)?$/},{action:`mute`,re:/\bmute\b|\bstop listening\b/},{action:`minimize`,re:/\bminimi[sz]e\b|\bhide\b[\s\w]*\b(?:chat|call|window|widget)\b/},{action:`expand`,re:/\bexpand\b|\bmaximi[sz]e\b|\bfull ?screen\b|\btheat(?:er|re) mode\b|\bbigger view\b/}],ze=/^(?:yes|yeah|yep|yup|sure|correct|confirm|affirmative|go ahead|do it|please do|ok(?:ay)?)\b/,Be=/^(?:no|nope|nah|cancel|never ?mind|don'?t|stop)\b/,Ve=/^(?:end|close|stop|finish|hang ?up|quit|exit|bye|good ?bye)\b/,He=e=>{let t=Re(e);if(!t)return null;for(let{action:e,re:n}of y)if(n.test(t)){let n=t.split(` `).length;return{action:e,confident:e===`end`?n<=10:n<=6}}return null},Ue=e=>`I didn't catch yes or no. Say yes to ${Le[e]}, or no to keep talking.`,b=({transport:ce,config:c,bindControls:le,composerDraftStore:ye})=>{let l=c.strings,[u,je]=m(c.openByDefault),{persona:_,messages:v,sending:y,assistantSpeaking:b,visitor:We,hasEmail:Ge,liveMode:Ke,assignedAgentName:qe,agentTypingName:Je,starters:Ye,featuredLinks:Xe,send:x,sendGif:Ze,notifyTyping:Qe,stop:$e,amend:et,hold:tt,resumeHeld:nt,duckSpeaking:rt,retry:it,rateMessage:at,rateExplanation:ot,explanationTransport:st,injectAssistant:ct,reconnectSupport:lt,appendUserDraft:ut,patchMessage:S,removeMessage:dt,submitCsat:ft,submitForm:pt,confirmHostedBooking:mt,transcribe:ht,uploadAttachment:gt,loadAttachment:_t,searchGifs:vt,demoSlots:yt,gifEnabled:bt,identify:xt,ended:C,endConversation:St,startNew:Ct,history:wt,viewingSessionId:Tt,viewMessages:Et,openConversation:Dt,closeHistoryView:Ot,shutdown:kt,stopSpeaking:w,speakAssistantText:At}=de(ce,c,u),jt=he(v,Ke),[Mt,Nt]=m(null),Pt=p(0),Ft=d((e,t,n)=>{n===Pt.current&&Nt({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),It=d((e,t,n)=>{let r=t.name,i=++Pt.current;Nt({status:`loading`,name:r}),_t(e,t,n).then(e=>Ft(e,r,i),()=>{i===Pt.current&&Nt({status:`error`,name:r})})},[_t,Ft]),Lt=d((e,t)=>Ft(e,t,++Pt.current),[Ft]),Rt=d(()=>{Pt.current+=1,Nt(null)},[]);f(()=>()=>{Mt?.status===`ready`&&URL.revokeObjectURL(Mt.url)},[Mt]);let zt=!!xe(_?.actions),[T,Bt]=m(0),[E,Vt]=m({mic:`off`,processing:!1}),[Ht,Ut]=m(null),[Wt,Gt]=m(!1),[D,Kt]=m(!1),[qt,Jt]=m(!1),[Yt,Xt]=m(!1),[Zt,Qt]=m(0),[O,k]=m(!1),[$t,A]=m(null),[en,tn]=m(null),[nn,rn]=m([]),[an,on]=m(``),[sn,cn]=m(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),ln=Ie(c.theme),un=_?.soundEnabled??!0;f(()=>{pe(c.sound&&un&&!sn)},[c.sound,un,sn]);let dn=d(()=>{cn(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),j=p(null),fn=p(null),pn=p(null),mn=p(0),M=p(!1),N=p(!1),P=p(null),F=p(0),hn=p(void 0),gn=p(0),_n=p(null),vn=p(!1),I=p(null),L=p(``),yn=p(()=>{}),bn=p(``),xn=p(y),Sn=p(x);Sn.current=x;let Cn=p(et);Cn.current=et;let wn=p(ht);wn.current=ht;let R=p(!1),z=p(!1),Tn=p(``);Tn.current=[...v].reverse().find(e=>e.role===`assistant`)?.content??``;let En=p(b);xn.current=y,En.current=b;let B=D?Wt?`timeout`:Yt||E.mic===`muted`?`muted`:E.mic===`unavailable`?E.reason===`permission-denied`||E.reason===`unsupported`?`denied`:`unavailable`:E.mic===`off`||E.mic===`starting`?`connecting`:E.mic===`hearing`?`hearing`:b?`speaking`:Ht??(E.processing||y?`processing`:`listening`):`idle`,[Dn,On]=m(!0),[kn,V]=m(!1),An=p(0),[H,jn]=m(!1),[U,W]=m(!1),Mn=p(null),[G,K]=m(!1),Nn=p({value:``}),Pn=ye??Nn.current,Fn=p({confirmEnd:H,confirmClear:U,showHistory:G});Fn.current={confirmEnd:H,confirmClear:U,showHistory:G};let[In,Ln]=m(!1),q=!!Tt,Rn=q?Et:v,zn=Rn.find(e=>e.id===$t&&e.visualization)?.visualization,Bn=Rn.find(e=>e.id===en&&e.visualization);f(()=>{!en||Bn||(tn(null),k(!1))},[en,Bn]),f(()=>{!$t||zn||(A(null),k(!1))},[zn,$t]);let Vn=d(()=>{je(!0),Bt(0),Se(`open`),c.onOpen?.(),c.onShow?.()},[c]),J=d(()=>{je(!1),k(!1),A(null),c.onClose?.(),c.onHide?.(),fn.current?.focus()},[c]),Hn=d(()=>u?J():Vn(),[u,Vn,J]),Un=d(()=>jn(!0),[]),Wn=d(()=>{St(),jn(!1)},[St]),Gn=d(()=>{Ct(),V(!1),On(!0)},[Ct]);f(()=>{H&&Mn.current?.focus()},[H]),f(()=>{le({open:Vn,close:J,toggle:Hn,identify:xt,startNew:Ct,endConversation:St,shutdown:kt})},[le,Vn,J,Hn,xt,Ct,St,kt]),f(()=>{let e=v.filter(e=>e.role===`assistant`&&!e.pending).length;if(u){mn.current=e;return}e>mn.current&&Bt(e-mn.current)},[v,u]),f(()=>{c.onUnreadChange?.(T)},[T,c]),f(()=>{let e=c.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>kt(),e*60*1e3);return()=>clearTimeout(t)},[c.sessionDurationMinutes,v,u,kt]),f(()=>{let e=c.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),Hn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[c.customLauncherSelector,Hn]);let Kn=p(!1);f(()=>{let e=c.proactiveMessage?.trim();if(!e||Kn.current)return;let t=c.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${c.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(u||C||v.some(e=>e.role===`user`))){Kn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}ct(e),Vn()}},Math.max(0,c.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[c.proactiveMessage]),f(()=>{let e=pn.current;if(!u||!e)return;let t=v[v.length-1],n=Date.now()<An.current;t?.role===`user`||Dn||n?(requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),V(!1),n&&On(!0)):V(!0)},[v,u,y,Dn]);let qn=p(!0);qn.current=Dn,f(()=>{let e=pn.current;if(!(!u||!e))return Ae(e,{isAtBottom:()=>qn.current,onUnseen:()=>V(!0)})},[u,q]);let Jn=d(()=>{let e=pn.current;if(!e)return;if(M.current&&!q){On(!0),V(!1);return}let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;On(t),t&&V(!1)},[q]),Y=d(()=>{let e=pn.current;e&&(e.scrollTop=e.scrollHeight),V(!1),On(!0)},[]),Yn=d(()=>{An.current=Date.now()+3e3,requestAnimationFrame(Y)},[Y]);f(()=>{if(!u||q||!D||B===`connecting`)return;An.current=Date.now()+6e4,Y();let e=requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)}),t=[80,180,360].map(e=>window.setTimeout(Y,e));return()=>{cancelAnimationFrame(e),t.forEach(e=>window.clearTimeout(e))}},[b,v,u,Y,y,D,q,B]);let Xn=d(()=>{j.current?.querySelector(`.cf-textarea`)?.focus()},[]),Zn=d((e,t)=>{Ut(e),hn.current&&window.clearTimeout(hn.current),hn.current=window.setTimeout(()=>Ut(null),3e3),t&&!N.current&&At(t)},[At]),Qn=d(e=>{let t=I.current;if(t)return t;Yn();let n=ut(e);return I.current=n,S(n,{content:L.current||e,pending:!0,streaming:!1}),n},[ut,Yn,S]),X=d(()=>{let e=I.current;if(e){if(L.current){S(e,{content:L.current,pending:!0});return}I.current=null,dt(e)}},[S,dt]),Z=d(()=>{z.current&&(z.current=!1,rt(!1)),R.current&&(R.current=!1,nt())},[rt,nt]),Q=d(()=>{M.current=!1,P.current?.stop(`call-ended`),P.current=null,R.current=!1,z.current=!1,N.current=!1,_n.current=null,vn.current=!1;let e=I.current;I.current=null,L.current=``,e&&dt(e),hn.current&&window.clearTimeout(hn.current),Ut(null),Gt(!1),Vt({mic:`off`,processing:!1}),Qt(0),Kt(!1),Jt(!1),Xt(!1),k(!1),A(null),w()},[dt,w]),$n=d(()=>{O&&A(null),k(!O)},[O]),er=d(e=>{A(e),k(!0)},[]),tr=d(e=>{tn(e),k(!0)},[]),nr=d(()=>{let e=$t,t=en;A(null),tn(null),k(!1),window.requestAnimationFrame(()=>{(t?j.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(j.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[$t,en]),rr=d(()=>{A(null),tn(null),k(!1)},[]),ir=d((e,t,n=!1)=>{if(Yn(),t&&(S(t,{content:e,pending:!1,streaming:!1}),I.current===t&&(I.current=null)),L.current=``,n){w(),Cn.current(e,{forceVoicePlayback:!0,userMessageId:t});return}M.current&&(tt()?Cn.current(e,{forceVoicePlayback:!0,userMessageId:t}):Sn.current(e,{forceVoicePlayback:!0,userMessageId:t}))},[Yn,tt,S,w]),$=d(e=>{ct(e),At(e)},[ct,At]),ar=d(()=>{if(F.current=Date.now(),Ut(null),En.current){z.current=!0,rt(!0);return}R.current||(R.current=tt()),Qn(`Listening...`)},[rt,Qn,tt]),or=d(e=>{let t=I.current;!t||z.current||S(t,{content:`${[L.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[S]),sr=d(e=>{F.current=Date.now();let t=[L.current,e.text].map(e=>e.trim()).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();if((z.current||e.overlappedOutput)&&se(e.text,Tn.current)){X(),Z();return}if(!t||be(t)||ve(t)){let e=z.current||R.current;X(),Z(),e||Zn(`misunderstood`);return}z.current&&(z.current=!1,$e(),w());let n=_n.current;if(n){L.current=``,X();let e=Re(t);if(ze.test(e)||n===`end`&&Ve.test(e)){_n.current=null,yn.current(n);return}if(Be.test(e)){_n.current=null,$(`Okay, never mind — what would you like to know?`);return}$(Ue(n));return}let r=He(t);if(r){if(L.current=``,X(),Z(),r.confident){yn.current(r.action);return}_n.current=r.action,$(`Just to confirm — you want me to ${Le[r.action]}? Please say yes or no.`);return}let i=Qn(t);S(i,{content:t,pending:!0});let a=R.current;R.current=!1,ir(t,i,a)},[Qn,S,Z,ir,X,Zn,$,$e,w]),cr=d(e=>{F.current=Date.now();let t=z.current||R.current;if(X(),Z(),!(t||e.overlappedOutput||e.reason===`too-short`)){if(e.reason===`transcribe-failed`){Zn(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`);return}Zn(`noise`)}},[Z,X,Zn]),lr=p({speechStart:ar,partial:or,turn:sr,noise:cr});lr.current={speechStart:ar,partial:or,turn:sr,noise:cr};let ur=d(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{rn(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||`Microphone ${t+1}`})))}).catch(()=>{})},[]),dr=d(()=>{if(M.current){Q();return}if(Xn(),!_?.allowVoiceInput||!_.talkbackMode||_.talkbackMode===`text`||xn.current||C||q)return;F.current=Date.now(),N.current=!1,M.current=!0,Xt(!1),Kt(!0),Jt(!1),Gt(!1);let e=!1,t=new a({deviceId:bn.current||void 0,transcribe:async({audio:e,mimeType:t,durationSeconds:n})=>{let r=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return me(await wn.current(e,t,r,n))},listener:{state:t=>{Vt(t),t.mic!==`starting`&&t.mic!==`off`&&Jt(!0),!e&&t.mic===`listening`&&(e=!0,ur())},speechStart:()=>lr.current.speechStart(),partial:({text:e})=>lr.current.partial(e),turn:e=>lr.current.turn(e),noise:e=>lr.current.noise(e),level:e=>{let t=performance.now();t-gn.current<90||(gn.current=t,Qt(e))}}});P.current=t,t.setOutputActive(En.current),t.start()},[Q,C,Xn,_,ur,q]),fr=d(()=>{let e=!N.current;N.current=e,Xt(e),P.current?.setMuted(e),e?(L.current=``,X(),Z()):F.current=Date.now()},[Z,X]),pr=d(e=>{switch(F.current=Date.now(),e){case`end`:vn.current=!0,$(`Okay — ending our call now. Goodbye!`),window.setTimeout(()=>{vn.current&&(vn.current=!1,Q())},2e3);break;case`mute`:N.current||fr(),$(`Muted. Tap the mic button when you want me to listen again.`);break;case`minimize`:J(),$(`Minimized — I'm still listening. Tap the call pill to bring the chat back.`);break;case`expand`:k(!0),$(`Sure — expanding the view.`);break;case`shrink`:A(null),k(!1),$(`Okay — back to the smaller view.`);break}},[J,Q,$,fr]);f(()=>{yn.current=pr},[pr]);let mr=p(!1);f(()=>{mr.current&&!b&&vn.current&&(vn.current=!1,Q()),mr.current=b},[b,Q]);let hr=d(e=>{bn.current=e,on(e),P.current?.selectDevice(e||void 0)},[]),gr=d(()=>{!M.current||N.current||(z.current=!1,R.current=!1,$e(),w(),F.current=Date.now())},[$e,w]);f(()=>{P.current?.setOutputActive(b),F.current=Date.now()},[b]),f(()=>{if(B!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,B]),f(()=>{if(!D)return;let e=window.setInterval(()=>{let e=P.current;!e||N.current||xn.current||En.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-F.current<6e4||(P.current?.log.add(`call-timeout`),Gt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,D]);let _r=D&&!Yt&&(y||b);f(()=>()=>Q(),[Q]);let[vr,yr]=m(``),br=p(!1);f(()=>{if(br.current&&!y){let e=[...v].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&yr(e.content)}br.current=y},[y,v]),Oe(()=>{if(!u)return;let e=j.current,t=H||U?e?.querySelector(`.cf-confirm__card`):G?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[U,H,u,G]),f(()=>{if(!u)return;let e=j.current,t=H||U?e?.querySelector(`.cf-confirm__card`):G?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Fn.current;if(t.confirmEnd){jn(!1);return}if(t.confirmClear){W(!1);return}if(t.showHistory){K(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;J();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[u,J,H,U,G]),f(()=>{let e=j.current;e&&(u?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[u]);let xr=c.accentColor??c.themeTokens?.accent??_?.accentColor,Sr=c.themeTokens?.accentText??Fe(xr,c.themeTokens?.background??(ln===`dark`?`#0f1c27`:`#ffffff`)),Cr={zIndex:c.zIndex,"--cf-h-pad":`${c.horizontalPadding}px`,"--cf-v-pad":`${c.verticalPadding}px`,...Sr?{"--cf-accent-ink":Sr}:{},...c.themeTokens?.accentStrong?{"--cf-accent-2":c.themeTokens.accentStrong}:{},...c.themeTokens?.background?{"--cf-bg":c.themeTokens.background}:{},...c.themeTokens?.surface?{"--cf-surface":c.themeTokens.surface}:{},...c.themeTokens?.surfaceMuted?{"--cf-surface-2":c.themeTokens.surfaceMuted}:{},...c.themeTokens?.text?{"--cf-text":c.themeTokens.text}:{},...c.themeTokens?.mutedText?{"--cf-muted":c.themeTokens.mutedText}:{},...c.themeTokens?.border?{"--cf-border":c.themeTokens.border}:{},...c.themeTokens?.shadow?{"--cf-shadow":c.themeTokens.shadow}:{},...c.themeTokens?.radius?{"--cf-radius":c.themeTokens.radius}:{},...c.themeTokens?.fontFamily?{"--cf-font":c.themeTokens.fontFamily}:{},...c.themeTokens?.success?{"--cf-success":c.themeTokens.success}:{},...c.themeTokens?.warning?{"--cf-warning":c.themeTokens.warning}:{},...c.themeTokens?.danger?{"--cf-danger":c.themeTokens.danger}:{},...xr?{"--cf-accent":xr,"--cf-accent-2":c.themeTokens?.accentStrong??`color-mix(in oklab, ${xr} 76%, #14141f)`}:{}},wr=e=>x(e),Tr=[...v].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,Er=v.some(e=>e.role===`user`),Dr=!!(_?.allowVoiceInput&&_?.talkbackMode&&_.talkbackMode!==`text`),Or=Dr,kr=!q&&Or&&!Er?Rn.filter((e,t)=>!(t===0&&e.role===`assistant`)):Rn,Ar=Ke===`human`&&qe?qe:_?.agentName??l.chatName,jr=Ke===`human`?l.liveSupport:Ke===`queued`?l.waitingForTeam:_?.offline?l.statusOffline:l.statusOnline,Mr=!C&&!q?_?.availableActions:void 0,Nr=!C&&!q?_?.actions:void 0,Pr=D&&!qt&&B===`connecting`&&!q;return h(De,{value:l,children:h(ie,{value:c.locale,children:g(`div`,{class:`cf-root`,dir:c.dir,"data-theme":ln,"data-align":c.alignment,"data-display":`floating`,style:Cr,children:[O&&u&&h(`div`,{class:`cf-theater-backdrop`,onClick:rr}),g(`div`,{ref:j,class:`cf-panel ${u?`is-open`:``} ${D?`cf-panel--call`:``} ${Pr?`cf-panel--voice-connecting`:``} ${O&&u?`cf-panel--theater`:``} ${zn||Bn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${l.chatName}: ${_?.agentName??l.assistantName}`,"aria-hidden":!u,children:[Mt&&u&&h(Me,{state:Mt,onClose:Rt}),g(`div`,{class:`cf-header`,children:[h(Ce,{persona:_,hideWhenMissing:!0}),g(`div`,{class:`cf-header__meta`,children:[h(`div`,{class:`cf-header__name`,children:Ar}),h(`div`,{class:`cf-header__status ${Ke===`ai`&&_?.offline?`cf-header__status--offline`:``}`,children:h(`span`,{class:`cf-header__status-text`,children:jr})})]}),g(`div`,{class:`cf-header__actions`,children:[wt.length>0&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.pastConversations,title:l.pastConversations,"aria-pressed":G,onClick:()=>K(e=>!e),children:h(ee,{})}),Er&&!C&&!q&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.endChat,title:l.endChat,onClick:Un,children:h(ge,{})}),c.sound&&un&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":sn?l.unmuteSounds:l.muteSounds,"aria-pressed":sn,onClick:dn,children:h(sn?te:re,{})}),h(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":l.closeChat,onClick:J,children:h(e,{})})]})]}),h(`div`,{class:`cf-panel__video`,children:zn?h(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":l.expandedAnalyticsResult,children:h(r,{visualization:zn,expanded:!0,onFollowUp:e=>{nr(),x(e)},onClose:nr})}):Bn?.visualization?h(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":l.expandedAnalyticsResult,children:h(oe,{visualization:Bn.visualization,onClose:nr,onFollowUp:e=>{nr(),x(e)},onFeedback:q?void 0:ot,transport:q?void 0:st(`widget`),onOpenSource:c.onOpenAnalyticsSource})}):!q&&Or?h(Ee,{persona:_,starters:[],onPick:x,onFocusComposer:dr,speaking:b,voiceState:B,replyPending:D&&y&&!b,pinned:!0,muted:Yt,onToggleMute:fr,onEndCall:Q,onTalkNow:gr,showTalkNow:_r,micLevel:Zt,theaterMode:O,onToggleTheater:$n,onMinimize:J,audioDevices:nn,selectedAudioDeviceId:an,onSelectAudioDevice:hr,connectingOnly:Pr}):null}),!Pr&&g(`div`,{class:`cf-panel__chat`,children:[c.preview&&h(`div`,{class:`cf-preview-banner`,children:l.previewBanner}),q&&h(`div`,{class:`cf-viewing-banner`,children:l.viewingPast}),g(`div`,{class:`cf-body`,ref:pn,role:`log`,onScroll:Jn,children:[kr.map((e,t)=>h(n,{msg:e,persona:_,isLast:!q&&t===kr.length-1,visitor:We,hasEmail:Ge,lastQuestion:Tr,showActions:!q&&t===kr.length-1&&!!(e.handoffOffered||e.selectedAction),onPickReply:wr,onSubmitForm:pt,onDemoSlots:yt,onConfirmHostedBooking:mt,onRetry:it,ratable:!q&&kr.slice(0,t).some(e=>e.role===`user`),onRate:at,onExplanationFeedback:q?void 0:ot,explanationTransport:q?void 0:st(`widget`),onOpenAnalyticsSource:c.onOpenAnalyticsSource,onExpandVisualization:q?void 0:er,onExpandExplanation:q?void 0:tr,onOpenAttachment:It,onReconnect:!q&&!C&&zt&&e.id===jt?lt:void 0},e.id)),!Er&&!q&&g(ke,{children:[kr.length===0&&h(Ne,{name:_?.agentName??l.assistantName,greeting:_?.greeting}),h(we,{items:Ye,onPick:x}),h(Te,{items:Xe})]}),kn&&g(`button`,{type:`button`,class:`cf-newmsg`,onClick:Y,children:[h(ne,{}),l.newMessages]})]}),h(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:vr}),y&&!C&&!q&&h(`div`,{class:`cf-stopbar`,children:g(`button`,{type:`button`,class:`cf-stop`,onClick:$e,children:[h(i,{}),l.stop]})}),q?h(`div`,{class:`cf-ended`,children:h(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Ot,children:l.backToChat})}):C?g(`div`,{class:`cf-ended`,children:[h(`p`,{class:`cf-ended__text`,children:l.conversationEnded}),c.csat&&Er?In?h(`p`,{class:`cf-ended__text`,children:l.feedbackThanks}):g(`div`,{class:`cf-csat`,children:[h(`span`,{class:`cf-csat__q`,children:l.csatPrompt}),h(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":l.feedbackHelpful,onClick:()=>{ft(`up`),Ln(!0)},children:h(s,{})}),h(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":l.feedbackNotHelpful,onClick:()=>{ft(`down`),Ln(!0)},children:h(o,{})})]}):null,h(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Gn,children:l.startNewChat})]}):g(ke,{children:[Je?h(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:t(l.agentTyping,{name:Je})}):null,Mr&&Mr.length>0&&h(`div`,{class:`cf-footer-actions`,children:h(ue,{actions:Mr,descriptors:Nr,visitor:We,onSubmitForm:pt,onDemoSlots:yt,onConfirmHostedBooking:mt,scheduler:_?.scheduler,translations:c.actionTranslations})},`footer-actions`),h(fe,{draftStore:Pn,onSend:x,onSendGif:Ze,onTyping:Qe,disabled:y,allowVoice:Dr,onTranscribe:ht,gifEnabled:bt,onSearchGifs:vt,allowAttach:c.attachments,analyzeAttachments:!0,onUpload:gt,onPreviewAttachment:Lt},`composer`)]}),!C&&_?.disclaimerText&&h(`div`,{class:`cf-disclaimer`,children:_.disclaimerText}),g(`div`,{class:`cf-footer`,children:[h(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":l.clearDeviceData,onClick:()=>W(!0),children:l.privacyAndData}),h(`span`,{"aria-hidden":`true`,children:`·`}),l.poweredBy,` `,h(`a`,{href:`https://accurix.tech/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),H&&h(`div`,{class:`cf-confirm`,onClick:()=>jn(!1),children:g(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":l.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Pe(e,e.currentTarget,()=>jn(!1)),children:[h(`div`,{class:`cf-confirm__title`,children:l.endChatConfirm}),h(`div`,{class:`cf-confirm__body`,children:l.endChatConfirmBody}),g(`div`,{class:`cf-confirm__actions`,children:[h(`button`,{ref:Mn,type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>jn(!1),children:l.cancel}),h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:Wn,children:l.endConfirmCta})]})]})},`confirm-end`),G&&h(`div`,{class:`cf-confirm`,onClick:()=>K(!1),children:g(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":l.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Pe(e,e.currentTarget,()=>K(!1)),children:[g(`div`,{class:`cf-history__head`,children:[h(`span`,{children:l.pastConversations}),h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.closeHistory,onClick:()=>K(!1),children:h(e,{})})]}),h(`div`,{class:`cf-history__list`,children:wt.map(e=>g(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===Tt?`is-active`:``}`,onClick:()=>{Dt(e.sessionId),K(!1)},children:[h(`span`,{class:`cf-history__title`,children:e.title}),g(`span`,{class:`cf-history__meta`,children:[new Date(e.ts).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),e.ended?` · ${l.historyEnded}`:``]})]},e.sessionId))}),h(`div`,{class:`cf-history__footer`,children:h(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{K(!1),W(!0)},children:l.clearDeviceData})})]})},`history`),U&&h(`div`,{class:`cf-confirm`,onClick:()=>W(!1),children:g(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":l.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Pe(e,e.currentTarget,()=>W(!1)),children:[h(`div`,{class:`cf-confirm__title`,children:l.clearDeviceData}),h(`div`,{class:`cf-confirm__body`,children:l.clearDeviceDataBody}),g(`div`,{class:`cf-confirm__actions`,children:[h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>W(!1),children:l.cancel}),h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{W(!1),kt()},children:l.clearDeviceDataCta})]})]})},`confirm-clear`)]}),D&&!u?h(ae,{persona:_,voiceState:B,muted:Yt,onToggleMute:fr,onEndCall:Q,micLevel:Zt,onExpand:Vn}):O&&u?null:!c.hideDefaultLauncher&&g(`button`,{ref:fn,type:`button`,class:`cf-launcher`,"aria-label":u?l.closeChat:T>0?`${l.openChat}. ${T===1?l.unreadMessage:t(l.unreadMessages,{count:String(T)})}`:l.openChat,"aria-expanded":u,onClick:Hn,children:[c.launcherIcon?h(`img`,{class:`cf-launcher__img`,src:c.launcherIcon,alt:``}):h(_e,{}),!u&&T>0&&h(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:T>99?`99+`:T})]})]})})})},We=`centrinfo-widget`;var Ge=class extends HTMLElement{constructor(...e){super(...e),le(this,`controls`,null),le(this,`composerDraftStore`,{value:``})}mountWith(e){let t=ye(e),n=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(t.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let e=new CSSStyleSheet;e.replaceSync(l),n.adoptedStyleSheets=[e]}else{let e=document.createElement(`style`);t.styleNonce&&(e.nonce=t.styleNonce),e.textContent=l,n.appendChild(e)}u(h(b,{transport:c(t),config:t,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore}),n)}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.shadowRoot&&u(null,this.shadowRoot)}};typeof customElements<`u`&&!customElements.get(We)&&customElements.define(We,Ge);const Ke=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(We);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),destroy:()=>{n.unmount(),n.remove()}}},qe=e=>Ke(e);let Je=null;const Ye=e=>{Je?.destroy();let t=qe(e);return Je=t,t},Xe={init:Ye,createWidget:qe};export{Xe as Centrinfo,qe as createWidget,Ye as init};
|
|
1
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,I as ee,K as s,L as te,M as ne,N as re,P as ie,R as ae,S as oe,T as se,U as ce,V as le,W as ue,a as de,b as fe,d as pe,et as me,f as he,g as ge,h as _e,i as ve,j as ye,k as be,m as xe,n as c,o as Se,q as Ce,t as we,tt as l,v as Te,w as Ee,x as De,y as Oe}from"./styles-BNPs-1he.mjs";import{render as u}from"preact";import{useCallback as d,useEffect as f,useLayoutEffect as ke,useRef as p,useState as m}from"preact/hooks";import{Fragment as Ae,jsx as h,jsxs as g}from"preact/jsx-runtime";const je=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom();n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},Me=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,Ne=({state:e,onClose:t})=>{let n=Ce(),r=p(null);f(()=>{r.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let i=e.status===`ready`?Me(e.mimeType):`other`;return h(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":s(n.attachPreviewTitle,{name:e.name}),onClick:e=>{e.target===e.currentTarget&&t()},children:g(`div`,{class:`cf-preview__frame`,children:[g(`div`,{class:`cf-preview__bar`,children:[h(`span`,{class:`cf-preview__name`,title:e.name,children:e.name}),e.status===`ready`&&h(`a`,{class:`cf-preview__btn`,href:e.url,download:e.name,children:n.attachDownload}),h(`button`,{ref:r,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":n.attachPreviewClose,onClick:t,children:`✕`})]}),g(`div`,{class:`cf-preview__body`,children:[e.status===`loading`&&h(`p`,{class:`cf-preview__note`,children:n.attachPreviewLoading}),e.status===`error`&&h(`p`,{class:`cf-preview__note`,children:n.attachPreviewFailed}),e.status===`ready`&&i===`image`&&h(`img`,{class:`cf-preview__image`,src:e.url,alt:e.name}),e.status===`ready`&&i===`pdf`&&h(`iframe`,{class:`cf-preview__pdf`,src:e.url,title:e.name}),e.status===`ready`&&i===`other`&&h(`p`,{class:`cf-preview__note`,children:n.attachPreviewUnsupported})]})]})})},Pe=({name:e,greeting:t})=>{let n=Ce();return g(`section`,{class:`cf-empty-welcome`,"aria-label":s(n.welcomeLabel,{name:e}),children:[h(`span`,{class:`cf-empty-welcome__eyebrow`,children:n.welcomeEyebrow}),h(`h2`,{children:e}),h(`p`,{children:t||n.welcomePrompt})]})},Fe=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,ee=r[0],s=r[r.length-1];e.shiftKey&&(o===ee||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),s.focus()):!e.shiftKey&&(o===s||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),ee.focus())},_=new Map,v=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},Ie=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(_.has(n))return _.get(n);let r=v(e),i=v(t)??[255,255,255,1];if(!r){_.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),ee=o[0]*.2126+o[1]*.7152+o[2]*.0722,s=1.05/(ee+.05)>=(ee+.05)/.059?`#ffffff`:`#0f1e2a`;return _.set(n,s),s},Le=e=>{let[t,n]=m(`light`);return f(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),r=()=>n(t.matches?`dark`:`light`);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`auto`?t:e},Re={end:`end the call`,mute:`mute your microphone`,minimize:`minimize the chat`,expand:`expand the view`,shrink:`exit the expanded view`},ze=e=>e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/\s+/g,` `).trim(),y=[{action:`shrink`,re:/\b(?:exit|leave|quit|close)\b[\s\w]*\b(?:full ?screen|expanded|theat(?:er|re))\b|\bshrink\b|\bsmaller view\b/},{action:`end`,re:/\b(?:end|close|stop|finish|hang ?up|quit|exit)\b[\s\w]*\b(?:call|chat|conversation|convo|session|talking)\b|\bhang ?up\b|\bgood ?bye\b|^bye(?: bye)?$/},{action:`mute`,re:/\bmute\b|\bstop listening\b/},{action:`minimize`,re:/\bminimi[sz]e\b|\bhide\b[\s\w]*\b(?:chat|call|window|widget)\b/},{action:`expand`,re:/\bexpand\b|\bmaximi[sz]e\b|\bfull ?screen\b|\btheat(?:er|re) mode\b|\bbigger view\b/}],Be=/^(?:yes|yeah|yep|yup|sure|correct|confirm|affirmative|go ahead|do it|please do|ok(?:ay)?)\b/,Ve=/^(?:no|nope|nah|cancel|never ?mind|don'?t|stop)\b/,He=/^(?:end|close|stop|finish|hang ?up|quit|exit|bye|good ?bye)\b/,Ue=e=>{let t=ze(e);if(!t)return null;for(let{action:e,re:n}of y)if(n.test(t)){let n=t.split(` `).length;return{action:e,confident:e===`end`?n<=10:n<=6}}return null},We=e=>`I didn't catch yes or no. Say yes to ${Re[e]}, or no to keep talking.`,b=({transport:me,config:c,bindControls:Ce,composerDraftStore:we})=>{let l=c.strings,[u,Me]=m(c.openByDefault),{persona:_,messages:v,sending:y,assistantSpeaking:b,visitor:Ge,hasEmail:Ke,liveMode:x,assignedAgentName:qe,agentTypingName:Je,starters:Ye,featuredLinks:Xe,send:S,sendGif:Ze,notifyTyping:Qe,stop:$e,amend:et,hold:tt,resumeHeld:nt,duckSpeaking:rt,retry:it,rateMessage:at,doubleCheckResponse:ot,retryResponse:st,rateExplanation:ct,explanationTransport:lt,injectAssistant:ut,reconnectSupport:dt,appendUserDraft:ft,patchMessage:C,removeMessage:pt,submitCsat:mt,submitForm:ht,confirmHostedBooking:gt,transcribe:_t,uploadAttachment:vt,loadAttachment:yt,searchGifs:bt,demoSlots:xt,gifEnabled:St,identify:Ct,ended:w,endConversation:wt,startNew:Tt,history:Et,viewingSessionId:Dt,viewMessages:Ot,openConversation:kt,closeHistoryView:At,shutdown:jt,stopSpeaking:T,speakAssistantText:Mt,analyticsModels:Nt,analyticsModelId:Pt,selectAnalyticsModel:Ft}=Se(me,c,u),It=de(v,x),[Lt,Rt]=m(null),zt=p(0),Bt=d((e,t,n)=>{n===zt.current&&Rt({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),Vt=d((e,t,n)=>{let r=t.name,i=++zt.current;Rt({status:`loading`,name:r}),yt(e,t,n).then(e=>Bt(e,r,i),()=>{i===zt.current&&Rt({status:`error`,name:r})})},[yt,Bt]),Ht=d((e,t)=>Bt(e,t,++zt.current),[Bt]),Ut=d(()=>{zt.current+=1,Rt(null)},[]);f(()=>()=>{Lt?.status===`ready`&&URL.revokeObjectURL(Lt.url)},[Lt]);let Wt=!!ve(_?.actions),[E,Gt]=m(0),[D,Kt]=m({mic:`off`,processing:!1}),[qt,Jt]=m(null),[Yt,Xt]=m(!1),[O,Zt]=m(!1),[Qt,$t]=m(!1),[en,tn]=m(!1),[nn,rn]=m(0),[k,A]=m(!1),[an,j]=m(null),[on,sn]=m(null),[cn,ln]=m([]),[un,dn]=m(``),[fn,pn]=m(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),mn=Le(c.theme),hn=_?.soundEnabled??!0;f(()=>{he(c.sound&&hn&&!fn)},[c.sound,hn,fn]);let gn=d(()=>{pn(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),M=p(null),_n=p(null),vn=p(null),yn=p(0),bn=p(!1),N=p(!1),P=p(null),F=p(0),xn=p(void 0),Sn=p(0),Cn=p(null),wn=p(!1),I=p(null),L=p(``),Tn=p(()=>{}),En=p(``),Dn=p(y),On=p(S);On.current=S;let kn=p(et);kn.current=et;let An=p(_t);An.current=_t;let R=p(!1),z=p(!1),jn=p(``);jn.current=[...v].reverse().find(e=>e.role===`assistant`)?.content??``;let Mn=p(b);Dn.current=y,Mn.current=b;let B=O?Yt?`timeout`:en||D.mic===`muted`?`muted`:D.mic===`unavailable`?D.reason===`permission-denied`||D.reason===`unsupported`?`denied`:`unavailable`:D.mic===`off`||D.mic===`starting`?`connecting`:D.mic===`hearing`?`hearing`:b?`speaking`:qt??(D.processing||y?`processing`:`listening`):`idle`,[Nn,Pn]=m(!0),[Fn,V]=m(!1),In=p(0),[H,Ln]=m(!1),[U,W]=m(!1),Rn=p(null),[G,K]=m(!1),zn=p({value:``}),Bn=we??zn.current,Vn=p({confirmEnd:H,confirmClear:U,showHistory:G});Vn.current={confirmEnd:H,confirmClear:U,showHistory:G};let[Hn,Un]=m(!1),q=!!Dt,Wn=q?Ot:v,Gn=Wn.find(e=>e.id===an&&e.visualization)?.visualization,Kn=Wn.find(e=>e.id===on&&e.visualization);f(()=>{!on||Kn||(sn(null),A(!1))},[on,Kn]),f(()=>{!an||Gn||(j(null),A(!1))},[Gn,an]);let qn=d(()=>{Me(!0),Gt(0),pe(`open`),c.onOpen?.(),c.onShow?.()},[c]),J=d(()=>{Me(!1),A(!1),j(null),c.onClose?.(),c.onHide?.(),_n.current?.focus()},[c]),Jn=d(()=>u?J():qn(),[u,qn,J]),Yn=d(()=>Ln(!0),[]),Xn=d(()=>{wt(),Ln(!1)},[wt]),Zn=d(()=>{Tt(),V(!1),Pn(!0)},[Tt]);f(()=>{H&&Rn.current?.focus()},[H]),f(()=>{Ce({open:qn,close:J,toggle:Jn,identify:Ct,startNew:Tt,endConversation:wt,shutdown:jt})},[Ce,qn,J,Jn,Ct,Tt,wt,jt]),f(()=>{let e=v.filter(e=>e.role===`assistant`&&!e.pending).length;if(u){yn.current=e;return}e>yn.current&&Gt(e-yn.current)},[v,u]),f(()=>{c.onUnreadChange?.(E)},[E,c]),f(()=>{let e=c.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>jt(),e*60*1e3);return()=>clearTimeout(t)},[c.sessionDurationMinutes,v,u,jt]),f(()=>{let e=c.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),Jn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[c.customLauncherSelector,Jn]);let Qn=p(!1);f(()=>{let e=c.proactiveMessage?.trim();if(!e||Qn.current)return;let t=c.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${c.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(u||w||v.some(e=>e.role===`user`))){Qn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}ut(e),qn()}},Math.max(0,c.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[c.proactiveMessage]),f(()=>{let e=vn.current;if(!u||!e)return;let t=v[v.length-1],n=Date.now()<In.current;t?.role===`user`||Nn||n?(requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),V(!1),n&&Pn(!0)):V(!0)},[v,u,y,Nn]);let $n=p(!0);$n.current=Nn,f(()=>{let e=vn.current;if(!(!u||!e))return je(e,{isAtBottom:()=>$n.current,onUnseen:()=>V(!0)})},[u,q]);let er=d(()=>{let e=vn.current;if(!e)return;if(bn.current&&!q){Pn(!0),V(!1);return}let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;Pn(t),t&&V(!1)},[q]),Y=d(()=>{let e=vn.current;e&&(e.scrollTop=e.scrollHeight),V(!1),Pn(!0)},[]),tr=d(()=>{In.current=Date.now()+3e3,requestAnimationFrame(Y)},[Y]);f(()=>{if(!u||q||!O||B===`connecting`)return;In.current=Date.now()+6e4,Y();let e=requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)}),t=[80,180,360].map(e=>window.setTimeout(Y,e));return()=>{cancelAnimationFrame(e),t.forEach(e=>window.clearTimeout(e))}},[b,v,u,Y,y,O,q,B]);let nr=d(()=>{M.current?.querySelector(`.cf-textarea`)?.focus()},[]),rr=d((e,t)=>{Jt(e),xn.current&&window.clearTimeout(xn.current),xn.current=window.setTimeout(()=>Jt(null),3e3),t&&!N.current&&Mt(t)},[Mt]),ir=d(e=>{let t=I.current;if(t)return t;tr();let n=ft(e);return I.current=n,C(n,{content:L.current||e,pending:!0,streaming:!1}),n},[ft,tr,C]),X=d(()=>{let e=I.current;if(e){if(L.current){C(e,{content:L.current,pending:!0});return}I.current=null,pt(e)}},[C,pt]),Z=d(()=>{z.current&&(z.current=!1,rt(!1)),R.current&&(R.current=!1,nt())},[rt,nt]),Q=d(()=>{bn.current=!1,P.current?.stop(`call-ended`),P.current=null,R.current=!1,z.current=!1,N.current=!1,Cn.current=null,wn.current=!1;let e=I.current;I.current=null,L.current=``,e&&pt(e),xn.current&&window.clearTimeout(xn.current),Jt(null),Xt(!1),Kt({mic:`off`,processing:!1}),rn(0),Zt(!1),$t(!1),tn(!1),A(!1),j(null),T()},[pt,T]),ar=d(()=>{k&&j(null),A(!k)},[k]),or=d(e=>{j(e),A(!0)},[]),sr=d(e=>{sn(e),A(!0)},[]),cr=d(()=>{let e=an,t=on;j(null),sn(null),A(!1),window.requestAnimationFrame(()=>{(t?M.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(M.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[an,on]),lr=d(()=>{j(null),sn(null),A(!1)},[]),ur=d((e,t,n=!1)=>{if(tr(),t&&(C(t,{content:e,pending:!1,streaming:!1}),I.current===t&&(I.current=null)),L.current=``,n){T(),kn.current(e,{forceVoicePlayback:!0,userMessageId:t});return}bn.current&&(tt()?kn.current(e,{forceVoicePlayback:!0,userMessageId:t}):On.current(e,{forceVoicePlayback:!0,userMessageId:t}))},[tr,tt,C,T]),$=d(e=>{ut(e),Mt(e)},[ut,Mt]),dr=d(()=>{if(F.current=Date.now(),Jt(null),Mn.current){z.current=!0,rt(!0);return}R.current||(R.current=tt()),ir(`Listening...`)},[rt,ir,tt]),fr=d(e=>{let t=I.current;!t||z.current||C(t,{content:`${[L.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[C]),pr=d(e=>{F.current=Date.now();let t=[L.current,e.text].map(e=>e.trim()).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();if((z.current||e.overlappedOutput)&&le(e.text,jn.current)){X(),Z();return}if(!t||xe(t)||_e(t)){let e=z.current||R.current;X(),Z(),e||rr(`misunderstood`);return}z.current&&(z.current=!1,$e(),T());let n=Cn.current;if(n){L.current=``,X();let e=ze(t);if(Be.test(e)||n===`end`&&He.test(e)){Cn.current=null,Tn.current(n);return}if(Ve.test(e)){Cn.current=null,$(`Okay, never mind — what would you like to know?`);return}$(We(n));return}let r=Ue(t);if(r){if(L.current=``,X(),Z(),r.confident){Tn.current(r.action);return}Cn.current=r.action,$(`Just to confirm — you want me to ${Re[r.action]}? Please say yes or no.`);return}let i=ir(t);C(i,{content:t,pending:!0});let a=R.current;R.current=!1,ur(t,i,a)},[ir,C,Z,ur,X,rr,$,$e,T]),mr=d(e=>{F.current=Date.now();let t=z.current||R.current;if(X(),Z(),!(t||e.overlappedOutput||e.reason===`too-short`)){if(e.reason===`transcribe-failed`){rr(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`);return}rr(`noise`)}},[Z,X,rr]),hr=p({speechStart:dr,partial:fr,turn:pr,noise:mr});hr.current={speechStart:dr,partial:fr,turn:pr,noise:mr};let gr=d(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{ln(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||`Microphone ${t+1}`})))}).catch(()=>{})},[]),_r=d(()=>{if(bn.current){Q();return}if(nr(),!_?.allowVoiceInput||!_.talkbackMode||_.talkbackMode===`text`||Dn.current||w||q)return;F.current=Date.now(),N.current=!1,bn.current=!0,tn(!1),Zt(!0),$t(!1),Xt(!1);let e=!1,n=new t({deviceId:En.current||void 0,transcribe:async({audio:e,mimeType:t,durationSeconds:n})=>{let r=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return ge(await An.current(e,t,r,n))},listener:{state:t=>{Kt(t),t.mic!==`starting`&&t.mic!==`off`&&$t(!0),!e&&t.mic===`listening`&&(e=!0,gr())},speechStart:()=>hr.current.speechStart(),partial:({text:e})=>hr.current.partial(e),turn:e=>hr.current.turn(e),noise:e=>hr.current.noise(e),level:e=>{let t=performance.now();t-Sn.current<90||(Sn.current=t,rn(e))}}});P.current=n,n.setOutputActive(Mn.current),n.start()},[Q,w,nr,_,gr,q]),vr=d(()=>{let e=!N.current;N.current=e,tn(e),P.current?.setMuted(e),e?(L.current=``,X(),Z()):F.current=Date.now()},[Z,X]),yr=d(e=>{switch(F.current=Date.now(),e){case`end`:wn.current=!0,$(`Okay — ending our call now. Goodbye!`),window.setTimeout(()=>{wn.current&&(wn.current=!1,Q())},2e3);break;case`mute`:N.current||vr(),$(`Muted. Tap the mic button when you want me to listen again.`);break;case`minimize`:J(),$(`Minimized — I'm still listening. Tap the call pill to bring the chat back.`);break;case`expand`:A(!0),$(`Sure — expanding the view.`);break;case`shrink`:j(null),A(!1),$(`Okay — back to the smaller view.`);break}},[J,Q,$,vr]);f(()=>{Tn.current=yr},[yr]);let br=p(!1);f(()=>{br.current&&!b&&wn.current&&(wn.current=!1,Q()),br.current=b},[b,Q]);let xr=d(e=>{En.current=e,dn(e),P.current?.selectDevice(e||void 0)},[]),Sr=d(()=>{!bn.current||N.current||(z.current=!1,R.current=!1,$e(),T(),F.current=Date.now())},[$e,T]);f(()=>{P.current?.setOutputActive(b),F.current=Date.now()},[b]),f(()=>{if(B!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,B]),f(()=>{if(!O)return;let e=window.setInterval(()=>{let e=P.current;!e||N.current||Dn.current||Mn.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-F.current<6e4||(P.current?.log.add(`call-timeout`),Xt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,O]);let Cr=O&&!en&&(y||b);f(()=>()=>Q(),[Q]);let[wr,Tr]=m(``),Er=p(!1);f(()=>{if(Er.current&&!y){let e=[...v].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&Tr(e.content)}Er.current=y},[y,v]),ke(()=>{if(!u)return;let e=M.current,t=H||U?e?.querySelector(`.cf-confirm__card`):G?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[U,H,u,G]),f(()=>{if(!u)return;let e=M.current,t=H||U?e?.querySelector(`.cf-confirm__card`):G?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Vn.current;if(t.confirmEnd){Ln(!1);return}if(t.confirmClear){W(!1);return}if(t.showHistory){K(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;J();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],ee=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&ee===a?(n.preventDefault(),o.focus()):!n.shiftKey&&ee===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[u,J,H,U,G]),f(()=>{let e=M.current;e&&(u?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[u]);let Dr=c.accentColor??c.themeTokens?.accent??_?.accentColor,Or=c.themeTokens?.accentText??Ie(Dr,c.themeTokens?.background??(mn===`dark`?`#0f1c27`:`#ffffff`)),kr={zIndex:c.zIndex,"--cf-h-pad":`${c.horizontalPadding}px`,"--cf-v-pad":`${c.verticalPadding}px`,...Or?{"--cf-accent-ink":Or}:{},...c.themeTokens?.accentStrong?{"--cf-accent-2":c.themeTokens.accentStrong}:{},...c.themeTokens?.background?{"--cf-bg":c.themeTokens.background}:{},...c.themeTokens?.surface?{"--cf-surface":c.themeTokens.surface}:{},...c.themeTokens?.surfaceMuted?{"--cf-surface-2":c.themeTokens.surfaceMuted}:{},...c.themeTokens?.text?{"--cf-text":c.themeTokens.text}:{},...c.themeTokens?.mutedText?{"--cf-muted":c.themeTokens.mutedText}:{},...c.themeTokens?.border?{"--cf-border":c.themeTokens.border}:{},...c.themeTokens?.shadow?{"--cf-shadow":c.themeTokens.shadow}:{},...c.themeTokens?.radius?{"--cf-radius":c.themeTokens.radius}:{},...c.themeTokens?.fontFamily?{"--cf-font":c.themeTokens.fontFamily}:{},...c.themeTokens?.success?{"--cf-success":c.themeTokens.success}:{},...c.themeTokens?.warning?{"--cf-warning":c.themeTokens.warning}:{},...c.themeTokens?.danger?{"--cf-danger":c.themeTokens.danger}:{},...Dr?{"--cf-accent":Dr,"--cf-accent-2":c.themeTokens?.accentStrong??`color-mix(in oklab, ${Dr} 76%, #14141f)`}:{}},Ar=e=>S(e),jr=[...v].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,Mr=v.some(e=>e.role===`user`),Nr=!!(_?.allowVoiceInput&&_?.talkbackMode&&_.talkbackMode!==`text`),Pr=Nr,Fr=!q&&Pr&&!Mr?Wn.filter((e,t)=>!(t===0&&e.role===`assistant`)):Wn,Ir=x===`human`&&qe?qe:_?.agentName??l.chatName,Lr=x===`human`?l.liveSupport:x===`queued`?l.waitingForTeam:_?.offline?l.statusOffline:l.statusOnline,Rr=!w&&!q?_?.availableActions:void 0,zr=!w&&!q?_?.actions:void 0,Br=O&&!Qt&&B===`connecting`&&!q;return h(o,{value:l,children:h(ue,{value:c.locale,children:g(`div`,{class:`cf-root`,dir:c.dir,"data-theme":mn,"data-align":c.alignment,"data-display":`floating`,style:kr,children:[k&&u&&h(`div`,{class:`cf-theater-backdrop`,onClick:lr}),g(`div`,{ref:M,class:`cf-panel ${u?`is-open`:``} ${O?`cf-panel--call`:``} ${Br?`cf-panel--voice-connecting`:``} ${k&&u?`cf-panel--theater`:``} ${Gn||Kn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${l.chatName}: ${_?.agentName??l.assistantName}`,"aria-hidden":!u,children:[Lt&&u&&h(Ne,{state:Lt,onClose:Ut}),g(`div`,{class:`cf-header`,children:[h(Oe,{persona:_,hideWhenMissing:!0}),g(`div`,{class:`cf-header__meta`,children:[h(`div`,{class:`cf-header__name`,children:Ir}),c.token.startsWith(`pub_test_`)?h(`small`,{role:`status`,children:l.testMode}):null,h(`div`,{class:`cf-header__status ${x===`ai`&&_?.offline?`cf-header__status--offline`:``}`,children:h(`span`,{class:`cf-header__status-text`,children:Lr})})]}),g(`div`,{class:`cf-header__actions`,children:[Et.length>0&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.pastConversations,title:l.pastConversations,"aria-pressed":G,onClick:()=>K(e=>!e),children:h(re,{})}),Mr&&!w&&!q&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.endChat,title:l.endChat,onClick:Yn,children:h(ne,{})}),c.sound&&hn&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":fn?l.unmuteSounds:l.muteSounds,"aria-pressed":fn,onClick:gn,children:h(fn?ie:a,{})}),h(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":l.closeChat,onClick:J,children:h(ye,{})})]})]}),h(`div`,{class:`cf-panel__video`,children:Gn?h(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":l.expandedAnalyticsResult,children:h(r,{visualization:Gn,expanded:!0,onFollowUp:e=>{cr(),S(e)},onClose:cr})}):Kn?.visualization?h(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":l.expandedAnalyticsResult,children:h(i,{visualization:Kn.visualization,onClose:cr,onFollowUp:e=>{cr(),S(e)},onFeedback:q?void 0:ct,transport:q?void 0:lt(`widget`),onOpenSource:c.onOpenAnalyticsSource})}):!q&&Pr?h(fe,{persona:_,starters:[],onPick:S,onFocusComposer:_r,speaking:b,voiceState:B,replyPending:O&&y&&!b,pinned:!0,muted:en,onToggleMute:vr,onEndCall:Q,onTalkNow:Sr,showTalkNow:Cr,micLevel:nn,theaterMode:k,onToggleTheater:ar,onMinimize:J,audioDevices:cn,selectedAudioDeviceId:un,onSelectAudioDevice:xr,connectingOnly:Br}):null}),!Br&&g(`div`,{class:`cf-panel__chat`,children:[c.preview&&h(`div`,{class:`cf-preview-banner`,children:l.previewBanner}),q&&h(`div`,{class:`cf-viewing-banner`,children:l.viewingPast}),g(`div`,{class:`cf-body`,ref:vn,role:`log`,onScroll:er,children:[Fr.map((e,t)=>h(Ee,{msg:e,persona:_,isLast:!q&&t===Fr.length-1,visitor:Ge,hasEmail:Ke,lastQuestion:jr,showActions:!q&&t===Fr.length-1&&!!(e.handoffOffered||e.selectedAction),onPickReply:Ar,onSubmitForm:ht,onDemoSlots:xt,onConfirmHostedBooking:gt,onRetry:it,ratable:!q&&Fr.slice(0,t).some(e=>e.role===`user`),onRate:at,onDoubleCheck:q||w?void 0:ot,onRetryResponse:q||w||x!==`ai`?void 0:st,doubleCheckDisabled:y,onExplanationFeedback:q?void 0:ct,explanationTransport:q?void 0:lt(`widget`),onOpenAnalyticsSource:c.onOpenAnalyticsSource,onExpandVisualization:q?void 0:or,onExpandExplanation:q?void 0:sr,onOpenAttachment:Vt,onReconnect:!q&&!w&&Wt&&e.id===It?dt:void 0},e.id)),!Mr&&!q&&g(Ae,{children:[Fr.length===0&&h(Pe,{name:_?.agentName??l.assistantName,greeting:_?.greeting}),h(se,{items:Ye,onPick:S}),h(oe,{items:Xe})]}),Fn&&g(`button`,{type:`button`,class:`cf-newmsg`,onClick:Y,children:[h(be,{}),l.newMessages]})]}),h(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:wr}),y&&!w&&!q&&h(`div`,{class:`cf-stopbar`,children:g(`button`,{type:`button`,class:`cf-stop`,onClick:$e,children:[h(ee,{}),l.stop]})}),q?h(`div`,{class:`cf-ended`,children:h(`button`,{type:`button`,class:`cf-ended__btn`,onClick:At,children:l.backToChat})}):w?g(`div`,{class:`cf-ended`,children:[h(`p`,{class:`cf-ended__text`,children:l.conversationEnded}),c.csat&&Mr?Hn?h(`p`,{class:`cf-ended__text`,children:l.feedbackThanks}):g(`div`,{class:`cf-csat`,children:[h(`span`,{class:`cf-csat__q`,children:l.csatPrompt}),h(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":l.feedbackHelpful,onClick:()=>{mt(`up`),Un(!0)},children:h(ae,{})}),h(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":l.feedbackNotHelpful,onClick:()=>{mt(`down`),Un(!0)},children:h(te,{})})]}):null,h(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Zn,children:l.startNewChat})]}):g(Ae,{children:[Je?h(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:s(l.agentTyping,{name:Je})}):null,Rr&&Rr.length>0&&h(`div`,{class:`cf-footer-actions`,children:h(Te,{actions:Rr,descriptors:zr,visitor:Ge,onSubmitForm:ht,onDemoSlots:xt,onConfirmHostedBooking:gt,scheduler:_?.scheduler,translations:c.actionTranslations})},`footer-actions`),h(De,{toolbarContent:c.showAnalyticsModelSelector?h(ce,{models:Nt,value:Pt,onChange:Ft,disabled:y}):null,draftStore:Bn,onSend:S,onSendGif:Ze,onTyping:Qe,disabled:y,allowVoice:Nr&&c.composer?.voice!==!1,onTranscribe:_t,gifEnabled:St,onSearchGifs:bt,allowAttach:c.attachments,analyzeAttachments:!0,onUpload:vt,onPreviewAttachment:Ht},`composer`)]}),!w&&_?.disclaimerText&&h(`div`,{class:`cf-disclaimer`,children:_.disclaimerText}),g(`div`,{class:`cf-footer`,children:[h(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":l.clearDeviceData,onClick:()=>W(!0),children:l.privacyAndData}),h(`span`,{"aria-hidden":`true`,children:`·`}),l.poweredBy,` `,h(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),H&&h(`div`,{class:`cf-confirm`,onClick:()=>Ln(!1),children:g(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":l.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>Ln(!1)),children:[h(`div`,{class:`cf-confirm__title`,children:l.endChatConfirm}),h(`div`,{class:`cf-confirm__body`,children:l.endChatConfirmBody}),g(`div`,{class:`cf-confirm__actions`,children:[h(`button`,{ref:Rn,type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>Ln(!1),children:l.cancel}),h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:Xn,children:l.endConfirmCta})]})]})},`confirm-end`),G&&h(`div`,{class:`cf-confirm`,onClick:()=>K(!1),children:g(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":l.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>K(!1)),children:[g(`div`,{class:`cf-history__head`,children:[h(`span`,{children:l.pastConversations}),h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.closeHistory,onClick:()=>K(!1),children:h(ye,{})})]}),h(`div`,{class:`cf-history__list`,children:Et.map(e=>g(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===Dt?`is-active`:``}`,onClick:()=>{kt(e.sessionId),K(!1)},children:[h(`span`,{class:`cf-history__title`,children:e.title}),g(`span`,{class:`cf-history__meta`,children:[new Date(e.ts).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),e.ended?` · ${l.historyEnded}`:``]})]},e.sessionId))}),h(`div`,{class:`cf-history__footer`,children:h(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{K(!1),W(!0)},children:l.clearDeviceData})})]})},`history`),U&&h(`div`,{class:`cf-confirm`,onClick:()=>W(!1),children:g(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":l.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>W(!1)),children:[h(`div`,{class:`cf-confirm__title`,children:l.clearDeviceData}),h(`div`,{class:`cf-confirm__body`,children:l.clearDeviceDataBody}),g(`div`,{class:`cf-confirm__actions`,children:[h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>W(!1),children:l.cancel}),h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{W(!1),jt()},children:l.clearDeviceDataCta})]})]})},`confirm-clear`)]}),O&&!u?h(n,{persona:_,voiceState:B,muted:en,onToggleMute:vr,onEndCall:Q,micLevel:nn,onExpand:qn}):k&&u?null:!c.hideDefaultLauncher&&g(`button`,{ref:_n,type:`button`,class:`cf-launcher`,"aria-label":u?l.closeChat:E>0?`${l.openChat}. ${E===1?l.unreadMessage:s(l.unreadMessages,{count:String(E)})}`:l.openChat,"aria-expanded":u,onClick:Jn,children:[c.launcherIcon?h(`img`,{class:`cf-launcher__img`,src:c.launcherIcon,alt:``}):h(e,{}),!u&&E>0&&h(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:E>99?`99+`:E})]})]})})})},Ge=`centrinfo-widget`;var Ke=class extends HTMLElement{constructor(...e){super(...e),l(this,`controls`,null),l(this,`composerDraftStore`,{value:``})}mountWith(e){let t=c(e),n=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(t.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let e=new CSSStyleSheet;e.replaceSync(we),n.adoptedStyleSheets=[e]}else{let e=document.createElement(`style`);t.styleNonce&&(e.nonce=t.styleNonce),e.textContent=we,n.appendChild(e)}u(h(b,{transport:me(t),config:t,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore}),n)}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.shadowRoot&&u(null,this.shadowRoot)}};typeof customElements<`u`&&!customElements.get(Ge)&&customElements.define(Ge,Ke);const x=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(Ge);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),destroy:()=>{n.unmount(),n.remove()}}},qe=e=>x(e);let Je=null;const Ye=e=>{Je?.destroy();let t=qe(e);return Je=t,t},Xe={init:Ye,createWidget:qe};export{Xe as Centrinfo,qe as createWidget,Ye as init};
|
package/dist/runtime.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./styles-
|
|
2
|
-
`)},n=(t,n,r)=>e.
|
|
1
|
+
const e=require(`./styles-Bp-0ZpvF.cjs`),t=(e,n)=>{let r=e.replace(/\/\*[\s\S]*?\*\//g,``),i=e=>n.some(t=>e.includes(t)),a=[],o=0;for(;o<r.length;){let e=r.indexOf(`{`,o);if(e<0)break;let s=r.slice(o,e).trim(),c=1,l=e+1;for(;l<r.length&&c>0;)r[l]===`{`?c++:r[l]===`}`&&c--,l++;let u=r.slice(e+1,l-1);if(s.startsWith(`@`))if(/^@(media|supports|container)\b/.test(s)){let e=t(u,n);e&&a.push(`${s} {\n${e}\n}`)}else /^@keyframes\b/.test(s)&&i(s)&&a.push(`${s} {${u}}`);else i(s)&&a.push(`${s} {${u}}`);o=l}return a.join(`
|
|
2
|
+
`)},n=(t,n,r)=>e.J(t,n,r),r=t(e.t,[`.cf-action`,`.cf-form`,`.cf-booking`]);exports.ANALYTICS_MODEL_SELECTOR_STYLES=e.H,exports.ActionsArea=e.v,exports.AnalyticsModelSelector=e.U,exports.ResultTable=e.Y,exports.StringsProvider=e.G,exports.WIDGET_ACTION_STYLES=r,exports.WidgetAnalyticsChart=e.Q,exports.analyticsResultDetails=n,exports.buildWidgetAnalyticsChartModel=e.$,exports.copyableChatResponse=e.z,exports.createAdaptiveVoiceActivityDetector=e.s,exports.createChatTransport=e.et,exports.createPreferredAudioRecorder=e.c,exports.createVoiceAudioConstraints=e.l,exports.findLiveSupportAction=e.i,exports.formatResultCell=e.X,exports.looksLikeEcho=e.p,exports.normalizeChatCustomization=e.r,exports.reconnectableHandbackId=e.a,exports.renderRich=e.O,exports.resolveConfig=e.n,exports.selectStyleRules=t,exports.serializeResultCsv=e.Z,exports.stopRecorderWithFlush=e.u,exports.usableTranscript=e._,exports.useChat=e.o;
|
package/dist/runtime.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import * as
|
|
1
|
+
import { A as AnalyticsPeriodComparison, C as Transport, D as AnalyticsAIExplanationTransport, E as ResultLabels, O as AnalyticsExplanationInput, S as PublicChatActionField, T as WidgetStrings, _ as DemoBooking, a as MessageAttachment, b as GifResult, c as Visitor, f as WidgetThemeTokens, g as AnalyticsVisualization, h as AnalyticsModelOption, i as FeaturedLink, k as AnalyticsGroupComparisonPoint, l as WidgetActionTranslation, m as ActionResult, n as ChatArtifact, o as SchedulerInfo, p as WidgetUser, r as ChatMessage, s as Source, t as BootstrapInfo, u as WidgetConfig, v as DemoSlotsResult, w as StringsProvider, x as PublicChatAction, y as ExplanationFeedbackInput } from "./types-CCk7I1fM.cjs";
|
|
2
|
+
import * as preact2 from "preact";
|
|
3
3
|
import { JSX } from "preact";
|
|
4
4
|
|
|
5
5
|
//#region ../centrinfo-results/src/analytics-chart-catalog.d.ts
|
|
@@ -125,6 +125,7 @@ interface ResultColumn {
|
|
|
125
125
|
currencyCode?: string;
|
|
126
126
|
formatPattern?: string;
|
|
127
127
|
grain?: ResultGrain;
|
|
128
|
+
semanticRole?: AnalyticsVisualizationColumn['semanticRole'];
|
|
128
129
|
}
|
|
129
130
|
interface ResultTableClassNames {
|
|
130
131
|
wrap?: string;
|
|
@@ -175,7 +176,7 @@ declare const WidgetAnalyticsChart: ({
|
|
|
175
176
|
expanded?: boolean;
|
|
176
177
|
/** Class prefix of the surface (`cf` widget, `ca` chat app). */
|
|
177
178
|
classPrefix?: string;
|
|
178
|
-
}) =>
|
|
179
|
+
}) => preact2.JSX.Element;
|
|
179
180
|
//#endregion
|
|
180
181
|
//#region ../centrinfo-results/src/result.d.ts
|
|
181
182
|
declare const formatResultCell: (value: unknown, locale?: string, column?: ResultColumn, context?: ResultFormatContext) => string;
|
|
@@ -202,7 +203,7 @@ declare const ResultTable: ({
|
|
|
202
203
|
expanded,
|
|
203
204
|
classNames,
|
|
204
205
|
emptyLabel
|
|
205
|
-
}: ResultTableProps) =>
|
|
206
|
+
}: ResultTableProps) => preact2.JSX.Element;
|
|
206
207
|
//#endregion
|
|
207
208
|
//#region ../centrinfo-results/src/result-details.d.ts
|
|
208
209
|
interface AnalyticsResultDetail {
|
|
@@ -211,8 +212,9 @@ interface AnalyticsResultDetail {
|
|
|
211
212
|
}
|
|
212
213
|
//#endregion
|
|
213
214
|
//#region src/config.d.ts
|
|
214
|
-
interface ResolvedConfig extends Required<Omit<WidgetConfig, 'accentColor' | 'agentName' | 'agentAvatarUrl' | 'launcherIcon' | 'themeTokens' | 'gifApiKey' | 'labels' | 'locale' | 'dir' | 'translations' | 'user' | 'analyticsContextToken' | 'identityToken' | 'getIdentityToken' | 'customLauncherSelector' | 'proactiveMessage' | 'proactiveOnPaths' | 'onOpen' | 'onClose' | 'onShow' | 'onHide' | 'onUnreadChange' | 'onMessage' | 'onOpenAnalyticsSource' | 'onAction' | 'onHandoff'>> {
|
|
215
|
+
interface ResolvedConfig extends Required<Omit<WidgetConfig, 'accentColor' | 'branding' | 'composer' | 'agentName' | 'agentAvatarUrl' | 'launcherIcon' | 'themeTokens' | 'gifApiKey' | 'labels' | 'locale' | 'dir' | 'translations' | 'user' | 'analyticsContextToken' | 'analyticsModelId' | 'identityToken' | 'getIdentityToken' | 'customLauncherSelector' | 'proactiveMessage' | 'proactiveOnPaths' | 'onOpen' | 'onClose' | 'onShow' | 'onHide' | 'onUnreadChange' | 'onMessage' | 'onOpenAnalyticsSource' | 'onAction' | 'onHandoff'>> {
|
|
215
216
|
accentColor?: string;
|
|
217
|
+
composer?: WidgetConfig['composer'];
|
|
216
218
|
agentName?: string;
|
|
217
219
|
agentAvatarUrl?: string;
|
|
218
220
|
launcherIcon?: string;
|
|
@@ -228,6 +230,7 @@ interface ResolvedConfig extends Required<Omit<WidgetConfig, 'accentColor' | 'ag
|
|
|
228
230
|
user?: WidgetConfig['user'];
|
|
229
231
|
/** Short-lived signed context for governed customer analytics. */
|
|
230
232
|
analyticsContextToken?: WidgetConfig['analyticsContextToken'];
|
|
233
|
+
analyticsModelId?: string;
|
|
231
234
|
identityToken?: WidgetConfig['identityToken'];
|
|
232
235
|
getIdentityToken?: WidgetConfig['getIdentityToken'];
|
|
233
236
|
customLauncherSelector?: string;
|
|
@@ -243,7 +246,7 @@ interface ResolvedConfig extends Required<Omit<WidgetConfig, 'accentColor' | 'ag
|
|
|
243
246
|
onAction?: WidgetConfig['onAction'];
|
|
244
247
|
onHandoff?: WidgetConfig['onHandoff'];
|
|
245
248
|
}
|
|
246
|
-
declare const resolveConfig: (
|
|
249
|
+
declare const resolveConfig: (input: WidgetConfig) => ResolvedConfig;
|
|
247
250
|
//#endregion
|
|
248
251
|
//#region src/api/factory.d.ts
|
|
249
252
|
/**
|
|
@@ -255,6 +258,10 @@ declare const createChatTransport: (config: ResolvedConfig) => Transport;
|
|
|
255
258
|
//#region src/rich.d.ts
|
|
256
259
|
declare const renderRich: (text: string) => JSX.Element[];
|
|
257
260
|
//#endregion
|
|
261
|
+
//#region src/response-content.d.ts
|
|
262
|
+
/** The text and structured values actually displayed with a chat reply. */
|
|
263
|
+
declare const copyableChatResponse: (message: ChatMessage) => string;
|
|
264
|
+
//#endregion
|
|
258
265
|
//#region src/result-details.d.ts
|
|
259
266
|
/** Reader-safe result context shared by the floating widget and chat app. */
|
|
260
267
|
declare const analyticsResultDetails: (result: AnalyticsVisualization, labels?: Partial<ResultLabels>, locale?: string) => AnalyticsResultDetail[];
|
|
@@ -306,6 +313,9 @@ interface OutgoingAttachment {
|
|
|
306
313
|
file?: Blob;
|
|
307
314
|
}
|
|
308
315
|
interface ChatApi {
|
|
316
|
+
analyticsModels: AnalyticsModelOption[];
|
|
317
|
+
analyticsModelId: string;
|
|
318
|
+
selectAnalyticsModel: (id: string) => void;
|
|
309
319
|
persona: BootstrapInfo | null;
|
|
310
320
|
messages: ChatMessage[];
|
|
311
321
|
sending: boolean;
|
|
@@ -355,6 +365,9 @@ interface ChatApi {
|
|
|
355
365
|
retry: (agentId: string, question: string, opts?: Pick<SendOpts, 'forceVoicePlayback'>) => void;
|
|
356
366
|
/** Record a 👍/👎 on an assistant reply (optional comment on 👎). Optimistic. */
|
|
357
367
|
rateMessage: (messageId: string, rating: 'up' | 'down', comment?: string) => void;
|
|
368
|
+
/** Verify a specific reply against the sources or data available to the agent. */
|
|
369
|
+
doubleCheckResponse: (messageId: string) => void;
|
|
370
|
+
retryResponse: (messageId: string) => void;
|
|
358
371
|
/** Record a vote on an analytics explanation. Rejects when it could not be
|
|
359
372
|
* saved (or the transport has no explanation feedback) so the UI can retry. */
|
|
360
373
|
rateExplanation: (input: Omit<ExplanationFeedbackInput, 'sessionId' | 'surface'>, surface?: ExplanationFeedbackInput['surface']) => Promise<void>;
|
|
@@ -404,8 +417,10 @@ interface ChatApi {
|
|
|
404
417
|
viewingSessionId: string | null;
|
|
405
418
|
/** The read-only transcript of the conversation being viewed. */
|
|
406
419
|
viewMessages: ChatMessage[];
|
|
407
|
-
/**
|
|
420
|
+
/** Resume an open signed-in conversation; otherwise show its read-only transcript. */
|
|
408
421
|
openConversation: (sessionId: string) => void;
|
|
422
|
+
renameConversation: (sessionId: string, title: string) => Promise<void>;
|
|
423
|
+
deleteConversation: (sessionId: string) => Promise<void>;
|
|
409
424
|
/** Leave the read-only history view, back to the live conversation. */
|
|
410
425
|
closeHistoryView: () => void;
|
|
411
426
|
/** Logout: erase ALL of this visitor's locally-stored data (identity,
|
|
@@ -459,6 +474,28 @@ declare const ActionsArea: ({
|
|
|
459
474
|
onClose?: () => void;
|
|
460
475
|
}) => JSX.Element | null;
|
|
461
476
|
//#endregion
|
|
477
|
+
//#region src/analytics-model-selector.d.ts
|
|
478
|
+
declare const ANALYTICS_MODEL_SELECTOR_STYLES = "\n.ci-analytics-model{display:block;flex:0 1 auto;min-width:0;width:fit-content;max-width:180px;margin:0 4px;--rv-bg:var(--ca-bg,var(--cf-bg,#fff));--rv-text:var(--ca-ink,var(--cf-text,#0f1e2a));--rv-border:var(--ca-line,var(--cf-border,#d3e0e8));--rv-accent:var(--ca-accent,var(--cf-accent,#167d55));--rv-surface:var(--ca-hover-bg,var(--cf-surface,#f4f6f8))}\n.ci-analytics-model summary{min-width:0;max-width:100%;min-height:30px;box-sizing:border-box;padding:5px 9px;font-size:12px;border-radius:8px}\n.ci-analytics-model summary>span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.ci-analytics-model summary[aria-disabled=\"true\"]{opacity:.6;cursor:default}\n";
|
|
479
|
+
declare const AnalyticsModelSelector: ({
|
|
480
|
+
models,
|
|
481
|
+
value,
|
|
482
|
+
onChange,
|
|
483
|
+
disabled,
|
|
484
|
+
copy,
|
|
485
|
+
classPrefix
|
|
486
|
+
}: {
|
|
487
|
+
models: AnalyticsModelOption[];
|
|
488
|
+
value: string;
|
|
489
|
+
onChange: (id: string) => void;
|
|
490
|
+
disabled?: boolean;
|
|
491
|
+
copy?: Partial<WidgetStrings>;
|
|
492
|
+
classPrefix?: string;
|
|
493
|
+
}) => preact2.JSX.Element | null;
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/customization.d.ts
|
|
496
|
+
/** Translate the simple options once; explicit advanced options take precedence. */
|
|
497
|
+
declare const normalizeChatCustomization: <T extends WidgetConfig>(config: T) => T & WidgetConfig;
|
|
498
|
+
//#endregion
|
|
462
499
|
//#region src/style-rules.d.ts
|
|
463
500
|
/**
|
|
464
501
|
* Picks the rules for some components out of a stylesheet, so another
|
|
@@ -534,4 +571,4 @@ declare const stopRecorderWithFlush: (recorder: MediaRecorder | null | undefined
|
|
|
534
571
|
*/
|
|
535
572
|
declare const WIDGET_ACTION_STYLES: string;
|
|
536
573
|
//#endregion
|
|
537
|
-
export { type ActionResult, ActionsArea, type AnalyticsVisualization, type BootstrapInfo, type ChatApi, type ChatArtifact, type ChatMessage, type DemoSlotsResult, type HistoryEntry, type MessageAttachment, type PublicChatAction, type PublicChatActionField, type ResolvedConfig, ResultTable, type Source, StringsProvider, type Transport, type VoiceReply, WIDGET_ACTION_STYLES, WidgetAnalyticsChart, type WidgetConfig, type WidgetThemeTokens, type WidgetUser, analyticsResultDetails, buildWidgetAnalyticsChartModel, createAdaptiveVoiceActivityDetector, createChatTransport, createPreferredAudioRecorder, createVoiceAudioConstraints, findLiveSupportAction, formatResultCell, looksLikeEcho, reconnectableHandbackId, renderRich, resolveConfig, selectStyleRules, serializeResultCsv, stopRecorderWithFlush, usableTranscript, useChat };
|
|
574
|
+
export { ANALYTICS_MODEL_SELECTOR_STYLES, type ActionResult, ActionsArea, AnalyticsModelSelector, type AnalyticsVisualization, type BootstrapInfo, type ChatApi, type ChatArtifact, type ChatMessage, type DemoSlotsResult, type HistoryEntry, type MessageAttachment, type PublicChatAction, type PublicChatActionField, type ResolvedConfig, ResultTable, type Source, StringsProvider, type Transport, type VoiceReply, WIDGET_ACTION_STYLES, WidgetAnalyticsChart, type WidgetConfig, type WidgetThemeTokens, type WidgetUser, analyticsResultDetails, buildWidgetAnalyticsChartModel, copyableChatResponse, createAdaptiveVoiceActivityDetector, createChatTransport, createPreferredAudioRecorder, createVoiceAudioConstraints, findLiveSupportAction, formatResultCell, looksLikeEcho, normalizeChatCustomization, reconnectableHandbackId, renderRich, resolveConfig, selectStyleRules, serializeResultCsv, stopRecorderWithFlush, usableTranscript, useChat };
|