sentifyd-bot 1.5.0 → 1.5.1
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/CHANGELOG.md +6 -0
- package/LICENSE.md +4 -3
- package/README.md +1 -1
- package/dist/{AzureTalkingAvatar-DwFpnwON.js → AzureTalkingAvatar-G4LQw7TE.js} +1 -1
- package/dist/{LiveCaptions-CxsuwP4M.js → LiveCaptions-DsQXlM8P.js} +1 -1
- package/dist/TalkingAvatar-CCG2emPQ.js +1 -0
- package/dist/index-BHDdsuP1.js +3243 -0
- package/dist/index.es.js +1 -1
- package/package.json +2 -2
- package/src/index.d.ts +20 -12
- package/src/react/SentifydBot.jsx +3 -2
- package/src/react/index.d.ts +28 -20
- package/src/react/index.js +3 -2
- package/src/vite-plugin.js +8 -0
- package/dist/TalkingAvatar--N4jOsLi.js +0 -1
- package/dist/index-DY_KYJkq.js +0 -3016
|
@@ -0,0 +1,3243 @@
|
|
|
1
|
+
import{io as t}from"socket.io-client";import{AudioConfig as e,SpeechRecognizer as a,ResultReason as i,CancellationReason as n,CancellationErrorCode as s,SpeechConfig as o,PropertyId as r,AutoDetectSourceLanguageConfig as c}from"microsoft-cognitiveservices-speech-sdk";import"js-cookie";import{jwtDecode as l}from"jwt-decode";import{v4 as h}from"uuid";import{createMachine as d,assign as u,fromPromise as p,createActor as g}from"xstate";import{html as v,nothing as m,css as b,LitElement as _}from"lit";import f from"toastify-js";import{styleMap as y}from"lit/directives/style-map.js";import{unsafeHTML as w}from"lit/directives/unsafe-html.js";const S=t=>new Promise((e=>setTimeout(e,t))),C=t=>{if(t){const e=[];let a=t;return a=a.replace(/```[\s\S]*?```/g,(t=>(e.push(t),`\0CS${e.length-1}\0`))),a=a.replace(/`[^`\n]+`/g,(t=>(e.push(t),`\0CS${e.length-1}\0`))),a=a.replace(/<(prosody|emphasis|say-as|phoneme|sub|voice|lang|p|s|w|audio|mark|desc)[^>]*>([\s\S]*?)<\/\1>/gi,"$2"),a=a.replace(/<(break|mark|audio)[^>]*\/?>/gi,""),a=a.replace(/<\/?[a-zA-Z][^>]*>/g,""),a=a.replace(/#\*[\s\S]*?\*#/g,""),a=a.replace(/\x00CS(\d+)\x00/g,((t,a)=>e[Number(a)])),a.trim()}return t},k=t=>(t instanceof Date?t:new Date(t)).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function A(){const t=function(){try{return void 0!==import.meta&&!1}catch(t){return!1}}()&&function(){try{return"true"===String(void import.meta||"").trim().toLowerCase()}catch(t){return!1}}();return"undefined"!=typeof window&&window.VITE_APP_SOCKET_URL?t&&window.location&&(e=window.VITE_APP_SOCKET_URL)&&"string"==typeof e&&/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/|$)/i.test(e.trim())?window.location.origin:window.VITE_APP_SOCKET_URL:"undefined"!=typeof window&&window.location&&t?window.location.origin:"undefined"!=typeof window&&window.location&&!function(){try{return void 0!==import.meta&&!0}catch(t){return!1}}()&&function(t){if(!t||"string"!=typeof t)return!1;const e=t.trim().toLowerCase();if("localhost"===e||"127.0.0.1"===e||"host.docker.internal"===e||"docker.for.win.localhost"===e||"docker.for.mac.localhost"===e)return!0;const a=e.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(!a)return!1;const i=a.slice(1).map(Number);if(i.some((t=>Number.isNaN(t)||t<0||t>255)))return!1;const[n,s]=i;return 10===n||192===n&&168===s||172===n&&s>=16&&s<=31}(window.location.hostname)?`${window.location.protocol||"http:"}//${window.location.hostname||"localhost"}:6085`:"https://sentifyd-serve.agreeablestone-0bc8c055.swedencentral.azurecontainerapps.io";var e}const x=A(),T={auth:{tokenRefreshInterval:6e5,speechTokenInterval:42e4,maxLoginRetries:3,loginRetryDelay:5e3,closeToExpirationLimit:6e4,speechTokenRetries:5,serverBaseURL:A()},avatar:{type:"gltf"},constants:{HEADROLL_BLENDSHAPE_INDEX:52,LEFTEYE_BLENDSHAPE_INDEX:53,RIGHTEYE_BLENDSHAPE_INDEX:54,FRAME_RATE:60},dom:{avatarDivId:"#avatar-container",toastifyDivId:"#toastify-container",canvasWidth:400,canvasHeight:500,headerAndFooterHeight:166,controlsHeight:90,smallDisplayWidth:768,shortDisplayHeight:500,smallScreenSafetyPadding:24},renderer:{alpha:!0,antialias:!0},speech:{authorizationEndPoint:"/api/v1/chatbot/get-speech-token",maxDurationTimeout:6e5,vad:{segmentationSilenceMs:1700,initialSilenceMs:12e3,semantic:!0},bargeIn:{enabled:!0,debug:!1}},captions:{wordsPerMinute:140,maxCharactersPerCaption:40,minCharactersPerCaption:15,captionChangeDelay:200,captionTimeout:1500},alerts:{maxAlerts:3,dismissableAlertDuration:4500},chatbot:{streaming:!1,thinkingTimeout:15e3,speakingTimeout:24e4},test:{stateTestMode:!1,enableDiagnostics:!1},connection:{reconnectInitialDelay:2e3,reconnectMaxDelay:3e4,reconnectFactor:1.6},videoAvatar:{idleDisconnectEnabled:!0,idleDisconnectMs:6e4,idleDisconnectPollMs:5e3,debug:!1}},I=async(t,e)=>{for(const a of t){const{name:t}=a;switch(t){case"RequestUserData":await E(e);break;case"EndConversation":await D(e);break;case"DisableCaptions":await M(e);break;case"EnableCaptions":await R(e);break;case"SwitchToChatMode":await P(e);break;case"SwitchToAvatarMode":await z(e);break;case"SetAvatarView":await O(e,a.view);break;case"SetAvatarMood":await L(e,a.mood);break;case"PlayOrStopAvatarGesture":await N(e,a.gesture,a.dur||3,a.mirror||!1,a.ms||1e3);break;case"PlayOrStopAvatarAnimation":await B(e,a.animation,a.dur||3);break;case"ControlAvatarLookAt":await $(e,a.target,a.t||1e3,a.x||0,a.y||0)}}},E=async t=>{t.emit("event_command_UI_RequestUserData")},D=async t=>{t.emit("event_command_UI_EndConversation")},M=async t=>{t.emit("event_command_UI_DisableCaptions")},R=async t=>{t.emit("event_command_UI_EnableCaptions")},P=async t=>{t.emit("event_command_UI_SwitchToChatMode")},z=async t=>{t.emit("event_command_UI_SwitchToAvatarMode")},O=async(t,e)=>{t.emit("event_command_Avatar_SetAvatarView",{view:e})},L=async(t,e)=>{t.emit("event_command_Avatar_SetAvatarMood",{mood:e})},N=async(t,e,a,i,n)=>{t.emit("event_command_Avatar_PlayOrStopGesture",{gesture:e,duration:a,mirror:i,ms:n})},B=async(t,e,a)=>{t.emit("event_command_Avatar_PlayOrStopAnimation",{animation:e,dur:a})},$=async(t,e,a,i,n)=>{t.emit("event_command_Avatar_ControlAvatarLookAt",{target:e,t:a,x:i,y:n})};class V{constructor(t,e=null){this.validateDependencies({auth:t}),this.socketUrl=x,this.auth=t,this.socket=null,this.isAuthenticating=!1,this.onConnectionStatusChange=e}validateDependencies(t){const e=Object.entries(t).filter((([t,e])=>!e)).map((([t])=>t));if(e.length>0)throw new Error(`Cannot initialize WebSocketManager due to missing dependencies: ${e.join(", ")}`)}async connect(){this.socket?.connected&&this.disconnect();const e=this.auth.getAccessToken();return new Promise(((a,i)=>{this.socket=t(this.socketUrl,{auth:{token:`Bearer ${e}`},path:"/socket.io",reconnection:!0,reconnectionAttempts:5,reconnectionDelay:500,reconnectionDelayMax:1e4}),this.registerWebsocketEventHandlers(a,i)}))}isSocketConnected(){return this.socket?.connected}isInitialised(){return null!==this.socket}disconnect(){this.socket&&(this.socket.disconnect(),this.socket.removeAllListeners(),this.socket=null)}registerWebsocketEventHandlers(t,e){this.socket.removeAllListeners(),this.socket.io.on("error",(t=>{})),this.socket.io.on("reconnect",(()=>{this.onConnectionStatusChange&&this.onConnectionStatusChange("connected")})),this.socket.io.on("reconnect_attempt",(t=>{})),this.socket.io.on("reconnect_error",(t=>{})),this.socket.io.on("reconnect_failed",(()=>{this.onConnectionStatusChange&&this.onConnectionStatusChange("failed"),this.socket=null,e(new Error("Websocket connection failed after maximum retries."))})),this.socket.on("connect",(()=>{this.socket.io.engine,this.onConnectionStatusChange&&this.onConnectionStatusChange("connected"),t()})),this.socket.on("connect_error",(t=>{t.message.includes("Token expired")||t.message.includes("Invalid token")?this.reAuthenticate():(this.onConnectionStatusChange&&this.onConnectionStatusChange("disconnected"),e?.(t))})),this.socket.on("disconnect",(t=>{this.socket&&this.socket.active||this.onConnectionStatusChange&&this.onConnectionStatusChange("disconnected")})),this.socket.onAny(((t,...e)=>{}))}reAuthenticate(){this.isAuthenticating||(this.isAuthenticating=!0,this.auth.authenticate().then((()=>{this.connect(),this.isAuthenticating=!1})).catch((t=>{this.isAuthenticating=!1,this.onConnectionStatusChange("failed")})))}on(t,e){this.socket&&this.socket.on(t,e)}off(t,e){this.socket&&(e?this.socket.off(t,e):this.socket.off(t))}emit(t,e,a){this.isSocketConnected()?a?this.socket.emit(t,e,a):this.socket.emit(t,e):this.onConnectionStatusChange&&this.onConnectionStatusChange("disconnected")}async emitWithResponse(t,e){return new Promise(((a,i)=>{this.isSocketConnected()?this.socket.emit(t,e,(t=>{a(t)})):(this.onConnectionStatusChange&&this.onConnectionStatusChange("disconnected"),i(new Error("Socket not connected")))}))}timeoutEmit(t,e,a,i){this.isSocketConnected()?i?this.socket.timeout(a).emit(t,e,i):this.socket.timeout(a).emit(t,e):this.onConnectionStatusChange&&this.onConnectionStatusChange("disconnected")}destroy(){this.socket&&(this.socket.disconnect(),this.socket.removeAllListeners(),this.socket=null),this.isAuthenticating=!1,this.onConnectionStatusChange=null}}class F{constructor(t,e={}){if(!t||"string"!=typeof t)throw new Error("ConnectionModule requires a valid name");this.name=t,this.connectionState="disconnected",this.blocking=!1!==e?.blocking,this.autoReconnect=!1!==e?.autoReconnect,this.subscribers=[]}isConnecting(){return"connecting"===this.connectionState}isDisconnected(){return"disconnected"===this.connectionState}isReconnecting(){return"reconnecting"===this.connectionState}isConnected(){return"connected"===this.connectionState}isFailed(){return"failed"===this.connectionState}setConnected(){this.updateConnectionState("connected")}setDisconnected(){this.updateConnectionState("disconnected")}setConnecting(){this.updateConnectionState("connecting")}setReconnecting(){this.updateConnectionState("reconnecting")}setFailed(){this.updateConnectionState("failed")}updateConnectionState(t){return!!["connected","connecting","reconnecting","disconnected","failed"].includes(t)&&this.connectionState!==t&&(this.connectionState,this.connectionState=t,this.notifySubscribers(),!0)}reconnect(){}subscribe(t){return"function"==typeof t&&!this.subscribers.includes(t)&&(this.subscribers.push(t),!0)}unsubscribe(t){if("function"!=typeof t)return!1;const e=this.subscribers.length;return this.subscribers=this.subscribers.filter((e=>e!==t)),this.subscribers.length<e}notifySubscribers(){0!==this.subscribers.length&&[...this.subscribers].forEach(((t,e)=>{try{t(this.connectionState,this.name)}catch(a){}}))}destroy(){try{this.subscribers=[],this.connectionState="disconnected"}catch(t){}}getStateInfo(){return{name:this.name,state:this.connectionState,subscriberCount:this.subscribers.length}}}class U{constructor(t,e,a){this.id=t,this.state="CREATED",this.abortController=new AbortController,this.audio=(t=>{let e,a=!1;return{readable:new ReadableStream({start(i){e=i,t?.addEventListener("abort",(()=>{try{e.error(new DOMException("Aborted","AbortError"))}catch{}a=!0}))}}),push:t=>{if(!a)try{e?.enqueue(t)}catch(i){}},close:()=>{if(!a)try{e?.close(),a=!0}catch(t){}},get isClosed(){return a}}})(this.abortController.signal),this.lipsync=(t=>{let e,a=!1;return{readable:new ReadableStream({start(a){e=a,t?.addEventListener("abort",(()=>{try{e.error(new DOMException("Aborted","AbortError"))}catch{}}))}}),push:t=>{if(!a)try{e?.enqueue(t)}catch(i){}},close:()=>{if(!a)try{e?.close(),a=!0}catch(t){}},get isClosed(){return a}}})(this.abortController.signal),this._watchdog=setTimeout((()=>{this._watchdog=null,a?.(this)}),e)}activate(){this.state="ACTIVE"}finish(){if("FINISHED"!==this.state){this.state="FINISHED",clearTimeout(this._watchdog);try{this.audio.close()}catch{}try{this.lipsync.close()}catch{}this.abortController.abort("turn finished")}}abort(){"FINISHED"!==this.state&&(this.state="STOPPING",this.abortController.abort("turn interrupted"),clearTimeout(this._watchdog))}get isActive(){return"ACTIVE"===this.state}get done(){return"FINISHED"===this.state}}const H={THREE_D:"3d",VIDEO:"video"},j={Azure:H.VIDEO,Simli:H.VIDEO,ReadyPlayerMe:H.THREE_D,Avaturn:H.THREE_D};function q(t){return t&&j[t.trim()]||H.THREE_D}function G(t){return q(t)===H.VIDEO}function W(t){return!!t&&"Azure"===t.trim()}const K=12e4;class Q extends F{static _instance=null;constructor(t,e,a,i){if(Q._instance)return Q._instance;super("chatSocket"),this.validateDependencies({bus:t,auth:e,sessionData:a,avatarOrchestrator:i}),this.socketManager=new V(e,(t=>this.updateConnectionState(t))),this.isChatbotShown=!0,this._chatbotMode="AVATAR",this.bus=t,this.sessionData=a,this.auth=e,this.avatarOrchestrator=i,this.pendingDelayedActions=null,this.turn=null,this.INTERRUPT_WATCHDOG=15e3,Q._instance=this}get chatbotMode(){return this._chatbotMode}set chatbotMode(t){const e="string"==typeof t&&t?t:this._chatbotMode,a=this._chatbotMode;if(this._chatbotMode=e,a!==e)try{this.bus?.emit?.("event_status_ChatbotMode_Changed",{chatbotMode:e})}catch(i){}}static getInstance(t,e,a,i){return Q._instance||(Q._instance=new Q(t,e,a,i)),Q._instance}_isDataForCurrentTurn(){return!!this.turn&&!this.turn.done&&this.turn.id===this.sessionData.conversation.currentTurnId}finishCurrentTurn(){this.turn&&!this.turn.done&&(this.turn.finish(),this.turn=null)}static resetInstance(){Q._instance&&(Q._instance._cleanup(),Q._instance=null)}_cleanup(){this.cleanupActiveStreams(),this.removeTTSEventHandlers(),this.socketManager?.disconnect(),this.pendingDelayedActions=null,this.turn=null,this.audioStream=null,this.lipsyncStream=null}validateDependencies(t){const e=Object.entries(t).filter((([t,e])=>!e)).map((([t])=>t));if(e.length>0)throw new Error(`Cannot initialize ChatSocket due to missing dependencies: ${e.join(", ")}`)}async init(){if(!this.sessionData||!this.sessionData.avatarName||!this.sessionData.language)throw new Error("Missing required session data for chat connection.");this.sessionData.trainingId;try{this.setConnecting(),await this.socketManager.connect()}catch(t){this.setDisconnected()}this.registerTTSEventHandlers()}async reconnect(){if(!this.isConnected()&&!this.isReconnecting()){this.isFailed()?this.setReconnecting():this.setConnecting();try{if(await this.socketManager.connect(),!this.socketManager.isSocketConnected())throw new Error("Socket still not connected after connect()");this.registerTTSEventHandlers(),this.setConnected()}catch(t){this.setFailed()}}}removeTTSEventHandlers(){this.socketManager&&["conversation_ai_reply","tts_stream_start","tts_viseme","tts_word","tts_blend","tts_error","tts_chunk","tts_stream_end"].forEach((t=>{this.socketManager.off(t)}))}registerTTSEventHandlers(){this.removeTTSEventHandlers(),this.socketManager.on("conversation_ai_reply",(t=>this.handleConversationResponse(t))),this.socketManager.on("tts_stream_start",(t=>{t?.turnId,this.turn&&this.turn.id===this.sessionData.conversation.currentTurnId||this.prepareStreamsForTurn(this.sessionData.conversation.currentTurnId),this.turn.activate(),this.avatarOrchestrator&&this.avatarOrchestrator.sendEvent("STREAM_START",{audioStream:this.audioStream,lipsyncStream:this.lipsyncStream,turnId:this.turn.id})})),this.socketManager.on("tts_viseme",(t=>{if(this._isDataForCurrentTurn()&&this.lipsyncStream&&!this.lipsyncStream.isClosed&&this.turn&&this.turn.isActive)try{this.lipsyncStream.push({type:"viseme",...t})}catch(e){if(e.message?.includes("closed readable stream"))return}})),this.socketManager.on("tts_word",(t=>{if(this._isDataForCurrentTurn()&&this.lipsyncStream&&!this.lipsyncStream.isClosed){if(!this.turn||!this.turn.isActive||!this.lipsyncStream)return;try{this.lipsyncStream.push({type:"word",...t})}catch(e){e.message?.includes("closed readable stream")}}})),this.socketManager.on("tts_blend",(t=>{if(this._isDataForCurrentTurn()&&this.lipsyncStream&&!this.lipsyncStream.isClosed){if(!this.turn||!this.turn.isActive||!this.lipsyncStream)return;try{this.lipsyncStream.push({type:"blend",...t})}catch(e){e.message?.includes("closed readable stream")}}})),this.socketManager.on("tts_error",(t=>{this.avatarOrchestrator&&this.avatarOrchestrator.sendEvent("TTS_ERROR",{error:t})})),this.socketManager.on("tts_chunk",(t=>{if(this._isDataForCurrentTurn()&&this.audioStream&&!this.audioStream.isClosed){if(!this.turn||!this.turn.isActive||!this.audioStream)return;try{this.audioStream.push(t)}catch(e){e.message?.includes("closed readable stream")}}})),this.socketManager.on("tts_stream_end",(t=>{const e=t?.turnId;t?.reason,this.turn&&e===this.turn.id&&(this.turn.finish(),this.avatarOrchestrator.sendEvent("STREAM_END"),this.turn=null)}))}async handleConversationResponse(t){if(this.sessionData?.conversation?.conversationId)if("success"===t?.status)t?.error,await this.processAIResponse(t);else if("error"===t?.status){const e={...t.error};t.conversationId&&!e.conversationId&&(e.conversationId=t.conversationId),this.avatarOrchestrator.sendEvent("CONVERSATION_ERROR",{error:e,chatbotMode:this.chatbotMode})}else this.avatarOrchestrator.sendEvent("CONVERSATION_ERROR",{error:{message:"No response from server. Please try again."},chatbotMode:this.chatbotMode})}async sendInitConversationEvent(){if(!this.socketManager.isSocketConnected())throw new Error("Socket not available.");return new Promise(((t,e)=>{this.socketManager.timeoutEmit("init_conversation",{avatarId:this.sessionData.avatarId,trainingId:this.sessionData.trainingId,conversationId:this.sessionData.conversation.conversationId,chatbotMode:this.chatbotMode,streaming:!1},K,((a,i)=>{a||"success"!==i?.status?e(new Error(a||i?.error?.message||"Conversation init failed")):t({initialized:!0})}))}))}async sendStartConversationEvent(t=!1,e={}){if(!this.socketManager.isSocketConnected())throw new Error("Socket not available.");const a=e.avatarSource??this.sessionData?.avatarItem?.avatarSource,i="boolean"==typeof e.isVideoAvatar?e.isVideoAvatar:!!a&&G(a),n=e.skipWelcome??i;return new Promise(((e,a)=>{this.socketManager.timeoutEmit("start_conversation",{avatarId:this.sessionData.avatarId,trainingId:this.sessionData.trainingId,conversationId:this.sessionData.conversation.conversationId,chatbotMode:this.chatbotMode,detectedLanguage:this.sessionData.language||"en-US",voice:this.sessionData.voice||"",lipsyncType:this.sessionData.lipsyncType,turnId:this.sessionData.conversation.currentTurnId,streaming:!1,isTermsAccepted:!0===this.sessionData.isTermsAccepted,isResume:t,skipWelcome:n},K,(async(t,i)=>{if(t||"success"!==i?.status){const e=i?.error?.code,n=t||i?.error?.message||"Conversation start failed";a(new Error(e?`${e}: ${n}`:n))}else try{await this.processAIResponse(i),e(i)}catch(n){a(n)}}))}))}async sendEndConversationEvent(t,e){if(!this.socketManager.isSocketConnected())throw new Error("Socket not available.");try{G(this.sessionData?.avatarItem?.avatarSource)?await new Promise((e=>{const a=setTimeout(e,2e3);this.bus?.emit?.("event_status_Conversation_Ending",{conversationId:t,onDisconnectComplete:()=>{clearTimeout(a),e()}})})):this.bus?.emit?.("event_status_Conversation_Ending",{conversationId:t})}catch(a){}this.socketManager.emit("end_conversation",{conversationId:t,satisfactionScore:e,chatbotMode:this.chatbotMode},(e=>{"success"===e?.status?this.avatarOrchestrator.sendEvent("CLEAR_CONVERSATION",{conversationId:t}):e?.status}))}prepareStreamsForTurn(t){this.turn&&!this.turn.done&&this.turn.abort(),this.turn=new U(t,this.INTERRUPT_WATCHDOG,(t=>{this.socketManager.emit("interrupt_tts",{turnId:t.id})})),this.audioStream=this.turn.audio,this.lipsyncStream=this.turn.lipsync}async processAIResponse(t){try{const e=t?.data?.actions||[],a=e.filter((t=>!1!==t.immediate)),i=e.filter((t=>!1===t.immediate)),n=a.some((t=>"SwitchToAvatarMode"===t.name));if(a.length>0&&await I(a,this.bus),i.length>0&&(this.pendingDelayedActions=i),"resume_silent"===t.data?.dataType)return;if("message"===t.data?.dataType?await this.receiveMessage(t.data,t.timestamp,{switchedToAvatar:n}):"avatar_structured_response"===t.data?.dataType?await this.receiveAvatarStructuredResponse(t.data,t.timestamp,{switchedToAvatar:n}):t?.data?.messageContent&&await this.receiveMessage(t.data,t.timestamp,{switchedToAvatar:n}),"CHAT"===this.chatbotMode&&this.pendingDelayedActions&&this.pendingDelayedActions.length>0)try{await I(this.pendingDelayedActions,this.bus)}finally{this.pendingDelayedActions=null}}catch(e){this.avatarOrchestrator.sendEvent("CONVERSATION_ERROR",{error:{message:"Error getting a response. Please try again."},chatbotMode:this.chatbotMode})}}async receiveAvatarStructuredResponse(t,e,a={}){if(!t?.structuredResponse)throw new Error("Avatar response is invalid");const i=k(e);this.avatarOrchestrator.sendEvent("AI_MESSAGE_RECEIVED",{message:t.messageContent,time:i,structuredResponse:t.structuredResponse,chatbotMode:this.chatbotMode,switchedToAvatar:a.switchedToAvatar})}async receiveMessage(t,e,a={}){if(!t?.messageContent)throw new Error("Message is invalid");const i=k(e);this.avatarOrchestrator.sendEvent("AI_MESSAGE_RECEIVED",{message:t.messageContent,time:i,chatbotMode:this.chatbotMode,switchedToAvatar:a.switchedToAvatar})}async sendMessage(t,e="CHAT"){if(this.pendingDelayedActions=null,!this.sessionData.trainingId||!t?.messageText)return{success:!1,error:"Missing required field(s)"};if(!this.sessionData.conversation.conversationId)return{success:!1,error:"No conversation found. Start a conversation first."};try{const a=this.sessionData.conversation.incrementTurnId();"AVATAR"===e?this.prepareStreamsForTurn(a):this.turn&&(this.turn.abort(),this.turn=null),this.socketManager.emit("user_chat_message",{trainingId:this.sessionData.trainingId,avatarId:this.sessionData.avatarId,userName:this.sessionData.username,conversationId:this.sessionData.conversation.conversationId,turnId:a,message:t.messageText,messageDuration:t?.messageDuration||0,chatbotMode:e,detectedLanguage:t?.detectedLanguage||this.sessionData.language,voice:this.sessionData.voice||"",lipsyncType:this.sessionData.lipsyncType,streaming:T.chatbot.streaming||!1});const i=k(new Date);return this.avatarOrchestrator.sendEvent("USER_MESSAGE_SENT",{message:t.messageText,time:i,chatbotMode:e}),this.sessionData.conversation.lastDetectedLanguage=t?.detectedLanguage,{success:!0}}catch(a){return{success:!1,error:a.message||"An error occurred while sending the message"}}}sendUserData(){const t=this.sessionData.conversation.incrementTurnId();this.prepareStreamsForTurn(t);try{const t=this.avatarOrchestrator?.getSnapshot?.(),e=t?.matches?.("lifecycle.conversation.inProgress.thinking");e||this.avatarOrchestrator?.sendEvent?.("THINK")}catch(e){}if(!this.socketManager.isSocketConnected())throw new Error("Socket not available.");this.socketManager.emit("update_user_data",{conversationId:this.sessionData.conversation.conversationId,turnId:t,detectedLanguage:this.sessionData.language||"en-US",voice:this.sessionData.voice||"",chatbotMode:this.chatbotMode,lipsyncType:this.sessionData.lipsyncType,userData:{username:this.sessionData.username,phoneNumber:this.sessionData.phoneNumber,email:this.sessionData.email,isTermsAccepted:this.sessionData.isTermsAccepted}},(async t=>{if("success"===t?.status)this.processAIResponse(t);else if("error"===t?.status)try{const e={...t?.error||{}};t?.conversationId&&!e.conversationId&&(e.conversationId=t.conversationId),this.avatarOrchestrator?.sendEvent?.("CONVERSATION_ERROR",{error:e,chatbotMode:this.chatbotMode})}catch(e){}}))}cleanupActiveStreams(){this.turn&&this.turn.abort()}async interruptCurrentTurn(){if(!this.turn)return{status:"warning",message:"No active turn"};try{return this.turn.abort(),await this.socketManager.emitWithResponse("interrupt_tts",{turnId:this.turn.id,chatbotMode:this.chatbotMode})}catch(t){return{status:"error",message:"Interruption failed"}}}destroy(){this.socketManager?.destroy()}}class Y{constructor({recognizer:t,speechConfig:e,audioConfig:a,bus:i,avatarOrchestrator:n,autoDetectLanguage:s}={}){this.validateDependencies({recognizer:t,speechConfig:e,audioConfig:a,bus:i,avatarOrchestrator:n}),this.bus=i,this.avatarOrchestrator=n,this.speechConfig=e,this.recognizer=t,this.audioConfig=a,this.messageText="",this.messageDuration=0,this.detectedLanguage="",this.isMessageSent=!1,this.isListening=!1,this.isMicDetected=!0,this.autoDetectLanguage=s,this.languageDurations={},this._isStopping=!1,this._needsRecreation=!1,this.maxDurationTimeoutId=null}_isFsmListening(){try{const t=this.avatarOrchestrator?.getSnapshot?.();return!(!t||!("function"==typeof t.matches&&t.matches("lifecycle.conversation.inProgress.listening")||"function"==typeof t.hasTag&&t.hasTag("listening")))}catch(t){return!1}}validateDependencies(t){const e=Object.entries(t).filter((([t,e])=>!e)).map((([t])=>t));if(e.length>0)throw new Error(`Cannot initialize SpeechRecognition due to missing dependencies: ${e.join(", ")}`)}static async build(t,e,a,i){if(!t)throw new Error("speechConfig is required");const{recognizer:n,audioConfig:s}=await this.init(t,e),o=new Y({recognizer:n,speechConfig:t,audioConfig:s,bus:a,avatarOrchestrator:i,autoDetectLanguage:!!e});return o._registerRecognizerEvents(),o}static async init(t,i){try{const n=e.fromDefaultMicrophoneInput();let s=null;return s=i?a.FromConfig(t,i,n):new a(t,n),{recognizer:s,audioConfig:n}}catch(n){throw new Error("Error in SpeechRecognition initialization: "+n)}}static async checkMicrophoneAccess(){try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Media devices not supported");if(0===(await navigator.mediaDevices.enumerateDevices()).filter((t=>"audioinput"===t.kind)).length)throw new Error("No microphone devices found");return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach((t=>t.stop())),!0}catch(t){throw new Error(`Microphone access issue: ${t.message}`)}}start(){try{this._isStopping=!1,clearTimeout(this.maxDurationTimeoutId),this.messageText="",this.messageDuration=0,this.isMessageSent=!1,this.autoDetectLanguage&&(this.languageDurations={}),this.recognizeNewMessage(),this._setMaxDurationTimeout()}catch(t){this.stop()}}stop(){if(!this._isStopping){this._isStopping=!0;try{this.recognizer&&this.recognizer.stopContinuousRecognitionAsync()}catch(t){}finally{this.isListening=!1,this._isStopping=!1}clearTimeout(this.maxDurationTimeoutId)}}sendMessage(){if(!this.isMessageSent&&this.messageText&&this.messageText.trim())try{this.autoDetectLanguage?this.detectedLanguage=this._determineMainLanguage():this.detectedLanguage=this.speechConfig.speechRecognitionLanguage,this.avatarOrchestrator.sendEvent("SPEECH_RECOGNITION_COMPLETE",{messageText:this.messageText,messageDuration:this.messageDuration,detectedLanguage:this.detectedLanguage}),this.isMessageSent=!0}catch(t){}}simulateRecognition(){this.avatarOrchestrator.transitionToListening(),this.messageText="Hello, how are you doing today?",this.avatarOrchestrator.sendEvent("SPEECH_RECOGNITION_COMPLETE",{messageText:this.messageText,messageDuration:3e3,detectedLanguage:"en-US"})}recognizeNewMessage(){try{this._startRecognizer()}catch(t){this._emitAlert("alertMicrophoneStartFailed"),this.stop()}}_startRecognizer(){this.recognizer.startContinuousRecognitionAsync((()=>{this._isFsmListening(),this.isListening=!0}),(async t=>{await this._handleRecognitionStartupError(t),this.isMicDetected=!1,this.stop()}))}async _handleRecognitionStartupError(t){let e="alertMicrophoneCheckSettings";try{await Y.checkMicrophoneAccess(),e="alertSpeechRecognitionSetupFailed"}catch(a){e=this._isBrowserPermissionError(a)?"alertMicrophoneAccessDenied":this._isBrowserDeviceError(a)?"alertNoMicrophoneDetected":"alertMicrophoneError"}this._emitAlert(e)}_isBrowserPermissionError(t){if(t&&"object"==typeof t)return"NotAllowedError"===t.name||"PermissionDeniedError"===t.name||"SecurityError"===t.name;const e=t.toString().toLowerCase();return e.includes("permission")||e.includes("notallowed")||e.includes("denied")}_isBrowserDeviceError(t){if(t&&"object"==typeof t)return"NotFoundError"===t.name||"DevicesNotFoundError"===t.name;const e=t.toString().toLowerCase();return e.includes("notfound")||e.includes("device")||e.includes("microphone not found")}close(){this.stop(),this.recognizer&&(this.recognizer.close(),this.recognizer.dispose(!0),this.recognizer=void 0)}_registerRecognizerEvents(){this.recognizer.sessionStarted=(t,e)=>{},this.recognizer.sessionStopped=(t,e)=>{if(!this._isStopping&&(this.isListening=!1,this._isFsmListening()))try{this.avatarOrchestrator.transitionToIdle()}catch(a){}},this.recognizer.recognized=(t,e)=>{if(!this._isStopping&&this.isListening&&!this.isMessageSent)if(e.result.reason===i.RecognizedSpeech){if(""!==e.result.text){if(this.messageText=(this.messageText?this.messageText+" ":"")+e.result.text,this.messageDuration+=e.result.duration,this.autoDetectLanguage){const t=e.result.language,a=e.result.duration;this.languageDurations[t]?this.languageDurations[t]+=a:this.languageDurations[t]=a}this.bus.emit("event_command_UI_UpdateSTTCaption",{STTCaption:this.messageText}),this._completeRecognitionTurn()}}else e.result.reason,i.NoMatch},this.recognizer.recognizing=(t,e)=>{this._isStopping||!this.isListening||this.isMessageSent||""!==e.result.text&&this.bus.emit("event_command_UI_UpdateSTTCaption",{STTCaption:this.messageText+" "+e.result.text})},this.recognizer.speechStartDetected=(t,e)=>{},this.recognizer.speechEndDetected=(t,e)=>{this._isStopping||!this.isListening||this.isMessageSent||this.messageText?.trim()&&this._completeRecognitionTurn()},this.recognizer.canceled=(t,e)=>{if(e.reason===n.Error&&this._handleAzureSpeechError(e),this.stop(),this._isFsmListening())try{this.avatarOrchestrator.transitionToIdle()}catch(a){}}}get needsRecreation(){return this._needsRecreation}_handleAzureSpeechError(t){const e=t.errorCode,a=t.errorDetails||"No additional details available";let i="",n=!1;switch(e){case s.NoError:i="alertSomeErrorOccurred";break;case s.AuthenticationFailure:i="alertVoiceServicesUnavailable",n=!0,this._needsRecreation=!0;break;case s.BadRequestParameters:i="alertServiceTemporarilyUnavailable";break;case s.TooManyRequests:i="alertTooManyRequests";break;case s.ConnectionFailure:i="alertConnectionIssue",this._needsRecreation=!0;break;case s.ServiceTimeout:i="alertResponseTimeout",this._needsRecreation=!0;break;case s.ServiceError:i="alertServiceTemporarilyUnavailable";break;case s.RuntimeError:i="alertSomeErrorOccurred";break;case s.Forbidden:i="alertServiceBusy";break;default:i="alertSomeErrorOccurred"}n&&this.bus.emit("event_error_VoiceBot_ExpiredOrInvalidToken",a),this.bus.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:i})}_emitAlert(t,e={}){if("string"!=typeof t||!this.bus)return;if(["alertMicrophoneStartFailed","alertMicrophoneCheckSettings","alertMicrophoneAccessDenied","alertNoMicrophoneDetected","alertMicrophoneError"].includes(t)&&this._isChatModeActive())return;const a={messageKey:t,...e};this.bus.emit("event_command_Alerts_ShowDismissableAlert",a)}_isChatModeActive(){try{const t=this.avatarOrchestrator?.getSnapshot?.(),e=t?.context?.chatSocket?.chatbotMode;return"CHAT"===e}catch(t){return!1}}_setMaxDurationTimeout(){this.maxDurationTimeoutId=setTimeout((()=>{this._completeRecognitionTurn({reason:"maxDuration"})}),T.speech.maxDurationTimeout)}_completeRecognitionTurn({reason:t}={}){if(this._isStopping||this.stop(),this.sendMessage(),"maxDuration"===t&&(!this.messageText||!this.messageText.trim())&&this._isFsmListening())try{this.avatarOrchestrator.transitionToIdle()}catch(e){}}_determineMainLanguage(){let t=null,e=0;for(const[a,i]of Object.entries(this.languageDurations))i>e&&(e=i,t=a);return t}destroy(){try{this.close()}catch(t){}}}class X extends F{constructor(t,e){super("speech-token",{blocking:!1}),this.auth=t,this.refreshTokenCallback=e,this.tokenRefreshLoop=null,this._lastRefreshTime=0}async requestAuthorizationToken(t=T.auth.speechTokenRetries){for(let a=1;a<=t;a++)try{const t=await this.fetchSpeechToken();return this._lastRefreshTime=Date.now(),this.setConnected(),t}catch(e){if(a===t)throw this.setFailed(),new Error(`Failed to fetch speech token after ${t} attempts`)}}async fetchSpeechToken(){try{const t=await this.auth.callSentifydApi(T.speech.authorizationEndPoint,"POST"),{token:e}=t.data;if(!e)throw new Error("Invalid token structure received from API.");return t.data}catch(t){throw new Error("Failed to fetch data from API.")}}async startTokenRefreshLoop(){await this.stopTokenRefreshLoop(),this.tokenRefreshLoop=setInterval((async()=>{try{const{token:t}=await this.requestAuthorizationToken();this.refreshTokenCallback(t),this._lastRefreshTime=Date.now(),this.setConnected()}catch(t){}}),T.auth.speechTokenInterval)}async stopTokenRefreshLoop(){this.tokenRefreshLoop&&(clearInterval(this.tokenRefreshLoop),this.tokenRefreshLoop=null)}isTokenLikelyStale(){return 0!==this._lastRefreshTime&&Date.now()-this._lastRefreshTime>T.auth.speechTokenInterval}async reconnect(){if(!this.isConnected()&&!this.isReconnecting()){this.isFailed()?this.setReconnecting():this.setConnecting(),await this.stopTokenRefreshLoop();try{const{token:t}=await this.requestAuthorizationToken();this.refreshTokenCallback(t),await this.startTokenRefreshLoop()}catch(t){this.setFailed()}}}}class Z{constructor({speechService:t,speechConfig:e,autoDetectSourceLanguageConfig:a,speechRecognizer:i,bus:n,auth:s,avatarOrchestrator:o,sessionData:r}={}){this.validateDependencies({speechService:t,speechConfig:e,speechRecognizer:i,bus:n,auth:s,avatarOrchestrator:o,sessionData:r}),this.sessionData=r,this.speechService=t,this.speechConfig=e,this.speechRecognizer=i,this.bus=n,this.avatarOrchestrator=o,this.autoDetectSourceLanguageConfig=a,this._currentTurnId=0,this._expectedTurnId=0,this._lastInterruptionTime=0,this.INTERRUPTION_DEBOUNCE=100,this._isHandlingAudioEnd=!1,this.registerEventListeners(),this.speechService.startTokenRefreshLoop()}validateDependencies(t){const e=Object.entries(t).filter((([t,e])=>!e)).map((([t])=>t));if(e.length>0)throw new Error(`Cannot initialize VoiceBot due to missing dependencies: ${e.join(", ")}`)}registerEventListeners(){this._busHandlers=this._busHandlers||[];const t=t=>{this.getNewSpeechToken()};this.bus.on("event_error_VoiceBot_ExpiredOrInvalidToken",t),this._busHandlers.push(["event_error_VoiceBot_ExpiredOrInvalidToken",t])}static async build(t,e,a,i){const{speechService:n,speechConfig:s,autoDetectSourceLanguageConfig:o,speechRecognizer:r}=await this.init(i,t,a,e);return new Z({speechService:n,speechConfig:s,autoDetectSourceLanguageConfig:o,speechRecognizer:r,bus:t,auth:a,avatarOrchestrator:e,sessionData:i})}static async init(t,e,a,i){try{const n=t?.language||"en-US",s=(t?.voice,t?.autodetectLanguages||[]);let l=null,h=null;const d=new X(a,(t=>{l&&(l.authorizationToken=t)})),{token:u,region:p}=await d.requestAuthorizationToken();if(!u||!p)throw new Error("Failed to get authorization token");l=o.fromAuthorizationToken(u,p);const g=T?.speech?.vad??{},v=t?.speech?.vad??t?.vad??{},m=v.segmentationSilenceMs??g.segmentationSilenceMs??800,b=v.initialSilenceMs??g.initialSilenceMs??8e3;l.setProperty(r.Speech_SegmentationSilenceTimeoutMs,String(m)),l.setProperty(r.SpeechServiceConnection_InitialSilenceTimeoutMs,String(b));const _=v.strategy??g.strategy,f=v.semantic??g.semantic,y="string"==typeof _?_:!0===f?"Semantic":null;y&&l.setProperty(r.Speech_SegmentationStrategy,y),"multilingual"===n?s.length>0?h=c.fromLanguages(s):l.speechRecognitionLanguage="en-US":l.speechRecognitionLanguage=n;const w=await Y.build(l,h,e,i);return{speechService:d,speechConfig:l,autoDetectSourceLanguageConfig:h,speechRecognizer:w}}catch(n){throw new Error("Error in VoiceBot initialization",{cause:n})}}async getNewSpeechToken(){try{const{token:t}=await this.speechService.requestAuthorizationToken();this.speechConfig.authorizationToken=t}catch(t){}}isConversationInProgress(){return!!this.sessionData?.conversation?.conversationId}async startListening(){if(this.speechRecognizer.isListening)return{success:!0,alreadyListening:!0};try{return await this._ensureFreshRecognizer(),this.speechRecognizer.isMicDetected||(this.speechRecognizer.close(),this.speechRecognizer=await Y.build(this.speechConfig,this.autoDetectSourceLanguageConfig,this.bus,this.avatarOrchestrator),this.speechRecognizer.isMicDetected=!0),this.speechRecognizer.start(),{success:!0,started:!0}}catch(t){return{success:!1,error:t.message||"Failed to start speech recognition"}}}async _ensureFreshRecognizer(){const t=this.speechService.isTokenLikelyStale(),e=this.speechRecognizer.needsRecreation;if(t||e){try{const{token:t}=await this.speechService.requestAuthorizationToken();this.speechConfig.authorizationToken=t}catch(a){}try{this.speechRecognizer.close()}catch(i){}this.speechRecognizer=await Y.build(this.speechConfig,this.autoDetectSourceLanguageConfig,this.bus,this.avatarOrchestrator)}}stopListening(){try{return this.speechRecognizer.stop(),{success:!0}}catch(t){return{success:!1,error:t.message||"Failed to stop speech recognition"}}}async updateSpeechLanguage(t){this.speechConfig.speechRecognitionLanguage=t,this.speechRecognizer.close(),this.speechRecognizer=await Y.build(this.speechConfig,this.autoDetectSourceLanguageConfig,this.bus,this.avatarOrchestrator)}destroy(){this._busHandlers?.forEach((([t,e])=>this.bus.off(t,e))),this._busHandlers=[],this.speechRecognizer?.destroy(),this.speechService?.stopTokenRefreshLoop()}}const J={enabled:!0,micThreshold:.0033,avatarQuietFloor:.009,minSignalRatio:1.2,minSignalRatioWhileSpeaking:.38,minSignalDelta:.0028,absoluteMicOverride:.012,minDurationMs:200,cooldownMs:1500,envelopeAttack:.6,envelopeRelease:.8,leakAdaptRate:.06,leakFloor:0,leakCeil:.25,leakMargin:.012,leakDecayHoldMs:300,leakDecayRate:.2,leakMinAvatar:.01,noiseStdK:3.4,minSnr:3.2,noiseMinSamples:90,warmupMs:400,speakingGuardMs:200,minConsecutive:3,hangoverMs:100,minAbsQuiet:.0032,bandpassHz:[350,3400],minDurationWhileSpeakingMs:260,debug:!1};class tt{constructor({talkingAvatar:t,avatarOrchestrator:e,config:a}={}){this.talkingAvatar=t,this.avatarOrchestrator=e,this.config={...J,...a||{}},this._audioCtx=null,this._micStream=null,this._micSource=null,this._micBpf=null,this._micAnalyser=null,this._micBuffer=null,this._avatarAnalyser=null,this._avatarBuffer=null,this._avatarAnalyserMissing=!1,this._armed=!1,this._candidateSince=null,this._lastTriggerTime=0,this._rafId=null,this._projectionUnsub=null,this._isDestroyed=!1,this._lastTickLog=0,this._micEnvelope=0,this._avatarEnvelope=0,this._leakEstimate=this.config.leakFloor??0,this._lastAvatarBelowMin=null,this._lastFrameTs=0,this._lastAudioResumeAttempt=0,this._armedAt=0,this._consecHits=0,this._lastQualifyTs=0,this._resetNoiseStats()}async init(){if(this.config.enabled)try{await this._ensureMicAnalyser(),this._subscribeToState()}catch(t){this._teardown()}}destroy(){this._isDestroyed=!0,this._unsubscribe(),this._disarm(),this._teardown()}async _ensureMicAnalyser(){if(this._micAnalyser)return;if("undefined"==typeof navigator||!navigator.mediaDevices?.getUserMedia)throw new Error("Media devices API not available");let t;this._audioCtx=this._audioCtx||new(window.AudioContext||window.webkitAudioContext);try{const e={audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!1}};t=await navigator.mediaDevices.getUserMedia(e)}catch(l){try{t=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(h){throw l}}this._micStream=t,this._micSource=this._audioCtx.createMediaStreamSource(t),this._micBpf=this._audioCtx.createBiquadFilter(),this._micBpf.type="bandpass";const[e,a]=Array.isArray(this.config.bandpassHz)&&2===this.config.bandpassHz.length?this.config.bandpassHz:[300,3e3],i=Math.max(10,Math.min(e,a||e)),n=Math.max(1.5*i,a||10*i),s=Math.sqrt(i*n);this._micBpf.frequency.value=Number.isFinite(s)?s:1e3;const o=Math.log2(n/i),r=Math.sinh(Math.log(2)/2*Math.max(o,.01)),c=r>0?1/(2*r):1;this._micBpf.Q.value=Math.max(.5,Math.min(4,c||1)),this._micAnalyser=this._audioCtx.createAnalyser(),this._micAnalyser.fftSize=512,this._micAnalyser.smoothingTimeConstant=.4,this._micSource.connect(this._micBpf).connect(this._micAnalyser),this._micBuffer=new Float32Array(this._micAnalyser.fftSize),this._debugEvent("mic-ready",{sampleRate:this._audioCtx.sampleRate,fftSize:this._micAnalyser.fftSize})}_subscribeToState(){this.avatarOrchestrator?.subscribeProjected&&(this._projectionUnsub=this.avatarOrchestrator.subscribeProjected((t=>{if(this._isDestroyed)return;const e=t?.lifecycle?.conversationSubstate;"speaking"===e?this._arm():this._disarm()})))}_unsubscribe(){if("function"==typeof this._projectionUnsub){try{this._projectionUnsub()}catch(t){}this._projectionUnsub=null}}_arm(){if(!this._micAnalyser)return;if(!this._avatarAnalyser&&!this._avatarAnalyserMissing){if(this._avatarAnalyser=this.talkingAvatar?.getSpeechAnalyzerNode?.()??null,!this._avatarAnalyser)return this._debugEvent("avatar-analyser-missing",{}),this._avatarAnalyserMissing=!0,void(this._armed=!1);this._avatarAnalyser.smoothingTimeConstant=Math.min(this._avatarAnalyser.smoothingTimeConstant??.4,.6),this._avatarBuffer=new Float32Array(this._avatarAnalyser.fftSize),this._debugEvent("avatar-analyser-ready",{fftSize:this._avatarAnalyser.fftSize})}if(this._armed)return;this._armed=!0,this._candidateSince=null,this._micEnvelope=0,this._avatarEnvelope=0,this._resetNoiseStats(),this._lastFrameTs=0,this._leakEstimate=Math.max(this.config.leakFloor??0,Math.min(this._leakEstimate,this.config.leakCeil??1));const t="undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now();this._armedAt=t,this._consecHits=0,this._lastQualifyTs=0,this._lastAvatarBelowMin=null,this._rafId||(this._rafId=requestAnimationFrame(this._monitorLoop)),this._debugEvent("armed",{micThreshold:this.config.micThreshold,avatarQuietFloor:this.config.avatarQuietFloor,minSignalRatio:this.config.minSignalRatio,minSignalRatioWhileSpeaking:this.config.minSignalRatioWhileSpeaking,minSignalDelta:this.config.minSignalDelta,absoluteMicOverride:this.config.absoluteMicOverride,minDurationMs:this.config.minDurationMs,cooldownMs:this.config.cooldownMs,warmupMs:this.config.warmupMs,speakingGuardMs:this.config.speakingGuardMs,minConsecutive:this.config.minConsecutive,hangoverMs:this.config.hangoverMs,bandpassHz:this.config.bandpassHz})}_disarm(){(this._armed||this._rafId)&&(this._armed=!1,this._candidateSince=null,this._micEnvelope=0,this._avatarEnvelope=0,this._resetNoiseStats(),this._lastFrameTs=0,this._leakEstimate=Math.max(this.config.leakFloor??0,Math.min(this._leakEstimate,this.config.leakCeil??1)),this._armedAt=0,this._consecHits=0,this._lastQualifyTs=0,this._lastAvatarBelowMin=null,this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._debugEvent("disarmed",{}))}_monitorLoop=()=>{if(this._isDestroyed)return;if(!this._armed)return void(this._rafId=null);const t=performance.now(),e=this._lastFrameTs?t-this._lastFrameTs:16.7;this._lastFrameTs=t,"suspended"===this._audioCtx?.state&&(0===this._lastAudioResumeAttempt||t-this._lastAudioResumeAttempt>=1e3)&&(this._lastAudioResumeAttempt=t,this._audioCtx.resume().catch((()=>{})));const a=this._clamp01(this._readRms(this._micAnalyser,this._micBuffer)),i=this._avatarAnalyser?this._readRms(this._avatarAnalyser,this._avatarBuffer):0,n=this._clamp01(i),s=this._updateEnvelope("_micEnvelope",a,e),o=this._updateEnvelope("_avatarEnvelope",n,e),r=this._updateLeakEstimate({micSignal:s,avatarSignal:o,candidateActive:!!this._candidateSince}),c=o>(this.config.leakMinAvatar??.01)?.85*(r+(this.config.leakMargin??.012)):0,l=Math.max(0,s-o*c),h=o>5e-4?l/Math.max(o,5e-4):1/0,d=l-o,u=o<=this.config.avatarQuietFloor,p=l>=this.config.micThreshold,g=s>=this.config.absoluteMicOverride,v=t-(this._armedAt||t),m=v<(this.config.warmupMs??400),b=!u&&v<(this.config.speakingGuardMs??250);!g&&!this._candidateSince&&u&&!m&&0===this._consecHits&&l<1.2*this.config.micThreshold&&this._updateNoiseStats(l);const _=this._noiseCount>=(this.config.noiseMinSamples??90),f=this._noiseMean,y=this._getNoiseStd(),w=_?(l+1e-7)/(f+1e-7):0,S=this.config.noiseStdK??3.2,C=_&&l>=f+S*y,k=_&&w>=(this.config.minSnr??3),A=!!u||g||h>=(this.config.minSignalRatioWhileSpeaking??this.config.minSignalRatio)||d>=this.config.minSignalDelta,x=this.config.minAbsQuiet??0,T=!u||l>=x,I=u?T&&(g||(_?C||k:p)):g||p,E=!m&&!b,D=E&&I&&A,M=this.config.minConsecutive??4;if(D)this._consecHits+=1,this._lastQualifyTs=t;else{const e=this.config.hangoverMs??120,a=t-this._lastQualifyTs<=e;this._consecHits=a?this._consecHits:0}this._debugTick({micLevel:a,avatarLevel:n,micSignal:s,avatarSignal:o,effectiveMic:l,leak:r,leakApply:c,noiseMean:f,noiseStd:y,noiseSamples:this._noiseCount,snr:w,exceedsNoise:C,snrDominates:k,ratio:h,delta:d,meetsMicThreshold:p,avatarQuiet:u,absoluteOverride:g,absQuietOK:T,energyOK:I,energyQualified:I,competitionOK:A,noiseReady:_,warmup:m,speakingGuard:b,frameAllowed:E,frameQualifies:D,qualifies:D,consecutiveHits:this._consecHits,requiredHits:M,candidateDuration:this._candidateSince?t-this._candidateSince:0,cooldownRemaining:Math.max(0,this.config.cooldownMs-(t-this._lastTriggerTime))}),this._consecHits>=M?this._candidateSince||(this._candidateSince=t,this._debugEvent("candidate-start",{micLevel:a,avatarLevel:n,micSignal:s,avatarSignal:o,effectiveMic:l,leak:r,noiseMean:f,noiseStd:y,snr:w,ratio:h,delta:d})):this._candidateSince&&!D&&t-this._lastQualifyTs>(this.config.hangoverMs??120)&&(this._debugEvent("candidate-reset",{micLevel:a,avatarLevel:n,micSignal:s,avatarSignal:o,effectiveMic:l,leak:r,noiseMean:f,noiseStd:y,snr:w,ratio:h,delta:d}),this._candidateSince=null,this._consecHits=0);const R=u?this.config.minDurationMs??200:this.config.minDurationWhileSpeakingMs??(this.config.minDurationMs??200)+60,P=this._candidateSince&&t-this._candidateSince>=R,z=t-this._lastTriggerTime>=this.config.cooldownMs;P&&z?this._emitBargeIn({micLevel:a,avatarLevel:n,micSignal:s,avatarSignal:o,effectiveMic:l,leak:r,noiseMean:f,noiseStd:y,snr:w,ratio:h,delta:d,timestamp:t}):P&&!z&&this._debugEvent("cooldown-block",{micLevel:a,avatarLevel:n,micSignal:s,avatarSignal:o,effectiveMic:l,leak:r,noiseMean:f,noiseStd:y,snr:w,ratio:h,delta:d,cooldownRemaining:Math.max(0,this.config.cooldownMs-(t-this._lastTriggerTime))}),this._rafId=requestAnimationFrame(this._monitorLoop)};_emitBargeIn({micLevel:t,avatarLevel:e,micSignal:a,avatarSignal:i,effectiveMic:n,leak:s,noiseMean:o,noiseStd:r,snr:c,ratio:l,delta:h,timestamp:d}){this._lastTriggerTime=d,this._candidateSince=null,this._consecHits=0,this._lastQualifyTs=0,this._debugEvent("trigger",{micLevel:t,avatarLevel:e,micSignal:a,avatarSignal:i,effectiveMic:n,leak:s,noiseMean:o,noiseStd:r,snr:c,ratio:l,delta:h,timestamp:d});try{this.avatarOrchestrator?.sendEvent?.("VOICE_BARGE_IN",{micLevel:t,avatarLevel:e,micSignal:a,avatarSignal:i,effectiveMic:n,leak:s,noiseMean:o,noiseStd:r,snr:c,ratio:l,delta:h,timestamp:d})}catch(u){}}_readRms(t,e){if(!t)return 0;try{t.getFloatTimeDomainData(e)}catch(i){return 0}let a=0;for(let n=0;n<e.length;n++){const t=e[n];a+=t*t}return Math.sqrt(a/e.length)}_teardown(){if(this._micStream&&(this._micStream.getTracks().forEach((t=>{try{t.stop()}catch(e){}})),this._micStream=null),this._micSource){try{this._micSource.disconnect()}catch(t){}this._micSource=null}if(this._micBpf){try{this._micBpf.disconnect()}catch(t){}this._micBpf=null}if(this._micAnalyser){try{this._micAnalyser.disconnect()}catch(t){}this._micAnalyser=null}if(this._audioCtx){try{this._audioCtx.close()}catch(t){}this._audioCtx=null}this._micBuffer=null,this._avatarAnalyser=null,this._avatarBuffer=null,this._avatarAnalyserMissing=!1,this._lastTickLog=0,this._micEnvelope=0,this._avatarEnvelope=0,this._leakEstimate=this.config.leakFloor??0,this._lastAvatarBelowMin=null,this._armedAt=0,this._consecHits=0,this._lastQualifyTs=0,this._resetNoiseStats(),this._lastFrameTs=0,this._lastAudioResumeAttempt=0}_debugTick(t){if(!this.config.debug)return;const e=performance.now?performance.now():Date.now();e-this._lastTickLog<150||(this._lastTickLog=e)}_debugEvent(t,e){this.config.debug}_updateEnvelope(t,e,a=16.7){const i="number"==typeof this[t]?this[t]:e,n=Math.min(Math.max(this.config.envelopeAttack,0),.999),s=Math.min(Math.max(this.config.envelopeRelease,0),.999),o=e>=i?n:s,r=Math.max(a/16.7,.1),c=i+(e-i)*(1-Math.pow(o,r)),l=this._clamp01(c);return this[t]=l,l}_updateLeakEstimate({micSignal:t,avatarSignal:e,candidateActive:a}){const i=this.config.leakMinAvatar??0,n=this.config.leakAdaptRate??.1,s=this.config.leakFloor??0,o=this.config.leakCeil??1,r="undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now();let c=this._leakEstimate??s;if(a||this._consecHits>0)return c;const l=this._noiseCount>=(this.config.noiseMinSamples??90),h=this._getNoiseStd(),d=this._noiseMean,u=l&&t>=d+(this.config.noiseStdK??3.2)*h;if(e>i&&t<.8*this.config.absoluteMicOverride&&!u){const a=t/Math.max(e,1e-5);c+=(Math.max(s,Math.min(a,o))-c)*n,this._leakEstimate=c,this._debugLeakUpdate({ratio:a,estimate:c}),this._lastAvatarBelowMin=null}else if(e<=i&&c>s){const t=this.config.leakDecayHoldMs??1e3,a=this.config.leakDecayRate??.1*n;null==this._lastAvatarBelowMin&&(this._lastAvatarBelowMin=r),e<=i?r-this._lastAvatarBelowMin>=t&&(c+=(s-c)*a):this._lastAvatarBelowMin=r,this._leakEstimate=Math.max(s,c)}return this._leakEstimate??s}_debugLeakUpdate({ratio:t,estimate:e}){this.config.debug&&this._debugEvent("leak-update",{ratio:t,estimate:e})}_resetNoiseStats(){this._noiseMean=0,this._noiseVar=0,this._noiseCount=0}_updateNoiseStats(t){const e=this._clamp01(t);if(!Number.isFinite(e))return;this._noiseCount>=500&&(this._noiseCount=Math.floor(350),this._noiseMean*=.95,this._noiseVar*=.9),this._noiseCount+=1;const a=e-this._noiseMean;this._noiseMean+=a/this._noiseCount;const i=e-this._noiseMean;this._noiseVar+=a*i}_getNoiseStd(){return this._noiseCount<2?0:Math.sqrt(Math.max(this._noiseVar/(this._noiseCount-1),0))}_clamp01(t){return Number.isFinite(t)?t<=0?0:t>=1?1:t:0}}let et=null;const at={setInstance(t){et=t},getItem:async t=>{if(!et)throw new Error("Storage instance not initialized");return et.getItem(t)},setItem:async(t,e)=>{if(!et)throw new Error("Storage instance not initialized");return et.setItem(t,e)},removeItem:async t=>{if(!et)throw new Error("Storage instance not initialized");return et.removeItem(t)}};class it extends Error{constructor(t,{statusCode:e=null,reason:a=null}={}){super(t),this.name="LoginError",this.statusCode=e,this.reason=a}}async function nt(t){try{const e=await fetch(`${t.serverBaseURL}/api/v1/chatbot/login`,{method:"POST",headers:{"Content-Type":"application/json","X-Sentifyd-Origin":t.targetApp},body:JSON.stringify({avatar_api_key:t.getAvatarAPIKey()})});if(!e.ok){const a=function(t){switch(t){case 404:return{message:"Avatar not found.",reason:"avatar-not-found",shouldStopRetrying:!0};case 401:return{message:"Unauthorized avatar login attempt.",reason:"unauthorized",shouldStopRetrying:!1};case 429:return{message:"Too many login attempts. Please retry later.",reason:"rate-limited",shouldStopRetrying:!1};default:return{message:`Login failed with status code ${t}.`,reason:"login-failed",shouldStopRetrying:!1}}}(e.status);throw a.shouldStopRetrying&&(t.retries=T.auth.maxLoginRetries),new it(a.message,{statusCode:e.status,reason:a.reason})}const a=await e.json();await async function(t,e){try{const a=e?.data?.avatar_params;if(!a||!a.avatarId)throw new Error("Invalid avatar parameters received in login response.");const i=a.avatarId;t.id=i;const n={accessToken:e.data.access_token,refreshToken:e.data.refresh_token,avatarParameters:a};await t.updateAuthData(n),t.setConnected()}catch(a){throw new Error(`Failed to process login response: ${a.message}`)}}(t,a)}catch(e){throw e}}const st=new class{constructor(t=1){this.max=t,this._fns=[],this._active=0}get remaining(){return this._fns.length}get active(){return this._active}take(t){this._fns.push(t),this._try()}_done(){this._active-=1,this._try()}_try(){if(this._active===this.max||0===this._fns.length)return;const t=this._fns.shift();this._active+=1,t&&t(this._done.bind(this))}}(1);class ot{constructor({serverBaseURL:t,getRefreshToken:e,updateAccessToken:a,onSuccess:i,onError:n}){this.serverBaseURL=t,this.getRefreshToken=e,this.onSuccess=i,this.onError=n,this.tokenRefreshIntervalId=null,this.updateAccessToken=a}startTokenRefreshInterval(){this.tokenRefreshIntervalId&&clearInterval(this.tokenRefreshIntervalId),this.tokenRefreshIntervalId=setInterval((async()=>{try{await this.refreshAccessToken()}catch(t){}}),T.auth.tokenRefreshInterval)}stopTokenRefreshInterval(){this.tokenRefreshIntervalId&&(clearInterval(this.tokenRefreshIntervalId),this.tokenRefreshIntervalId=null)}async refreshAccessToken(){return new Promise(((t,e)=>{st.take((async a=>{try{const e=this.getRefreshToken();if(!e)throw new Error("No refresh token available");const a=await fetch(`${this.serverBaseURL}/api/v1/chatbot/token_exchange`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+e}});if(!a.ok){const t=`Failed to refresh JWT token (Status: ${a.status} ${a.statusText})`;throw"function"==typeof this.onError&&this.onError(new Error(t)),new Error(t)}const i=await a.json();if(!i?.data?.access_token)throw new Error("Invalid token data received during refresh.");this.updateAccessToken&&await this.updateAccessToken(i.data.access_token),"function"==typeof this.onSuccess&&this.onSuccess(i.data.access_token),t(!0)}catch(i){"function"==typeof this.onError&&this.onError(i),e(i)}finally{a()}}))}))}}class rt extends F{#t;#e;#a;constructor(t="",e="",a=""){if(rt._instance)return rt._instance;super("authentication"),rt._instance=this,this.#t=t,this.tokenEndpoint=e,this.#e=null,this.#a=null,this.avatarParameters=null,this.id=a,this.serverBaseURL=T.auth.serverBaseURL||"",this.targetApp="",this.lastFailureDetails=null,this.tokenRefresher=new ot({serverBaseURL:this.serverBaseURL,getRefreshToken:()=>this.#a,updateAccessToken:async t=>await this.updateAuthData({accessToken:t}),onSuccess:()=>{},onError:t=>{this.handleAuthenticationFailure("Error refreshing access token",t)}})}async init(t="web",e="",a="",i=""){this.id=i,this.targetApp=t,this.#t=e,this.tokenEndpoint=a;try{await this.authenticate();try{await this.updateAvatarParametersFromServer()}catch(n){}return this.startTokenRefreshInterval(),!0}catch(s){return this.handleAuthenticationFailure(`Error during authentication initialization: ${s.message}`,s),!1}}async authenticate(){for(this.retries=0,this.setConnecting();this.retries<T.auth.maxLoginRetries;)try{if(this.#t?.trim())await nt(this);else{if(!this.tokenEndpoint?.trim()){const t="authenticate: No API key or token endpoint provided for authentication.";throw this.handleAuthenticationFailure(t),new Error(t)}await this.requestDataFromServer()}return void this.clearFailureDetails()}catch(t){if(this.setDisconnected(),this.recordFailure({message:`authenticate: Attempt #${this.retries+1} failed`,reason:t instanceof it?t.reason:t?.message||null,statusCode:t instanceof it&&"number"==typeof t.statusCode?t.statusCode:null}),this.retries++,this.retries>=T.auth.maxLoginRetries){const e=`authenticate: All ${T.auth.maxLoginRetries} authentication attempts failed.`;if(this.handleAuthenticationFailure(e,t),t instanceof Error)throw t;throw new Error(`${e} Last error: ${t}`)}await S(T.auth.loginRetryDelay)}}startTokenRefreshInterval(){this.tokenRefresher.startTokenRefreshInterval()}stopTokenRefreshInterval(){this.tokenRefresher.stopTokenRefreshInterval()}isTokenCloseToExpiration(){if(!this.#e)return!0;try{const{exp:t}=l(this.#e);if(!t)return!0;if(1e3*t-Date.now()<=T.auth.closeToExpirationLimit)return!0}catch(t){return!0}return!1}async callSentifydApi(t,e="POST",a=null){if(!this.isConnected())throw new Error("Cannot call the API without active authentication");const i=`${this.serverBaseURL}${t}`,n=new Headers({"Content-Type":"application/json"}),s=this.getAccessToken();if(!s)throw new Error("Cannot call the API without an access token");n.append("Authorization",`Bearer ${s}`);const o={method:e,headers:n,body:a?JSON.stringify(a):void 0};try{let t=await fetch(i,o);if(401===t.status)try{await this.authenticate();const e={...o,headers:{...o.headers,Authorization:`Bearer ${this.getAccessToken()}`}};if(t=await fetch(i,e),401===t.status)throw this.handleAuthenticationFailure("callSentifydApi: Authentication failed in API call. Not authorized."),new Error(`API call failed: ${t.statusText} (Status: ${t.status})`)}catch(r){throw this.handleAuthenticationFailure("callSentifydApi: Authentication failed in API call. Not authorized."),new Error("API call failed")}if(!t.ok)throw new Error(`API call failed: ${t.statusText} (Status: ${t.status})`);return await t.json()}catch(r){throw r}}async isAuthRequired(){const t=this.#i();return!(t&&t.accessToken&&t.refreshToken&&t.avatarParameters&&!this.isTokenCloseToExpiration())}async logout(){this.id&&await async function(t){if(t)try{await at.removeItem(`authData_${t}`)}catch(e){}}(this.id),this.stopTokenRefreshInterval(),this.#e=null,this.#a=null,this.avatarParameters=null,this.clearFailureDetails(),this.setDisconnected()}async#n(){if(!this.id)return!1;const t=await async function(t){if(!t)return null;try{const e=await at.getItem(`authData_${t}`);return e?JSON.parse(e):null}catch(e){return null}}(this.id);if(!t)return!1;try{return this.#e=t.accessToken,this.#a=t.refreshToken,this.avatarParameters=t.avatarParameters,!(await this.isAuthRequired())||(this.setDisconnected(),!1)}catch(e){return this.setDisconnected(),!1}}#i(){return this.id&&this.#e&&this.#a&&this.avatarParameters?{accessToken:this.#e,refreshToken:this.#a,avatarParameters:this.avatarParameters}:null}getAccessToken(){return this.#e||null}getRefreshToken(){return this.#a||null}getAvatarAPIKey(){return this.#t}async updateAccessToken(t){await this.updateAuthData({accessToken:t})}getAvatarParameters(){return this.avatarParameters||null}async updateAuthData({accessToken:t,refreshToken:e,avatarParameters:a}){const i=this.#i()||{};t&&(this.#e=t,i.accessToken=t),e&&(this.#a=e,i.refreshToken=e),a&&(this.avatarParameters=a,i.avatarParameters=a);try{await async function(t,e){if(t)try{await at.setItem(`authData_${t}`,JSON.stringify(e))}catch(a){}}(this.id,i),this.clearFailureDetails()}catch(n){}}async requestDataFromServer(){if(!this.tokenEndpoint?.trim())throw new Error("requestDataFromServer: Token URL is not specified.");try{const t=await fetch(this.tokenEndpoint,{method:"GET"});if(!t.ok)throw new Error(`requestDataFromServer: Failed to request tokens (Status: ${t.status} ${t.statusText})`);const e=await t.json();if(!this.#s(e))throw new Error("requestDataFromServer: Invalid token response received from server.");await this.updateAuthData({accessToken:e.tokens.accessToken,refreshToken:e.tokens.refreshToken,avatarParameters:e.avatarParameters}),this.setConnected()}catch(t){throw this.setDisconnected(),t}}#s(t){return t?.tokens?.accessToken&&t?.tokens?.refreshToken&&t?.avatarParameters}async updateAvatarParametersFromServer(){try{const t=await this.callSentifydApi("/api/v1/chatbot/get-avatar-params","POST");if(!t||!t.data||!t.data.avatar_params)return;this.avatarParameters=t.data.avatar_params,this.updateAuthData({avatarParameters:this.avatarParameters})}catch(t){}}handleAuthenticationFailure(t,e=null){this.recordFailure({message:t,reason:e instanceof it?e.reason:e instanceof Error?e.message:null,statusCode:e instanceof it&&"number"==typeof e.statusCode?e.statusCode:null}),this.setFailed()}recordFailure({message:t,reason:e=null,statusCode:a=null}={}){this.lastFailureDetails={message:t||"Unknown authentication error",reason:e??(t||"Unknown authentication error"),statusCode:a,timestamp:Date.now()}}clearFailureDetails(){this.lastFailureDetails=null}getLastFailureDetails(){return this.lastFailureDetails?{...this.lastFailureDetails}:null}async reconnect(){if(!this.isConnected()&&!this.isReconnecting()){this.stopTokenRefreshInterval(),this.isFailed()?this.setReconnecting():this.setConnecting();try{if(await this.authenticate(),this.isConnected()){try{await this.updateAvatarParametersFromServer()}catch(t){}this.startTokenRefreshInterval()}else this.setFailed()}catch(e){this.handleAuthenticationFailure("Authentication reconnect failed",e)}}}static resetInstance(){rt._instance=null}}class ct{constructor(t,e=h){this.avatarId=t,this.conversationData={id:void 0,transcript:[],currentTurnId:0},this.lastDetectedLanguage=null,this.uuidGenerator=e,this.lastStartWasResumeAttempt=!1,this.transcriptLengthBeforeResume=0}get conversationId(){return this.conversationData.id}set conversationId(t){this.conversationData.id=t}get transcript(){return this.conversationData.transcript}set transcript(t){this.conversationData.transcript=t}get currentTurnId(){return this.conversationData.currentTurnId}set currentTurnId(t){this.conversationData.currentTurnId=t}incrementTurnId(){return this.conversationData.currentTurnId++,this.conversationData.currentTurnId}async getConversationData(){if(!this.avatarId)return null;const t=await at.getItem(`conversationData_${this.avatarId}`),e={id:void 0,transcript:[],currentTurnId:0};return this.conversationData=t?{...e,...JSON.parse(t)}:e,this.conversationData}async saveConversationData(){this.avatarId&&await at.setItem(`conversationData_${this.avatarId}`,JSON.stringify(this.conversationData))}async notifyConversationInit(){await this.getConversationData(),this.conversationId||(await this.clearOngoingConversation(),await this.generateNewConversationId())}async notifyConversationStart(t=!1){if(t)this.lastStartWasResumeAttempt=!1,this.transcriptLengthBeforeResume=0,await this.clearOngoingConversation(),await this.generateNewConversationId(),this.incrementTurnId();else{await this.getConversationData();const t=!!this.conversationId,e=Array.isArray(this.transcript)&&this.transcript.length>0;this.lastStartWasResumeAttempt=t&&e,this.transcriptLengthBeforeResume=e?this.transcript.length:0,this.conversationId||(await this.clearOngoingConversation(),await this.generateNewConversationId()),this.incrementTurnId()}}async notifyConversationEnd(){this.lastStartWasResumeAttempt=!1,await this.clearOngoingConversation()}async clearOngoingConversation(){this.conversationData={id:void 0,transcript:[],currentTurnId:0};try{await at.removeItem(`conversationData_${this.avatarId}`)}catch(t){await this.saveConversationData()}}async discardConversationHistory(){const t=this.conversationId,e=this.currentTurnId;this.conversationData={id:t,transcript:[],currentTurnId:e},await this.saveConversationData()}async generateNewConversationId(){const t=this.uuidGenerator();this.conversationId=t,await this.saveConversationData()}async appendMessage(t,e,a){if(!this.conversationId)return null;const i={speaker:a,messageText:C(t),time:e};return this.transcript.push(i),await this.saveConversationData(),i}async handleConversationSuccessfulStart(t){const e=t?.isInProgress,a=t?.conversationId,i=this.conversationId,n=!!this.lastStartWasResumeAttempt;let s=!1;if(!1===e&&(s=!0),a&&i&&a!==i&&(this.conversationId=a,s=!0),n&&s){const t=this.transcript.slice(this.transcriptLengthBeforeResume);this.conversationData.transcript=t,await this.saveConversationData()}return{serverStartedNew:s,resumeAttempt:n,resumeFailed:s&&n}}}class lt{constructor(){if(lt._instance)return lt._instance;this._avatarId=null,this._avatarName="",this._avatarItem=null,this._trainingId=null,this._language="",this._autodetectLanguages=[],this._voice="",this._lipsyncType="words",this._wordsPerMinute=150,this._userData={username:"",phoneNumber:"",email:"",isTermsAccepted:!1},this.conversation=null,lt._instance=this,Object.seal(this)}static getInstance(){return lt._instance||(lt._instance=new lt),lt._instance}static hasInstance(){return null!==lt._instance&&void 0!==lt._instance}static resetInstance(){if(lt._instance)try{return lt._instance.destroy(),lt._instance=null,!0}catch(t){return!1}return!0}async init(t,e){const{avatarId:a,avatarName:i,trainingId:n,language:s,autodetectLanguages:o,voice:r,wordsPerMinute:c}=t;if(![a,i,e,s,r].every((t=>null!=t&&""!==t))||!Array.isArray(o))return!1;this._trainingId=null===n||""===n?null:n,this._avatarId=a,this._avatarName=i,this._avatarItem=e,this._language=s,this._autodetectLanguages=o,this._voice=r,this._lipsyncType=e?.lipsyncType||"words",this._wordsPerMinute=c||150;try{return this.conversation=new ct(this._avatarId),!0}catch(l){return!1}}get isUserDataDefined(){return this._userData.username&&!0===this._userData.isTermsAccepted}get avatarId(){return this._avatarId}set avatarId(t){this._avatarId=t,this.conversation&&(this.conversation.avatarId=t)}get avatarName(){return this._avatarName}set avatarName(t){"string"==typeof t&&""!==t.trim()&&(this._avatarName=t)}get avatarItem(){return this._avatarItem}set avatarItem(t){t&&"object"==typeof t&&(this._avatarItem=t)}get trainingId(){return this._trainingId}set trainingId(t){(null==t||"string"==typeof t&&""!==t.trim())&&(this._trainingId=t)}get language(){return this._language}set language(t){"string"==typeof t&&""!==t.trim()&&(this._language=t)}get autodetectLanguages(){return this._autodetectLanguages}set autodetectLanguages(t){Array.isArray(t)&&(this._autodetectLanguages=t)}get voice(){return this._voice}set voice(t){"string"==typeof t&&""!==t.trim()&&(this._voice=t)}get lipsyncType(){return this._lipsyncType}set lipsyncType(t){["words","visemes","blendshapes"].includes(t)&&(this._lipsyncType=t)}get wordsPerMinute(){return this._wordsPerMinute}set wordsPerMinute(t){"number"!=typeof t||t<=0||(this._wordsPerMinute=t)}get username(){return this._userData.username}set username(t){"string"==typeof t&&""!==t.trim()&&(this._userData.username=t)}get phoneNumber(){return this._userData.phoneNumber}set phoneNumber(t){"string"==typeof t&&""!==t.trim()&&(this._userData.phoneNumber=t)}get email(){return this._userData.email}set email(t){"string"==typeof t&&""!==t.trim()&&(this._userData.email=t)}get isTermsAccepted(){return this._userData.isTermsAccepted}set isTermsAccepted(t){"boolean"==typeof t&&(this._userData.isTermsAccepted=t)}destroy(){try{this.conversation&&"function"==typeof this.conversation.destroy&&this.conversation.destroy()}catch(t){}}}function ht(t){try{t?.talkingAvatar?.liveCaptions?.clearCaptions?.()}catch(e){}try{t?.bus?.emit?.("event_command_UI_ClearCaptions")}catch(e){}}lt._instance=null;const dt=d({id:"avatarOrchestrator",context:({input:t})=>({bus:t?.bus??null,talkingAvatar:t?.talkingAvatar??null,chatSocket:t?.chatSocket??null,voiceBot:t?.voiceBot??null,conversation:t?.conversation??null,speakingAvatar:t?.speakingAvatar??null,eventPayload:null,isPageVisible:!0,currentPage:"LoaderPage",pendingStart:null,userSilenced:!1,initFailed:!1,firstConnectionCompleted:!1}),type:"parallel",states:{lifecycle:{initial:"init",states:{init:{initial:"initializing",states:{initializing:{id:"initializing",on:{READY:{target:"complete",actions:["onLeaveInitializing"]},FAIL:{target:"failed",actions:u({initFailed:!0})}}},failed:{id:"failed",on:{RETRY:{target:"initializing"},CONNECT:{target:"initializing"}}},complete:{always:{target:"#avatarOrchestrator.lifecycle.conversation.stopped"}}}},checkingResume:{id:"checkingResume",invoke:{id:"checkResumeOnStart",src:"checkResumeActor",input:({context:t})=>({conversation:t.conversation,bus:t.bus}),onDone:[{target:"conversation.autoResuming",guard:({event:t})=>!!t.output?.resumable},{target:"conversation.stopped"}],onError:{target:"conversation.stopped"}}},conversation:{initial:"stopped",on:{CONVERSATION_TIMEOUT:{target:".timedOut"}},states:{stopped:{id:"stopped",entry:["armVideoIdleDisconnectOnStopped"],exit:["disarmVideoIdleDisconnect"],on:{START_CONVERSATION:[{guard:({context:t})=>!t.isPageVisible,actions:"onDeferStart",target:void 0},{target:"inProgress.startingConversation",actions:u({eventPayload:({event:t})=>t.payload})}],INIT_CONVERSATION:{target:"initializingConversation"},END_CONVERSATION:{target:"endingConversation"},CLEAR_CONVERSATION:{target:"clearingConversation"},RESTORED_CONNECTION:{target:"#checkingResume"},AVATAR_INITIALIZED:{target:"#checkingResume"},CONVERSATION_INIT_SUCCESS:{actions:["onConversationInitSuccess"]},CONVERSATION_INIT_FAILED:{target:"#avatarOrchestrator.lifecycle.init.failed",actions:u({initFailed:!0})},CONVERSATION_TIMEOUT:{target:"#avatarOrchestrator.lifecycle.conversation.timedOut"},DISCONNECT:{actions:[]},FAIL:{target:"#avatarOrchestrator.lifecycle.init.failed",actions:u({initFailed:!0})}}},timedOut:{id:"timedOut",entry:[({context:t,event:e})=>{try{const a=e?.payload?.conversationId??t?.conversation?.conversationId;t.bus?.emit?.("event_status_Conversation_TimedOut",{conversationId:a})}catch(a){}},"armVideoIdleDisconnectOnStopped"],exit:["disarmVideoIdleDisconnect"],on:{START_CONVERSATION:[{guard:({context:t})=>!t.isPageVisible,actions:"onDeferStart",target:void 0},{target:"inProgress.startingConversation",actions:u({eventPayload:({event:t})=>t.payload})}],INIT_CONVERSATION:{target:"initializingConversation"},END_CONVERSATION:{target:"endingConversation"},CLEAR_CONVERSATION:{target:"clearingConversation"},RESTORED_CONNECTION:{target:"#checkingResume"},AVATAR_INITIALIZED:{target:"#checkingResume"},CONVERSATION_INIT_SUCCESS:{actions:["onConversationInitSuccess"]},CONVERSATION_INIT_FAILED:{target:"#avatarOrchestrator.lifecycle.init.failed",actions:u({initFailed:!0})},FAIL:{target:"#avatarOrchestrator.lifecycle.init.failed",actions:u({initFailed:!0})}}},autoResuming:{id:"autoResuming",tags:["thinking","inputs_blocked"],entry:["onStartingConversation"],invoke:{id:"autoResumeService",src:"startConversationService",input:({context:t})=>({isNew:!1,skipFallback:!0,bus:t.bus,conversation:t.conversation,chatSocket:t.chatSocket,talkingAvatar:t.talkingAvatar,speakingAvatar:t.speakingAvatar}),onDone:[{guard:({context:t,event:e})=>"resume_silent"===e.output?.data?.dataType&&!0===t.talkingAvatar?.isVideoAvatar,target:"inProgress.listening",actions:["onConversationStartSuccess","onAutoResumeToListening"]},{guard:({event:t})=>"resume_silent"===t.output?.data?.dataType,target:"inProgress.idle",actions:"onConversationStartSuccess"},{target:"inProgress.thinking",actions:"onConversationStartSuccess"}],onError:{target:"resumeExpired",actions:["onAutoResumeFailed"]}},on:{AI_MESSAGE_RECEIVED:{actions:"handleAiMessage"},AUDIO_END:{actions:["onAudioEnd"]},STREAM_START:{target:"inProgress.pendingAudioStart",actions:["onStreamStart"]},IDLE:"inProgress.idle"}},resumeExpired:{id:"resumeExpired",entry:[({context:t})=>{try{const e=t?.conversation?.conversationId;t.bus?.emit?.("event_status_Conversation_ResumeExpired",{conversationId:e})}catch(e){}}],on:{START_NEW_CONVERSATION:{target:"inProgress.startingConversation",actions:u({eventPayload:{fresh:!0}})},DISMISS:{target:"stopped",actions:[({context:t})=>{try{t.conversation?.clearOngoingConversation?.()}catch(e){}}]},CLEAR_CONVERSATION:{target:"clearingConversation"},END_CONVERSATION:{target:"endingConversation"},FAIL:{target:"#avatarOrchestrator.lifecycle.init.failed",actions:u({initFailed:!0})}}},paused:{id:"paused",entry:["onConversationPaused"],tags:["conversation_paused","inputs_blocked"],on:{AUDIO_END:{actions:["onAudioEnd"]},RECONNECT:[{target:"inProgress.idle",guard:"hasActiveConversation"},{target:"clearingConversation"}],RESTORED_CONNECTION:[{target:"inProgress.idle",guard:"hasActiveConversation"},{target:"clearingConversation"}],END_CONVERSATION:{target:"endingConversation"},CLEAR_CONVERSATION:{target:"clearingConversation"},FAIL:{target:"#avatarOrchestrator.lifecycle.init.failed",actions:u({initFailed:!0})}}},initializingConversation:{id:"initializingConversation",invoke:{id:"initConversationActor",src:"initConversationActor",input:({context:t})=>({conversation:t.conversation,chatSocket:t.chatSocket,bus:t.bus}),onDone:{target:"stopped",actions:"onConversationInitSuccess"},onError:{target:"stopped",actions:[u({initFailed:!0}),"onConversationInitFailed"]}},on:{FAIL:{target:"#avatarOrchestrator.lifecycle.init.failed",actions:u({initFailed:!0})}}},inProgress:{id:"inProgress",tags:["conversation_in_progress"],on:{STOP:{target:"stopped",actions:["onStop"]},END_CONVERSATION:{target:"endingConversation"},CLEAR_CONVERSATION:{target:"clearingConversation"},DISCONNECT:[{target:"paused",guard:"hasActiveConversation"},{target:"stopped"}],AUDIO_START:{target:"#speaking",actions:["onAudioStarted"]},AI_MESSAGE_RECEIVED:{actions:"handleAiMessage"},FAIL:{target:"#avatarOrchestrator.lifecycle.init.failed",actions:u({initFailed:!0})}},initial:"idle",states:{idle:{id:"idle",entry:["onIdle","armVideoIdleDisconnect"],exit:["disarmVideoIdleDisconnect"],on:{STREAM_START:{target:"pendingAudioStart",actions:["onStreamStart"]},LISTEN:"listening",THINK:"thinking",START_CONVERSATION:{target:"startingConversation",actions:u({eventPayload:({event:t})=>t.payload})},SEND_TEXT_MESSAGE:{target:"processingTextMessage"},MIC_BUTTON:[{guard:"isRequestBlocked",actions:["onMicButtonBlocked"]},{target:"listening",actions:["onMicButtonStartListening"]}],AUDIO_END:{actions:["onAudioEnd"]}}},listening:{id:"listening",tags:["listening"],entry:["onListenEntry"],invoke:{id:"listenActor",src:"listenActor",input:({context:t})=>({voiceBot:t.voiceBot,talkingAvatar:t.talkingAvatar,bus:t.bus,currentPage:t.currentPage,isPageVisible:t.isPageVisible,chatbotMode:t.chatSocket?.chatbotMode}),onDone:[{guard:({event:t})=>!t?.output?.started,target:"idle"}],onError:{target:"idle",actions:["onListenFailed"]}},on:{STREAM_START:{target:"pendingAudioStart",actions:["onStreamStart"]},THINK:"thinking",START_CONVERSATION:{target:"startingConversation",actions:["onIdle",u({eventPayload:({event:t})=>t.payload})]},SPEECH_RECOGNITION_COMPLETE:{target:"processingSpeechRecognition"},SEND_TEXT_MESSAGE:{target:"processingTextMessage",actions:[({context:t})=>{if(t.voiceBot){t.voiceBot.stopListening();try{t.talkingAvatar?.liveCaptions?.clearCaptions?.()}catch(e){}try{t.bus.emit("event_command_UI_ClearCaptions")}catch(e){}}}]},MIC_BUTTON:{target:"idle",actions:["setUserSilencedTrue","onMicButtonStopListening"]},IDLE:"idle",AUDIO_END:{actions:["onAudioEnd"]}}},processingSpeechRecognition:{id:"processingSpeechRecognition",invoke:{id:"speechRecognitionActor",src:"speechRecognitionActor",input:({context:t,event:e})=>({chatSocket:t.chatSocket,payload:e.payload,conversation:t.conversation,bus:t.bus}),onDone:{target:"thinking"},onError:{target:"idle",actions:["onSpeechRecognitionFailed"]}},on:{AUDIO_END:{actions:["onAudioEnd"]}}},processingTextMessage:{id:"processingTextMessage",invoke:{id:"sendTextMessageActor",src:"sendTextMessageActor",input:({context:t,event:e})=>({chatSocket:t.chatSocket,payload:e.payload,conversation:t.conversation,bus:t.bus}),onDone:{target:"thinking"},onError:{target:"idle",actions:["onSendTextMessageFailed"]}},on:{AUDIO_END:{actions:["onAudioEnd"]}}},thinking:{id:"thinking",tags:["thinking","inputs_blocked"],on:{AUDIO_END:{actions:["onAudioEnd"]},STREAM_START:{target:"pendingAudioStart",actions:["onStreamStart"]},IDLE:"idle",START_CONVERSATION:{target:"startingConversation",actions:u({eventPayload:({event:t})=>t.payload})}}},startingConversation:{id:"startingConversation",tags:["thinking","inputs_blocked"],entry:["onStartingConversation"],invoke:{id:"startConversationService",src:"startConversationService",input:({context:t})=>({isNew:t.eventPayload?.fresh||!1,bus:t.bus,conversation:t.conversation,chatSocket:t.chatSocket,talkingAvatar:t.talkingAvatar,speakingAvatar:t.speakingAvatar}),onDone:[{guard:({context:t,event:e})=>"resume_silent"===e.output?.data?.dataType&&!0===t.talkingAvatar?.isVideoAvatar,target:"listening",actions:["onConversationStartSuccess","onAutoResumeToListening"]},{guard:({event:t})=>"resume_silent"===t.output?.data?.dataType,target:"idle",actions:"onConversationStartSuccess"},{target:"thinking",actions:"onConversationStartSuccess"}],onError:{target:"#avatarOrchestrator.lifecycle.conversation.stopped",actions:[u({initFailed:!0}),"onConversationStartFailed"]}},on:{AI_MESSAGE_RECEIVED:{actions:"handleAiMessage"},AUDIO_END:{actions:["onAudioEnd"]},STREAM_START:{target:"pendingAudioStart",actions:["onStreamStart"]},IDLE:"idle"}},pendingAudioStart:{id:"pendingAudioStart",tags:["thinking","inputs_blocked"],after:{speechStartTimeout:{guard:"isPendingAudioStart",target:"#speaking",actions:["onAudioStartedFallback"]}},on:{SEND_TEXT_MESSAGE:{target:"#inProgress.processingTextMessage",actions:["onInterruptSpeaking"]},MIC_BUTTON:{target:"#inProgress.listening",actions:["onInterruptSpeaking","onMicButtonInterruptSpeaking"]},INTERRUPT:{target:"#inProgress.listening",actions:["onInterruptSpeaking"]},VOICE_BARGE_IN:{target:"#inProgress.listening",actions:["emitVoiceBargeInEvent","onVoiceBargeIn","onInterruptSpeaking"]},AUDIO_END:[{target:"#inProgress.listening",guard:({context:t})=>!!t.isPageVisible&&!!t.voiceBot&&t.voiceBot.isConversationInProgress?.(),actions:["onAudioEnd"]},{target:"#inProgress.idle",actions:["onAudioEnd"]}],IDLE:{target:"#inProgress.idle"},LISTEN:{target:"#inProgress.listening",actions:["onInterruptSpeaking"]},START_CONVERSATION:{target:"#inProgress.interruptingForRestart",actions:["onInterruptSpeaking",u({eventPayload:({event:t})=>t.payload})]}}},speaking:{id:"speaking",tags:["speaking"],on:{SEND_TEXT_MESSAGE:{target:"#inProgress.processingTextMessage",actions:["onInterruptSpeaking"]},MIC_BUTTON:{target:"#inProgress.listening",actions:["onInterruptSpeaking","onMicButtonInterruptSpeaking"]},INTERRUPT:{target:"#inProgress.listening",actions:["onInterruptSpeaking"]},VOICE_BARGE_IN:{target:"#inProgress.listening",actions:["emitVoiceBargeInEvent","onVoiceBargeIn","onInterruptSpeaking"]},STREAM_END:{actions:["onStreamEnd"],internal:!0},AUDIO_END:[{target:"#inProgress.listening",guard:({context:t})=>!!t.isPageVisible&&!!t.voiceBot&&t.voiceBot.isConversationInProgress?.(),actions:["onAudioEnd"]},{target:"#inProgress.idle",actions:["onAudioEnd"]}],IDLE:{target:"#inProgress.idle"},LISTEN:{target:"#inProgress.listening",actions:["onInterruptSpeaking"]},START_CONVERSATION:{target:"#inProgress.interruptingForRestart",actions:["onInterruptSpeaking",u({eventPayload:({event:t})=>t.payload})]}}},interruptingForRestart:{id:"interruptingForRestart",entry:["onEnsureCleanupComplete"],invoke:{src:"cleanupInterruptionActor",input:({context:t})=>({talkingAvatar:t.talkingAvatar,chatSocket:t.chatSocket,voiceBot:t.voiceBot}),onDone:{target:"startingConversation"},onError:{target:"#avatarOrchestrator.lifecycle.conversation.stopped"}},tags:["inputs_blocked"],on:{AUDIO_END:{actions:["onAudioEnd"]}}}}},endingConversation:{id:"endingConversation",tags:["inputs_blocked"],invoke:{id:"endConversationActor",src:"endConversationActor",input:({context:t,event:e})=>({conversation:t.conversation,chatSocket:t.chatSocket,talkingAvatar:t.talkingAvatar,voiceBot:t.voiceBot,payload:e?.payload}),onDone:{target:"stopped",actions:[({context:t})=>{try{t.bus.emit("event_command_UI_ClearConversation")}catch(e){}}]},onError:{target:"stopped",actions:[({context:t})=>{try{t.bus.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:"alertFailedEndConversation"})}catch(e){}}]}}},clearingConversation:{id:"clearingConversation",tags:["inputs_blocked"],invoke:{id:"clearConversationActor",src:"clearConversationActor",input:({context:t,event:e})=>({conversation:t.conversation,talkingAvatar:t.talkingAvatar,payload:e?.payload}),onDone:{target:"stopped",actions:[({context:t})=>{try{t.bus.emit("event_command_UI_ClearConversation")}catch(e){}}]},onError:{target:"stopped",actions:[({context:t})=>{try{t.bus.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:"alertFailedClearConversation"})}catch(e){}}]}}}}}}},connection:{initial:"connected",states:{connected:{id:"connected",on:{DISCONNECT:"disconnected"}},disconnected:{id:"disconnected",on:{RECONNECT:{target:"connected",actions:["onLeaveDisconnected",u({firstConnectionCompleted:()=>!0})]},CONNECT:{target:"connected",actions:["onLeaveDisconnected",u({firstConnectionCompleted:()=>!0})]}}}}}},on:{INJECT_MODULES:{actions:[u((({context:t,event:e})=>({talkingAvatar:e.payload?.talkingAvatar??t.talkingAvatar,chatSocket:e.payload?.chatSocket??t.chatSocket,voiceBot:e.payload?.voiceBot??t.voiceBot,conversation:e.payload?.conversation??t.conversation,speakingAvatar:e.payload?.speakingAvatar??t.speakingAvatar}))),({context:t,self:e,event:a})=>{try{const n=e.getSnapshot?.(),s=n?.matches?.("lifecycle.conversation.stopped")||n?.matches?.("lifecycle.conversation.timedOut");s&&t.conversation&&e.send({type:"AVATAR_INITIALIZED"});const o=!!n?.matches?.("lifecycle.conversation.inProgress.idle"),r=a.payload?.talkingAvatar;if(o&&r?.isVideoAvatar){const e="AvatarPage"===t.currentPage,a="AVATAR"===t.chatSocket?.chatbotMode,n=!1!==t.chatSocket?.isChatbotShown;if(t.isPageVisible&&e&&a&&n)try{r.armIdleDisconnect?.()}catch(i){}}if(s&&r?.isVideoAvatar){const e="AvatarPage"===t.currentPage,a="AVATAR"===t.chatSocket?.chatbotMode,n=!1!==t.chatSocket?.isChatbotShown;if(t.isPageVisible&&e&&a&&n)try{r.armIdleDisconnect?.()}catch(i){}}}catch(i){}}]},PAGE_CHANGED:{actions:["onPageChanged","setCurrentPage"]},DEFER_START:{actions:["onDeferStart"]},VISIBILITY_CHANGED:{actions:["onVisibilityChanged"]},UI_CHATBOT_MODE:{actions:["onUiChatbotMode"]},CONVERSATION_ERROR:{actions:["onConversationError"]},TTS_ERROR:{actions:["onTtsError"]},INTERRUPT:{actions:[({context:t})=>{try{t.talkingAvatar?.interruptSpeaking?.()}catch{}try{t.chatSocket?.interruptCurrentTurn?.()}catch{}try{t.voiceBot?.stopListening?.()}catch{}try{t.bus?.emit?.("event_command_UI_ClearCaptions")}catch{}}]}}},{actions:{onPageChanged:({context:t,event:e,self:a})=>{try{const n=e?.payload?.newPage;if(!n)return;const s=a.getSnapshot?.(),o=!!s?.hasTag?.("speaking")||s?.matches?.("lifecycle.conversation.inProgress.speaking")||s?.matches?.("lifecycle.conversation.inProgress.pendingAudioStart"),r=!!s?.hasTag?.("listening")||s?.matches?.("lifecycle.conversation.inProgress.listening");if("AvatarPage"!==n&&(o||r)&&(o?a.send({type:"INTERRUPT"}):r&&a.send({type:"IDLE"})),"AvatarPage"===n)try{const e="AVATAR"===t.chatSocket?.chatbotMode,n=!1!==t.chatSocket?.isChatbotShown;e&&n&&t.isPageVisible&&t.talkingAvatar?.resumeRendering?.({forceReconnect:!0});const s=a.getSnapshot?.();s?.matches?.("lifecycle.conversation.inProgress.idle")&&t.voiceBot&&e&&n&&t.isPageVisible&&a.send({type:"LISTEN"});const o=a.getSnapshot?.(),r=!!o?.matches?.("lifecycle.conversation.inProgress.idle"),c=!!o?.matches?.("lifecycle.conversation.stopped"),l=!!o?.matches?.("lifecycle.conversation.timedOut");if(r||c||l){const e=o?.context,a=e?.talkingAvatar??t.talkingAvatar;if(a?.isVideoAvatar)try{a.armIdleDisconnect?.()}catch(i){}}}catch(i){}}catch(n){}},setCurrentPage:u((({event:t})=>{const e=t?.payload?.newPage;return e?{currentPage:e}:{}})),onDeferStart:u((({context:t,event:e})=>{if(!t.isPageVisible){const a=e.payload?.fresh??!1;return null!==t.pendingStart&&t.pendingStart,{pendingStart:a}}return null!==t.pendingStart?{pendingStart:null}:{}})),onVisibilityChanged:u((({context:t,event:e,self:a})=>{const i=e&&(e.payload?.isVisible??e.isVisible),n=void 0===i?!!t.isPageVisible:!!i,s=n&&!t.isPageVisible;if(!n&&t.isPageVisible){if(t.voiceBot&&(ht(t),t.voiceBot.stopListening?.()),t.talkingAvatar){t.talkingAvatar.interruptSpeaking?.();try{t.talkingAvatar.suspendRendering?.("visibility")}catch(o){}}a.send({type:"IDLE"})}else{if(s&&null!==t.pendingStart){const e=t.pendingStart;return a.send({type:"START_CONVERSATION",payload:{fresh:e}}),{isPageVisible:n,pendingStart:null}}s&&t.voiceBot&&"AvatarPage"===t.currentPage&&a.getSnapshot().matches("lifecycle.conversation.inProgress.idle")&&a.send({type:"LISTEN"})}try{if(n&&"AvatarPage"===t.currentPage){const e="AVATAR"===t.chatSocket?.chatbotMode,i=!1!==t.chatSocket?.isChatbotShown;e&&i&&t.talkingAvatar?.resumeRendering?.();const n=a.getSnapshot?.(),s=!!n?.matches?.("lifecycle.conversation.inProgress.idle"),r=!!n?.matches?.("lifecycle.conversation.stopped")||!!n?.matches?.("lifecycle.conversation.timedOut");if(s||r){const e=n?.context,a=e?.talkingAvatar??t.talkingAvatar;if(a?.isVideoAvatar)try{a.armIdleDisconnect?.()}catch(o){}}}}catch(o){}return{isPageVisible:n}})),onListenEntry:({context:t})=>{t.voiceBot&&ht(t)},onListenFailed:({context:t,event:e})=>{try{t.bus.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:"alertCouldNotStartListening"})}catch(a){}},onIdle:({context:t})=>{t.voiceBot&&(ht(t),t.voiceBot.stopListening().success)},armVideoIdleDisconnect:({context:t})=>{try{const e=t.talkingAvatar;if(!e?.isVideoAvatar)return;T?.videoAvatar?.idleDisconnectEnabled;const a="AvatarPage"===t.currentPage,i="AVATAR"===t.chatSocket?.chatbotMode,n=!1!==t.chatSocket?.isChatbotShown;if(!(t.isPageVisible&&a&&i&&n))return;const s=T?.videoAvatar?.idleDisconnectMs;!0===T?.videoAvatar?.debug||T?.test?.enableDiagnostics,e.armIdleDisconnect?.(s)}catch(e){}},armVideoIdleDisconnectOnStopped:({context:t})=>{try{const e=t.talkingAvatar;if(!e?.isVideoAvatar)return;T?.videoAvatar?.idleDisconnectEnabled;const a="AvatarPage"===t.currentPage,i="AVATAR"===t.chatSocket?.chatbotMode,n=!1!==t.chatSocket?.isChatbotShown;if(!(t.isPageVisible&&a&&i&&n))return;const s=T?.videoAvatar?.idleDisconnectMs;!0===T?.videoAvatar?.debug||T?.test?.enableDiagnostics,e.armIdleDisconnect?.(s)}catch(e){}},disarmVideoIdleDisconnect:({context:t})=>{try{t.talkingAvatar?.isVideoAvatar&&(!0===T?.videoAvatar?.debug||T?.test?.enableDiagnostics,t.talkingAvatar.disarmIdleDisconnect?.())}catch(e){}},onStop:({context:t})=>{t.voiceBot&&(ht(t),t.voiceBot.stopListening())},onAudioStarted:({context:t,event:e})=>{const a=e?.payload?.audioStartTime??("undefined"!=typeof performance?performance.now():Date.now());try{t.bus?.emit?.("event_command_UI_PlayCaptions",{audioStartTime:a})}catch(i){}},onAudioStartedFallback:({context:t})=>{const e="undefined"!=typeof performance?performance.now():Date.now();try{t.bus?.emit?.("event_command_UI_PlayCaptions",{audioStartTime:e})}catch(a){}},onStreamStart:({context:t,event:e})=>{const{audioStream:a,lipsyncStream:i,turnId:n}=e.payload||{},s=!0===t.talkingAvatar?.isVideoAvatar;t.voiceBot&&void 0!==n&&(t.voiceBot._currentTurnId=n,t.voiceBot._expectedTurnId=n),t.talkingAvatar&&(s?t.talkingAvatar.startStreaming(a??null,i??null,n):a&&i&&t.talkingAvatar.startStreaming(a,i,n))},onInterruptSpeaking:({context:t,self:e})=>{if(t.voiceBot){const a=Date.now();if(a-t.voiceBot._lastInterruptionTime<t.voiceBot.INTERRUPTION_DEBOUNCE)return;const i=-1!==t.voiceBot._expectedTurnId,n=t.voiceBot._isHandlingAudioEnd,s=e.getSnapshot(),o=s?.hasTag?.("speaking")||s?.matches?.("lifecycle.conversation.inProgress.speaking")||s?.matches?.("lifecycle.conversation.inProgress.pendingAudioStart");i&&o&&!n&&(t.voiceBot._expectedTurnId=-1,t.voiceBot._lastInterruptionTime=a),ht(t),t.voiceBot.stopListening().success}t.talkingAvatar&&t.talkingAvatar.interruptSpeaking(),t.chatSocket&&t.chatSocket.interruptCurrentTurn()},onEnsureCleanupComplete:({context:t,self:e})=>{},onSpeechRecognitionFailed:({context:t,event:e})=>{try{t.bus.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:"alertCouldNotStartListening"})}catch(a){}},onSendTextMessageFailed:({context:t,event:e})=>{try{t.bus.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:"alertSomeErrorOccurred"})}catch(a){}},onUiChatbotMode:({context:t,event:e,self:a})=>{const i=e.payload;if(!i||void 0===i.isShown&&!i.chatbotMode)return;const n=i.chatbotMode;if(t.chatSocket&&(void 0!==n&&(t.chatSocket.chatbotMode=n),void 0!==i.isShown&&(t.chatSocket.isChatbotShown=i.isShown)),"CHAT"===n){const e=a.getSnapshot();if(e.matches("lifecycle.conversation.inProgress.speaking")||e.matches("lifecycle.conversation.inProgress.pendingAudioStart")){try{t.talkingAvatar?.interruptSpeaking()}catch(s){}try{t.chatSocket?.interruptCurrentTurn?.()}catch(s){}t.voiceBot&&(ht(t),t.voiceBot.stopListening?.(),t.voiceBot._expectedTurnId=-1),a.send({type:"IDLE"})}else e.matches("lifecycle.conversation.inProgress.listening")&&(t.voiceBot&&(ht(t),t.voiceBot.stopListening?.()),a.send({type:"IDLE"}));try{t.talkingAvatar?.suspendRendering?.("chat")}catch(s){}}else if("AVATAR"===n)try{const e=a.getSnapshot(),i=e.matches?.("lifecycle.conversation.inProgress"),n=e.matches?.("lifecycle.conversation.inProgress.idle"),s=!!t.isPageVisible;i&&n&&s&&a.send({type:"LISTEN"})}catch(s){}if(!1===i.isShown)try{const e=a.getSnapshot();if(e.matches?.("lifecycle.conversation.inProgress.speaking")||e.matches?.("lifecycle.conversation.inProgress.pendingAudioStart")){try{t.talkingAvatar?.interruptSpeaking?.()}catch(s){}try{t.chatSocket?.interruptCurrentTurn?.()}catch(s){}t.voiceBot&&(ht(t),t.voiceBot.stopListening?.(),t.voiceBot._expectedTurnId=-1),a.send({type:"IDLE"})}else e.matches?.("lifecycle.conversation.inProgress.listening")&&(t.voiceBot&&(ht(t),t.voiceBot.stopListening?.()),a.send({type:"IDLE"}));try{t.talkingAvatar?.suspendRendering?.("ui-hidden")}catch(s){}}catch(s){}else if(!0===i.isShown)try{const e=a.getSnapshot(),i=e.matches?.("lifecycle.conversation.inProgress"),s=e.matches?.("lifecycle.conversation.inProgress.idle"),o=!!t.isPageVisible;"AVATAR"===(void 0!==n?n:t.chatSocket?.chatbotMode)&&i&&s&&o&&"AvatarPage"===t.currentPage&&a.send({type:"LISTEN"})}catch(s){}try{const e=void 0!==n?n:t.chatSocket?.chatbotMode,a=void 0!==i.isShown?i.isShown:!1!==t.chatSocket?.isChatbotShown;if("AVATAR"===e&&a&&t.isPageVisible&&"AvatarPage"===t.currentPage)t.talkingAvatar?.resumeRendering?.({forceReconnect:!0});else if("AVATAR"===e&&a&&t.isPageVisible);else if(t.talkingAvatar?.isRenderingActive?.()&&("CHAT"===e||!a||!t.isPageVisible))try{t.talkingAvatar?.suspendRendering?.("conditions-change")}catch(s){}}catch(s){}},onLeaveDisconnected:({self:t})=>t.send({type:"RESTORED_CONNECTION"}),onLeaveInitializing:({self:t})=>t.send({type:"AVATAR_INITIALIZED"}),onStartingConversation:({context:t,event:e})=>{t.voiceBot&&(ht(t),t.voiceBot.stopListening(),t.voiceBot._expectedTurnId=-1),t.talkingAvatar&&t.talkingAvatar.interruptSpeaking()},onConversationStartSuccess:({context:t,event:e})=>{try{t.bus?.emit?.("event_status_Conversation_Started",{conversationId:t.conversation?.conversationId})}catch(a){}},onConversationStartFailed:({context:t,event:e})=>{try{const a=e.error?.message||String(e.error)||"Failed to start conversation";t.bus?.emit?.("event_status_Conversation_StartFailed",{error:e.error,message:a})}catch(a){}},onAutoResumeFailed:({context:t,event:e})=>{},onAutoResumeToListening:({context:t})=>{try{t.bus?.emit?.("event_status_Conversation_AutoResumedToListening",{conversationId:t.conversation?.conversationId})}catch(e){}},onConversationInitFailed:({context:t,event:e})=>{},onConversationInitSuccess:({context:t,event:e})=>{},handleAiMessage:({context:t,event:e,self:a})=>{const{message:i,time:n,structuredResponse:s}=e.payload||{},o="string"==typeof i?C(i):"";if("string"==typeof i&&""!==i.trim())try{t.bus.emit("event_command_UI_UpdateCurrentMessage",{speaker:"assistant",messageText:o})}catch(d){}const r=s?.avatar_mood??e.payload?.structuredResponse?.avatar_mood;if(r)try{t.bus.emit("event_command_Avatar_SetAvatarMood",{mood:r})}catch(d){}t.conversation&&i&&Promise.resolve().then((async()=>{try{const a=n||(new Date).toLocaleTimeString(),s=await t.conversation.appendMessage(i,a,"assistant");try{t.bus.emit("event_status_Conversation_MessageAppended",s)}catch(e){}}catch(d){}}));const c="AVATAR"===t.chatSocket?.chatbotMode,l=e.payload?.switchedToAvatar,h=!0===t.talkingAvatar?.isVideoAvatar;if(c&&h&&!l&&i){const e=t.chatSocket?.sessionData?.conversation?.currentTurnId;try{t.talkingAvatar.setPendingMessage(i,e)}catch(d){}setTimeout((()=>{try{a?.send?.({type:"STREAM_START",payload:{audioStream:null,lipsyncStream:null,turnId:e}})}catch(d){}}),0)}else{if(c&&!h&&!l&&"string"==typeof i&&""!==i.trim()&&t.chatSocket?.turn&&void 0!==t.chatSocket.turn.id){const e=t.chatSocket.turn.id;setTimeout((()=>{try{const i=a.getSnapshot?.();if(!i?.matches?.("lifecycle.conversation.inProgress.thinking"))return;const n=i.context?.chatSocket;if(!n?.turn||n.turn.id!==e||n.turn.isActive)return;try{n.finishCurrentTurn?.()}catch(t){}a?.send?.({type:"IDLE"})}catch(t){}}),2500)}c&&!l||setTimeout((()=>{try{const t=a.getSnapshot?.();(t?.matches?.("lifecycle.conversation.inProgress.thinking")||t?.matches?.("lifecycle.conversation.inProgress.startingConversation")||t?.matches?.("lifecycle.conversation.autoResuming"))&&a?.send?.({type:"IDLE"})}catch(t){}}),0)}},onAudioEnd:({context:t,event:e})=>{const{turnId:a}=e.payload||{};ht(t);try{!0===t.talkingAvatar?.isVideoAvatar&&a&&t.chatSocket?.turn?.id===a&&t.chatSocket?.finishCurrentTurn?.()}catch(i){}if(t.voiceBot){if(-1===t.voiceBot._expectedTurnId||a!==t.voiceBot._expectedTurnId)return;t.voiceBot._expectedTurnId=-1,t.voiceBot._isHandlingAudioEnd=!0}t.chatSocket?.pendingDelayedActions?.length>0&&(I(t.chatSocket.pendingDelayedActions,t.bus),t.chatSocket.pendingDelayedActions=null),t.voiceBot&&setTimeout((()=>{t.voiceBot._isHandlingAudioEnd=!1}),50)},onStreamEnd:({context:t})=>{try{t.talkingAvatar?.finalizeTurn?.()}catch(e){}if(t.chatSocket?.pendingDelayedActions?.length>0){try{I(t.chatSocket.pendingDelayedActions,t.bus)}catch(e){}t.chatSocket.pendingDelayedActions=null}},onMicButtonBlocked:({context:t})=>{t.bus.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:"alertWaitForAIResponse"})},onMicButtonStartListening:u((()=>({userSilenced:!1}))),setUserSilencedTrue:u((()=>({userSilenced:!0}))),onMicButtonStopListening:({context:t})=>{},onMicButtonInterruptSpeaking:u((()=>({userSilenced:!1}))),emitVoiceBargeInEvent:({context:t,event:e})=>{const a=e?.payload||{};try{t.bus?.emit?.("event_status_Speech_BargeInTriggered",{micLevel:a.micLevel,avatarLevel:a.avatarLevel,ratio:a.ratio,delta:a.delta,timestamp:a.timestamp})}catch(i){}},onVoiceBargeIn:u((()=>({userSilenced:!1}))),onAssistantMessage:({context:t,event:e})=>{try{t.bus.emit("event_command_UI_AutoScrollChat",{message:e?.payload?.message||e?.message})}catch(a){}},onConversationError:({context:t,event:e,self:a})=>{const{error:i,chatbotMode:n}=e.payload||{};if(!i)return;if((908===i.code||404===i.code||408===i.code)&&void 0!==i.conversationId)return void a.send({type:"CONVERSATION_TIMEOUT",payload:{conversationId:i.conversationId}});const s=i.message?{errorMessage:i.message}:{messageKey:"alertSomeErrorOccurred"};t.bus.emit("event_command_Alerts_ShowDismissableAlert",s);const o=a.getSnapshot();o.matches("lifecycle.conversation.inProgress.thinking")&&a.send({type:"IDLE"}),"AVATAR"===n&&o.matches("lifecycle.conversation.inProgress.idle")&&a.send({type:"LISTEN"})},onTtsError:({context:t,self:e})=>{t.chatSocket?.cleanupActiveStreams();const a=e.getSnapshot();a.matches("lifecycle.conversation.inProgress.speaking")||a.matches("lifecycle.conversation.inProgress.pendingAudioStart")?(t.talkingAvatar?.interruptSpeaking&&t.talkingAvatar.interruptSpeaking(),e.send({type:"IDLE"})):e.send({type:"IDLE"})},onConversationPaused:({context:t})=>{t.voiceBot&&(ht(t),t.voiceBot.stopListening()),t.talkingAvatar&&t.talkingAvatar.interruptSpeaking()}},guards:{isRequestBlocked:({self:t})=>{try{const e=t.getSnapshot?.();return!!e?.hasTag?.("thinking")}catch(e){return!1}},isAvatarMode:({context:t})=>{try{return"AVATAR"===t?.chatSocket?.chatbotMode}catch(e){return!1}},hasActiveConversation:({context:t})=>{if(!t.conversation)return!1;try{const e=!!t.conversation.conversationId,a=(t.conversation.conversationData?.currentTurnId||0)>0,i=Array.isArray(t.conversation.conversationData?.transcript)&&t.conversation.conversationData.transcript.length>0;return e&&(a||i)}catch(e){return!1}},isPendingAudioStart:({self:t})=>{try{return t.getSnapshot?.().matches?.("lifecycle.conversation.inProgress.pendingAudioStart")}catch(e){return!1}}},actors:{startConversationService:p((async({input:t})=>{const{isNew:e,skipFallback:a,bus:i,conversation:n,chatSocket:s,talkingAvatar:o,speakingAvatar:r}=t||{};if(!n||!s)throw new Error("Conversation or ChatSocket module not available");if(await Promise.resolve(),o?.conversationStreamActive)try{await(o.stopConversationStream?.())}catch(d){}e&&n.conversationId&&await n.notifyConversationEnd(),await n.notifyConversationStart(e);const c=!e;let l;try{l=await s.sendStartConversationEvent(c,{isVideoAvatar:!0===o?.isVideoAvatar})}catch(u){const t=u?.message?.includes("404")||u?.message?.includes("408");if(c&&t&&!a){try{await n.clearOngoingConversation()}catch(d){}await n.notifyConversationStart(!0),l=await s.sendStartConversationEvent(!1,{isVideoAvatar:!0===o?.isVideoAvatar});try{i?.emit?.("event_status_Conversation_ResumeFailedAndRestarted",{conversationId:n.conversationId})}catch(d){}return r?.isVideoAvatarInitPending?.()&&await r.initializeVideoAvatarScene(),o&&await o.startConversationStream(),l}throw u}r?.isVideoAvatarInitPending?.()&&await r.initializeVideoAvatarScene(),o&&await o.startConversationStream();const h=await(n.handleConversationSuccessfulStart?.(l))||{};if(h.resumeFailed)try{i?.emit?.("event_status_Conversation_ResumeFailedAndRestarted",{conversationId:n.conversationId})}catch(d){}else if(h.resumeAttempt&&!h.serverStartedNew)try{i?.emit?.("event_status_Conversation_ResumedSuccessfully",{conversationId:n.conversationId})}catch(d){}return l})),initConversationActor:p((async({input:t})=>{const{conversation:e,chatSocket:a}=t||{};if(!e)throw new Error("Conversation module not available");return await e.notifyConversationInit(),a&&await a.sendInitConversationEvent(),{initialized:!0}})),listenActor:p((async({input:t})=>{const{voiceBot:e,talkingAvatar:a,currentPage:i,isPageVisible:n,chatbotMode:s}=t||{};if(!e)return{started:!1};if(!n||"AvatarPage"!==i||"AVATAR"!==s)return{started:!1};if(a?.isVideoAvatar&&"function"==typeof a.isRenderingActive){const t=8e3,e=250,i=Date.now();for(;!a.isRenderingActive()&&Date.now()-i<t;)await new Promise((t=>setTimeout(t,e)));if(!a.isRenderingActive())return{started:!1}}const o=await e.startListening();if(!o.success)throw new Error(o.error||"Failed to start listening");return{started:!0}})),speechRecognitionActor:p((async({input:t})=>{const{chatSocket:e,payload:a,conversation:i,bus:n}=t||{};if(!e||!i)throw new Error("Dependencies not available");if(!a||!a.messageText)throw new Error("Invalid speech payload");const s=await i.appendMessage(a.messageText,k(new Date),"user");try{n?.emit("event_status_Conversation_MessageAppended",s)}catch(r){}const o=await e.sendMessage(a,"AVATAR");if(!o.success)throw n?.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:"alertSomeErrorOccurred"}),new Error(o.error||"Failed to process speech input");return{sent:!0}})),sendTextMessageActor:p((async({input:t})=>{const{chatSocket:e,payload:a,conversation:i,bus:n}=t||{};if(!e||!i)throw new Error("Dependencies not available");if(!a||!a.message)throw new Error("Invalid text payload");const s=await i.appendMessage(a.message,k(new Date),"user");try{n?.emit("event_status_Conversation_MessageAppended",s)}catch(l){}const o={messageText:a.message},r=a.chatbotMode||"CHAT",c=await e.sendMessage(o,r);if(!c.success)throw n?.emit("event_command_Alerts_ShowDismissableAlert",{messageKey:"alertSomeErrorOccurred"}),new Error(c.error||"Failed to send text message");return{sent:!0}})),endConversationActor:p((async({input:t})=>{const{conversation:e,chatSocket:a,talkingAvatar:i,voiceBot:n,payload:s}=t||{};if(!e)return!0;const o=e.conversationId,{satisfactionScore:r=0}=s||{};if(await e.notifyConversationEnd(),a&&o)try{a.sendEndConversationEvent(o,r)}catch(c){}try{i?.interruptSpeaking?.()}catch(c){}try{await(i?.stopConversationStream?.())}catch(c){}try{i?.liveCaptions?.clearCaptions?.(),n?.stopListening?.()}catch(c){}return!0})),clearConversationActor:p((async({input:t})=>{const{conversation:e,talkingAvatar:a,payload:i}=t||{};if(!e)return!0;const{conversationId:n}=i||{};if(n===e.conversationId){await e.clearOngoingConversation();try{await(a?.stopConversationStream?.())}catch(s){}}return!0})),checkResumeActor:p((async({input:t})=>{const{conversation:e,bus:a}=t||{};if(!e)return{resumable:!1};try{const t=await(e.getConversationData?.());if(t?.id&&Array.isArray(t.transcript)&&t.transcript.length>0)return{resumable:!0}}catch(i){throw i}return{resumable:!1}})),cleanupInterruptionActor:p((async({input:t})=>{const{talkingAvatar:e,chatSocket:a,voiceBot:i}=t||{};try{try{e?.liveCaptions?.clearCaptions?.()}catch(n){}if(i)try{i.stopListening?.()}catch(n){}try{e?.interruptSpeaking?.()}catch(n){}try{a?.interruptCurrentTurn?.()}catch(n){}return await new Promise((t=>setTimeout(t,10))),!0}catch(s){throw s}}))},delays:{thinkingTimeout:T?.chatbot?.thinkingTimeout,speechStartTimeout:Math.min(Math.max(T?.chatbot?.speechStartTimeout??8e3,2e3),6e4)}});class ut{constructor(t){if(!t)throw new Error("Cannot initialize AvatarOrchestrator: missing bus instance");this.bus=t,this.actor=null,this._pendingEvents=[],this._deferredModules=null,this.diagnostics=null}start(t={}){if(this._deferredModules&&(t={...t,...this._deferredModules},this._deferredModules=null),this.actor)t&&Object.keys(t).length>0&&this.injectModules(t);else if(this.actor=g(dt,{input:{bus:this.bus,...t}}).start(),this.actor.subscribe((t=>{this.handleStateTransition(t)})),this._pendingEvents.length>0){for(const t of this._pendingEvents)this.actor.send(t);this._pendingEvents.length=0}}handleStateTransition(t){t&&this.diagnostics&&t?.changed&&(this.diagnostics.logStateTransition(t.history?.value,t.value),t.matches?.("lifecycle.conversation.stopped")&&this.diagnostics.displayDiagnosticsInConsole())}sendEvent(t,e=null){const a={type:t,payload:e};this.actor?this.actor.send(a):this._pendingEvents.push(a)}is(t){return!!this.actor&&this.actor.getSnapshot().matches(t)}getCurrentState(){return this.actor?.getSnapshot().value}getSnapshot(){return this.actor?this.actor.getSnapshot():null}destroy(){this.actor?.stop(),this.actor=null,this.diagnostics=null,this._pendingEvents=[]}interruptSpeaking(){this.sendEvent("INTERRUPT")}transitionToListening(){this.sendEvent("LISTEN")}transitionToIdle(){this.sendEvent("IDLE")}injectModules(t={}){this.actor?this.actor.send({type:"INJECT_MODULES",payload:t}):this._deferredModules={...this._deferredModules||{},...t}}subscribeProjected(t){if(!this.actor)return()=>{};let e={};const a=this.actor.subscribe((a=>{const i={lifecycle:{initInitializing:a.matches?.("lifecycle.init.initializing")||!1,initFailed:a.matches?.("lifecycle.init.failed")||!1,convoStopped:a.matches?.("lifecycle.conversation.stopped")||!1,convoAutoResuming:a.matches?.("lifecycle.conversation.autoResuming")||!1,convoResumeExpired:a.matches?.("lifecycle.conversation.resumeExpired")||!1,convoInProgress:a.matches?.("lifecycle.conversation.inProgress")||!1,convoStarting:a.matches?.("lifecycle.conversation.inProgress.startingConversation")||!1,convoInitializing:a.matches?.("lifecycle.conversation.initializingConversation")||!1,conversationSubstate:a.matches?.("lifecycle.conversation.inProgress.pendingAudioStart")?"pendingAudioStart":a.matches?.("lifecycle.conversation.inProgress.speaking")?"speaking":a.matches?.("lifecycle.conversation.inProgress.listening")?"listening":a.matches?.("lifecycle.conversation.inProgress.thinking")?"thinking":a.matches?.("lifecycle.conversation.inProgress.startingConversation")?"startingConversation":a.matches?.("lifecycle.conversation.inProgress.idle")?"idle":""},connection:{connected:a.matches?.("connection.connected")||!1,disconnected:a.matches?.("connection.disconnected")||!1},flags:{userSilenced:a.context?.userSilenced||!1,isPageVisible:!!a.context?.isPageVisible,pendingStart:"boolean"==typeof a.context?.pendingStart?a.context.pendingStart:null}};!function(t,e){if(t===e)return!0;if(!t||!e)return!1;const a=t.lifecycle,i=e.lifecycle;if(!a||!i)return!1;if(a.initInitializing!==i.initInitializing||a.initFailed!==i.initFailed||a.convoStopped!==i.convoStopped||a.convoResumable!==i.convoResumable||a.convoInProgress!==i.convoInProgress||a.convoStarting!==i.convoStarting||a.convoInitializing!==i.convoInitializing||a.conversationSubstate!==i.conversationSubstate)return!1;const n=t.connection,s=e.connection;if(!n||!s)return!1;if(n.connected!==s.connected||n.disconnected!==s.disconnected)return!1;const o=t.flags,r=e.flags;return!(!o||!r)&&o.userSilenced===r.userSilenced&&o.isPageVisible===r.isPageVisible&&o.pendingStart===r.pendingStart}(i,e)&&(e=i,t(i,a))}));return()=>a.unsubscribe()}}class pt{constructor(t,e){if(!t||!e)throw new Error("Cannot initialize connectionManager due to missing bus or avatarOrchestrator");this.connectionModules={},this._allConnectionsReady=!1,this._wasAllReady=!1,this.isReconnecting=!1,this.bus=t,this.avatarOrchestrator=e,this._reconnectTimer=null,this._retryDelay=T?.connection?.reconnectInitialDelay,this._maxDelay=T?.connection?.reconnectMaxDelay,this._factor=T?.connection?.reconnectFactor,this._reconnectHandler=async()=>{try{this._resetBackoff(),await this.reconnectFailedModules(!0)}catch(t){}},this.bus.on("event_command_ConnectionManager_ReconnectFailedModules",this._reconnectHandler)}get allConnectionsReady(){return this._allConnectionsReady}set allConnectionsReady(t){this._allConnectionsReady=t}registerNewConnectionModule(t,e=null){try{const a=new F(t);e&&(a.reconnect=e),a.subscribe((()=>this.updateAvatarState())),this.connectionModules[t]=a}catch(a){}}registerConnectionModule(t){try{if(!t||!t.name||"function"!=typeof t.subscribe)throw new Error("Invalid module: must have 'name' property and 'subscribe' method");t.subscribe((()=>this.updateAvatarState())),this.connectionModules[t.name]=t,this.updateAvatarState()}catch(e){}}setReconnectFunction(t,e){try{const a=this.connectionModules[t];if(!a)return;a.reconnect=e}catch(a){}}waitUntilReady(t=15e3){return new Promise(((e,a)=>{if(this._allConnectionsReady)return e(!0);let i,n;const s=()=>{i&&clearTimeout(i),n&&this.bus.off("connectionStateChanged",n)};i=setTimeout((()=>{s(),a(new Error("Connection timeout"))}),t),n=()=>{this._allConnectionsReady&&(s(),e(!0))},this.bus.on("connectionStateChanged",n)}))}updateAvatarState(){if(!this.avatarOrchestrator)return;const t=Object.values(this.connectionModules).filter((t=>!1!==t?.blocking)),e=t.every((t=>t.isConnected())),a=t.filter((t=>!1!==t?.autoReconnect));if(this.allConnectionsReady=e,this.bus.emit("connectionStateChanged"),e){if(this._clearReconnectTimer(),!this._wasAllReady)try{const t=this.avatarOrchestrator.getSnapshot?.();this.avatarOrchestrator.sendEvent("RECONNECT"),(t?.matches?.("lifecycle.init.failed")||t?.matches?.("lifecycle.init.initializing"))&&this.avatarOrchestrator.sendEvent("CONNECT")}catch(i){}this._wasAllReady=!0}else{if(a.some((t=>!t.isConnected()))&&this._scheduleAutoReconnect(),this._wasAllReady)try{this.avatarOrchestrator.sendEvent("DISCONNECT")}catch(i){}this._wasAllReady=!1}}async reconnectFailedModules(t=!1){if(this.isReconnecting)return;this.isReconnecting=!0;const e=Object.values(this.connectionModules).filter((t=>!1!==t?.autoReconnect&&(t.isFailed()||t.isDisconnected()))).map((async t=>{try{await(t.reconnect?.())}catch(e){}}));await Promise.allSettled(e),this.isReconnecting=!1,this.updateAvatarState(),t||this._stepBackoff()}async reconnectDisconnectedModules(){if(this.isReconnecting)return;this.isReconnecting=!0;const t=Object.values(this.connectionModules).filter((t=>!1!==t?.autoReconnect&&!t.isConnected())).map((async t=>{try{await(t.reconnect?.())}catch(e){}}));await Promise.allSettled(t),this.isReconnecting=!1,this.updateAvatarState()}getConnectionReport(){let t=`System is ${this.allConnectionsReady?"Ready":"Not Ready"}\n\n`;for(const e of Object.values(this.connectionModules))t+=`${e.name}: ${e.isConnected()?"connected":"disconnected"}, \n`;return t}_scheduleAutoReconnect(){this._reconnectTimer||(this._reconnectTimer=setTimeout((async()=>{this._reconnectTimer=null,await this.reconnectFailedModules()}),this._retryDelay))}_clearReconnectTimer(){this._reconnectTimer&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=null),this._resetBackoff()}_resetBackoff(){this._retryDelay=T?.connection?.reconnectInitialDelay}_stepBackoff(){this._retryDelay=Math.min(Math.ceil(this._retryDelay*this._factor),this._maxDelay)}destroy(){try{this._reconnectHandler&&(this.bus?.off("event_command_ConnectionManager_ReconnectFailedModules",this._reconnectHandler),this._reconnectHandler=null),this._clearReconnectTimer()}catch(t){}}}class gt{constructor({bus:t,socketManager:e,getConversationId:a,getChatbotMode:i,provider:n="Azure"}){this.provider=n.trim(),this.bus=t,this.socketManager=e,this.getConversationId=a,this.getChatbotMode=i,this._webrtcConnected=!1,this._chatbotMode="CHAT",this._conversationId=null,this._sentConnectEvent=!1,this.webRtcEventName=this._getWebRtcEventName(),this._onWebRtcConnectionChanged=t=>{const e=!!t?.connected,a=this._webrtcConnected;this._webrtcConnected=e,!a&&e?this._sendConnectEvent():a&&!e&&this._sendDisconnectEvent("webrtc_disconnected")},this._onChatbotModeChanged=t=>{const e=t?.chatbotMode,a="AVATAR"===this._chatbotMode;"string"==typeof e&&e&&(this._chatbotMode=e),a&&"AVATAR"!==this._chatbotMode&&this._webrtcConnected&&this._sentConnectEvent&&this._sendDisconnectEvent("mode_changed_to_chat")},this._onPageHide=()=>{this._webrtcConnected&&this._sentConnectEvent&&this._sendDisconnectEvent("page_hide",{keepalive:!0})},this._onBeforeUnload=()=>{this._webrtcConnected&&this._sentConnectEvent&&this._sendDisconnectEvent("before_unload",{keepalive:!0})},this._onVisibilityChange=()=>{},this._onConversationEnding=async t=>{try{await this.notifyBeforeEndConversation()}finally{try{"function"==typeof t?.onDisconnectComplete&&t.onDisconnectComplete()}catch(e){}}},this._onConversationStarted=t=>{this._webrtcConnected&&!this._sentConnectEvent&&this._sendConnectEvent()},this._bind();try{const t=this.getChatbotMode?.();"string"==typeof t&&t&&(this._chatbotMode=t)}catch(s){}}_getWebRtcEventName(){return"Azure"===this.provider?"event_status_AzureAvatar_WebRtcConnectionChanged":`event_status_${this.provider.charAt(0).toUpperCase()+this.provider.slice(1)}Avatar_WebRtcConnectionChanged`}_bind(){try{this.bus?.on?.(this.webRtcEventName,this._onWebRtcConnectionChanged)}catch(t){}try{this.bus?.on?.("event_status_ChatbotMode_Changed",this._onChatbotModeChanged)}catch(e){}try{this.bus?.on?.("event_status_Conversation_Ending",this._onConversationEnding)}catch(e){}try{this.bus?.on?.("event_status_Conversation_Started",this._onConversationStarted)}catch(e){}try{"undefined"!=typeof window&&window.addEventListener&&(window.addEventListener("pagehide",this._onPageHide,{capture:!0}),window.addEventListener("beforeunload",this._onBeforeUnload,{capture:!0}))}catch(e){}try{"undefined"!=typeof document&&document.addEventListener&&document.addEventListener("visibilitychange",this._onVisibilityChange,{capture:!0})}catch(e){}}_refreshConversationId(){let t=null;try{t=this.getConversationId?.()??null}catch(e){}return t&&"string"==typeof t?(this._conversationId=t,t):null}_sendConnectEvent(){const t=this._refreshConversationId();if(!t)return;if("AVATAR"!==this._chatbotMode)return;const e=this.socketManager?.isSocketConnected?.();if(e)try{this.socketManager.emit("video_avatar_connected",{conversationId:t,chatbotMode:this._chatbotMode,timestamp:Date.now(),provider:this.provider}),this._sentConnectEvent=!0}catch(a){}}async _sendDisconnectEvent(t,e={}){const a=this._conversationId;if(!a||!this._sentConnectEvent)return!1;if(!this.socketManager?.isSocketConnected?.())return this._sentConnectEvent=!1,!1;try{return await this.socketManager.emitWithResponse("video_avatar_disconnected",{conversationId:a,reason:t,timestamp:Date.now(),provider:this.provider}),this._sentConnectEvent=!1,!0}catch(i){return this._sentConnectEvent=!1,!1}}async notifyBeforeEndConversation(){return!(!this._webrtcConnected||!this._sentConnectEvent)&&await this._sendDisconnectEvent("conversation_ending")}async destroy(){this._webrtcConnected&&this._sentConnectEvent&&this._sendDisconnectEvent("meter_destroyed");try{this.bus?.off?.(this.webRtcEventName,this._onWebRtcConnectionChanged)}catch(t){}try{this.bus?.off?.("event_status_ChatbotMode_Changed",this._onChatbotModeChanged)}catch(t){}try{this.bus?.off?.("event_status_Conversation_Ending",this._onConversationEnding)}catch(t){}try{this.bus?.off?.("event_status_Conversation_Started",this._onConversationStarted)}catch(t){}try{"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener("pagehide",this._onPageHide,{capture:!0}),window.removeEventListener("beforeunload",this._onBeforeUnload,{capture:!0}))}catch(t){}try{"undefined"!=typeof document&&document.removeEventListener&&document.removeEventListener("visibilitychange",this._onVisibilityChange,{capture:!0})}catch(t){}this.bus=null,this.socketManager=null,this.getConversationId=null,this.getChatbotMode=null}}const vt={...H};class mt{constructor(t){if(!t)throw new Error("Cannot initialize SpeakingAvatar due to missing bus instance");this.voiceBot=null,this.chatSocket=null,this.bus=t,this.avatarOrchestrator=new ut(t),this.avatarOrchestrator.start(),this.connectionManager=this.createConnectionManager(this.bus,this.avatarOrchestrator),this.sessionData=lt.getInstance(),this.auth=new rt,this.connectionManager.registerConnectionModule(this.auth),this.voiceBargeInDetector=null,this.avatarType=vt.THREE_D,this.videoUsageMeter=null}createConnectionManager(t,e){if(!t||!e)throw new Error("Missing dependencies for ConnectionManager creation.");return new pt(t,e)}async init(t){if(!t?.avatarContainer||!t.avatarAPIKey&&!t.tokenEndpoint||!t.avatarId||!t.targetApp)return!1;try{await this.initializeAuthentication(t);const{avatarParameters:e,avatarItem:a}=await this.setupAvatarData();if(!e||!a)return!1;const i=e.avatarSource;if(this.avatarType=t.avatarType||q(i)||T?.avatar?.avatarType||vt.THREE_D,this.avatarType===vt.VIDEO&&W(i)){const i=e.avatarSourceId||t.azureCharacter||"lisa:casual-sitting",[n,s]=i.includes(":")?i.split(":"):[i,"casual-sitting"];a.azureCharacter=n,a.azureStyle=s||e.bodyType||t.azureStyle||"casual-sitting",a.azureBackendUrl=T?.azure?.backendUrl||A()}return this.avatarModule=await this._createAvatarModule(e.avatarSource),await this.sessionData.init(e,a),this.avatarType===vt.VIDEO?(await this.initializeVoiceBot(),await this.initializeChatSocket(),this._deferredVideoAvatarParams={avatarItem:a,avatarContainer:t.avatarContainer,initOptions:{speechConfig:this.voiceBot?.speechConfig,auth:this.auth},provider:e.avatarSource},this.bus?.emit?.("event_status_VideoAvatar_ShowPlaceholder",{avatarId:e.avatarId,avatarSource:e.avatarSource})):await Promise.all([this.initializeChatSocket(),this.initializeVoiceBot(),this.initializeAvatarScene(a,t.avatarContainer)]),this.avatarOrchestrator.injectModules({talkingAvatar:this.avatarModule,chatSocket:this.chatSocket,voiceBot:this.voiceBot,conversation:this.sessionData.conversation,speakingAvatar:this.avatarType===vt.VIDEO?this:null}),await this.initializeVoiceBargeInDetector(),await this.connectionManager.waitUntilReady(),this.avatarOrchestrator.sendEvent("READY","SpeakingAAvatar.init"),!0}catch(e){return!1}}async _createAvatarModule(t){try{switch(this.avatarType){case vt.VIDEO:{if(W(t)){const{AzureTalkingAvatar:t}=await import("./AzureTalkingAvatar-G4LQw7TE.js");return new t(this.bus,this.avatarOrchestrator)}const{AzureTalkingAvatar:e}=await import("./AzureTalkingAvatar-G4LQw7TE.js");return new e(this.bus,this.avatarOrchestrator)}case vt.THREE_D:default:{const{TalkingAvatar:t}=await import("./TalkingAvatar-CCG2emPQ.js");return new t(this.bus,this.avatarOrchestrator)}}}catch(e){throw new Error(`SpeakingAvatar: Failed to load avatar module for source '${t}'. Please verify that the requested avatar provider is correctly configured and available.`)}}async initializeAuthentication(t){if(!(await this.auth.init(t.targetApp,t.avatarAPIKey||"",t.tokenEndpoint||"",t.avatarId)))throw new Error("Authentication initialization failed.")}async setupAvatarData(){const t=await this.auth.getAvatarParameters();if(!t)throw new Error("Failed to retrieve avatar parameters from authentication");return{avatarParameters:t,avatarItem:this.constructAvatarItem(t)}}constructAvatarItem(t){let e=t.avatarUrl;"ReadyPlayerMe"===t.avatarSource&&e&&e.includes("models.readyplayer.me")&&(e+="?morphTargets=ARKit,Oculus+Visemes,mouthOpen,mouthSmile,eyesClosed,eyesLookUp,eyesLookDown&textureSizeLimit=1024&textureFormat=png");let a=t.lipsyncType||"visemes";return{id:t.avatarSourceId,type:T?.avatar?.type,url:e,source:t.avatarSource,bodyType:t.bodyType,gender:t.gender,voice:t.voice,lipsyncType:a}}async initializeChatSocket(){try{Q.resetInstance?.()}catch{}this.chatSocket=Q.getInstance(this.bus,this.auth,this.sessionData,this.avatarOrchestrator),await this.chatSocket.init(),this.connectionManager.registerConnectionModule(this.chatSocket)}async initializeVoiceBot(){this.voiceBot=await Z.build(this.bus,this.avatarOrchestrator,this.auth,this.sessionData),this.connectionManager.registerConnectionModule(this.voiceBot.speechService)}async initializeVoiceBargeInDetector(){if(!this.voiceBargeInDetector&&!1!==T?.speech?.bargeIn?.enabled)try{this.voiceBargeInDetector=new tt({talkingAvatar:this.avatarModule,avatarOrchestrator:this.avatarOrchestrator,config:T?.speech?.bargeIn}),await this.voiceBargeInDetector.init()}catch(t){this.voiceBargeInDetector=null}}async setBargeInEnabled(t){if(T?.speech?.bargeIn&&(T.speech.bargeIn.enabled=t),t)this.voiceBargeInDetector||this.avatarModule&&this.avatarOrchestrator&&await this.initializeVoiceBargeInDetector();else if(this.voiceBargeInDetector){try{this.voiceBargeInDetector.destroy()}catch(e){}this.voiceBargeInDetector=null}}async initializeAvatarScene(t,e,a=void 0){try{if(!this.avatarModule)throw new Error("Avatar module not initialized.");await this.avatarModule.init(t,e,a),this.connectionManager.registerConnectionModule(this.avatarModule)}catch(i){throw i}}async initializeVideoAvatarScene(){if(!this._deferredVideoAvatarParams)return!0;const{avatarItem:t,avatarContainer:e,initOptions:a,provider:i}=this._deferredVideoAvatarParams;try{this.videoUsageMeter?.destroy?.()}catch(n){}return this.videoUsageMeter=new gt({bus:this.bus,socketManager:this.chatSocket?.socketManager,getConversationId:()=>this.sessionData?.conversation?.conversationId,getChatbotMode:()=>this.chatSocket?.chatbotMode,provider:i}),await this.initializeAvatarScene(t,e,a),this._deferredVideoAvatarParams=null,this.bus?.emit?.("event_status_VideoAvatar_HidePlaceholder",{}),!0}isVideoAvatarInitPending(){return!!this._deferredVideoAvatarParams}destroy(){try{this.videoUsageMeter?.destroy?.()}catch{}this.videoUsageMeter=null;try{Q.resetInstance?.()}catch{}this.voiceBot?.destroy?.(),this.voiceBargeInDetector?.destroy?.(),this.voiceBargeInDetector=null,this.avatarModule?.destroy?.(),this.connectionManager?.destroy?.(),this.sessionData?.destroy?.(),this.auth?.destroy?.(),this.avatarOrchestrator?.destroy?.()}async refreshAvatar(){return!!this.avatarModule&&(this.avatarModule.refreshAvatar?.()??!1)}getAvatarType(){return this.avatarType}isVideoAvatar(){return this.avatarType===vt.VIDEO}isAzureAvatar(){return!!this.isVideoAvatar()&&(!!this.avatarModule?.isAzureAvatar||!!this.sessionData?.avatarItem?.source&&W(this.sessionData.avatarItem.source))}}class bt extends EventTarget{constructor(){super(),this._listeners=new Map,this._disposers=new Set,this._isDisposed=!1,this._globalListeners=new Set}on(t,e){if(this._isDisposed)return()=>{};if("*"===t)return this.onAll(e);const a=t=>{try{const a=t.detail;e(a)}catch(a){}};this._listeners.has(t)||this._listeners.set(t,new Map),this._listeners.get(t).set(e,a),this.addEventListener(t,a);const i=()=>{this._isDisposed||(this.removeEventListener(t,a),this._listeners.get(t)?.delete(e),this._disposers.delete(i))};return this._disposers.add(i),i}off(t,e){if("*"===t)return this.offAll(e);const a=this._listeners.get(t)?.get(e);a&&(this.removeEventListener(t,a),this._listeners.get(t)?.delete(e))}emit(t,e=void 0){if(this._isDisposed)return;const a=new CustomEvent(t,{detail:e,bubbles:!1,cancelable:!1});this.dispatchEvent(a),this._globalListeners.forEach((a=>{try{a(t,e)}catch(i){}}))}onAll(t){if(this._isDisposed)return()=>{};this._globalListeners.add(t);const e=()=>{this._isDisposed||(this._globalListeners.delete(t),this._disposers.delete(e))};return this._disposers.add(e),e}offAll(t){this._globalListeners.delete(t)}clear(){this._listeners.forEach(((t,e)=>{t.forEach(((t,a)=>{this.removeEventListener(e,t)}))})),this._listeners.clear(),this._globalListeners.clear(),this._disposers.clear()}dispose(){this._isDisposed||(this._disposers.forEach((t=>{try{t()}catch(e){}})),this._listeners.clear(),this._globalListeners.clear(),this._disposers.clear(),this._isDisposed=!0)}get disposerCount(){return this._disposers.size}get isDisposed(){return this._isDisposed}get listenerCount(){let t=this._globalListeners.size;return this._listeners.forEach((e=>{t+=e.size})),t}}const _t="en",ft={en:{start:"Start Conversation",connect:"Connect",endConversation:"End Conversation",restartConversation:"Restart Conversation",hideTyping:"Hide typing input",showTyping:"Show typing input",reconnecting:"Reconnecting...",waitForResponse:"Please wait for response...",typeHere:"Type here.",noMessagesYet:"No messages yet...",conversationStatus:"Conversation Status",conversationInProgress:"Conversation In Progress",conversationStopped:"Conversation Stopped",startConversation:"Start Conversation",downloadConversation:"Download Conversation",liveCaptions:"Live captions",toggleChatbot:"Toggle avatar chatbot",avatar:"Avatar",switchToAvatar:"Back to avatar",switchToChat:"Switch to chat",chat:"Chat",statusInitializing:"Hang tight, we're waking up the avatar!",statusReconnecting:"Connection issue, attempting to reconnect...",statusFailed:"Connection failed. Manual action may be required.",statusInvalidConfiguration:"The avatar is not configured correctly, contact the admin.",avatarIdleDisconnected:"The avatar is resting.",reconnectAvatar:"Wake up Avatar",close:"Close",lastAssistantMessage:"Last message",fullBodyView:"Full body view",upperBodyView:"Upper body view",secureFormTitle:"Secure Form",secureFormDescription:"Enter your information.",name:"Name*",namePlaceholder:"Enter your name",phoneNumber:"Phone Number",phonePlaceholder:"Enter your phone number",email:"Email",emailPlaceholder:"Enter your email",secureFormNote:"Your information will not be shared with the LLM and will not be stored after this session. By sending you agree to share your info to get additional support.",save:"Save",send:"Send",cancel:"Cancel",conversationEndedPrompt:"Conversation ended. Please rate your satisfaction with the conversation.",submit:"Submit",skip:"Skip and end",consentTitle:"Consent for AI conversation",consentInfo1:"For general information only — no medical, legal, financial, or safety advice.",consentInfo2:"We use session storage and send your input to provide replies. We don’t keep your conversation or personal info after this session.",consentReadOur:"Read our",consentTermsLabel:"Terms",consentAnd:"and",consentPrivacyLabel:"Privacy Policy",consentMoreDetails:"for more details.",consentInfo4:"(Your consent applies to this session only and clears when you close the tab/window)",consentAccept:"I agree",consentDecline:"Decline",consentAcceptAria:"I agree – start chat",consentDeclineAria:"Decline",interruptSpeaking:"Interrupt speaking avatar",turnOnMic:"Turn on microphone",turnOffMic:"Turn off microphone",tapToSpeak:"Tap to speak",thinking:"Thinking...",starting:"Starting...",startConversationReminder:"Start a conversation to chat.",chatPlaceholderTitle:"Ready to chat?",chatPlaceholderDescription:"Start a conversation to continue in text mode.",enterInfoOnMobile:"Enter your information in User Information page",waitCurrentResponse:"Please wait for the current response before sending another message.",resumeConversationFailedNewStarted:"We couldn't resume your previous conversation. A new one has been started instead.",end:"End",endConversationPrompt:"Would you like to end the conversation? Ending it will permanently delete the conversation history.",restartConversationPrompt:"Are you sure you want to start a new conversation? Current conversation will be deleted.",newConversation:"New",conversationExpiredPrompt:"This conversation has expired and cannot be resumed. Would you like to download a copy and end or end only?",conversationExpiredResumePrompt:"Your previous conversation has expired and cannot be resumed. Would you like to download a copy of your conversation history?",downloadAndClear:"Download & Clear",downloadAndStartNew:"Download & Start New",startNew:"Start New",ok:"OK",download:"Download",onlyClear:"Only Clear",confirm:"Confirm",alertGenericError:"An error occurred.",alertFailedEndConversation:"Failed to end the conversation. Please try again.",alertFailedClearConversation:"Failed to clear the conversation.",alertCouldNotStartListening:"Could not start listening. Please try again.",alertSomeErrorOccurred:"Some error occurred. Please try again.",alertWaitForAIResponse:"Please wait for the AI response before starting to speak.",alertVoiceServicesUnavailable:"Unable to connect to voice services. Please try again later.",alertServiceTemporarilyUnavailable:"Service is temporarily unavailable. Please try again.",alertTooManyRequests:"Too many simultaneous requests. Please wait a moment and try again.",alertConnectionIssue:"Connection issue detected. Please check your internet connection and try again.",alertResponseTimeout:"Response timeout. Please try again.",alertServiceBusy:"Voice service is currently busy. Please try again in a few minutes.",alertMicrophoneStartFailed:"Failed to start listening. Make sure your microphone is working.",alertMicrophoneCheckSettings:"Failed to start listening. Please check your microphone settings.",alertSpeechRecognitionSetupFailed:"Speech recognition setup failed. Please refresh the page and try again.",alertMicrophoneAccessDenied:"Microphone access denied. Please allow microphone access in your browser settings and refresh the page.",alertNoMicrophoneDetected:"No microphone detected. Please connect a microphone and refresh the page.",alertMicrophoneError:"Microphone error. Please check your microphone.",conversationStartFailed:"Failed to start conversation. Please try again.",insufficientBalanceError:"Insufficient credits to start the conversation. Please add more credits to continue."},fr:{start:"Démarrer la conversation",connect:"Se connecter",endConversation:"Terminer la conversation",restartConversation:"Redémarrer la conversation",hideTyping:"Masquer la saisie",showTyping:"Afficher la saisie",reconnecting:"Reconnexion...",waitForResponse:"Veuillez attendre la réponse...",typeHere:"Tapez ici.",noMessagesYet:"Pas encore de messages...",conversationStatus:"État de la conversation",conversationInProgress:"Conversation en cours",conversationStopped:"Conversation terminée",startConversation:"Commencer la conversation",downloadConversation:"Télécharger la conversation",liveCaptions:"Sous-titres en direct",toggleChatbot:"Afficher/Masquer l'avatar",avatar:"Avatar",switchToAvatar:"Retour à l'avatar",switchToChat:"Passer au chat",chat:"Chat",statusInitializing:"Patientez, nous réveillons l'avatar !",statusReconnecting:"Problème de connexion, tentative de reconnexion...",statusFailed:"Échec de la connexion. Une action manuelle peut être nécessaire.",statusInvalidConfiguration:"L'avatar n'est pas configuré correctement, contactez l'administrateur.",avatarIdleDisconnected:"L'avatar se repose.",reconnectAvatar:"Réveiller l'avatar",close:"Fermer",lastAssistantMessage:"Dernier message",fullBodyView:"Vue du corps entier",upperBodyView:"Vue du haut du corps",secureFormTitle:"Formulaire sécurisé",secureFormDescription:"Saisissez vos informations.",name:"Nom*",namePlaceholder:"Entrez votre nom",phoneNumber:"Numéro de téléphone",phonePlaceholder:"Entrez votre numéro de téléphone",email:"E-mail",emailPlaceholder:"Entrez votre e-mail",secureFormNote:"Vos informations ne seront pas partagées avec le LLM et ne seront pas conservées après cette session. En envoyant, vous acceptez de partager vos informations pour obtenir un support supplémentaire.",save:"Enregistrer",send:"Envoyer",cancel:"Annuler",conversationEndedPrompt:"Conversation terminée. Veuillez évaluer votre satisfaction.",submit:"Envoyer",skip:"Ignorer et terminer",consentTitle:"Consentement pour la conversation IA",consentInfo1:"À titre informatif uniquement — aucun conseil médical, juridique, financier ou de sécurité.",consentInfo2:"Nous utilisons le stockage de session et envoyons votre saisie pour fournir des réponses. Nous ne conservons pas votre conversation ni vos informations personnelles après cette session.",consentReadOur:"Lisez nos",consentTermsLabel:"Conditions",consentAnd:"et",consentPrivacyLabel:"Politique de confidentialité",consentMoreDetails:"pour plus de détails.",consentInfo4:"(Votre consentement s'applique uniquement à cette session et est réinitialisé lorsque vous fermez l'onglet ou la fenêtre)",consentAccept:"J'accepte",consentDecline:"Refuser",consentAcceptAria:"J'accepte – démarrer le chat",consentDeclineAria:"Refuser",interruptSpeaking:"Interrompre l'avatar",turnOnMic:"Activer le microphone",turnOffMic:"Désactiver le microphone",tapToSpeak:"Appuyez pour parler",thinking:"Réflexion...",starting:"Démarrage...",startConversationReminder:"Démarrez une conversation pour discuter.",chatPlaceholderTitle:"Prêt à discuter ?",chatPlaceholderDescription:"Lancez une conversation pour continuer en mode texte.",enterInfoOnMobile:"Saisissez vos informations dans la page Informations utilisateur",waitCurrentResponse:"Veuillez attendre la réponse en cours avant d'envoyer un autre message.",resumeConversationFailedNewStarted:"Nous n'avons pas pu reprendre votre conversation précédente. Une nouvelle a été démarrée à la place.",end:"Terminer",endConversationPrompt:"Souhaitez-vous terminer la conversation ? Cela supprimera définitivement l'historique de la conversation.",restartConversationPrompt:"Voulez-vous démarrer une nouvelle conversation ? La conversation actuelle sera supprimée.",newConversation:"Nouveau",conversationExpiredPrompt:"Cette conversation a expiré et ne peut pas être reprise. Voulez-vous en télécharger une copie puis la supprimer, ou simplement la supprimer ?",conversationExpiredResumePrompt:"Votre conversation précédente a expiré et ne peut pas être reprise. Voulez-vous télécharger une copie de votre historique de conversation ?",downloadAndClear:"Télécharger et effacer",downloadAndStartNew:"Télécharger et démarrer",startNew:"Nouvelle conv.",onlyClear:"Effacer uniquement",confirm:"Confirmer",ok:"OK",download:"Télécharger",alertGenericError:"Une erreur s'est produite.",alertFailedEndConversation:"Échec de la fin de la conversation. Veuillez réessayer.",alertFailedClearConversation:"Échec de l'effacement de la conversation.",alertCouldNotStartListening:"Impossible de démarrer l'écoute. Veuillez réessayer.",alertSomeErrorOccurred:"Une erreur s'est produite. Veuillez réessayer.",alertWaitForAIResponse:"Veuillez attendre la réponse de l'IA avant de commencer à parler.",alertVoiceServicesUnavailable:"Impossible de se connecter aux services vocaux. Veuillez réessayer plus tard.",alertServiceTemporarilyUnavailable:"Service temporairement indisponible. Veuillez réessayer.",alertTooManyRequests:"Trop de demandes simultanées. Veuillez patienter un instant et réessayer.",alertConnectionIssue:"Problème de connexion détecté. Veuillez vérifier votre connexion internet et réessayer.",alertResponseTimeout:"Délai de réponse dépassé. Veuillez réessayer.",alertServiceBusy:"Le service vocal est actuellement occupé. Veuillez réessayer dans quelques minutes.",alertMicrophoneStartFailed:"Impossible de démarrer l'écoute. Assurez-vous que votre microphone fonctionne.",alertMicrophoneCheckSettings:"Impossible de démarrer l'écoute. Veuillez vérifier les paramètres de votre microphone.",alertSpeechRecognitionSetupFailed:"Échec de la configuration de la reconnaissance vocale. Veuillez actualiser la page et réessayer.",alertMicrophoneAccessDenied:"Accès au microphone refusé. Veuillez autoriser l'accès au microphone dans les paramètres de votre navigateur et actualiser la page.",alertNoMicrophoneDetected:"Aucun microphone détecté. Veuillez connecter un microphone et actualiser la page.",alertMicrophoneError:"Erreur de microphone. Veuillez vérifier votre microphone.",conversationStartFailed:"Échec du démarrage de la conversation. Veuillez réessayer.",insufficientBalanceError:"Crédits insuffisants pour démarrer la conversation. Veuillez ajouter des crédits pour continuer."},de:{start:"Starten Sie die Konversation",connect:"Verbinden",endConversation:"Gespräch beenden",restartConversation:"Gespräch neu starten",hideTyping:"Eingabefeld ausblenden",showTyping:"Eingabefeld anzeigen",reconnecting:"Verbindung wird wiederhergestellt...",waitForResponse:"Bitte auf die Antwort warten...",typeHere:"Hier eingeben.",noMessagesYet:"Noch keine Nachrichten...",conversationStatus:"Gesprächsstatus",conversationInProgress:"Gespräch läuft",conversationStopped:"Gespräch beendet",startConversation:"Gespräch starten",downloadConversation:"Gespräch herunterladen",liveCaptions:"Live-Untertitel",toggleChatbot:"Avatar-Chatbot ein-/ausblenden",avatar:"Avatar",switchToAvatar:"Zurück zum Avatar",switchToChat:"Zum Chat wechseln",chat:"Chat",statusInitializing:"Einen Moment, der Avatar wird gestartet!",statusReconnecting:"Verbindungsproblem, versuche erneut zu verbinden...",statusFailed:"Verbindung fehlgeschlagen. Möglicherweise ist ein manueller Eingriff erforderlich.",statusInvalidConfiguration:"Der Avatar ist nicht korrekt konfiguriert, wenden Sie sich an den Administrator.",avatarIdleDisconnected:"Der Avatar ruht.",reconnectAvatar:"Avatar aufwecken",close:"Schließen",lastAssistantMessage:"Letzte Nachricht",fullBodyView:"Ganzkörperansicht",upperBodyView:"Oberkörperansicht",secureFormTitle:"Sicheres Formular",secureFormDescription:"Geben Sie Ihre Informationen ein.",name:"Name*",namePlaceholder:"Geben Sie Ihren Namen ein",phoneNumber:"Telefonnummer",phonePlaceholder:"Geben Sie Ihre Telefonnummer ein",email:"E-Mail",emailPlaceholder:"Geben Sie Ihre E-Mail ein",secureFormNote:"Ihre Informationen werden nicht mit dem LLM geteilt und nach dieser Sitzung nicht gespeichert. Mit dem Absenden erklären Sie sich einverstanden, Ihre Daten zu teilen, um zusätzliche Unterstützung zu erhalten.",save:"Speichern",send:"Senden",cancel:"Abbrechen",conversationEndedPrompt:"Gespräch beendet. Bitte bewerten Sie Ihre Zufriedenheit.",submit:"Senden",skip:"Überspringen und beenden",consentTitle:"Einwilligung für das KI-Gespräch",consentInfo1:"Nur zu allgemeinen Informationszwecken – keine medizinischen, rechtlichen, finanziellen oder sicherheitsrelevanten Ratschläge.",consentInfo2:"Wir verwenden den Sitzungspeicher und senden Ihre Eingaben, um Antworten bereitzustellen. Wir speichern Ihr Gespräch oder persönliche Daten nach dieser Sitzung nicht.",consentReadOur:"Lesen Sie unsere",consentTermsLabel:"Nutzungsbedingungen",consentAnd:"und",consentPrivacyLabel:"Datenschutzerklärung",consentMoreDetails:"für weitere Informationen.",consentInfo4:"(Ihre Einwilligung gilt nur für diese Sitzung und wird zurückgesetzt, wenn Sie den Tab oder das Fenster schließen)",consentAccept:"Ich stimme zu",consentDecline:"Ablehnen",consentAcceptAria:"Ich stimme zu – Chat starten",consentDeclineAria:"Ablehnen",interruptSpeaking:"Sprechenden Avatar unterbrechen",turnOnMic:"Mikrofon einschalten",turnOffMic:"Mikrofon ausschalten",tapToSpeak:"Tippen zum Sprechen",thinking:"Nachdenken...",starting:"Starten...",startConversationReminder:"Starten Sie ein Gespräch, um zu chatten.",chatPlaceholderTitle:"Bereit zum Chatten?",chatPlaceholderDescription:"Starten Sie ein Gespräch, um im Textmodus fortzufahren.",enterInfoOnMobile:"Geben Sie Ihre Daten auf der Seite Benutzerinformationen ein",waitCurrentResponse:"Bitte warten Sie die aktuelle Antwort ab, bevor Sie eine weitere Nachricht senden.",resumeConversationFailedNewStarted:"Wir konnten Ihr vorheriges Gespräch nicht fortsetzen. Stattdessen wurde ein neues gestartet.",end:"Beenden",endConversationPrompt:"Möchten Sie das Gespräch beenden? Dadurch wird der Gesprächsverlauf dauerhaft gelöscht.",restartConversationPrompt:"Möchten Sie ein neues Gespräch beginnen? Das aktuelle Gespräch wird gelöscht.",newConversation:"Neu",conversationExpiredPrompt:"Dieses Gespräch ist abgelaufen und kann nicht fortgesetzt werden. Möchten Sie eine Kopie herunterladen und löschen oder nur löschen?",conversationExpiredResumePrompt:"Ihr vorheriges Gespräch ist abgelaufen und kann nicht fortgesetzt werden. Möchten Sie eine Kopie Ihres Gesprächsverlaufs herunterladen?",downloadAndClear:"Herunterladen & löschen",downloadAndStartNew:"Herunterladen & Neu starten",startNew:"Neu starten",onlyClear:"Nur löschen",confirm:"Bestätigen",ok:"OK",download:"Herunterladen",alertGenericError:"Ein Fehler ist aufgetreten.",alertFailedEndConversation:"Das Gespräch konnte nicht beendet werden. Bitte versuchen Sie es erneut.",alertFailedClearConversation:"Das Gespräch konnte nicht gelöscht werden.",alertCouldNotStartListening:"Zuhören konnte nicht gestartet werden. Bitte versuchen Sie es erneut.",alertSomeErrorOccurred:"Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.",alertWaitForAIResponse:"Bitte warten Sie auf die KI-Antwort, bevor Sie zu sprechen beginnen.",alertVoiceServicesUnavailable:"Verbindung zu Sprachdiensten nicht möglich. Bitte versuchen Sie es später erneut.",alertServiceTemporarilyUnavailable:"Der Dienst ist vorübergehend nicht verfügbar. Bitte versuchen Sie es erneut.",alertTooManyRequests:"Zu viele gleichzeitige Anfragen. Bitte warten Sie einen Moment und versuchen Sie es erneut.",alertConnectionIssue:"Verbindungsproblem erkannt. Bitte überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut.",alertResponseTimeout:"Zeitüberschreitung bei der Antwort. Bitte versuchen Sie es erneut.",alertServiceBusy:"Der Sprachdienst ist derzeit ausgelastet. Bitte versuchen Sie es in einigen Minuten erneut.",alertMicrophoneStartFailed:"Zuhören konnte nicht gestartet werden. Stellen Sie sicher, dass Ihr Mikrofon funktioniert.",alertMicrophoneCheckSettings:"Zuhören konnte nicht gestartet werden. Bitte überprüfen Sie Ihre Mikrofoneinstellungen.",alertSpeechRecognitionSetupFailed:"Einrichtung der Spracherkennung fehlgeschlagen. Bitte aktualisieren Sie die Seite und versuchen Sie es erneut.",alertMicrophoneAccessDenied:"Mikrofonzugriff verweigert. Bitte erlauben Sie den Mikrofonzugriff in Ihren Browsereinstellungen und aktualisieren Sie die Seite.",alertNoMicrophoneDetected:"Kein Mikrofon erkannt. Bitte schließen Sie ein Mikrofon an und aktualisieren Sie die Seite.",alertMicrophoneError:"Mikrofonfehler. Bitte überprüfen Sie Ihr Mikrofon.",conversationStartFailed:"Konversation konnte nicht gestartet werden. Bitte versuchen Sie es erneut.",insufficientBalanceError:"Nicht genügend Guthaben, um die Konversation zu starten. Bitte fügen Sie mehr Guthaben hinzu."},es:{start:"Iniciar conversación",connect:"Conectar",endConversation:"Terminar conversación",restartConversation:"Reiniciar conversación",hideTyping:"Ocultar entrada de texto",showTyping:"Mostrar entrada de texto",reconnecting:"Reconectando...",waitForResponse:"Espere la respuesta...",typeHere:"Escriba aquí.",noMessagesYet:"Todavía no hay mensajes...",conversationStatus:"Estado de la conversación",conversationInProgress:"Conversación en curso",conversationStopped:"Conversación detenida",startConversation:"Iniciar conversación",downloadConversation:"Descargar conversación",liveCaptions:"Subtítulos en vivo",toggleChatbot:"Mostrar/ocultar avatar",avatar:"Avatar",switchToAvatar:"Volver al avatar",switchToChat:"Cambiar al chat",chat:"Chat",statusInitializing:"Espere, estamos iniciando el avatar",statusReconnecting:"Problema de conexión, intentando reconectar...",statusFailed:"La conexión falló. Puede ser necesaria una acción manual.",statusInvalidConfiguration:"El avatar no está configurado correctamente, contacte al administrador.",avatarIdleDisconnected:"El avatar está descansando.",reconnectAvatar:"Despertar el avatar",close:"Cerrar",lastAssistantMessage:"Último mensaje",fullBodyView:"Vista de cuerpo completo",upperBodyView:"Vista de torso",secureFormTitle:"Formulario seguro",secureFormDescription:"Ingrese su información.",name:"Nombre*",namePlaceholder:"Ingrese su nombre",phoneNumber:"Número de teléfono",phonePlaceholder:"Ingrese su número de teléfono",email:"Correo electrónico",emailPlaceholder:"Ingrese su correo electrónico",secureFormNote:"Su información no se compartirá con el LLM ni se almacenará después de esta sesión. Al enviar, acepta compartir su información para obtener soporte adicional.",save:"Guardar",send:"Enviar",cancel:"Cancelar",conversationEndedPrompt:"Conversación finalizada. Califique su satisfacción.",submit:"Enviar",skip:"Omitir y terminar",consentTitle:"Consentimiento para conversación con IA",consentInfo1:"Solo con fines informativos — sin consejos médicos, legales, financieros ni de seguridad.",consentInfo2:"Usamos almacenamiento de sesión y enviamos su entrada para responder. No guardamos su conversación ni datos personales tras esta sesión.",consentReadOur:"Lea nuestros",consentTermsLabel:"Términos",consentAnd:"y",consentPrivacyLabel:"Política de privacidad",consentMoreDetails:"para más detalles.",consentInfo4:"(Su consentimiento se aplica solo a esta sesión y se borra al cerrar la pestaña o ventana)",consentAccept:"Acepto",consentDecline:"Rechazar",consentAcceptAria:"Acepto – iniciar chat",consentDeclineAria:"Rechazar",interruptSpeaking:"Interrumpir avatar que habla",turnOnMic:"Activar micrófono",turnOffMic:"Desactivar micrófono",tapToSpeak:"Toca para hablar",thinking:"Pensando...",starting:"Iniciando...",startConversationReminder:"Inicie una conversación para chatear.",chatPlaceholderTitle:"¿Listo para chatear?",chatPlaceholderDescription:"Inicia una conversación para continuar en modo texto.",enterInfoOnMobile:"Ingrese su información en la página de usuario",waitCurrentResponse:"Espere la respuesta actual antes de enviar otro mensaje.",resumeConversationFailedNewStarted:"No pudimos reanudar su conversación anterior. En su lugar, se ha iniciado una nueva.",end:"Terminar",endConversationPrompt:"¿Desea terminar la conversación? Esto eliminará el historial permanentemente.",restartConversationPrompt:"¿Seguro que quiere iniciar una nueva conversación? La conversación actual se eliminará.",newConversation:"Nueva",conversationExpiredPrompt:"Esta conversación ha expirado y no se puede reanudar. ¿Desea descargar una copia y borrar o solo borrar?",conversationExpiredResumePrompt:"Su conversación anterior ha expirado y no se puede reanudar. ¿Desea descargar una copia de su historial de conversación?",downloadAndClear:"Descargar y borrar",downloadAndStartNew:"Descargar e iniciar",startNew:"Iniciar nueva",onlyClear:"Solo borrar",confirm:"Confirmar",ok:"OK",download:"Descargar",alertGenericError:"Se produjo un error.",alertFailedEndConversation:"No se pudo terminar la conversación. Por favor, inténtelo de nuevo.",alertFailedClearConversation:"No se pudo borrar la conversación.",alertCouldNotStartListening:"No se pudo iniciar la escucha. Por favor, inténtelo de nuevo.",alertSomeErrorOccurred:"Se produjo un error. Por favor, inténtelo de nuevo.",alertWaitForAIResponse:"Por favor, espere la respuesta de la IA antes de comenzar a hablar.",alertVoiceServicesUnavailable:"No se puede conectar a los servicios de voz. Por favor, inténtelo más tarde.",alertServiceTemporarilyUnavailable:"El servicio no está disponible temporalmente. Por favor, inténtelo de nuevo.",alertTooManyRequests:"Demasiadas solicitudes simultáneas. Por favor, espere un momento e inténtelo de nuevo.",alertConnectionIssue:"Problema de conexión detectado. Por favor, verifique su conexión a internet e inténtelo de nuevo.",alertResponseTimeout:"Tiempo de respuesta agotado. Por favor, inténtelo de nuevo.",alertServiceBusy:"El servicio de voz está ocupado actualmente. Por favor, inténtelo en unos minutos.",alertMicrophoneStartFailed:"No se pudo iniciar la escucha. Asegúrese de que su micrófono funcione.",alertMicrophoneCheckSettings:"No se pudo iniciar la escucha. Por favor, verifique la configuración de su micrófono.",alertSpeechRecognitionSetupFailed:"Error en la configuración del reconocimiento de voz. Por favor, actualice la página e inténtelo de nuevo.",alertMicrophoneAccessDenied:"Acceso al micrófono denegado. Por favor, permita el acceso al micrófono en la configuración de su navegador y actualice la página.",alertNoMicrophoneDetected:"No se detectó ningún micrófono. Por favor, conecte un micrófono y actualice la página.",alertMicrophoneError:"Error de micrófono. Por favor, verifique su micrófono.",conversationStartFailed:"No se pudo iniciar la conversación. Por favor, inténtelo de nuevo.",insufficientBalanceError:"Créditos insuficientes para iniciar la conversación. Por favor, agregue más créditos para continuar."},ar:{start:"ابدأ المحادثة",connect:"اتصل",endConversation:"إنهاء المحادثة",restartConversation:"إعادة بدء المحادثة",hideTyping:"إخفاء حقل الكتابة",showTyping:"إظهار حقل الكتابة",reconnecting:"جارٍ إعادة الاتصال...",waitForResponse:"يرجى انتظار الرد...",typeHere:"اكتب هنا.",noMessagesYet:"لا توجد رسائل بعد...",conversationStatus:"حالة المحادثة",conversationInProgress:"المحادثة جارية",conversationStopped:"المحادثة متوقفة",startConversation:"ابدأ المحادثة",downloadConversation:"تنزيل المحادثة",liveCaptions:"تعليقات نصية مباشرة",toggleChatbot:"إظهار/إخفاء روبوت المحادثة",avatar:"أفاتار",switchToAvatar:"العودة إلى الأفاتار",switchToChat:"التبديل إلى الدردشة",chat:"دردشة",statusInitializing:"يرجى الانتظار، نقوم بتشغيل الأفاتار!",statusReconnecting:"مشكلة في الاتصال، جارٍ المحاولة مجددًا...",statusFailed:"فشل الاتصال. قد يتطلب الأمر تدخلاً يدويًا.",statusInvalidConfiguration:"الأفاتار غير مهيأ بشكل صحيح، يرجى التواصل مع المسؤول.",avatarIdleDisconnected:"الأفاتار يستريح.",reconnectAvatar:"إيقاظ الأفاتار",close:"إغلاق",lastAssistantMessage:"آخر رسالة",fullBodyView:"عرض كامل للجسم",upperBodyView:"عرض للجزء العلوي",secureFormTitle:"نموذج آمن",secureFormDescription:"أدخل معلوماتك.",name:"الاسم*",namePlaceholder:"أدخل اسمك",phoneNumber:"رقم الهاتف",phonePlaceholder:"أدخل رقم هاتفك",email:"البريد الإلكتروني",emailPlaceholder:"أدخل بريدك الإلكتروني",secureFormNote:"لن تتم مشاركة معلوماتك مع نموذج اللغة ولن يتم تخزينها بعد هذه الجلسة. بالإرسال فإنك توافق على مشاركة معلوماتك للحصول على دعم إضافي.",save:"حفظ",send:"إرسال",cancel:"إلغاء",conversationEndedPrompt:"انتهت المحادثة. يرجى تقييم مدى رضاك.",submit:"إرسال",skip:"تخطي وإنهاء",consentTitle:"موافقة على محادثة الذكاء الاصطناعي",consentInfo1:"للمعلومات العامة فقط — بدون نصائح طبية أو قانونية أو مالية أو أمنية.",consentInfo2:"نستخدم تخزين الجلسة ونرسل مدخلاتك لتقديم الردود. لا نحتفظ بمحادثتك أو بياناتك الشخصية بعد هذه الجلسة.",consentReadOur:"اقرأ",consentTermsLabel:"الشروط",consentAnd:"و",consentPrivacyLabel:"سياسة الخصوصية",consentMoreDetails:"للمزيد من التفاصيل.",consentInfo4:"(تنطبق موافقتك على جلسة التصفح الحالية فقط ويتم مسحها عند إغلاق الصفحة أو النافذة)",consentAccept:"أوافق",consentDecline:"رفض",consentAcceptAria:"أوافق - ابدأ المحادثة",consentDeclineAria:"رفض",interruptSpeaking:"إيقاف الأفاتار المتكلم",turnOnMic:"تشغيل الميكروفون",turnOffMic:"إيقاف الميكروفون",tapToSpeak:"انقر للتحدث",thinking:"جاري التفكير...",starting:"جاري البدء...",startConversationReminder:"ابدأ محادثة للتحدث.",chatPlaceholderTitle:"مستعد للدردشة؟",chatPlaceholderDescription:"ابدأ محادثة للمتابعة في وضع النص.",enterInfoOnMobile:"أدخل معلوماتك في صفحة معلومات المستخدم",waitCurrentResponse:"يرجى انتظار الرد الحالي قبل إرسال رسالة أخرى.",resumeConversationFailedNewStarted:"لم نتمكن من استئناف محادثتك السابقة. تم بدء محادثة جديدة بدلاً من ذلك. ",end:"إنهاء",endConversationPrompt:"هل ترغب في إنهاء المحادثة؟ سيؤدي ذلك إلى حذف المحادثة نهائيًا.",restartConversationPrompt:"هل أنت متأكد من بدء محادثة جديدة؟ سيتم حذف المحادثة الحالية.",newConversation:"جديدة",conversationExpiredPrompt:"انتهت صلاحية هذه المحادثة ولا يمكن استئنافها. هل تريد تنزيل نسخة ثم حذفها أو الحذف فقط؟",conversationExpiredResumePrompt:"انتهت صلاحية محادثتك السابقة ولا يمكن استئنافها. هل ترغب في تنزيل نسخة من سجل المحادثة؟",downloadAndClear:"تنزيل وحذف",downloadAndStartNew:"تنزيل وبدء جديدة",startNew:"بدء جديدة",onlyClear:"حذف فقط",confirm:"تأكيد",ok:"موافق",download:"تنزيل",alertGenericError:"حدث خطأ.",alertFailedEndConversation:"فشل في إنهاء المحادثة. يرجى المحاولة مرة أخرى.",alertFailedClearConversation:"فشل في مسح المحادثة.",alertCouldNotStartListening:"تعذر بدء الاستماع. يرجى المحاولة مرة أخرى.",alertSomeErrorOccurred:"حدث خطأ ما. يرجى المحاولة مرة أخرى.",alertWaitForAIResponse:"يرجى انتظار رد الذكاء الاصطناعي قبل البدء في التحدث.",alertVoiceServicesUnavailable:"تعذر الاتصال بخدمات الصوت. يرجى المحاولة لاحقاً.",alertServiceTemporarilyUnavailable:"الخدمة غير متاحة مؤقتاً. يرجى المحاولة مرة أخرى.",alertTooManyRequests:"طلبات متزامنة كثيرة جداً. يرجى الانتظار لحظة والمحاولة مرة أخرى.",alertConnectionIssue:"تم اكتشاف مشكلة في الاتصال. يرجى التحقق من اتصالك بالإنترنت والمحاولة مرة أخرى.",alertResponseTimeout:"انتهت مهلة الاستجابة. يرجى المحاولة مرة أخرى.",alertServiceBusy:"خدمة الصوت مشغولة حالياً. يرجى المحاولة بعد بضع دقائق.",alertMicrophoneStartFailed:"تعذر بدء الاستماع. تأكد من أن الميكروفون يعمل.",alertMicrophoneCheckSettings:"تعذر بدء الاستماع. يرجى التحقق من إعدادات الميكروفون.",alertSpeechRecognitionSetupFailed:"فشل إعداد التعرف على الكلام. يرجى تحديث الصفحة والمحاولة مرة أخرى.",alertMicrophoneAccessDenied:"تم رفض الوصول إلى الميكروفون. يرجى السماح بالوصول إلى الميكروفون في إعدادات المتصفح وتحديث الصفحة.",alertNoMicrophoneDetected:"لم يتم اكتشاف ميكروفون. يرجى توصيل ميكروفون وتحديث الصفحة.",alertMicrophoneError:"خطأ في الميكروفون. يرجى التحقق من الميكروفون.",conversationStartFailed:"فشل بدء المحادثة. يرجى المحاولة مرة أخرى.",insufficientBalanceError:"رصيد غير كافٍ لبدء المحادثة. يرجى إضافة المزيد من الرصيد للمتابعة."},zh:{start:"开始对话",connect:"连接",endConversation:"结束对话",restartConversation:"重新开始对话",hideTyping:"隐藏输入框",showTyping:"显示输入框",reconnecting:"正在重新连接...",waitForResponse:"请等待回复...",typeHere:"在此输入。",noMessagesYet:"暂无消息...",conversationStatus:"对话状态",conversationInProgress:"对话进行中",conversationStopped:"对话已停止",startConversation:"开始对话",downloadConversation:"下载对话",liveCaptions:"实时字幕",toggleChatbot:"显示/隐藏虚拟形象助手",avatar:"虚拟形象",switchToAvatar:"返回虚拟形象",switchToChat:"切换到聊天",chat:"聊天",statusInitializing:"请稍候,我们正在唤醒虚拟形象!",statusReconnecting:"连接出现问题,正在尝试重新连接...",statusFailed:"连接失败。可能需要手动处理。",statusInvalidConfiguration:"虚拟形象配置不正确,请联系管理员。",avatarIdleDisconnected:"虚拟形象正在休息。",reconnectAvatar:"唤醒虚拟形象",close:"关闭",lastAssistantMessage:"助手的上一条消息",fullBodyView:"全身视图",upperBodyView:"半身视图",secureFormTitle:"安全表单",secureFormDescription:"请输入您的信息。",name:"姓名*",namePlaceholder:"请输入姓名",phoneNumber:"电话号码",phonePlaceholder:"请输入电话号码",email:"电子邮件",emailPlaceholder:"请输入电子邮件",secureFormNote:"您的信息不会与大语言模型共享,会话结束后也不会被存储。发送即表示您同意共享您的信息以获得额外支持。",save:"保存",send:"发送",cancel:"取消",conversationEndedPrompt:"对话已结束。请评价您的满意度。",submit:"提交",skip:"跳过并结束",consentTitle:"同意进行人工智能对话",consentInfo1:"仅供一般信息参考——不提供医疗、法律、财务或安全建议。",consentInfo2:"我们使用会话存储并发送您的输入以提供回复。本次会话结束后我们不会保留您的对话或个人信息。",consentReadOur:"阅读我们的",consentTermsLabel:"条款",consentAnd:"和",consentPrivacyLabel:"隐私政策",consentMoreDetails:"了解更多详情。",consentInfo4:"(您的同意仅适用于本次会话,关闭标签页或窗口后将被清除)",consentAccept:"同意",consentDecline:"拒绝",consentAcceptAria:"同意——开始聊天",consentDeclineAria:"拒绝",interruptSpeaking:"打断虚拟形象讲话",turnOnMic:"开启麦克风",turnOffMic:"关闭麦克风",tapToSpeak:"点击说话",thinking:"思考中...",starting:"启动中...",startConversationReminder:"开始对话以便聊天。",chatPlaceholderTitle:"准备好聊天了吗?",chatPlaceholderDescription:"开始对话以继续使用文字模式。",enterInfoOnMobile:"请在用户信息页面输入您的信息",waitCurrentResponse:"请等待当前回复后再发送新消息。",resumeConversationFailedNewStarted:"我们无法恢复您之前的对话。已启动一个新的对话。",end:"结束",endConversationPrompt:"是否结束对话?结束后将永久删除历史记录。",restartConversationPrompt:"确定要开始新的对话吗?当前对话将被删除。",newConversation:"新",conversationExpiredPrompt:"此对话已过期且无法恢复。您要下载副本并清除,还是仅清除?",conversationExpiredResumePrompt:"您之前的对话已过期且无法恢复。您是否要下载对话记录的副本?",downloadAndClear:"下载并清除",downloadAndStartNew:"下载并开始新对话",startNew:"开始新对话",onlyClear:"仅清除",confirm:"确认",ok:"确定",download:"下载",alertGenericError:"发生错误。",alertFailedEndConversation:"无法结束对话。请重试。",alertFailedClearConversation:"无法清除对话。",alertCouldNotStartListening:"无法开始聆听。请重试。",alertSomeErrorOccurred:"发生了错误。请重试。",alertWaitForAIResponse:"请等待AI回复后再开始说话。",alertVoiceServicesUnavailable:"无法连接到语音服务。请稍后重试。",alertServiceTemporarilyUnavailable:"服务暂时不可用。请重试。",alertTooManyRequests:"同时请求过多。请稍等片刻后重试。",alertConnectionIssue:"检测到连接问题。请检查您的网络连接后重试。",alertResponseTimeout:"响应超时。请重试。",alertServiceBusy:"语音服务当前繁忙。请几分钟后重试。",alertMicrophoneStartFailed:"无法开始聆听。请确保您的麦克风正常工作。",alertMicrophoneCheckSettings:"无法开始聆听。请检查您的麦克风设置。",alertSpeechRecognitionSetupFailed:"语音识别设置失败。请刷新页面后重试。",alertMicrophoneAccessDenied:"麦克风访问被拒绝。请在浏览器设置中允许麦克风访问并刷新页面。",alertNoMicrophoneDetected:"未检测到麦克风。请连接麦克风并刷新页面。",alertMicrophoneError:"麦克风错误。请检查您的麦克风。",conversationStartFailed:"无法开始对话。请重试。",insufficientBalanceError:"余额不足,无法开始对话。请充值后继续。"}};function yt(t,e){const a=function(t){if(!t||"string"!=typeof t)return _t;const e=t.toLowerCase();if(ft[e])return e;const a=e.split("-")[0];return ft[a]?a:_t}(t),i=ft[a]?.[e];return void 0!==i?i:ft[_t]?.[e]??e}class wt{constructor(t,e,a){this.bus=t,this.dismissableContainer=e,this._getLanguage=a||(()=>"en"),this.dismissableAlerts=new Map,this.bus.on("event_command_Alerts_ShowDismissableAlert",(t=>{let e;e=t?.messageKey?yt(this._getLanguage(),t.messageKey):t?.errorMessage||yt(this._getLanguage(),"alertGenericError");const a=t?.className||"alert-danger";this.showDismissableAlert(e,a)}))}showDismissableAlert(t,e){if(this.dismissableAlerts.has(t))return;if(this.dismissableAlerts.size>=T.alerts.maxAlerts){const t=this.dismissableAlerts.keys().next().value,e=this.dismissableAlerts.get(t);e&&(e.hideToast(),this.dismissableAlerts.delete(t))}const a=f({text:t,duration:T.alerts.dismissableAlertDuration,close:!0,gravity:"top",position:"left",stopOnFocus:!0,className:`alert ${e}`,selector:this.dismissableContainer,callback:()=>{this.dismissableAlerts.delete(t)}});a.showToast(),this.dismissableAlerts.set(t,a)}}const St=t=>/[\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/.test(t);class Ct{#o=null;#r="wakeLock"in navigator;get isActive(){return!!this.#o}get isSupported(){return this.#r}async request(){const t="undefined"!=typeof process&&process.env&&"test"===process.env.NODE_ENV,e="undefined"!=typeof document&&"visible"===document.visibilityState;if(this.#r&&!this.isActive&&!t&&e)try{this.#o=await navigator.wakeLock.request("screen"),this.#o.addEventListener("release",(()=>{this.#o=null}))}catch(a){}}async release(){try{await(this.#o?.release())}finally{this.#o=null,this.#r}}}const kt={"&":"&","<":"<",">":">",'"':""","'":"'"},At=t=>t.replace(/[&<>"']/g,(t=>kt[t])),xt=new RegExp("(?<!\\(|\"|')(?:https?:\\/\\/)(?:[^\\s<>)\"']+)","g"),Tt=t=>`<a href="${t}" target="_blank" rel="noopener noreferrer">${t}</a>`;function It(t){if(!t)return"";let e=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/ /g," ");const a=[];return e=e.replace(/```(?:\w*)\n?([\s\S]*?)```/g,((t,e)=>{const i=a.length;return a.push(`<pre class="md-code-block"><code>${At(e.replace(/\n$/,""))}</code></pre>`),`\0CB${i}\0`})),e=At(e),e=e.replace(/`([^`\n]+)`/g,'<code class="md-code-inline">$1</code>'),e=e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),e=e.replace(/__(.+?)__/g,"<strong>$1</strong>"),e=e.replace(new RegExp("(?<![\\\\*\\w])\\*([^*\\n]+?)\\*(?![*\\w])","g"),"<em>$1</em>"),e=e.replace(new RegExp("(?<![\\\\_ \\w])_([^_\\n]+?)_(?![_\\w])","g"),"<em>$1</em>"),e=e.replace(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),e=e.replace(xt,(t=>{const e=/[.,;:!?)]+$/.exec(t);if(e){const a=t.slice(0,-e[0].length);return`${Tt(a)}${e[0]}`}return Tt(t)})),e=e.replace(/^#{6}\s+(.+)$/gm,'<h6 class="md-heading">$1</h6>'),e=e.replace(/^#{5}\s+(.+)$/gm,'<h5 class="md-heading">$1</h5>'),e=e.replace(/^#{4}\s+(.+)$/gm,'<h4 class="md-heading">$1</h4>'),e=e.replace(/^#{3}\s+(.+)$/gm,'<h3 class="md-heading">$1</h3>'),e=e.replace(/^#{1,2}\s+(.+)$/gm,'<h3 class="md-heading">$1</h3>'),e=e.replace(/^(?:[*-])\s+(.+)$/gm,'<li class="md-li-ul">$1</li>'),e=e.replace(/^\d+\.\s+(.+)$/gm,'<li class="md-li-ol">$1</li>'),e=e.replace(/(?:^<li class="md-li-ul">([\s\S]*?)<\/li>\n?)+/gm,(t=>`<ul class="md-list">${t}</ul>`)).replace(/(?:^<li class="md-li-ol">([\s\S]*?)<\/li>\n?)+/gm,(t=>`<ol class="md-list">${t}</ol>`)),e=e.replace(/\x00CB(\d+)\x00/g,((t,e)=>a[Number(e)])),e}const Et=v`
|
|
2
|
+
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
|
3
|
+
width="25px" height="30.42px" viewBox="0 0 1052.000000 1280.000000"
|
|
4
|
+
preserveAspectRatio="xMidYMid meet">
|
|
5
|
+
<metadata>
|
|
6
|
+
Created by potrace 1.15, written by Peter Selinger 2001-2017
|
|
7
|
+
</metadata>
|
|
8
|
+
<g transform="translate(0.000000,1280.000000) scale(0.100000,-0.100000)"
|
|
9
|
+
fill="#000000" stroke="none">
|
|
10
|
+
<path d="M4950 12790 c-25 -4 -63 -15 -85 -23 -22 -8 -67 -20 -100 -27 -33 -7
|
|
11
|
+
-99 -27 -147 -46 -48 -19 -105 -34 -126 -34 -60 0 -199 -27 -277 -53 -137 -47
|
|
12
|
+
-256 -119 -365 -222 -36 -33 -103 -83 -149 -110 -107 -64 -199 -154 -343 -335
|
|
13
|
+
-63 -80 -125 -154 -138 -165 -49 -43 -80 -106 -80 -163 0 -29 5 -62 10 -73 9
|
|
14
|
+
-16 2 -28 -53 -83 -35 -35 -86 -97 -112 -137 -27 -41 -64 -92 -82 -114 -48
|
|
15
|
+
-56 -120 -206 -143 -299 -11 -43 -25 -120 -30 -170 -6 -50 -17 -146 -26 -213
|
|
16
|
+
-11 -90 -12 -137 -5 -185 21 -132 51 -441 61 -622 6 -103 17 -222 26 -264 18
|
|
17
|
+
-90 61 -186 102 -225 36 -35 34 -77 -4 -77 -64 0 -127 -51 -166 -135 -22 -47
|
|
18
|
+
-23 -61 -22 -240 2 -219 18 -331 68 -475 91 -257 114 -300 233 -433 47 -52 86
|
|
19
|
+
-109 116 -170 55 -109 116 -174 208 -221 53 -27 65 -38 73 -67 25 -94 131
|
|
20
|
+
-408 171 -509 l46 -115 14 -400 c21 -616 23 -712 15 -680 -4 17 -8 57 -9 90
|
|
21
|
+
-2 57 -3 59 -17 40 -9 -11 -106 -202 -215 -425 -110 -223 -212 -429 -227 -459
|
|
22
|
+
l-27 -54 -215 -119 c-332 -184 -779 -441 -1170 -671 -1067 -630 -1651 -1038
|
|
23
|
+
-1688 -1182 -45 -170 -72 -1000 -72 -2227 l0 -698 5262 0 5261 0 -6 993 c-9
|
|
24
|
+
1486 -29 1887 -99 1991 -125 190 -978 745 -2323 1512 -192 110 -435 247 -538
|
|
25
|
+
305 -188 104 -189 104 -212 155 -60 134 -439 894 -446 894 -4 0 -10 -19 -12
|
|
26
|
+
-42 -2 -24 -3 9 -1 72 2 63 9 293 15 510 l12 395 47 120 c47 119 120 335 160
|
|
27
|
+
472 l20 71 63 30 c97 46 137 88 201 209 37 72 80 134 125 185 91 101 131 160
|
|
28
|
+
157 233 13 33 38 101 58 150 62 161 79 270 80 510 l1 210 -29 58 c-33 68 -97
|
|
29
|
+
117 -153 117 -29 0 -33 3 -33 26 0 14 14 43 30 64 69 87 104 211 115 405 8
|
|
30
|
+
143 53 622 65 701 7 40 6 89 0 140 -6 43 -17 141 -26 217 -25 226 -77 374
|
|
31
|
+
-177 504 -29 37 -76 102 -105 143 -28 41 -73 97 -101 124 -43 43 -48 52 -40
|
|
32
|
+
73 12 32 12 105 -1 138 -6 15 -34 52 -64 83 -29 31 -107 125 -173 207 -66 83
|
|
33
|
+
-147 176 -181 207 -55 51 -170 128 -190 128 -5 0 -41 32 -82 70 -176 168 -369
|
|
34
|
+
256 -615 281 -79 8 -128 18 -175 38 -36 16 -90 34 -120 41 -30 7 -90 24 -134
|
|
35
|
+
38 -116 36 -205 22 -276 -44 -24 -22 -33 -24 -104 -20 -61 3 -82 8 -99 24 -46
|
|
36
|
+
44 -132 65 -207 52z"/>
|
|
37
|
+
</g>
|
|
38
|
+
</svg>`,Dt=v`
|
|
39
|
+
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
|
40
|
+
width="25px" height="50px" viewBox="0 0 640.000000 1280.000000"
|
|
41
|
+
preserveAspectRatio="xMidYMid meet">
|
|
42
|
+
<metadata>
|
|
43
|
+
Created by potrace 1.15, written by Peter Selinger 2001-2017
|
|
44
|
+
</metadata>
|
|
45
|
+
<g transform="translate(0.000000,1280.000000) scale(0.100000,-0.100000)"
|
|
46
|
+
fill="#000000" stroke="none">
|
|
47
|
+
<path d="M3108 12784 c-90 -19 -148 -45 -225 -100 -142 -102 -221 -254 -243
|
|
48
|
+
-472 -12 -114 -6 -197 17 -252 8 -19 19 -84 24 -145 14 -181 68 -335 148 -427
|
|
49
|
+
35 -39 41 -53 47 -109 8 -82 -9 -175 -38 -206 -75 -80 -270 -140 -598 -183
|
|
50
|
+
-335 -44 -430 -65 -524 -114 -113 -59 -172 -199 -213 -511 -24 -179 -23 -743
|
|
51
|
+
1 -1040 30 -372 84 -809 126 -1013 16 -82 17 -98 5 -132 -39 -110 -50 -211
|
|
52
|
+
-49 -460 1 -303 6 -351 114 -975 62 -366 76 -461 100 -710 21 -216 77 -371
|
|
53
|
+
178 -492 49 -58 52 -66 52 -117 0 -130 45 -615 91 -976 35 -273 57 -419 101
|
|
54
|
+
-655 l31 -170 -21 -165 c-47 -366 -59 -628 -43 -930 18 -321 43 -500 141 -995
|
|
55
|
+
67 -342 100 -552 100 -642 0 -51 3 -64 19 -73 11 -5 25 -26 31 -45 16 -49 1
|
|
56
|
+
-116 -71 -310 -33 -87 -62 -178 -66 -200 -5 -38 -2 -43 35 -77 65 -59 138 -81
|
|
57
|
+
267 -82 154 -1 254 29 309 94 33 40 34 86 5 213 -20 84 -21 119 -20 407 0 173
|
|
58
|
+
3 338 6 365 14 129 86 920 100 1085 31 383 45 663 45 920 0 156 5 283 11 310
|
|
59
|
+
7 27 12 179 14 375 1 182 7 389 13 460 19 213 82 1447 82 1604 0 46 3 81 6 78
|
|
60
|
+
12 -11 33 -769 33 -1172 1 -387 -2 -427 -34 -600 -13 -67 -19 -182 -25 -455
|
|
61
|
+
-5 -201 -14 -437 -20 -525 -14 -193 -8 -792 16 -1390 24 -628 23 -715 -10
|
|
62
|
+
-945 -15 -107 -28 -231 -27 -275 0 -44 -9 -141 -20 -215 -12 -74 -19 -152 -16
|
|
63
|
+
-173 11 -84 96 -128 260 -135 165 -7 296 26 375 94 38 32 42 40 42 80 0 26
|
|
64
|
+
-21 109 -51 202 -34 104 -53 181 -56 227 -5 66 -3 73 22 103 23 28 28 45 36
|
|
65
|
+
139 15 161 43 326 105 611 30 142 69 320 85 397 119 551 179 1076 179 1561 0
|
|
66
|
+
82 6 140 25 220 98 439 178 1007 216 1554 l13 175 42 45 c135 146 180 285 214
|
|
67
|
+
660 6 68 15 140 20 160 5 19 13 71 20 115 6 44 39 211 75 370 120 543 145 714
|
|
68
|
+
145 980 0 169 -15 299 -44 382 -8 23 -10 49 -5 66 13 47 47 396 66 662 12 175
|
|
69
|
+
17 384 17 695 1 463 -7 597 -45 828 -34 206 -74 303 -152 365 -103 82 -206
|
|
70
|
+
119 -522 186 -322 69 -467 120 -542 191 -32 29 -38 59 -38 196 l0 121 42 46
|
|
71
|
+
c94 101 142 246 150 447 4 107 9 144 25 178 19 40 20 50 9 155 -26 245 -121
|
|
72
|
+
392 -315 487 -135 67 -274 85 -418 54z m-964 -3709 c46 -256 95 -614 112 -822
|
|
73
|
+
6 -76 4 -86 -25 -156 -35 -86 -74 -206 -94 -292 -14 -58 -14 -56 -9 85 3 86 0
|
|
74
|
+
160 -6 182 -8 30 -6 49 9 97 10 33 24 119 30 191 16 175 -2 488 -47 815 -14
|
|
75
|
+
100 5 36 30 -100z m2176 -690 c14 -123 35 -223 55 -272 11 -27 13 -44 6 -63
|
|
76
|
+
-25 -66 -51 -272 -51 -404 0 -33 -2 -57 -5 -54 -3 3 -12 58 -20 124 -16 130
|
|
77
|
+
-58 374 -80 470 -16 70 -11 137 41 539 l29 220 6 -230 c4 -126 12 -275 19
|
|
78
|
+
-330z"/>
|
|
79
|
+
</g>
|
|
80
|
+
</svg>`,Mt=v`
|
|
81
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 304" aria-hidden="true" focusable="false">
|
|
82
|
+
<path fill="currentColor" opacity="1.000000" stroke="none"
|
|
83
|
+
d="
|
|
84
|
+
M1.000000,288.470459
|
|
85
|
+
C4.336832,282.053436 4.111762,275.237854 5.412516,268.835938
|
|
86
|
+
C9.171879,250.333588 12.256336,231.695190 15.732928,213.134018
|
|
87
|
+
C20.612299,187.083603 25.519182,161.037720 30.578411,135.021805
|
|
88
|
+
C34.731358,113.666214 48.112289,99.843201 67.283409,90.909126
|
|
89
|
+
C75.588669,87.038719 84.634201,86.823570 93.477028,85.684494
|
|
90
|
+
C103.980019,84.331566 114.508003,83.170403 125.029549,81.964516
|
|
91
|
+
C134.897934,80.833488 144.770737,79.740570 154.643967,78.652489
|
|
92
|
+
C167.640717,77.220169 180.643631,75.843018 193.636826,74.379372
|
|
93
|
+
C207.287781,72.841637 220.930206,71.228279 234.576675,69.650711
|
|
94
|
+
C247.073685,68.206024 259.608582,67.028587 272.059296,65.258904
|
|
95
|
+
C289.515259,62.777817 311.662506,68.169601 320.750824,87.776169
|
|
96
|
+
C321.000000,103.687561 321.000000,119.375122 320.863403,135.868958
|
|
97
|
+
C316.264496,158.378265 311.369873,180.004089 307.475647,201.808578
|
|
98
|
+
C304.316284,219.498672 298.646210,235.390030 283.605621,246.605179
|
|
99
|
+
C273.533966,254.115143 262.694183,259.369141 249.831314,259.369751
|
|
100
|
+
C196.869217,259.372223 143.907104,259.350830 90.945038,259.387451
|
|
101
|
+
C84.199684,259.392120 77.875465,260.870514 72.208954,264.918091
|
|
102
|
+
C61.420639,272.624237 50.447315,280.070831 39.624340,287.729126
|
|
103
|
+
C31.661816,293.363373 23.058926,298.128632 16.000000,305.000000
|
|
104
|
+
C11.069987,305.000000 6.139974,305.000000 1.000000,305.000000
|
|
105
|
+
C1.000000,299.648193 1.000000,294.294556 1.000000,288.470459
|
|
106
|
+
M275.033142,85.223404
|
|
107
|
+
C261.697052,86.618607 248.357925,87.985428 235.025940,89.418671
|
|
108
|
+
C225.656281,90.425941 216.291748,91.484985 206.933121,92.590202
|
|
109
|
+
C193.793808,94.141907 180.663681,95.771080 167.526703,97.342773
|
|
110
|
+
C154.387085,98.914795 141.245880,100.474091 128.101654,102.007111
|
|
111
|
+
C115.450096,103.482681 102.819870,105.228951 90.133003,106.292244
|
|
112
|
+
C73.891426,107.653465 62.091988,115.644218 53.905109,129.331238
|
|
113
|
+
C48.555580,138.274689 48.386028,148.694748 46.454941,158.543243
|
|
114
|
+
C40.881393,186.968201 35.619186,215.456558 30.531080,243.972916
|
|
115
|
+
C28.920919,252.997086 26.530741,261.929657 25.918119,272.252594
|
|
116
|
+
C36.635975,264.858246 46.765110,258.271790 56.444744,251.080322
|
|
117
|
+
C66.348396,243.722427 76.826538,239.448746 89.501419,239.526108
|
|
118
|
+
C141.147202,239.841385 192.798050,239.398087 244.442627,239.800262
|
|
119
|
+
C261.984772,239.936874 281.514282,227.005966 285.644775,207.139023
|
|
120
|
+
C292.085327,176.161133 298.743103,145.214188 304.327423,114.078094
|
|
121
|
+
C307.426147,96.800697 293.495605,83.732857 275.033142,85.223404
|
|
122
|
+
z"/>
|
|
123
|
+
<path fill="currentColor" opacity="1.000000" stroke="none"
|
|
124
|
+
d="
|
|
125
|
+
M192.532394,1.000000
|
|
126
|
+
C198.885437,3.923073 203.176651,8.184974 205.187256,14.653214
|
|
127
|
+
C208.319366,24.729303 203.666061,36.642429 194.050446,41.903614
|
|
128
|
+
C191.173523,43.477734 189.510925,45.181450 189.158447,48.664070
|
|
129
|
+
C188.728455,52.912342 187.194672,57.038986 186.596146,61.282810
|
|
130
|
+
C185.959412,65.797729 183.572113,67.820358 179.205505,68.640800
|
|
131
|
+
C176.553574,69.139076 173.958298,69.407784 171.312668,69.340088
|
|
132
|
+
C166.723129,69.222649 164.992142,67.162018 165.843384,62.631424
|
|
133
|
+
C166.882172,57.102543 168.063232,51.597549 169.321182,46.113976
|
|
134
|
+
C169.895721,43.609554 169.353165,41.690746 167.635925,39.742435
|
|
135
|
+
C156.688034,27.321487 158.771332,12.419515 172.627487,3.362831
|
|
136
|
+
C173.595947,2.729820 174.576691,2.115573 175.775848,1.246300
|
|
137
|
+
C181.354935,1.000000 186.709854,1.000000 192.532394,1.000000
|
|
138
|
+
M178.466064,43.194557
|
|
139
|
+
C181.738434,43.962490 184.899261,44.061489 187.786880,41.793179
|
|
140
|
+
C184.632401,38.947304 176.496841,37.868542 173.029633,39.773766
|
|
141
|
+
C173.948669,41.843548 175.914566,42.277782 178.466064,43.194557
|
|
142
|
+
z"/>
|
|
143
|
+
<path fill="currentColor" opacity="1.000000" stroke="none"
|
|
144
|
+
d="
|
|
145
|
+
M173.396362,219.107773
|
|
146
|
+
C160.763672,219.844223 148.703918,219.893875 137.623154,213.420822
|
|
147
|
+
C131.992325,210.131485 131.001694,206.611771 134.787186,201.285965
|
|
148
|
+
C140.284882,193.551270 141.590897,193.347229 150.244125,196.974045
|
|
149
|
+
C162.473145,202.099594 173.937256,200.460480 184.371277,192.233063
|
|
150
|
+
C190.470139,187.423981 200.297089,190.002045 202.970245,197.391357
|
|
151
|
+
C204.333099,201.158630 202.500916,204.293793 199.573578,206.589478
|
|
152
|
+
C191.914856,212.595642 183.503372,217.124847 173.396362,219.107773
|
|
153
|
+
z"/>
|
|
154
|
+
<path fill="currentColor" opacity="1.000000" stroke="none"
|
|
155
|
+
d="
|
|
156
|
+
M231.931488,115.814880
|
|
157
|
+
C232.718384,116.499748 233.215561,116.943787 233.683640,117.416611
|
|
158
|
+
C240.780563,124.585335 240.799484,126.221283 233.876999,133.186096
|
|
159
|
+
C225.797806,141.314667 225.797806,141.314667 234.738693,148.488159
|
|
160
|
+
C242.166809,154.447922 240.659515,164.336533 231.641388,167.987823
|
|
161
|
+
C227.904327,169.500900 224.864883,167.448578 222.159653,165.126251
|
|
162
|
+
C216.626480,160.376236 211.124985,155.586761 205.700455,150.713333
|
|
163
|
+
C198.421768,144.174057 198.716476,138.061127 206.050339,131.712906
|
|
164
|
+
C211.563812,126.940407 216.752579,121.786278 221.985779,116.699028
|
|
165
|
+
C224.990524,113.778091 228.029648,112.640854 231.931488,115.814880
|
|
166
|
+
z"/>
|
|
167
|
+
<path fill="currentColor" opacity="1.000000" stroke="none"
|
|
168
|
+
d="
|
|
169
|
+
M138.709229,129.454376
|
|
170
|
+
C143.972031,137.631577 143.546768,146.953293 137.345932,152.521545
|
|
171
|
+
C131.264923,157.982208 121.845360,160.255585 114.151199,154.600388
|
|
172
|
+
C108.040939,150.109360 108.031036,143.842911 108.868034,137.581924
|
|
173
|
+
C109.740639,131.054550 114.375092,127.080360 120.324982,124.957504
|
|
174
|
+
C127.137169,122.526985 133.365952,123.659859 138.709229,129.454376
|
|
175
|
+
z"/>
|
|
176
|
+
</svg>`,Rt=v`
|
|
177
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="80" height="80" aria-hidden="true" focusable="false">
|
|
178
|
+
<!-- Main chat bubble -->
|
|
179
|
+
<rect x="10" y="15" width="55" height="40" rx="8" ry="8" fill="currentColor" opacity="0.15"/>
|
|
180
|
+
<!-- Secondary chat bubble -->
|
|
181
|
+
<rect x="35" y="40" width="55" height="40" rx="8" ry="8" fill="currentColor" opacity="0.3"/>
|
|
182
|
+
<!-- Dots in main bubble -->
|
|
183
|
+
<circle cx="25" cy="35" r="4" fill="currentColor" opacity="0.4"/>
|
|
184
|
+
<circle cx="38" cy="35" r="4" fill="currentColor" opacity="0.4"/>
|
|
185
|
+
<circle cx="51" cy="35" r="4" fill="currentColor" opacity="0.4"/>
|
|
186
|
+
</svg>`,Pt=Mt,zt=v`<span class="material-icons">call_end</span>`,Ot=v`<span class="material-icons last-message-icon">history</span>`,Lt=v`<span class="material-icons switch-chat-icon">chat</span>`,Nt=v`<span class="material-icons">refresh</span>`,Bt=v`<span class="material-icons">send</span>`,$t=v`<span class="material-icons chat-bubble-icon">chat_bubble</span>`,Vt=v`<span class="material-icons">close</span>`,Ft=v`<span class="material-icons">menu</span>`,Ut=v`<span class="material-icons error-icon">error</span>`,Ht=v`<span class="material-icons"> content_copy</span>`,jt=v`<span class="material-icons">check</span>`,qt=v`<span class="material-icons">keyboard</span>`,Gt=t=>v`
|
|
187
|
+
<div class="button-container">
|
|
188
|
+
<button @click="${t._handleStartConversationBtn}" type="button" class="btn start-button" id="start_conversation_button" title="${t._t("start")}">${t._t("start")}</button>
|
|
189
|
+
</div>
|
|
190
|
+
`,Wt=t=>v`
|
|
191
|
+
<div class="button-container">
|
|
192
|
+
<button @click="${t._handleConnectBtn}" type="button" class="btn-lg start-button" id="connect_button" title="${t._t("connect")}">${t._t("connect")}</button>
|
|
193
|
+
</div>`,Kt=t=>t._isStartingConversation?t._t("starting"):t._t("thinking"),Qt=t=>{const e=(t=>t._isConversationPaused?"paused":t._isSpeaking?"speaking":t._isThinking?"thinking":t._isListening?"listening":"idle")(t),a=((t,e)=>{switch(e){case"paused":return t._t("reconnecting");case"speaking":return t._t("interruptSpeaking");case"thinking":return t._t("waitForResponse");case"listening":return t._t("turnOffMic");default:return t._t("turnOnMic")}})(t,e),i=t._inputsBlocked&&"idle"===e,n="paused"===e,s="idle"===e&&!i,o="thinking"===e;return v`
|
|
194
|
+
<div class="voice-visualizer-wrapper">
|
|
195
|
+
${o?m:v`
|
|
196
|
+
<div
|
|
197
|
+
class="voice-visualizer state-${e} ${i||n?"visualizer-disabled":""}"
|
|
198
|
+
@click="${i||n?m:t._handleMicBtn}"
|
|
199
|
+
title="${a}"
|
|
200
|
+
role="button"
|
|
201
|
+
tabindex="${i||n?-1:0}"
|
|
202
|
+
aria-label="${a}"
|
|
203
|
+
>
|
|
204
|
+
<div class="audio-bar"></div>
|
|
205
|
+
<div class="audio-bar"></div>
|
|
206
|
+
<div class="audio-bar"></div>
|
|
207
|
+
<div class="audio-bar"></div>
|
|
208
|
+
<div class="audio-bar"></div>
|
|
209
|
+
</div>`}
|
|
210
|
+
${s?v`<span class="visualizer-hint">${t._t("tapToSpeak")}</span>`:m}
|
|
211
|
+
${o?v`<span class="thinking-label">${Kt(t)}</span>`:m}
|
|
212
|
+
</div>
|
|
213
|
+
`},Yt=t=>v`
|
|
214
|
+
<div id="chatbot-container" class="${t._showChatbot||!t.toggler?"show-chatbot":""}${t.toggler?"":" embedded"}">
|
|
215
|
+
${t.toggler?(t=>v`
|
|
216
|
+
<button id="chatbot-toggler" @click="${t._handleToggleChatbot}" aria-label="${t._t("toggleChatbot")}">
|
|
217
|
+
${Pt}
|
|
218
|
+
${Vt}
|
|
219
|
+
</button>
|
|
220
|
+
`)(t):m}
|
|
221
|
+
${(()=>m)()}
|
|
222
|
+
<div class="chatbot-layout ${t._stateTestMode?"with-test-stats":""}">
|
|
223
|
+
${t._stateTestMode?(t=>{const e=t._actorSnapshot,a="function"==typeof t.initStatus?t.initStatus():"UNKNOWN",i=!!t._isStartingConversation,n=!!t._isInitializingConversation,s=!!t._isConversationInProgress,o=!!t._isConversationPaused,r=!!t._isAutoResuming,c=!!t._isConversationStopped,l=!!t._isFailed,h=l?"FAILED":i?"STARTING":n?"INITIALIZING":s?"IN_PROGRESS":o?"PAUSED":r?"AUTO_RESUMING":c?"STOPPED":"CLEARED",d=!!t._isSpeaking,u=!!t._isThinking||!!t._isStartingConversation,p=s&&!d&&!u&&!t._isListening,g=!!t._isListening,b=d?"speaking":u?"thinking":g?"listening":p?"idle":i?"startingConversation":"",_=!!t._inputsBlocked||u,f=t._speakingAvatar?.connectionManager,y=!0===f?.allConnectionsReady,w=!!t._isDisconnected,S=y?"connected":w?"disconnected":l?"recovering":"connecting",C=function(t){const e=t?.value;if(!e)return"";const a=(t,e=[])=>{if("string"==typeof t)return[e.concat(t).join(".")];if(t&&"object"==typeof t){const i=[];for(const n of Object.keys(t))i.push(...a(t[n],e.concat(n)));return i}return[]};try{return a(e).join(" | ")}catch(i){try{return JSON.stringify(e)}catch{return String(e)}}}(e),k=!t.toggler||t._showChatbot,A="AvatarPage"===t._shownPage?"AVATAR":"CHAT",x=e?.context?.chatSocket?.chatbotMode||"unknown";return v`
|
|
224
|
+
<div class="test-mode-states">
|
|
225
|
+
<div><b>FSM</b>: ${C||"(no state)"}</div>
|
|
226
|
+
<div><b>UI</b>: Chatbot Visible=${String(k)}, Mode (UI → FSM)=${A} → ${x}</div>
|
|
227
|
+
<div>Initialization: ${a}</div>
|
|
228
|
+
<div>Conversation: ${h}</div>
|
|
229
|
+
<div>Substate: ${b}</div>
|
|
230
|
+
<div>AvatarRunning: ${String(t._avatarRunning)}</div>
|
|
231
|
+
<div>InputsBlocked: ${_}</div>
|
|
232
|
+
<div>isPageVisible: ${t._actorSnapshot?.context?.isPageVisible}</div>
|
|
233
|
+
<div>pendingStart: ${String(t._actorSnapshot?.context?.pendingStart)}</div>
|
|
234
|
+
<div>Connection: ${S}</div>
|
|
235
|
+
<pre style="white-space: pre-wrap; margin: 4px 0;">${f?.getConnectionReport?.()}</pre>
|
|
236
|
+
<div style="display:flex; flex-wrap: wrap; gap: 6px; width:50%;">
|
|
237
|
+
<button @click="${()=>t._testSetAuthConnected("disconnected")}">Disconnect Auth</button>
|
|
238
|
+
<button @click="${()=>t._testSetAuthConnected("failed")}">Fail Auth</button>
|
|
239
|
+
<button @click="${()=>t._testSetAuthConnected()}">Connect Auth</button>
|
|
240
|
+
<button @click="${()=>t._testSetSocketConnected("disconnected")}">Disconnect Socket</button>
|
|
241
|
+
<button @click="${()=>t._testSetSocketConnected("failed")}">Fail Socket</button>
|
|
242
|
+
<button @click="${()=>t._testSetSocketConnected()}">Connect Socket</button>
|
|
243
|
+
<button @click="${()=>t._testSetSpeechConnected("disconnected")}">Disconnect Speech</button>
|
|
244
|
+
<button @click="${()=>t._testSetSpeechConnected("failed")}">Fail Speech</button>
|
|
245
|
+
<button @click="${()=>t._testSetSpeechConnected()}">Connect Speech</button>
|
|
246
|
+
${f?.reconnectFailedModules?v`<button @click="${()=>f.reconnectFailedModules(!0)}">Reconnect Failed</button>`:m}
|
|
247
|
+
${f?.reconnectDisconnectedModules?v`<button @click="${()=>f.reconnectDisconnectedModules()}">Reconnect All</button>`:m}
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
`})(t):m}
|
|
251
|
+
<div
|
|
252
|
+
class="chatbot ${t.target_app} ${t.compact?"compact":""}"
|
|
253
|
+
@click="${t._handleChatbotClick}"
|
|
254
|
+
style="
|
|
255
|
+
${t.toggler||"mobile"===t.target_app?`width: ${t._canvasWidth}px; height: ${"mobile"===t.target_app||t.toggler&&(window.innerWidth<T.dom.smallDisplayWidth||window.innerHeight<T.dom.shortDisplayHeight)?"calc(var(--chatbot-dynamic-height) - var(--chatbot-bottom-offset, 0px))":`${t._chatbotHeight}px`};`:t._stateTestMode?`width: ${t._canvasWidth}px; height: ${t._chatbotHeight}px;`:`width: 100%; height: ${t._chatbotHeight}px;`}
|
|
256
|
+
"
|
|
257
|
+
>
|
|
258
|
+
${t.compact?m:(t=>v`
|
|
259
|
+
<header @click="${t=>t.stopPropagation()}">
|
|
260
|
+
<div class="header-container">
|
|
261
|
+
<div class="header-left">
|
|
262
|
+
<div class="menu-icon" @click="${t._handleToggleMenu}">
|
|
263
|
+
${t._showMenu?Vt:Ft}
|
|
264
|
+
</div>
|
|
265
|
+
${(t=>{const e=t._isConversationInProgress,a=t._isStartingConversation||t._isInitializingConversation,i=t._isConversationStopped,n=t._isAutoResuming;return v`
|
|
266
|
+
${t._showMenu?v`<div class="menu-backdrop" @click="${t._handleToggleMenu}"></div>`:null}
|
|
267
|
+
<div id="menu" class="${t._showMenu?"show":"hide"}">
|
|
268
|
+
<div class="menu-items" >
|
|
269
|
+
<div class="conversation-details">
|
|
270
|
+
<span class="conversation-status" title="${t._t("conversationStatus")}">${e?v`<small>${t._t("conversationInProgress")}</small>`:v`<small>${t._t("conversationStopped")}</small>`}</span>
|
|
271
|
+
</div>
|
|
272
|
+
<div ?hidden=${!i||e||a||n}>
|
|
273
|
+
<button type="button" class="menu-button" @click="${t._handleStartConversationMenuBtn}">${t._t("startConversation")}</button>
|
|
274
|
+
</div>
|
|
275
|
+
<div ?hidden=${!e}>
|
|
276
|
+
<button type="button" class="menu-button" @click="${t._handleEndConversationBtn}">${t._t("endConversation")}</button>
|
|
277
|
+
</div>
|
|
278
|
+
<hr>
|
|
279
|
+
<div ?hidden=${!t._canDownloadTranscript()}>
|
|
280
|
+
<button type="button" class="menu-button" @click="${t._handleDownloadTranscriptMenuBtn}">${t._t("downloadConversation")}</button>
|
|
281
|
+
</div>
|
|
282
|
+
<div class="labels-container">
|
|
283
|
+
<label>${t._t("liveCaptions")}</label>
|
|
284
|
+
<label class="captions-switch">
|
|
285
|
+
<input type="checkbox" .checked=${t.enable_captions} @click="${t._handleToggleCaptionsSwitch}">
|
|
286
|
+
<span class="captions-slider round"></span>
|
|
287
|
+
</label>
|
|
288
|
+
</div>
|
|
289
|
+
<div class="menu-switch-container">
|
|
290
|
+
${(t=>"AvatarPage"===t._shownPage||"ChatPage"===t._shownPage?v`
|
|
291
|
+
<div class="switches-container" dir="ltr">
|
|
292
|
+
<input type="radio" id="switchAvatar" name="switchMode" value="Avatar" .checked=${"AvatarPage"===t._shownPage} />
|
|
293
|
+
<input type="radio" id="switchChat" name="switchMode" value="Chat" .checked=${"ChatPage"===t._shownPage}/>
|
|
294
|
+
<label for="switchAvatar" @click="${t._handleShowAvatarPage}">${t._t("avatar")}</label>
|
|
295
|
+
<label for="switchChat" @click="${t._handleShowChatPage}">${t._t("chat")}</label>
|
|
296
|
+
<div class="switch-wrapper">
|
|
297
|
+
<div class="switch">
|
|
298
|
+
<div>${t._t("avatar")}</div>
|
|
299
|
+
<div>${t._t("chat")}</div>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
`:m)(t)}
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
`})(t)}
|
|
308
|
+
</div>
|
|
309
|
+
<div class="header-center">
|
|
310
|
+
<h3 id="avatar-name">${t._avatarName}</h3>
|
|
311
|
+
</div>
|
|
312
|
+
<div class="header-right">
|
|
313
|
+
${t.brand_logo?v`
|
|
314
|
+
<div>
|
|
315
|
+
<img src="${t.brand_logo}" class="logo-image">
|
|
316
|
+
</div>
|
|
317
|
+
`:m}
|
|
318
|
+
${t.toggler?v`
|
|
319
|
+
<div class="header-close-icon" @click="${t._handleToggleChatbot}" aria-label="${t._t("close")}" role="button" tabindex="0">
|
|
320
|
+
${Vt}
|
|
321
|
+
</div>
|
|
322
|
+
`:m}
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</header>
|
|
326
|
+
`)(t)}
|
|
327
|
+
|
|
328
|
+
<div
|
|
329
|
+
class="chatbot-body ${"ChatPage"===t._shownPage?"chat-mode":""} ${t.target_app} ${t.compact?"compact":""}"
|
|
330
|
+
>
|
|
331
|
+
${(t=>{const e=t._statusBarStatus;if(!e||"connected"===e)return m;const a={initializing:t._t("statusInitializing"),disconnected:t._t("statusReconnecting"),recovering:t._t("statusReconnecting"),failed:t._t("statusFailed"),invalidConfiguration:t._t("statusInvalidConfiguration")}[e]||"";return a?v`
|
|
332
|
+
<div class="status-bar status--${e}" role="status">
|
|
333
|
+
${a}
|
|
334
|
+
</div>
|
|
335
|
+
`:m})(t)}
|
|
336
|
+
<div id="toastify-dismissable-alerts"></div>
|
|
337
|
+
${(t=>"LoaderPage"===t._shownPage?v`
|
|
338
|
+
<div class="page-wrapper" id="loader_page">
|
|
339
|
+
<div class="page-center">
|
|
340
|
+
<div class="lds-dual-ring"></div>
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
`:m)(t)}
|
|
344
|
+
${(t=>{const e=t._isVideoAvatar&&"AvatarPage"===t._shownPage&&(t._isVideoAvatarReconnecting||t._isStartingConversation&&!t._avatarRunning&&!t._isConversationInProgress),a=t._isVideoAvatar&&t._isVideoAvatarIdleDisconnected&&!t._isVideoAvatarReconnecting&&"AvatarPage"===t._shownPage&&t._isConversationInProgress&&!t._isStartingConversation,i=t._isVideoAvatar&&!t._avatarRunning&&"AvatarPage"===t._shownPage;return v`
|
|
345
|
+
<div class="page-wrapper avatar-wrapper" id="avatar-page" ?hidden=${"AvatarPage"!==t._shownPage}>
|
|
346
|
+
<div class="avatarbox">
|
|
347
|
+
<div id="avatar-container" style=${y(t._getAvatarBackgroundStyleObj())}></div>
|
|
348
|
+
${e?v`
|
|
349
|
+
<div class="video-avatar-loading-overlay">
|
|
350
|
+
<div class="lds-dual-ring"></div>
|
|
351
|
+
</div>
|
|
352
|
+
`:m}
|
|
353
|
+
${i?v`
|
|
354
|
+
<div class="video-avatar-placeholder-overlay">
|
|
355
|
+
<div class="video-avatar-placeholder-content">
|
|
356
|
+
${t._videoAvatarPlaceholderImageUrl?v`
|
|
357
|
+
<img
|
|
358
|
+
class="video-avatar-placeholder-image"
|
|
359
|
+
src="${t._videoAvatarPlaceholderImageUrl}"
|
|
360
|
+
alt="${t._avatarName||"Avatar"}"
|
|
361
|
+
@error=${t._handlePlaceholderImageError}
|
|
362
|
+
/>
|
|
363
|
+
<svg class="video-avatar-placeholder-icon video-avatar-placeholder-fallback" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="64" height="64" style="display: none;">
|
|
364
|
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"/>
|
|
365
|
+
</svg>
|
|
366
|
+
`:v`
|
|
367
|
+
<svg class="video-avatar-placeholder-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="64" height="64">
|
|
368
|
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"/>
|
|
369
|
+
</svg>
|
|
370
|
+
`}
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
`:m}
|
|
374
|
+
${a?v`
|
|
375
|
+
<div class="video-avatar-idle-overlay">
|
|
376
|
+
<div class="video-avatar-idle-content">
|
|
377
|
+
<p class="video-avatar-idle-message">${t._t("avatarIdleDisconnected")}</p>
|
|
378
|
+
<button class="video-avatar-reconnect-btn" @click=${t._handleVideoAvatarReconnect}>
|
|
379
|
+
${t._t("reconnectAvatar")}
|
|
380
|
+
</button>
|
|
381
|
+
</div>
|
|
382
|
+
</div>
|
|
383
|
+
`:m}
|
|
384
|
+
${(t=>v`
|
|
385
|
+
${t._isLiveCaptionsVisible&&t._liveCaption&&""!==t._liveCaption.trim()?v`
|
|
386
|
+
<div id="captions-wrapper" class="center-aligned">
|
|
387
|
+
<div class="${"assistant"===t._liveCaptionSpeaker?"assistant-live-caption":"user-live-caption"}" style="direction: ${St(t._liveCaption)?"rtl":"ltr"}" @click="${t._openLastMessage}">
|
|
388
|
+
<div class="caption-content ${t._liveCaption.split(" ").length>5?"long-text":t._liveCaption.length<10?"short-text":""}">
|
|
389
|
+
<span class="${"assistant"===t._liveCaptionSpeaker?"caption-highlight":""}">${t._liveCaption}</span>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
`:m}
|
|
394
|
+
`)(t)}
|
|
395
|
+
${(t=>{const e=t._isConversationInProgress;return v`
|
|
396
|
+
<div class="conversation-buttons-overlay">
|
|
397
|
+
${e?(t=>v`
|
|
398
|
+
<button @click="${t._handleEndConversationBtn}" type="button" title="${t._t("endConversation")}" class="secondary-button stop-button">
|
|
399
|
+
${zt}
|
|
400
|
+
</button>
|
|
401
|
+
`)(t):m}
|
|
402
|
+
${e?(t=>v`
|
|
403
|
+
<button @click="${t._handleRestartConversation}" type="button" class="secondary-button restart-button" id="restart_button" title="${t._t("restartConversation")}">
|
|
404
|
+
${Nt}
|
|
405
|
+
</button>
|
|
406
|
+
`)(t):m}
|
|
407
|
+
${e?(t=>{const e=t._currentMessage,a=e&&"string"==typeof e.messageText&&""!==e.messageText.trim();return v`
|
|
408
|
+
${a?v`
|
|
409
|
+
<div @click="${t._openLastMessage}" class="last-message-button" title="${t._t("lastAssistantMessage")}">
|
|
410
|
+
${Ot}
|
|
411
|
+
</div>
|
|
412
|
+
`:m}
|
|
413
|
+
`})(t):m}
|
|
414
|
+
${(t=>v`
|
|
415
|
+
<div
|
|
416
|
+
@click="${t._handleSwitchToChat}"
|
|
417
|
+
class="switch-chat-button"
|
|
418
|
+
title="${t._t("switchToChat")}"
|
|
419
|
+
aria-label="${t._t("switchToChat")}"
|
|
420
|
+
role="button"
|
|
421
|
+
tabindex="0">
|
|
422
|
+
${Lt}
|
|
423
|
+
</div>
|
|
424
|
+
`)(t)}
|
|
425
|
+
</div>
|
|
426
|
+
`})(t)}
|
|
427
|
+
${t._isVideoAvatar?m:v`
|
|
428
|
+
<div class="body-icons-overlay">
|
|
429
|
+
${t._isFullBody?(t=>v`
|
|
430
|
+
<div id="body-icons-wrapper" class="button-container vertical-icons">
|
|
431
|
+
<div class="icon-button" @click="${t._handleFullBodyIcon}" title="${t._t("fullBodyView")}">
|
|
432
|
+
${Dt}
|
|
433
|
+
</div>
|
|
434
|
+
<div class="icon-button" @click="${t._handleUpperBodyIcon}" title="${t._t("upperBodyView")}">
|
|
435
|
+
${Et}
|
|
436
|
+
</div>
|
|
437
|
+
</div>
|
|
438
|
+
`)(t):m}
|
|
439
|
+
</div>
|
|
440
|
+
`}
|
|
441
|
+
<div class="voice-controls-container">
|
|
442
|
+
${(t=>{const e=t._isVideoAvatar&&!t._isVideoAvatarIdleDisconnected&&(t._isVideoAvatarReconnecting||t._isStartingConversation&&!t._avatarRunning||t._isConversationInProgress&&!t._avatarRunning||t._isConversationPaused&&!t._avatarRunning);if(t._isConversationPaused)return e?v`
|
|
443
|
+
<div class="button-container active-conversation">
|
|
444
|
+
<div class="state-control">
|
|
445
|
+
<div class="voice-visualizer-wrapper">
|
|
446
|
+
<span class="thinking-label">${Kt(t)}</span>
|
|
447
|
+
</div>
|
|
448
|
+
</div>
|
|
449
|
+
</div>
|
|
450
|
+
`:v`
|
|
451
|
+
<div class="button-container active-conversation">
|
|
452
|
+
<div class="state-control">
|
|
453
|
+
${Qt(t)}
|
|
454
|
+
</div>
|
|
455
|
+
</div>
|
|
456
|
+
`;if(t._isConversationInProgress)return e?v`
|
|
457
|
+
<div class="button-container active-conversation">
|
|
458
|
+
<div class="state-control">
|
|
459
|
+
<div class="voice-visualizer-wrapper">
|
|
460
|
+
<span class="thinking-label">${Kt(t)}</span>
|
|
461
|
+
</div>
|
|
462
|
+
</div>
|
|
463
|
+
</div>
|
|
464
|
+
`:v`
|
|
465
|
+
<div class="button-container active-conversation">
|
|
466
|
+
<div class="state-control">
|
|
467
|
+
${Qt(t)}
|
|
468
|
+
</div>
|
|
469
|
+
${t._showTyping?m:v`
|
|
470
|
+
<div
|
|
471
|
+
class="state-control"
|
|
472
|
+
@click="${t._handleToggleTyping}"
|
|
473
|
+
@keydown="${e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t._handleToggleTyping(e))}}"
|
|
474
|
+
title="${t._t("showTyping")}"
|
|
475
|
+
role="button"
|
|
476
|
+
tabindex="0"
|
|
477
|
+
aria-label="${t._t("showTyping")}"
|
|
478
|
+
style="cursor: pointer;"
|
|
479
|
+
>
|
|
480
|
+
${qt}
|
|
481
|
+
</div>
|
|
482
|
+
`}
|
|
483
|
+
</div>
|
|
484
|
+
${t._showTyping?(t=>{const e=!!t._inputsBlocked||!!t._isThinking||!!t._isStartingConversation,a=t._isConversationPaused?t._t("reconnecting"):e?t._t("waitForResponse"):t._t("typeHere");return v`
|
|
485
|
+
<div class="typing-input ${e?"input-blocked":""}">
|
|
486
|
+
<div class="close-input-button" @click="${t._handleToggleTyping}" aria-label="Close typing input" role="button">
|
|
487
|
+
${Vt}
|
|
488
|
+
</div>
|
|
489
|
+
${e?v`
|
|
490
|
+
<div class="input-loading-dots">
|
|
491
|
+
<div class="dot"></div>
|
|
492
|
+
<div class="dot"></div>
|
|
493
|
+
<div class="dot"></div>
|
|
494
|
+
</div>
|
|
495
|
+
`:m}
|
|
496
|
+
<textarea
|
|
497
|
+
@keyup="${t._handleTypingKeyUp}"
|
|
498
|
+
type="text"
|
|
499
|
+
id="typed_input"
|
|
500
|
+
placeholder="${a}"
|
|
501
|
+
?disabled="${e}"
|
|
502
|
+
></textarea>
|
|
503
|
+
<div
|
|
504
|
+
@click="${t._handleSendTypedInput}"
|
|
505
|
+
id="typing_send_button"
|
|
506
|
+
class="${e?"send-button-disabled":""}"
|
|
507
|
+
>
|
|
508
|
+
${Bt}
|
|
509
|
+
</div>
|
|
510
|
+
</div>
|
|
511
|
+
`})(t):m}
|
|
512
|
+
`;if(t._isCheckingResume||t._isAutoResuming)return t._isVideoAvatar?v`
|
|
513
|
+
<div class="button-container active-conversation">
|
|
514
|
+
<div class="state-control">
|
|
515
|
+
<div class="voice-visualizer-wrapper">
|
|
516
|
+
<span class="thinking-label">${Kt(t)}</span>
|
|
517
|
+
</div>
|
|
518
|
+
</div>
|
|
519
|
+
</div>
|
|
520
|
+
`:m;const a=t._speakingAvatar?.connectionManager;return a?.connectionModules&&Object.values(a.connectionModules).some((t=>t.isFailed()))?Wt(t):Gt(t)})(t)}
|
|
521
|
+
</div>
|
|
522
|
+
</div>
|
|
523
|
+
</div>
|
|
524
|
+
`})(t)}
|
|
525
|
+
${(t=>{let e,a="";const i=t._isStartingConversation,n=t._isInitializingConversation,s=t._isConversationInProgress,o=t._isConversationPaused,r=t._isAutoResuming;return i||n||r?(e=v`
|
|
526
|
+
<div class="chat-start-container center-aligned">
|
|
527
|
+
<div class="lds-dual-ring small"></div>
|
|
528
|
+
</div>`,a="center-aligned"):s||o?e=v`
|
|
529
|
+
<ul class="chatbox">
|
|
530
|
+
${t._conversationTranscript.length?t._conversationTranscript.map((t=>((t,{speaker:e,messageText:a,time:i})=>{const n=St(a)?"rtl":"ltr",s="rtl"===n?"right":"left",o="rtl"===n?"time-left":"time-right",r="assistant"===e?w(It(a)):a;return v`
|
|
531
|
+
<li class="chat ${e}">
|
|
532
|
+
${"assistant"===e?$t:""}
|
|
533
|
+
<div style="direction: ${n}; text-align: ${s}" class="message-container">
|
|
534
|
+
<div class="message-bubble ${"assistant"===e?"md-formatted":""}" style="word-wrap: break-word; word-break: break-word;">${r}</div>
|
|
535
|
+
<small class="message-time ${o}">${i}</small>
|
|
536
|
+
</div>
|
|
537
|
+
</li>
|
|
538
|
+
`})(0,t))):(t=>v`<h3 id="no-msgs-head">${t._t("noMessagesYet")}</h3>`)(t)}
|
|
539
|
+
</ul>
|
|
540
|
+
${(t=>{const e=!!t._inputsBlocked||!!t._isThinking||!!t._isStartingConversation,a=t._isConversationPaused?t._t("reconnecting"):e?t._t("waitForResponse"):t._t("typeHere");return v`
|
|
541
|
+
<div class="chat-input ${e?"input-blocked":""}">
|
|
542
|
+
${e?v`
|
|
543
|
+
<div class="input-loading-dots">
|
|
544
|
+
<div class="dot"></div>
|
|
545
|
+
<div class="dot"></div>
|
|
546
|
+
<div class="dot"></div>
|
|
547
|
+
</div>
|
|
548
|
+
`:m}
|
|
549
|
+
<textarea
|
|
550
|
+
@keyup="${t._handleChatKeyUp}"
|
|
551
|
+
type="text"
|
|
552
|
+
id="message_input"
|
|
553
|
+
placeholder="${a}"
|
|
554
|
+
?disabled="${e}"
|
|
555
|
+
></textarea>
|
|
556
|
+
<div
|
|
557
|
+
@click="${t._handleSendTextMessage}"
|
|
558
|
+
id="chat_send_button"
|
|
559
|
+
class="${e?"send-button-disabled":""}"
|
|
560
|
+
>
|
|
561
|
+
${Bt}
|
|
562
|
+
</div>
|
|
563
|
+
</div>
|
|
564
|
+
`})(t)}
|
|
565
|
+
`:(e=v`
|
|
566
|
+
<div class="chat-placeholder-container">
|
|
567
|
+
<div class="chat-placeholder-content">
|
|
568
|
+
<div class="chat-placeholder-icon">
|
|
569
|
+
${Rt}
|
|
570
|
+
</div>
|
|
571
|
+
<h3 class="chat-placeholder-title">${t._t("chatPlaceholderTitle")}</h3>
|
|
572
|
+
<p class="chat-placeholder-description">${t._t("chatPlaceholderDescription")}</p>
|
|
573
|
+
</div>
|
|
574
|
+
<div class="chat-placeholder-button">
|
|
575
|
+
${Gt(t)}
|
|
576
|
+
</div>
|
|
577
|
+
</div>`,a="placeholder-mode"),v`
|
|
578
|
+
<div class="page-wrapper" id="chat-page" ?hidden=${"ChatPage"!==t._shownPage}>
|
|
579
|
+
<div class="chat-wrapper ${a}">
|
|
580
|
+
${(t=>v`
|
|
581
|
+
<button
|
|
582
|
+
@click="${t._handleBackToAvatar}"
|
|
583
|
+
class="floating-avatar-button"
|
|
584
|
+
title="${t._t("switchToAvatar")}"
|
|
585
|
+
aria-label="${t._t("switchToAvatar")}"
|
|
586
|
+
>
|
|
587
|
+
${Dt}
|
|
588
|
+
</button>
|
|
589
|
+
`)(t)}
|
|
590
|
+
${e}
|
|
591
|
+
</div>
|
|
592
|
+
</div>
|
|
593
|
+
`})(t)}
|
|
594
|
+
${(t=>"ErrorPage"===t._shownPage?v`
|
|
595
|
+
<div class="page-wrapper" id="error_page">
|
|
596
|
+
<div class="page-center">
|
|
597
|
+
${Ut}
|
|
598
|
+
</div>
|
|
599
|
+
</div>
|
|
600
|
+
`:m)(t)}
|
|
601
|
+
${(t=>"DisconnectedPage"===t._shownPage?v`
|
|
602
|
+
<div class="page-wrapper" id="disconnected_page">
|
|
603
|
+
<div class="page-center">
|
|
604
|
+
${Wt(t)}
|
|
605
|
+
</div>
|
|
606
|
+
</div>
|
|
607
|
+
`:m)(t)}
|
|
608
|
+
</div>
|
|
609
|
+
${"mobile"===t.target_app||t.compact?m:(t=>{const e=t.brand_name||"Sentifyd",a=!!t.brand_name;return v`
|
|
610
|
+
<footer>
|
|
611
|
+
${a?v`<small>${e}</small>`:v`<small><a href="https://sentifyd.io" target="_blank">Sentifyd</a></small>`}
|
|
612
|
+
</footer>
|
|
613
|
+
`})(t)}
|
|
614
|
+
${(t=>t._showLastMessage?v`
|
|
615
|
+
<div class="last-message" @click="${t._closeLastMessage}">
|
|
616
|
+
<div class="last-message-content">
|
|
617
|
+
<div style="direction: ${St(t._lastMessageText)?"rtl":"ltr"}" class="last-message-scrollable md-formatted">
|
|
618
|
+
${w(It(t._lastMessageText))}
|
|
619
|
+
<button class="last-message-copy-button" @click="${e=>((t,e)=>{t.stopPropagation();const a=e._lastMessageText;a&&navigator.clipboard.writeText(a).then((()=>{e._showCopyTick=!0,setTimeout((()=>{e._showCopyTick=!1}),1500)})).catch((t=>{}))})(e,t)}">
|
|
620
|
+
${t._showCopyTick?jt:Ht}
|
|
621
|
+
</button>
|
|
622
|
+
</div>
|
|
623
|
+
</div>
|
|
624
|
+
</div>
|
|
625
|
+
`:m)(t)}
|
|
626
|
+
${(t=>t._showConfirmationDialog?v`
|
|
627
|
+
<div class="dialog-overlay">
|
|
628
|
+
<div class="dialog">
|
|
629
|
+
|
|
630
|
+
<p>${t._dialogMessage}</p>
|
|
631
|
+
<div class="dialog-button-wrapper">
|
|
632
|
+
<button class="confirm-button" @click="${t._handleConfirm}">${t._confirmButtonLabel}</button>
|
|
633
|
+
<button class="cancel-button" @click="${t._handleCancel}">${t._cancelButtonLabel}</button>
|
|
634
|
+
</div>
|
|
635
|
+
</div>
|
|
636
|
+
</div>
|
|
637
|
+
`:m)(t)}
|
|
638
|
+
${(t=>t._showUserData?v`
|
|
639
|
+
<div class="dialog-overlay">
|
|
640
|
+
<div class="dialog">
|
|
641
|
+
<h3>${t._t("secureFormTitle")}</h3>
|
|
642
|
+
<p>${t._t("secureFormDescription")}</p>
|
|
643
|
+
<div class="form-group">
|
|
644
|
+
<label for="username">${t._t("name")}</label>
|
|
645
|
+
<input @input="${e=>t.username=e.target.value}" type="text" id="username" placeholder="${t._t("namePlaceholder")}" .value=${t.username} required>
|
|
646
|
+
</div>
|
|
647
|
+
<div class="form-group">
|
|
648
|
+
<label for="email">${t._t("email")}*</label>
|
|
649
|
+
<input @input="${e=>t.email=e.target.value}" type="email" id="email" placeholder="${t._t("emailPlaceholder")}" .value=${t.email} required>
|
|
650
|
+
</div>
|
|
651
|
+
<div class="form-group">
|
|
652
|
+
<label for="phoneNumber">${t._t("phoneNumber")}</label>
|
|
653
|
+
<input @input="${e=>t.phoneNumber=e.target.value}" type="tel" id="phoneNumber" placeholder="${t._t("phonePlaceholder")}" .value=${t.phoneNumber}>
|
|
654
|
+
</div>
|
|
655
|
+
<div> <p style="font-size: 0.8em;">${t._t("secureFormNote")}</p></div>
|
|
656
|
+
<div class="dialog-button-group" style="text-align: start;">
|
|
657
|
+
<button class="button-save" @click="${t._handleSaveClick}" type="button" ?disabled="${!t.username?.trim()||!t.email?.trim()}">${t._t("send")}</button>
|
|
658
|
+
<button class="button-cancel" @click="${t._handleCancelClick}">${t._t("cancel")}</button>
|
|
659
|
+
</div>
|
|
660
|
+
</div>
|
|
661
|
+
</div>
|
|
662
|
+
`:m)(t)}
|
|
663
|
+
${(t=>t._showSatisfactionScore?v`
|
|
664
|
+
<div class="dialog-overlay">
|
|
665
|
+
<div class="dialog">
|
|
666
|
+
<p>${t._t("conversationEndedPrompt")}</p>
|
|
667
|
+
<div class="radio-group">
|
|
668
|
+
${[1,2,3,4,5].map((e=>v`
|
|
669
|
+
<label class="radio-label">
|
|
670
|
+
<input
|
|
671
|
+
class="radio-input"
|
|
672
|
+
type="radio"
|
|
673
|
+
name="satisfactionScore"
|
|
674
|
+
value="${e}"
|
|
675
|
+
@change="${e=>t._satisfactionScore=parseInt(e.target.value)}"
|
|
676
|
+
?checked="${t._satisfactionScore===e}"
|
|
677
|
+
/>
|
|
678
|
+
${e}
|
|
679
|
+
</label>
|
|
680
|
+
`))}
|
|
681
|
+
</div>
|
|
682
|
+
<div class="dialog-button-group">
|
|
683
|
+
<button
|
|
684
|
+
class="button-save"
|
|
685
|
+
@click="${t._handleSubmitScoreClick}"
|
|
686
|
+
type="button"
|
|
687
|
+
?disabled="${null==t._satisfactionScore}"
|
|
688
|
+
>
|
|
689
|
+
${t._t("submit")}
|
|
690
|
+
</button>
|
|
691
|
+
<button class="button-cancel" @click="${t._handleCancelScoreClick}">
|
|
692
|
+
${t._t("skip")}
|
|
693
|
+
</button>
|
|
694
|
+
</div>
|
|
695
|
+
</div>
|
|
696
|
+
</div>
|
|
697
|
+
`:m)(t)}
|
|
698
|
+
${(t=>t._showChatConsentDialog?v`
|
|
699
|
+
<div class="dialog-overlay">
|
|
700
|
+
<div class="dialog consent-dialog" role="dialog" aria-modal="true" aria-labelledby="chat-consent-title">
|
|
701
|
+
<p id="chat-consent-title" class="label"><b>${t._t("consentTitle")}</b></p>
|
|
702
|
+
<div class="consent-text scrollable" tabindex="0" aria-label="${t._t("consentScrollableAria")||t._t("consentTitle")}">
|
|
703
|
+
<p>${t._t("consentInfo1")}</p>
|
|
704
|
+
<p>${t._t("consentInfo2")}</p>
|
|
705
|
+
<p>
|
|
706
|
+
${t._t("consentReadOur")}
|
|
707
|
+
<a href="${t.terms_href}" target="_blank" rel="noopener noreferrer">${t._t("consentTermsLabel")}</a>
|
|
708
|
+
${t._t("consentAnd")}
|
|
709
|
+
<a href="${t.privacy_href}" target="_blank" rel="noopener noreferrer">${t._t("consentPrivacyLabel")}</a>
|
|
710
|
+
${t._t("consentMoreDetails")}
|
|
711
|
+
</p>
|
|
712
|
+
<p><small>${t._t("consentInfo4")}</small></p>
|
|
713
|
+
</div>
|
|
714
|
+
<div class="dialog-button-group" style="text-align: center;">
|
|
715
|
+
<button class="button-save" aria-label="${t._t("consentAcceptAria")}" @click="${t._handleConsentAccept}" type="button">${t._t("consentAccept")}</button>
|
|
716
|
+
<button class="button-cancel" aria-label="${t._t("consentDeclineAria")}" @click="${t._handleConsentDecline}" type="button">${t._t("consentDecline")}</button>
|
|
717
|
+
</div>
|
|
718
|
+
</div>
|
|
719
|
+
</div>`:m)(t)}
|
|
720
|
+
</div>
|
|
721
|
+
</div>
|
|
722
|
+
</div>
|
|
723
|
+
`,Xt=b`
|
|
724
|
+
|
|
725
|
+
:host {
|
|
726
|
+
--z-chatbot: 100; /* the widget panel */
|
|
727
|
+
--z-toggler: 110; /* floating open/close button (outside .chatbot) */
|
|
728
|
+
|
|
729
|
+
--z-controls: 200; /* in-widget controls over the canvas (buttons/icons) */
|
|
730
|
+
--z-status: 600; /* inline status bar at top of .chatbot-body */
|
|
731
|
+
--z-toasts: 700; /* dismissable alerts above status, below menus/modals */
|
|
732
|
+
|
|
733
|
+
--z-menu-backdrop: 1100; /* menu scrim (header) - below modal */
|
|
734
|
+
--z-menu: 1150; /* menu panel - below modal */
|
|
735
|
+
|
|
736
|
+
--z-overlay: 1200; /* modal backdrops (last-message, dialogs) - topmost */
|
|
737
|
+
/* modal content uses overlay+1 */
|
|
738
|
+
|
|
739
|
+
width: 100%;
|
|
740
|
+
height: 100%;
|
|
741
|
+
display: block;
|
|
742
|
+
|
|
743
|
+
font-size: 16px;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/* Prevent flash of icon text (FOUT) for ligature-based Material Icons */
|
|
747
|
+
:host(:not(.icons-ready)) .material-icons {
|
|
748
|
+
/* Keep layout space but hide fallback text until the icon font loads */
|
|
749
|
+
visibility: hidden;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
.material-icons {
|
|
753
|
+
font-family: 'Material Icons';
|
|
754
|
+
font-weight: normal;
|
|
755
|
+
font-style: normal;
|
|
756
|
+
font-size: 24px;
|
|
757
|
+
display: inline-block;
|
|
758
|
+
line-height: 1;
|
|
759
|
+
text-transform: none;
|
|
760
|
+
letter-spacing: normal;
|
|
761
|
+
word-wrap: normal;
|
|
762
|
+
white-space: nowrap;
|
|
763
|
+
direction: ltr;
|
|
764
|
+
|
|
765
|
+
/* Optional: use this for better rendering */
|
|
766
|
+
-webkit-font-smoothing: antialiased;
|
|
767
|
+
text-rendering: optimizeLegibility;
|
|
768
|
+
-moz-osx-font-smoothing: grayscale;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
* {
|
|
772
|
+
margin: 0;
|
|
773
|
+
padding: 0;
|
|
774
|
+
box-sizing: border-box;
|
|
775
|
+
font-family: "Poppins", sans-serif;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
[hidden] {
|
|
779
|
+
display: none;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.center-text {
|
|
783
|
+
text-align: center;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.center-aligned {
|
|
787
|
+
display: flex;
|
|
788
|
+
justify-content: center;
|
|
789
|
+
align-items: center;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
.btn {
|
|
793
|
+
margin-right: 10px;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
.page-wrapper {
|
|
797
|
+
width: 100%;
|
|
798
|
+
height: 100%;
|
|
799
|
+
flex-grow: 1;
|
|
800
|
+
min-height: 0;
|
|
801
|
+
display: flex;
|
|
802
|
+
flex-direction: column;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
.page-wrapper[hidden] {
|
|
806
|
+
display: none !important;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
.page-center {
|
|
811
|
+
margin-top: 150px;
|
|
812
|
+
text-align: center;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
.lds-dual-ring {
|
|
816
|
+
display: inline-block;
|
|
817
|
+
width: 80px;
|
|
818
|
+
height: 80px;
|
|
819
|
+
margin-left: auto;
|
|
820
|
+
margin-right: auto;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
.lds-dual-ring:after {
|
|
824
|
+
content: " ";
|
|
825
|
+
display: block;
|
|
826
|
+
width: 64px;
|
|
827
|
+
height: 64px;
|
|
828
|
+
margin: 8px;
|
|
829
|
+
border-radius: 50%;
|
|
830
|
+
border: 6px solid var(--secondary-color, #801bea);
|
|
831
|
+
border-color: var(--secondary-color, #801bea) transparent var(--secondary-color, #801bea) transparent;
|
|
832
|
+
animation: lds-dual-ring 1.2s linear infinite;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
.lds-dual-ring.small {
|
|
836
|
+
width: 40px;
|
|
837
|
+
height: 40px;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.lds-dual-ring.small:after {
|
|
841
|
+
width: 32px;
|
|
842
|
+
height: 32px;
|
|
843
|
+
margin: 4px;
|
|
844
|
+
border-width: 4px;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
@keyframes lds-dual-ring {
|
|
848
|
+
0% {
|
|
849
|
+
transform: rotate(0deg);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
100% {
|
|
853
|
+
transform: rotate(360deg);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
.error-icon {
|
|
858
|
+
color: #f8d7da;
|
|
859
|
+
font-size: 96px;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
.test-mode-states {
|
|
863
|
+
display: flex;
|
|
864
|
+
flex-direction: column;
|
|
865
|
+
justify-content: center;
|
|
866
|
+
height: 100%;
|
|
867
|
+
margin: 20px;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
`,Zt=b`
|
|
871
|
+
#chatbot-container {
|
|
872
|
+
height: 100%;
|
|
873
|
+
width: 100%;
|
|
874
|
+
max-height: 100vh;
|
|
875
|
+
max-width: 100vw;
|
|
876
|
+
margin: 0;
|
|
877
|
+
padding: 0;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/* Test mode: show module/states panel beside chatbot (embedded only) */
|
|
881
|
+
#chatbot-container.embedded .chatbot-layout.with-test-stats {
|
|
882
|
+
display: flex;
|
|
883
|
+
align-items: stretch;
|
|
884
|
+
justify-content: center;
|
|
885
|
+
gap: 12px;
|
|
886
|
+
width: 100%;
|
|
887
|
+
height: 100%;
|
|
888
|
+
box-sizing: border-box;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
#chatbot-container.embedded .chatbot-layout.with-test-stats .test-mode-states {
|
|
892
|
+
flex: 0 0 min(340px, 45%);
|
|
893
|
+
max-height: 100%;
|
|
894
|
+
overflow: auto;
|
|
895
|
+
margin: 0;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
#chatbot-toggler {
|
|
899
|
+
position: fixed;
|
|
900
|
+
bottom: 30px;
|
|
901
|
+
right: 35px;
|
|
902
|
+
outline: none;
|
|
903
|
+
border: none;
|
|
904
|
+
height: 72px; /* slightly larger for better visibility */
|
|
905
|
+
width: 72px; /* slightly larger for better visibility */
|
|
906
|
+
display: flex;
|
|
907
|
+
cursor: pointer;
|
|
908
|
+
align-items: center;
|
|
909
|
+
justify-content: center;
|
|
910
|
+
border-radius: 50%;
|
|
911
|
+
background: var(--secondary-color, #801bea);
|
|
912
|
+
color: var(--text-color-secondary-bg, #fff); /* controls inline SVG/logo and close icon color */
|
|
913
|
+
transition: all 0.2s ease;
|
|
914
|
+
z-index: var(--z-toggler);
|
|
915
|
+
user-select: none; /* avoid text selection */
|
|
916
|
+
-webkit-user-select: none;
|
|
917
|
+
-ms-user-select: none;
|
|
918
|
+
-moz-user-select: none;
|
|
919
|
+
caret-color: transparent; /* hide blinking caret when focused */
|
|
920
|
+
-webkit-tap-highlight-color: transparent; /* remove mobile tap highlight */
|
|
921
|
+
-webkit-appearance: none;
|
|
922
|
+
-moz-appearance: none;
|
|
923
|
+
appearance: none;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
#chatbot-container.show-chatbot #chatbot-toggler {
|
|
927
|
+
transform: rotate(90deg);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/* Center immediate children (icon and close glyph) and disable pointer events on them */
|
|
931
|
+
#chatbot-toggler > * {
|
|
932
|
+
position: absolute;
|
|
933
|
+
pointer-events: none; /* ensure clicks hit the button, not the icon/svg */
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/* Material icon sizing (close icon) */
|
|
937
|
+
#chatbot-toggler > span {
|
|
938
|
+
color: currentColor; /* inherit from button color variable */
|
|
939
|
+
font-size: 34px; /* scale icon with larger button */
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/* Size the inline SVG logo to fit the button */
|
|
943
|
+
#chatbot-toggler > svg {
|
|
944
|
+
width: var(--toggler-icon-size, 38px);
|
|
945
|
+
height: var(--toggler-icon-size, 38px);
|
|
946
|
+
display: block;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
#chatbot-toggler > :last-child,
|
|
951
|
+
#chatbot-container.show-chatbot #chatbot-toggler > :first-child {
|
|
952
|
+
opacity: 0;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
#chatbot-container.show-chatbot #chatbot-toggler > :last-child {
|
|
956
|
+
opacity: 1;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
.chatbot {
|
|
960
|
+
position: fixed;
|
|
961
|
+
right: 35px;
|
|
962
|
+
bottom: 112px; /* toggler bottom (30) + toggler size (72) + 10px clearance */
|
|
963
|
+
max-height: var(--chatbot-max-height, calc(100vh - 100px));
|
|
964
|
+
background: #F8F8FF;
|
|
965
|
+
border-radius: var(--corner-radius, 15px);
|
|
966
|
+
overflow: hidden;
|
|
967
|
+
opacity: 0;
|
|
968
|
+
pointer-events: none;
|
|
969
|
+
transform: scale(0.5);
|
|
970
|
+
transform-origin: bottom right;
|
|
971
|
+
box-shadow: 0 0 128px 0 rgba(0, 0, 0, 0.1), 0 32px 64px -48px rgba(0, 0, 0, 0.5);
|
|
972
|
+
transition: all 0.1s ease;
|
|
973
|
+
z-index: var(--z-chatbot);
|
|
974
|
+
display: flex;
|
|
975
|
+
flex-direction: column;
|
|
976
|
+
align-items: center;
|
|
977
|
+
/* width/height are now set inline by JS; allow flex to handle internals */
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/* Global cursor policy inside chatbot: default everywhere, text only in inputs, pointer for clickable */
|
|
981
|
+
.chatbot :where(*) {
|
|
982
|
+
cursor: default;
|
|
983
|
+
caret-color: transparent; /* hide blinking caret by default */
|
|
984
|
+
}
|
|
985
|
+
.chatbot :where(input, textarea) {
|
|
986
|
+
cursor: text;
|
|
987
|
+
caret-color: auto; /* allow caret in real text fields */
|
|
988
|
+
}
|
|
989
|
+
.chatbot :where(button, a, [role="button"], .clickable, .voice-visualizer, .restart-button, .stop-button, .last-message-button, .input-toggle-button, .close-icon, .menu-icon, #chat_send_button, #typing_send_button) {
|
|
990
|
+
cursor: pointer;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
#chatbot-container.show-chatbot .chatbot {
|
|
995
|
+
opacity: 1;
|
|
996
|
+
pointer-events: auto;
|
|
997
|
+
transform: scale(1);
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
#chatbot-container.embedded .chatbot {
|
|
1001
|
+
position: relative;
|
|
1002
|
+
right: 0;
|
|
1003
|
+
bottom: 0;
|
|
1004
|
+
transform: scale(1);
|
|
1005
|
+
opacity: 1;
|
|
1006
|
+
pointer-events: auto;
|
|
1007
|
+
z-index: auto;
|
|
1008
|
+
width: 100%;
|
|
1009
|
+
height: 100%;
|
|
1010
|
+
max-height: 100%;
|
|
1011
|
+
min-height: 420px; /* safety: ensures decent space before JS computes height */
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
#chatbot-container .chatbot.mobile {
|
|
1015
|
+
position: fixed;
|
|
1016
|
+
top: var(--chatbot-dynamic-top, 0) !important;
|
|
1017
|
+
right: 0;
|
|
1018
|
+
bottom: auto;
|
|
1019
|
+
left: 0;
|
|
1020
|
+
margin: 0 !important;
|
|
1021
|
+
width: 100vw !important;
|
|
1022
|
+
max-width: 100vw !important;
|
|
1023
|
+
/* Fallback to dynamic height CSS var when dvh unsupported */
|
|
1024
|
+
height: calc(var(--chatbot-dynamic-height, 100vh) - var(--chatbot-bottom-offset, 0px)) !important;
|
|
1025
|
+
max-height: calc(var(--chatbot-dynamic-height, 100vh) - var(--chatbot-bottom-offset, 0px)) !important;
|
|
1026
|
+
/* Prefer dvh for accurate viewport height on mobile */
|
|
1027
|
+
height: calc(100dvh - var(--chatbot-bottom-offset, 0px)) !important;
|
|
1028
|
+
max-height: calc(100dvh - var(--chatbot-bottom-offset, 0px)) !important;
|
|
1029
|
+
border-radius: 0;
|
|
1030
|
+
transform: none !important;
|
|
1031
|
+
opacity: 1;
|
|
1032
|
+
pointer-events: auto;
|
|
1033
|
+
z-index: var(--z-chatbot);
|
|
1034
|
+
overflow: hidden;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
#chatbot-container .chatbot.page {
|
|
1038
|
+
position: fixed;
|
|
1039
|
+
height: 100%;
|
|
1040
|
+
max-height: 100vh !important;
|
|
1041
|
+
border-radius: 0;
|
|
1042
|
+
transform: none;
|
|
1043
|
+
opacity: 1;
|
|
1044
|
+
pointer-events: auto;
|
|
1045
|
+
z-index: var(--z-chatbot);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
.chatbot :where(.avatarbox, .chatbox, .chatbot-body, textarea, .last-message-content)::-webkit-scrollbar {
|
|
1049
|
+
width: 6px;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
.chatbot :where(.avatarbox, .chatbox, .chatbot-body, textarea, .last-message-content)::-webkit-scrollbar-track {
|
|
1053
|
+
background: #fff;
|
|
1054
|
+
border-radius: 25px;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
.chatbot :where(.avatarbox, .chatbox, .chatbot-body, textarea, .last-message-content)::-webkit-scrollbar-thumb {
|
|
1058
|
+
background: #ccc;
|
|
1059
|
+
border-radius: 25px;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
.chatbot-body {
|
|
1063
|
+
width: 100%;
|
|
1064
|
+
height: 100%;
|
|
1065
|
+
overflow-y: auto;
|
|
1066
|
+
overflow-x: hidden;
|
|
1067
|
+
min-height: 0;
|
|
1068
|
+
flex-grow: 1;
|
|
1069
|
+
position: relative;
|
|
1070
|
+
display: flex;
|
|
1071
|
+
flex-direction: column;
|
|
1072
|
+
/* align-items: center;*/
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
.chatbot-body.chat-mode, .chatbot-body.compact {
|
|
1076
|
+
overflow-y: auto;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
.chatbot-body.mobile {
|
|
1080
|
+
height: 100%;
|
|
1081
|
+
width: 100%;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
@media (max-width: 768px) {
|
|
1085
|
+
#chatbot-toggler {
|
|
1086
|
+
right: 20px;
|
|
1087
|
+
bottom: 20px;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
#chatbot-container.show-chatbot #chatbot-toggler {
|
|
1091
|
+
display: none !important;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
#chatbot-container.show-chatbot:not(.embedded) .chatbot {
|
|
1095
|
+
position: fixed;
|
|
1096
|
+
top: var(--chatbot-dynamic-top, 0);
|
|
1097
|
+
left: 0;
|
|
1098
|
+
bottom: auto;
|
|
1099
|
+
width: 100vw;
|
|
1100
|
+
/* Fallback to dynamic height CSS var when dvh unsupported */
|
|
1101
|
+
height: calc(var(--chatbot-dynamic-height, 100vh) - var(--chatbot-bottom-offset, 0px));
|
|
1102
|
+
max-height: calc(var(--chatbot-dynamic-height, 100vh) - var(--chatbot-bottom-offset, 0px));
|
|
1103
|
+
/* Prefer dvh; provide fallback CSS var */
|
|
1104
|
+
height: calc(100dvh - var(--chatbot-bottom-offset, 0px));
|
|
1105
|
+
max-height: calc(100dvh - var(--chatbot-bottom-offset, 0px));
|
|
1106
|
+
border-radius: 0;
|
|
1107
|
+
transform: none;
|
|
1108
|
+
display: flex;
|
|
1109
|
+
flex-direction: column;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
#chatbot-container.embedded .chatbot {
|
|
1113
|
+
position: relative;
|
|
1114
|
+
width: 100%;
|
|
1115
|
+
height: 100%;
|
|
1116
|
+
max-width: 100%;
|
|
1117
|
+
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
.chatbot-body {
|
|
1121
|
+
flex-grow: 1;
|
|
1122
|
+
min-height: 0;
|
|
1123
|
+
width: 100%;
|
|
1124
|
+
overflow-y: auto;
|
|
1125
|
+
overflow-x: hidden;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/* Landscape small screens (mobile/tablet rotated) - also use full screen */
|
|
1131
|
+
@media (max-height: 500px) and (min-width: 769px) {
|
|
1132
|
+
#chatbot-container.show-chatbot #chatbot-toggler {
|
|
1133
|
+
display: none !important;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
#chatbot-container.show-chatbot:not(.embedded) .chatbot {
|
|
1137
|
+
position: fixed;
|
|
1138
|
+
top: var(--chatbot-dynamic-top, 0);
|
|
1139
|
+
left: 0;
|
|
1140
|
+
bottom: auto;
|
|
1141
|
+
right: 0;
|
|
1142
|
+
width: 100vw;
|
|
1143
|
+
height: calc(var(--chatbot-dynamic-height, 100vh) - var(--chatbot-bottom-offset, 0px));
|
|
1144
|
+
max-height: calc(var(--chatbot-dynamic-height, 100vh) - var(--chatbot-bottom-offset, 0px));
|
|
1145
|
+
height: calc(100dvh - var(--chatbot-bottom-offset, 0px));
|
|
1146
|
+
max-height: calc(100dvh - var(--chatbot-bottom-offset, 0px));
|
|
1147
|
+
border-radius: 0;
|
|
1148
|
+
transform: none;
|
|
1149
|
+
display: flex;
|
|
1150
|
+
flex-direction: column;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
`,Jt=b`
|
|
1155
|
+
.chatbot header {
|
|
1156
|
+
padding: 16px 0;
|
|
1157
|
+
text-align: center;
|
|
1158
|
+
color: #fff;
|
|
1159
|
+
background: var(--secondary-color, #801bea);
|
|
1160
|
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
1161
|
+
flex: none;
|
|
1162
|
+
width: 100%;
|
|
1163
|
+
min-height: 90px;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
.chatbot header .header-container {
|
|
1167
|
+
display: flex;
|
|
1168
|
+
justify-content: space-between;
|
|
1169
|
+
align-items: end;
|
|
1170
|
+
width: 100%;
|
|
1171
|
+
margin: 0 auto;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
.chatbot header .header-left, .chatbot header .header-right {
|
|
1175
|
+
margin: 10px;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
.header-right {
|
|
1179
|
+
display: flex;
|
|
1180
|
+
flex-direction: column;
|
|
1181
|
+
justify-content: flex-start;
|
|
1182
|
+
align-items: end;
|
|
1183
|
+
gap: 10px;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
#avatar-name {
|
|
1187
|
+
font-size: 18px;
|
|
1188
|
+
margin-bottom: 10px;
|
|
1189
|
+
color: var(--text-color-secondary-bg, white);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
.logo-image {
|
|
1193
|
+
max-height: 30px;
|
|
1194
|
+
/* Maximum height for the logo */
|
|
1195
|
+
width: auto;
|
|
1196
|
+
/* Maintain aspect ratio */
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
.header-right .close-icon {
|
|
1200
|
+
cursor: pointer;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/* Close button in header - hidden by default, shown on small screens when toggler mode */
|
|
1204
|
+
.header-close-icon {
|
|
1205
|
+
display: none;
|
|
1206
|
+
cursor: pointer;
|
|
1207
|
+
color: var(--text-color-secondary-bg, white);
|
|
1208
|
+
padding: 4px;
|
|
1209
|
+
border-radius: 4px;
|
|
1210
|
+
transition: background-color 0.2s ease;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
.header-close-icon:hover {
|
|
1214
|
+
background-color: rgba(255, 255, 255, 0.15);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
.header-close-icon:focus {
|
|
1218
|
+
outline: 2px solid rgba(255, 255, 255, 0.5);
|
|
1219
|
+
outline-offset: 2px;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/* Show close button on small screens */
|
|
1223
|
+
@media (max-width: 768px) {
|
|
1224
|
+
.chatbot header {
|
|
1225
|
+
padding: 6px 0;
|
|
1226
|
+
min-height: 52px;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
.chatbot header .header-container {
|
|
1230
|
+
align-items: center;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
.chatbot header .header-left, .chatbot header .header-right {
|
|
1234
|
+
margin: 6px;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
.header-right {
|
|
1238
|
+
gap: 6px;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
#avatar-name {
|
|
1242
|
+
font-size: 16px;
|
|
1243
|
+
margin-bottom: 0;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
.logo-image {
|
|
1247
|
+
max-height: 24px;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
.header-close-icon {
|
|
1251
|
+
display: flex;
|
|
1252
|
+
align-items: center;
|
|
1253
|
+
justify-content: center;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/* Show close button on landscape small screens (mobile/tablet rotated) */
|
|
1258
|
+
@media (max-height: 500px) and (min-width: 769px) {
|
|
1259
|
+
.chatbot header {
|
|
1260
|
+
padding: 6px 0;
|
|
1261
|
+
min-height: 52px;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
.chatbot header .header-container {
|
|
1265
|
+
align-items: center;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
.chatbot header .header-left, .chatbot header .header-right {
|
|
1269
|
+
margin: 6px;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
.header-right {
|
|
1273
|
+
gap: 6px;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
#avatar-name {
|
|
1277
|
+
font-size: 16px;
|
|
1278
|
+
margin-bottom: 0;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
.logo-image {
|
|
1282
|
+
max-height: 24px;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
.header-close-icon {
|
|
1286
|
+
display: flex;
|
|
1287
|
+
align-items: center;
|
|
1288
|
+
justify-content: center;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.header-left .menu-icon {
|
|
1293
|
+
display: block;
|
|
1294
|
+
cursor: pointer;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
/* menu */
|
|
1299
|
+
|
|
1300
|
+
.menu-backdrop {
|
|
1301
|
+
position: fixed;
|
|
1302
|
+
top: 0;
|
|
1303
|
+
bottom: 0;
|
|
1304
|
+
left: 0;
|
|
1305
|
+
right: 0;
|
|
1306
|
+
/* Backdrop should sit above alerts and status bar but below the menu panel */
|
|
1307
|
+
z-index: var(--z-menu-backdrop);
|
|
1308
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
#menu {
|
|
1312
|
+
position: absolute;
|
|
1313
|
+
background-color: #f9f9f9;
|
|
1314
|
+
min-width: 200px;
|
|
1315
|
+
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
|
1316
|
+
padding: 12px 8px;
|
|
1317
|
+
/* Menu panel should be topmost among app chrome */
|
|
1318
|
+
z-index: var(--z-menu);
|
|
1319
|
+
border-radius: 10px;
|
|
1320
|
+
animation: fadeIn 0.5s;
|
|
1321
|
+
display: none; /* Initially hide the menu */
|
|
1322
|
+
opacity: 0; /* Ensure opacity is set to 0 initially */
|
|
1323
|
+
visibility: hidden; /* Ensure visibility is set to hidden initially */
|
|
1324
|
+
transition: opacity 0.5s, visibility 0.5s, display 0s 0.5s;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
|
|
1328
|
+
#menu.show {
|
|
1329
|
+
opacity: 1;
|
|
1330
|
+
visibility: visible;
|
|
1331
|
+
display: block;
|
|
1332
|
+
transition: opacity 0.5s, visibility 0.5s;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
#menu.hide {
|
|
1336
|
+
opacity: 0;
|
|
1337
|
+
visibility: hidden;
|
|
1338
|
+
display: none; /* Ensure menu is hidden from layout */
|
|
1339
|
+
transition: opacity 0.5s, visibility 0.5s, display 0s 0.5s; /* Delay display change */
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
@keyframes fadeIn {
|
|
1344
|
+
0% {
|
|
1345
|
+
opacity: 0;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
100% {
|
|
1349
|
+
opacity: 1;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
@keyframes fadeOut {
|
|
1354
|
+
0% {
|
|
1355
|
+
opacity: 1;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
100% {
|
|
1359
|
+
opacity: 0;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
#menu label {
|
|
1366
|
+
color: black;
|
|
1367
|
+
margin-bottom: 8px;
|
|
1368
|
+
display: inline-block;
|
|
1369
|
+
font-weight: 400;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
.menu-items>div,
|
|
1373
|
+
.menu-items a {
|
|
1374
|
+
text-align: start;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
#menu .menu-items a {
|
|
1378
|
+
color: black;
|
|
1379
|
+
padding: 12px 8px;
|
|
1380
|
+
text-decoration: none;
|
|
1381
|
+
display: block;
|
|
1382
|
+
text-align: start;
|
|
1383
|
+
white-space: nowrap;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
/* Menu button styling - matches anchor tag appearance */
|
|
1387
|
+
#menu .menu-items .menu-button {
|
|
1388
|
+
color: black;
|
|
1389
|
+
padding: 12px 8px;
|
|
1390
|
+
text-decoration: none;
|
|
1391
|
+
display: block;
|
|
1392
|
+
text-align: start;
|
|
1393
|
+
white-space: nowrap;
|
|
1394
|
+
background: none;
|
|
1395
|
+
border: none;
|
|
1396
|
+
cursor: pointer;
|
|
1397
|
+
font-size: inherit;
|
|
1398
|
+
font-family: inherit;
|
|
1399
|
+
width: 100%;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
#menu .menu-items .menu-button:hover {
|
|
1403
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
#menu .menu-items hr {
|
|
1407
|
+
border: none;
|
|
1408
|
+
border-top: 1px solid #d3d3d3;
|
|
1409
|
+
background: transparent;
|
|
1410
|
+
margin: 8px 0;
|
|
1411
|
+
width: 100%;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
#menu:not([hidden]) {
|
|
1415
|
+
display: block;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
.conversation-details {
|
|
1421
|
+
display: inline-block;
|
|
1422
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
1423
|
+
border-radius: 12px;
|
|
1424
|
+
padding: 4px 12px;
|
|
1425
|
+
margin-top: 2px;
|
|
1426
|
+
margin-bottom: 8px;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
.conversation-status small {
|
|
1430
|
+
color: rgba(255, 255, 255, 0.9);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
/* mode switch */
|
|
1435
|
+
|
|
1436
|
+
.switches-container {
|
|
1437
|
+
width: 12rem;
|
|
1438
|
+
position: relative;
|
|
1439
|
+
display: flex;
|
|
1440
|
+
padding: 0;
|
|
1441
|
+
position: relative;
|
|
1442
|
+
background: var(--primary-color, #00bfdb);
|
|
1443
|
+
line-height: 2rem;
|
|
1444
|
+
border-radius: 2rem;
|
|
1445
|
+
margin-left: auto;
|
|
1446
|
+
margin-right: auto;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
/* input (radio) for toggling. hidden - use labels for clicking on */
|
|
1450
|
+
.switches-container input {
|
|
1451
|
+
visibility: hidden;
|
|
1452
|
+
position: absolute;
|
|
1453
|
+
top: 0;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
/* labels for the input (radio) boxes - something to click on */
|
|
1457
|
+
.switches-container label {
|
|
1458
|
+
width: 50%;
|
|
1459
|
+
padding: 0;
|
|
1460
|
+
margin: 0;
|
|
1461
|
+
text-align: center;
|
|
1462
|
+
cursor: pointer;
|
|
1463
|
+
color: var(--text-color-primary-bg, white);
|
|
1464
|
+
position: relative;
|
|
1465
|
+
z-index: 1;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
.menu-switch-container .switches-container label {
|
|
1469
|
+
color: #333; /* Dark text for light menu background */
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
/* switch highlighters wrapper (sliding left / right)
|
|
1473
|
+
- need wrapper to enable the even margins around the highlight box
|
|
1474
|
+
*/
|
|
1475
|
+
.switch-wrapper {
|
|
1476
|
+
position: absolute;
|
|
1477
|
+
top: 0;
|
|
1478
|
+
bottom: 0;
|
|
1479
|
+
width: 50%;
|
|
1480
|
+
padding: 0.1rem;
|
|
1481
|
+
z-index: 3;
|
|
1482
|
+
pointer-events: none;
|
|
1483
|
+
transition: transform .5s cubic-bezier(.77, 0, .175, 1);
|
|
1484
|
+
/* transition: transform 1s; */
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/* switch box highlighter */
|
|
1488
|
+
.switch {
|
|
1489
|
+
border-radius: 1.5rem;
|
|
1490
|
+
background: white;
|
|
1491
|
+
height: 100%;
|
|
1492
|
+
width: 100%;
|
|
1493
|
+
font-weight: bold;
|
|
1494
|
+
pointer-events: none;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
.menu-switch-container .switch {
|
|
1498
|
+
background: var(--secondary-color, #801bea); /* Colored highlight for menu */
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/* switch box labels
|
|
1502
|
+
- default setup
|
|
1503
|
+
- toggle afterwards based on radio:checked status
|
|
1504
|
+
*/
|
|
1505
|
+
.switch div {
|
|
1506
|
+
width: 100%;
|
|
1507
|
+
text-align: center;
|
|
1508
|
+
opacity: 0;
|
|
1509
|
+
display: block;
|
|
1510
|
+
color: var(--secondary-color, #00bfdb);
|
|
1511
|
+
transition: opacity .2s cubic-bezier(.77, 0, .175, 1) .125s;
|
|
1512
|
+
will-change: opacity;
|
|
1513
|
+
position: absolute;
|
|
1514
|
+
top: 0;
|
|
1515
|
+
left: 0;
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
.menu-switch-container .switch div {
|
|
1519
|
+
color: white; /* White text on colored highlight */
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
/* slide the switch box from right to left */
|
|
1523
|
+
.switches-container input:nth-of-type(1):checked~.switch-wrapper {
|
|
1524
|
+
transform: translateX(0%);
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
/* slide the switch box from left to right */
|
|
1528
|
+
.switches-container input:nth-of-type(2):checked~.switch-wrapper {
|
|
1529
|
+
transform: translateX(100%);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
/* toggle the switch box labels - first checkbox:checked - show first switch div */
|
|
1533
|
+
.switches-container input:nth-of-type(1):checked~.switch-wrapper .switch div:nth-of-type(1) {
|
|
1534
|
+
opacity: 1;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
/* toggle the switch box labels - second checkbox:checked - show second switch div */
|
|
1538
|
+
.switches-container input:nth-of-type(2):checked~.switch-wrapper .switch div:nth-of-type(2) {
|
|
1539
|
+
opacity: 1;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
.labels-container {
|
|
1543
|
+
display: flex;
|
|
1544
|
+
justify-content: space-between;
|
|
1545
|
+
align-items: center;
|
|
1546
|
+
gap: 10px;
|
|
1547
|
+
color: black;
|
|
1548
|
+
padding: 12px 8px;
|
|
1549
|
+
text-decoration: none;
|
|
1550
|
+
white-space: nowrap;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
.menu-switch-container {
|
|
1554
|
+
padding: 12px 8px;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
.menu-switch-container .switches-container {
|
|
1558
|
+
background: #eee; /* Light background for the track in menu */
|
|
1559
|
+
border: 1px solid #ddd;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
.captions-switch {
|
|
1563
|
+
position: relative;
|
|
1564
|
+
display: inline-block;
|
|
1565
|
+
width: 45px;
|
|
1566
|
+
height: 26px;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
.captions-switch input {
|
|
1570
|
+
opacity: 0;
|
|
1571
|
+
width: 0;
|
|
1572
|
+
height: 0;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
.captions-slider {
|
|
1576
|
+
position: absolute;
|
|
1577
|
+
cursor: pointer;
|
|
1578
|
+
top: 0;
|
|
1579
|
+
left: 0;
|
|
1580
|
+
right: 0;
|
|
1581
|
+
bottom: 0;
|
|
1582
|
+
background-color: #ccc;
|
|
1583
|
+
-webkit-transition: .4s;
|
|
1584
|
+
transition: .4s;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
.captions-slider:before {
|
|
1588
|
+
position: absolute;
|
|
1589
|
+
content: "";
|
|
1590
|
+
height: 20px;
|
|
1591
|
+
width: 20px;
|
|
1592
|
+
left: 3px;
|
|
1593
|
+
bottom: 3px;
|
|
1594
|
+
background-color: white;
|
|
1595
|
+
-webkit-transition: .4s;
|
|
1596
|
+
transition: .4s;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
input:checked+.captions-slider {
|
|
1600
|
+
background-color: var(--secondary-color, #801bea);
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
input:focus+.captions-slider {
|
|
1604
|
+
box-shadow: 0 0 1px var(--secondary-color, #801bea);
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
input:checked+.captions-slider:before {
|
|
1608
|
+
-webkit-transform: translateX(20px);
|
|
1609
|
+
-ms-transform: translateX(20px);
|
|
1610
|
+
transform: translateX(20px);
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
.captions-slider.round {
|
|
1614
|
+
border-radius: 28px;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
.captions-slider.round:before {
|
|
1618
|
+
border-radius: 50%;
|
|
1619
|
+
}
|
|
1620
|
+
`,te=b`
|
|
1621
|
+
|
|
1622
|
+
.avatar-wrapper {
|
|
1623
|
+
position: relative;
|
|
1624
|
+
display: flex;
|
|
1625
|
+
flex-direction: column;
|
|
1626
|
+
/* Let flex manage spacing */
|
|
1627
|
+
height: 100%;
|
|
1628
|
+
width: 100%;
|
|
1629
|
+
overflow: hidden;
|
|
1630
|
+
flex-grow: 1;
|
|
1631
|
+
min-height: 0;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
.chatbot .avatarbox {
|
|
1635
|
+
display: flex;
|
|
1636
|
+
flex-direction: column;
|
|
1637
|
+
align-items: center;
|
|
1638
|
+
justify-content: center;
|
|
1639
|
+
width: 100%;
|
|
1640
|
+
/* Let flex grow fill remaining height */
|
|
1641
|
+
flex-grow: 1;
|
|
1642
|
+
min-height: 0;
|
|
1643
|
+
position: relative;
|
|
1644
|
+
overflow: hidden;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
#avatar-container {
|
|
1648
|
+
width: 100%;
|
|
1649
|
+
height: 100%;
|
|
1650
|
+
margin: 0;
|
|
1651
|
+
padding: 0;
|
|
1652
|
+
display: flex;
|
|
1653
|
+
align-items: center;
|
|
1654
|
+
justify-content: center;
|
|
1655
|
+
overflow: hidden;
|
|
1656
|
+
box-sizing: border-box;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
/* No special casing needed for embedded mode */
|
|
1660
|
+
|
|
1661
|
+
#avatar-container canvas {
|
|
1662
|
+
max-width: 100%;
|
|
1663
|
+
max-height: 100%;
|
|
1664
|
+
/* width/height set by renderer via ResizeObserver */
|
|
1665
|
+
display: block;
|
|
1666
|
+
touch-action: auto;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
/* ========================================
|
|
1670
|
+
* STATUS BAR - Reactive template component
|
|
1671
|
+
* ======================================== */
|
|
1672
|
+
/* Embedded status bar overlay (single, non-dismissable) */
|
|
1673
|
+
.chatbot-body > .status-bar {
|
|
1674
|
+
width: 100%;
|
|
1675
|
+
max-width: 100%;
|
|
1676
|
+
min-height: 36px;
|
|
1677
|
+
padding: 8px 16px;
|
|
1678
|
+
border-radius: 0;
|
|
1679
|
+
font-weight: 600;
|
|
1680
|
+
text-align: center;
|
|
1681
|
+
border: 1px solid transparent;
|
|
1682
|
+
pointer-events: none; /* never block avatar controls/icons */
|
|
1683
|
+
display: flex;
|
|
1684
|
+
align-items: center;
|
|
1685
|
+
justify-content: center;
|
|
1686
|
+
position: absolute;
|
|
1687
|
+
top: 0;
|
|
1688
|
+
left: 0;
|
|
1689
|
+
right: 0;
|
|
1690
|
+
z-index: var(--z-status);
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
/* Status bar variants */
|
|
1694
|
+
.chatbot-body > .status-bar.status--initializing {
|
|
1695
|
+
color: #664d03;
|
|
1696
|
+
background-color: #fff3cd;
|
|
1697
|
+
border-color: #ffe69c;
|
|
1698
|
+
}
|
|
1699
|
+
.chatbot-body > .status-bar.status--recovering {
|
|
1700
|
+
color: #664d03;
|
|
1701
|
+
background-color: #fff3cd;
|
|
1702
|
+
border-color: #ffe69c;
|
|
1703
|
+
}
|
|
1704
|
+
.chatbot-body > .status-bar.status--disconnected,
|
|
1705
|
+
.chatbot-body > .status-bar.status--failed,
|
|
1706
|
+
.chatbot-body > .status-bar.status--invalidConfiguration {
|
|
1707
|
+
color: #58151c;
|
|
1708
|
+
background-color: #f8d7da;
|
|
1709
|
+
border-color: #f1aeb5;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
/* ========================================
|
|
1713
|
+
* TOASTIFY DISMISSABLE ALERTS - Managed by Alerts.js
|
|
1714
|
+
* ======================================== */
|
|
1715
|
+
#toastify-container,
|
|
1716
|
+
#toastify-dismissable-alerts {
|
|
1717
|
+
position: absolute;
|
|
1718
|
+
top: 0;
|
|
1719
|
+
left: 0;
|
|
1720
|
+
right: 0;
|
|
1721
|
+
display: flex;
|
|
1722
|
+
flex-direction: column;
|
|
1723
|
+
align-items: center;
|
|
1724
|
+
gap: 8px;
|
|
1725
|
+
padding: 12px 16px 0;
|
|
1726
|
+
pointer-events: none;
|
|
1727
|
+
z-index: var(--z-toasts);
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
#toastify-container .toastify,
|
|
1731
|
+
#toastify-dismissable-alerts .toastify {
|
|
1732
|
+
width: min(420px, calc(100% - 32px));
|
|
1733
|
+
pointer-events: auto;
|
|
1734
|
+
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
|
|
1735
|
+
border-radius: 12px;
|
|
1736
|
+
overflow: hidden;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
.alert-danger {
|
|
1740
|
+
color: #721c24;
|
|
1741
|
+
background-color: #f8d7da;
|
|
1742
|
+
border-color: #f5c6cb;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
.alert-warning {
|
|
1746
|
+
color: #856404;
|
|
1747
|
+
background-color: #fff3cd;
|
|
1748
|
+
border-color: #ffeeba;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
.alert {
|
|
1752
|
+
position: relative;
|
|
1753
|
+
padding: .75rem 1.25rem;
|
|
1754
|
+
margin-bottom: 1rem;
|
|
1755
|
+
border: 1px solid transparent;
|
|
1756
|
+
border-radius: .25rem;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
.toast-close {
|
|
1760
|
+
font-weight: bold;
|
|
1761
|
+
font-size: 18px;
|
|
1762
|
+
background: transparent;
|
|
1763
|
+
border: none;
|
|
1764
|
+
margin: 5px;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
.voice-controls-container {
|
|
1768
|
+
display: flex;
|
|
1769
|
+
flex-direction: column;
|
|
1770
|
+
width: 100%;
|
|
1771
|
+
align-items: center;
|
|
1772
|
+
justify-content: center;
|
|
1773
|
+
flex-shrink: 0;
|
|
1774
|
+
position: absolute;
|
|
1775
|
+
bottom: 10px;
|
|
1776
|
+
left: 0;
|
|
1777
|
+
right: 0;
|
|
1778
|
+
pointer-events: none; /* Allow clicks through to canvas */
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
.voice-controls-container > * {
|
|
1782
|
+
pointer-events: auto; /* Re-enable clicks on actual controls */
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
.button-container {
|
|
1786
|
+
display: flex;
|
|
1787
|
+
justify-content: center;
|
|
1788
|
+
align-items: center;
|
|
1789
|
+
position: relative;
|
|
1790
|
+
min-height: 40px;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/* Only show glass background when conversation is active (has visualizer) */
|
|
1794
|
+
.button-container.active-conversation {
|
|
1795
|
+
background: rgba(255, 255, 255, 1);
|
|
1796
|
+
backdrop-filter: blur(8px);
|
|
1797
|
+
border-radius: 35px;
|
|
1798
|
+
padding: 4px 16px;
|
|
1799
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
.state-control {
|
|
1803
|
+
display: flex;
|
|
1804
|
+
justify-content: center;
|
|
1805
|
+
align-items: center;
|
|
1806
|
+
margin: 2px 12px;
|
|
1807
|
+
min-height: 40px;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
.btn-lg {
|
|
1811
|
+
padding: .5em 1em;
|
|
1812
|
+
font-size: 1.25em;
|
|
1813
|
+
line-height: 1.5;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
.button-primary,
|
|
1817
|
+
.button-secondary {
|
|
1818
|
+
border-radius: 100%;
|
|
1819
|
+
border: none;
|
|
1820
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
1821
|
+
position: relative;
|
|
1822
|
+
transition: transform 0.3s, box-shadow 0.3s;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
.button-primary:hover,
|
|
1826
|
+
.button-secondary:hover {
|
|
1827
|
+
transform: scale(1.05);
|
|
1828
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
.button-primary {
|
|
1832
|
+
padding: .7rem .7rem;
|
|
1833
|
+
background-color: var(--primary-color, #00bfdb);
|
|
1834
|
+
color: var(--text-color-primary-bg, #fff);
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
.button-secondary {
|
|
1838
|
+
padding: .4rem .4rem;
|
|
1839
|
+
background-color: var(--secondary-color, #801bea);
|
|
1840
|
+
color: var(--text-color-secondary-bg, white);
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
.start-button {
|
|
1844
|
+
background-color: var(--secondary-color, #801bea);
|
|
1845
|
+
border-radius: 25px;
|
|
1846
|
+
border: none;
|
|
1847
|
+
color: var(--text-color-secondary-bg, white);
|
|
1848
|
+
padding: .65rem 1.5rem;
|
|
1849
|
+
line-height: 1.4;
|
|
1850
|
+
cursor: pointer;
|
|
1851
|
+
box-shadow: 0 4px 16px rgba(128, 27, 234, 0.3);
|
|
1852
|
+
position: relative;
|
|
1853
|
+
transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s;
|
|
1854
|
+
max-width: 220px;
|
|
1855
|
+
font-weight: 500;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
.start-button:hover {
|
|
1859
|
+
filter: brightness(90%);
|
|
1860
|
+
transform: scale(1.02);
|
|
1861
|
+
box-shadow: 0 6px 20px rgba(128, 27, 234, 0.4);
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
.voice-controls-container {
|
|
1865
|
+
/* sits over the canvas as an overlay */
|
|
1866
|
+
z-index: var(--z-controls);
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
.restart-button {
|
|
1870
|
+
z-index: var(--z-controls);
|
|
1871
|
+
cursor: pointer;
|
|
1872
|
+
outline: none;
|
|
1873
|
+
user-select: none;
|
|
1874
|
+
margin-top: 0.5rem;
|
|
1875
|
+
background: transparent;
|
|
1876
|
+
border: none;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
.stop-button {
|
|
1880
|
+
z-index: var(--z-controls);
|
|
1881
|
+
cursor: pointer;
|
|
1882
|
+
outline: none;
|
|
1883
|
+
user-select: none;
|
|
1884
|
+
border: none;
|
|
1885
|
+
background: transparent;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
.last-message-button {
|
|
1889
|
+
z-index: var(--z-controls);
|
|
1890
|
+
cursor: pointer;
|
|
1891
|
+
outline: none;
|
|
1892
|
+
user-select: none;
|
|
1893
|
+
margin-top: 0.5rem;
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
.switch-chat-button {
|
|
1897
|
+
z-index: var(--z-controls);
|
|
1898
|
+
cursor: pointer;
|
|
1899
|
+
outline: none;
|
|
1900
|
+
user-select: none;
|
|
1901
|
+
margin-top: 0.5rem;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
.time-right,
|
|
1905
|
+
.time-left {
|
|
1906
|
+
position: absolute;
|
|
1907
|
+
bottom: 5px;
|
|
1908
|
+
color: #aaa;
|
|
1909
|
+
font-size: 0.7rem;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
.time-right {
|
|
1913
|
+
right: 10px;
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
.time-left {
|
|
1917
|
+
left: 10px;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
/* Live caption styles */
|
|
1921
|
+
|
|
1922
|
+
.captions-overlay {
|
|
1923
|
+
position: absolute;
|
|
1924
|
+
bottom: 100px; /* Above voice controls */
|
|
1925
|
+
width: 100%;
|
|
1926
|
+
z-index: var(--z-controls);
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
/* Position captions overlay over the canvas without affecting layout */
|
|
1930
|
+
#captions-wrapper {
|
|
1931
|
+
position: absolute;
|
|
1932
|
+
bottom: 100px; /* Above voice controls */
|
|
1933
|
+
left: 0;
|
|
1934
|
+
right: 0;
|
|
1935
|
+
margin-left: auto;
|
|
1936
|
+
margin-right: auto;
|
|
1937
|
+
width: 90%;
|
|
1938
|
+
max-width: 500px;
|
|
1939
|
+
z-index: calc(var(--z-controls) - 1);
|
|
1940
|
+
pointer-events: none; /* allow clicks through by default */
|
|
1941
|
+
display: flex;
|
|
1942
|
+
justify-content: center;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
/* Allow interaction with caption bubble itself if needed */
|
|
1946
|
+
#captions-wrapper > div {
|
|
1947
|
+
pointer-events: auto;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
.user-live-caption,
|
|
1951
|
+
.assistant-live-caption {
|
|
1952
|
+
display: inline-block;
|
|
1953
|
+
position: relative;
|
|
1954
|
+
padding: 10px;
|
|
1955
|
+
border-radius: 15px;
|
|
1956
|
+
width: 80%;
|
|
1957
|
+
min-width: 100px;
|
|
1958
|
+
text-overflow: ellipsis;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
.user-live-caption {
|
|
1962
|
+
color: var(--text-color-secondary-bg, #fff);
|
|
1963
|
+
background-color: var(--secondary-color, #801bea);
|
|
1964
|
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
.user-live-caption::after { display: none; }
|
|
1968
|
+
|
|
1969
|
+
.assistant-live-caption {
|
|
1970
|
+
color: white !important;
|
|
1971
|
+
font-size: 1.2em;
|
|
1972
|
+
text-align: center;
|
|
1973
|
+
margin: 0 auto;
|
|
1974
|
+
}
|
|
1975
|
+
.caption-highlight {
|
|
1976
|
+
background-color: #000;
|
|
1977
|
+
padding: 0.2rem;
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
.caption-content {
|
|
1981
|
+
position: relative;
|
|
1982
|
+
max-height: 70vh;
|
|
1983
|
+
transition: opacity 0.3s ease, max-height 0.3s ease;
|
|
1984
|
+
opacity: 1;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
.caption-content.short-text {
|
|
1988
|
+
white-space: nowrap;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
.caption-content.long-text {
|
|
1992
|
+
display: -webkit-box;
|
|
1993
|
+
-webkit-box-orient: vertical;
|
|
1994
|
+
-webkit-line-clamp: 3;
|
|
1995
|
+
word-wrap: break-word;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
.caption-content.hidden {
|
|
1999
|
+
opacity: 0;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
.caption-content.visible {
|
|
2003
|
+
opacity: 1;
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
|
|
2007
|
+
/* Last message styles */
|
|
2008
|
+
|
|
2009
|
+
.conversation-buttons-overlay {
|
|
2010
|
+
display: flex;
|
|
2011
|
+
flex-direction: column;
|
|
2012
|
+
position: absolute;
|
|
2013
|
+
top: 50px;
|
|
2014
|
+
right: 5%;
|
|
2015
|
+
z-index: var(--z-controls);
|
|
2016
|
+
background: rgba(255, 255, 255, 0.85);
|
|
2017
|
+
backdrop-filter: blur(8px);
|
|
2018
|
+
border-radius: 12px;
|
|
2019
|
+
padding: 8px;
|
|
2020
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
.last-message {
|
|
2024
|
+
position: absolute;
|
|
2025
|
+
width: 100%;
|
|
2026
|
+
height: 100%;
|
|
2027
|
+
top: 0;
|
|
2028
|
+
left: 0;
|
|
2029
|
+
right: 0;
|
|
2030
|
+
bottom: 0;
|
|
2031
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
2032
|
+
z-index: var(--z-overlay);
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
.last-message-content {
|
|
2036
|
+
position: absolute; /* or fixed, depending on your design */
|
|
2037
|
+
top: 25%;
|
|
2038
|
+
left: 50%;
|
|
2039
|
+
transform: translateX(-50%); /* center horizontally */
|
|
2040
|
+
max-width: 50%;
|
|
2041
|
+
max-height: 50%;
|
|
2042
|
+
padding: 20px;
|
|
2043
|
+
box-sizing: border-box;
|
|
2044
|
+
background-color: white;
|
|
2045
|
+
border-radius: 15px;
|
|
2046
|
+
z-index: calc(var(--z-overlay) + 1);
|
|
2047
|
+
overflow-y: auto;
|
|
2048
|
+
scrollbar-width: thin;
|
|
2049
|
+
scrollbar-color: #ccc #fff;
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
.last-message-scrollable {
|
|
2053
|
+
position: relative;
|
|
2054
|
+
width: 100%;
|
|
2055
|
+
height: 100%;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
/* Markdown in last-message overlay */
|
|
2059
|
+
.last-message-scrollable .md-code-inline {
|
|
2060
|
+
background: rgba(0, 0, 0, 0.06);
|
|
2061
|
+
padding: 1px 5px;
|
|
2062
|
+
border-radius: 4px;
|
|
2063
|
+
font-family: 'Courier New', Courier, monospace;
|
|
2064
|
+
font-size: 0.9em;
|
|
2065
|
+
}
|
|
2066
|
+
.last-message-scrollable .md-code-block {
|
|
2067
|
+
background: #1e1e1e;
|
|
2068
|
+
color: #d4d4d4;
|
|
2069
|
+
padding: 12px 14px;
|
|
2070
|
+
border-radius: 8px;
|
|
2071
|
+
overflow-x: auto;
|
|
2072
|
+
font-family: 'Courier New', Courier, monospace;
|
|
2073
|
+
font-size: 0.85em;
|
|
2074
|
+
line-height: 1.5;
|
|
2075
|
+
margin: 8px 0;
|
|
2076
|
+
white-space: pre;
|
|
2077
|
+
}
|
|
2078
|
+
.last-message-scrollable .md-heading {
|
|
2079
|
+
font-weight: 600;
|
|
2080
|
+
margin: 10px 0 4px 0;
|
|
2081
|
+
}
|
|
2082
|
+
.last-message-scrollable .md-list {
|
|
2083
|
+
margin: 6px 0;
|
|
2084
|
+
padding-left: 22px;
|
|
2085
|
+
}
|
|
2086
|
+
.last-message-scrollable a {
|
|
2087
|
+
color: #1a73e8;
|
|
2088
|
+
text-decoration: underline;
|
|
2089
|
+
}
|
|
2090
|
+
.last-message-scrollable a:hover {
|
|
2091
|
+
color: #1558b0;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
.last-message-copy-button {
|
|
2095
|
+
display: block;
|
|
2096
|
+
background: none;
|
|
2097
|
+
border: none;
|
|
2098
|
+
cursor: pointer;
|
|
2099
|
+
margin-top: 20px;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
/* Body icons */
|
|
2103
|
+
.body-icons-overlay {
|
|
2104
|
+
position: absolute;
|
|
2105
|
+
top: 50px;
|
|
2106
|
+
left: 3%;
|
|
2107
|
+
z-index: var(--z-controls);
|
|
2108
|
+
background: rgba(255, 255, 255, 0.85);
|
|
2109
|
+
backdrop-filter: blur(8px);
|
|
2110
|
+
border-radius: 12px;
|
|
2111
|
+
padding: 8px;
|
|
2112
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
.vertical-icons {
|
|
2116
|
+
display: flex;
|
|
2117
|
+
flex-direction: column;
|
|
2118
|
+
align-items: center;
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
.icon-button {
|
|
2122
|
+
margin: 5px 0;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
.typing-input {
|
|
2126
|
+
display: flex;
|
|
2127
|
+
gap: 5px;
|
|
2128
|
+
position: relative;
|
|
2129
|
+
width: 90%;
|
|
2130
|
+
max-width: 400px;
|
|
2131
|
+
background: rgba(255, 255, 255, 0.95);
|
|
2132
|
+
padding: 6px 12px;
|
|
2133
|
+
border-radius: 25px;
|
|
2134
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
|
|
2135
|
+
overflow: hidden;
|
|
2136
|
+
margin-top: 8px;
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
.typing-input .close-input-button {
|
|
2140
|
+
display: flex;
|
|
2141
|
+
align-items: center;
|
|
2142
|
+
justify-content: center;
|
|
2143
|
+
cursor: pointer;
|
|
2144
|
+
color: #999;
|
|
2145
|
+
padding-right: 5px;
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
.typing-input .close-input-button:hover {
|
|
2149
|
+
color: #666;
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
.typing-input textarea {
|
|
2153
|
+
height: 36px;
|
|
2154
|
+
width: 100%;
|
|
2155
|
+
border: none;
|
|
2156
|
+
outline: none;
|
|
2157
|
+
resize: none;
|
|
2158
|
+
padding: 8px 10px 8px 4px;
|
|
2159
|
+
font-size: 0.9em;
|
|
2160
|
+
cursor: text;
|
|
2161
|
+
caret-color: auto;
|
|
2162
|
+
background: transparent;
|
|
2163
|
+
overflow-y: auto;
|
|
2164
|
+
scrollbar-width: none;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
.typing-input textarea::-webkit-scrollbar {
|
|
2168
|
+
display: none;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
.typing-input #typing_send_button {
|
|
2172
|
+
visibility: visible;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
.typing-input #typing_send_button span {
|
|
2176
|
+
align-self: flex-end;
|
|
2177
|
+
color: var(--secondary-color, #801bea);
|
|
2178
|
+
cursor: pointer;
|
|
2179
|
+
height: 55px;
|
|
2180
|
+
display: flex;
|
|
2181
|
+
align-items: center;
|
|
2182
|
+
font-size: 1.35rem;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
/* Disabled input styles */
|
|
2186
|
+
.typing-input.input-blocked {
|
|
2187
|
+
opacity: 0.6;
|
|
2188
|
+
background-color: #f5f5f5;
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
.typing-input.input-blocked textarea {
|
|
2192
|
+
|
|
2193
|
+
cursor: not-allowed;
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
.typing-input .send-button-disabled {
|
|
2197
|
+
pointer-events: none;
|
|
2198
|
+
opacity: 0.5;
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
.typing-input .send-button-disabled span {
|
|
2202
|
+
color: #ccc !important;
|
|
2203
|
+
cursor: not-allowed !important;
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
/* ========================================
|
|
2207
|
+
* VOICE VISUALIZER - Animated audio bars
|
|
2208
|
+
* ======================================== */
|
|
2209
|
+
.voice-visualizer {
|
|
2210
|
+
display: flex;
|
|
2211
|
+
justify-content: center;
|
|
2212
|
+
align-items: center;
|
|
2213
|
+
width: 70px;
|
|
2214
|
+
height: 40px;
|
|
2215
|
+
background: transparent;
|
|
2216
|
+
border-radius: 22px;
|
|
2217
|
+
padding: 6px;
|
|
2218
|
+
cursor: pointer;
|
|
2219
|
+
transition: background 0.3s ease;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
.voice-visualizer-wrapper {
|
|
2223
|
+
display: flex;
|
|
2224
|
+
flex-direction: column;
|
|
2225
|
+
align-items: center;
|
|
2226
|
+
gap: 4px;
|
|
2227
|
+
position: relative;
|
|
2228
|
+
min-height: 40px; /* Compact height for overlay */
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
.voice-visualizer.visualizer-disabled {
|
|
2232
|
+
opacity: 0.5;
|
|
2233
|
+
cursor: not-allowed;
|
|
2234
|
+
pointer-events: none;
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
.visualizer-hint {
|
|
2238
|
+
position: absolute;
|
|
2239
|
+
bottom: -2px;
|
|
2240
|
+
left: 50%;
|
|
2241
|
+
transform: translateX(-50%);
|
|
2242
|
+
white-space: nowrap;
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
.visualizer-hint {
|
|
2246
|
+
font-size: 0.6rem;
|
|
2247
|
+
color: var(--text-color-muted, #888);
|
|
2248
|
+
opacity: 0.8;
|
|
2249
|
+
text-align: center;
|
|
2250
|
+
animation: fadeInHint 0.5s ease-in-out;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
@keyframes fadeInHint {
|
|
2254
|
+
from { opacity: 0; transform: translateX(-50%) translateY(-5px); }
|
|
2255
|
+
to { opacity: 0.8; transform: translateX(-50%) translateY(0); }
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
/* Thinking label shown in visualizer wrapper during processing */
|
|
2259
|
+
.thinking-label {
|
|
2260
|
+
position: relative;
|
|
2261
|
+
bottom: auto;
|
|
2262
|
+
left: auto;
|
|
2263
|
+
transform: none;
|
|
2264
|
+
font-size: 0.65rem;
|
|
2265
|
+
color: var(--primary-color, #00bfdb);
|
|
2266
|
+
text-align: center;
|
|
2267
|
+
animation: thinkingPulse 1.5s infinite ease-in-out;
|
|
2268
|
+
letter-spacing: 0.5px;
|
|
2269
|
+
font-weight: 500;
|
|
2270
|
+
padding: 12px 0 4px;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
@keyframes thinkingPulse {
|
|
2274
|
+
0%, 100% { opacity: 0.6; }
|
|
2275
|
+
50% { opacity: 1; }
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
.audio-bar {
|
|
2279
|
+
width: 6px;
|
|
2280
|
+
margin: 0 3px;
|
|
2281
|
+
background: linear-gradient(180deg, var(--primary-color, #00bfdb), var(--secondary-color, #801bea));
|
|
2282
|
+
border-radius: 99px;
|
|
2283
|
+
transform-origin: center;
|
|
2284
|
+
height: 10px;
|
|
2285
|
+
transition: all 0.3s ease;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
/* --- STATE: IDLE --- */
|
|
2289
|
+
.state-idle .audio-bar {
|
|
2290
|
+
height: 8px;
|
|
2291
|
+
opacity: 0.5;
|
|
2292
|
+
animation: none;
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
/* --- STATE: LISTENING (Microphone active) --- */
|
|
2296
|
+
@keyframes listen-wave {
|
|
2297
|
+
0%, 100% { transform: scaleY(1); opacity: 0.8; }
|
|
2298
|
+
50% { transform: scaleY(1.8); opacity: 1; }
|
|
2299
|
+
}
|
|
2300
|
+
.state-listening .audio-bar {
|
|
2301
|
+
animation: listen-wave 1.5s infinite ease-in-out;
|
|
2302
|
+
}
|
|
2303
|
+
.state-listening .audio-bar:nth-child(1) { animation-delay: 0.0s; }
|
|
2304
|
+
.state-listening .audio-bar:nth-child(2) { animation-delay: 0.2s; }
|
|
2305
|
+
.state-listening .audio-bar:nth-child(3) { animation-delay: 0.4s; }
|
|
2306
|
+
.state-listening .audio-bar:nth-child(4) { animation-delay: 0.2s; }
|
|
2307
|
+
.state-listening .audio-bar:nth-child(5) { animation-delay: 0.0s; }
|
|
2308
|
+
|
|
2309
|
+
/* --- STATE: THINKING (Processing) --- */
|
|
2310
|
+
/* Distinct "loading" style: sequential pulse sweep left-to-right with glow */
|
|
2311
|
+
@keyframes think-pulse {
|
|
2312
|
+
0%, 100% {
|
|
2313
|
+
height: 8px;
|
|
2314
|
+
opacity: 0.4;
|
|
2315
|
+
background: linear-gradient(180deg, var(--primary-color, #00bfdb), var(--secondary-color, #801bea));
|
|
2316
|
+
}
|
|
2317
|
+
40%, 60% {
|
|
2318
|
+
height: 24px;
|
|
2319
|
+
opacity: 1;
|
|
2320
|
+
background: linear-gradient(180deg, #00e5ff, #aa55ff);
|
|
2321
|
+
box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
.state-thinking .audio-bar {
|
|
2325
|
+
animation: think-pulse 1.2s infinite ease-in-out;
|
|
2326
|
+
}
|
|
2327
|
+
/* Sequential cascade from left to right */
|
|
2328
|
+
.state-thinking .audio-bar:nth-child(1) { animation-delay: 0.0s; }
|
|
2329
|
+
.state-thinking .audio-bar:nth-child(2) { animation-delay: 0.15s; }
|
|
2330
|
+
.state-thinking .audio-bar:nth-child(3) { animation-delay: 0.30s; }
|
|
2331
|
+
.state-thinking .audio-bar:nth-child(4) { animation-delay: 0.45s; }
|
|
2332
|
+
.state-thinking .audio-bar:nth-child(5) { animation-delay: 0.60s; }
|
|
2333
|
+
|
|
2334
|
+
/* --- STATE: SPEAKING (Voice Output) --- */
|
|
2335
|
+
@keyframes speak-wave {
|
|
2336
|
+
0% { height: 15%; }
|
|
2337
|
+
20% { height: 60%; }
|
|
2338
|
+
40% { height: 35%; }
|
|
2339
|
+
50% { height: 100%; }
|
|
2340
|
+
100% { height: 15%; }
|
|
2341
|
+
}
|
|
2342
|
+
.state-speaking .audio-bar {
|
|
2343
|
+
height: 30px;
|
|
2344
|
+
animation: speak-wave 0.8s infinite ease-in-out;
|
|
2345
|
+
}
|
|
2346
|
+
.state-speaking .audio-bar:nth-child(1) { animation-duration: 0.7s; }
|
|
2347
|
+
.state-speaking .audio-bar:nth-child(2) { animation-duration: 0.9s; }
|
|
2348
|
+
.state-speaking .audio-bar:nth-child(3) { animation-duration: 0.6s; }
|
|
2349
|
+
.state-speaking .audio-bar:nth-child(4) { animation-duration: 0.8s; }
|
|
2350
|
+
.state-speaking .audio-bar:nth-child(5) { animation-duration: 1.0s; }
|
|
2351
|
+
|
|
2352
|
+
/* --- STATE: PAUSED (Disconnected) --- */
|
|
2353
|
+
.state-paused .audio-bar {
|
|
2354
|
+
height: 8px;
|
|
2355
|
+
opacity: 0.3;
|
|
2356
|
+
animation: none;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
@media (max-width: 768px) {
|
|
2360
|
+
.chatbot .avatarbox {
|
|
2361
|
+
flex-grow: 1;
|
|
2362
|
+
width: 100%;
|
|
2363
|
+
height: 100%;
|
|
2364
|
+
overflow: hidden;
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
#avatar-container {
|
|
2368
|
+
width: 100%;
|
|
2369
|
+
height: 100%;
|
|
2370
|
+
/* On small screens, remove any top padding in embedded or mobile to avoid letterboxing */
|
|
2371
|
+
padding-top: 0;
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
:host([toggler="false"]) #avatar-container {
|
|
2375
|
+
padding: 0 !important;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
:host(.mobile) #avatar-container,
|
|
2379
|
+
:host([target_app="mobile"]) #avatar-container {
|
|
2380
|
+
padding: 0 !important;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
#avatar-container canvas {
|
|
2384
|
+
width: 100%;
|
|
2385
|
+
height: 100%;
|
|
2386
|
+
touch-action: pan-y pinch-zoom !important;
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
/* Compact voice controls on mobile */
|
|
2390
|
+
.voice-controls-container {
|
|
2391
|
+
bottom: 10px;
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
.button-container {
|
|
2395
|
+
padding: 6px 12px;
|
|
2396
|
+
border-radius: 28px;
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
.typing-input {
|
|
2400
|
+
width: 85%;
|
|
2401
|
+
max-width: 320px;
|
|
2402
|
+
padding: 4px 10px;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
.typing-input textarea {
|
|
2406
|
+
height: 32px;
|
|
2407
|
+
font-size: 0.85em;
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
#captions-wrapper {
|
|
2411
|
+
bottom: 85px; /* Adjust for mobile voice controls */
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
.captions-overlay {
|
|
2415
|
+
bottom: 85px;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
/* Ensure conversation buttons are visible on mobile */
|
|
2420
|
+
.chatbot.mobile .conversation-buttons-overlay {
|
|
2421
|
+
top: 10px;
|
|
2422
|
+
right: 10px;
|
|
2423
|
+
z-index: 1000;
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
/* Video avatar loading overlay */
|
|
2427
|
+
.video-avatar-loading-overlay {
|
|
2428
|
+
position: absolute;
|
|
2429
|
+
top: 0;
|
|
2430
|
+
left: 0;
|
|
2431
|
+
width: 100%;
|
|
2432
|
+
height: 100%;
|
|
2433
|
+
display: flex;
|
|
2434
|
+
align-items: center;
|
|
2435
|
+
justify-content: center;
|
|
2436
|
+
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
2437
|
+
z-index: 1;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
/* Video avatar placeholder overlay (shown before conversation starts) */
|
|
2441
|
+
.video-avatar-placeholder-overlay {
|
|
2442
|
+
position: absolute;
|
|
2443
|
+
top: 0;
|
|
2444
|
+
left: 0;
|
|
2445
|
+
width: 100%;
|
|
2446
|
+
height: 100%;
|
|
2447
|
+
display: flex;
|
|
2448
|
+
align-items: center;
|
|
2449
|
+
justify-content: center;
|
|
2450
|
+
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
2451
|
+
z-index: 1;
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
.video-avatar-placeholder-content {
|
|
2455
|
+
display: flex;
|
|
2456
|
+
flex-direction: column;
|
|
2457
|
+
align-items: center;
|
|
2458
|
+
gap: 16px;
|
|
2459
|
+
padding: 30px;
|
|
2460
|
+
text-align: center;
|
|
2461
|
+
width: 100%;
|
|
2462
|
+
height: 100%;
|
|
2463
|
+
box-sizing: border-box;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
.video-avatar-placeholder-image {
|
|
2467
|
+
max-width: 100%;
|
|
2468
|
+
max-height: 100%;
|
|
2469
|
+
width: auto;
|
|
2470
|
+
height: auto;
|
|
2471
|
+
object-fit: contain;
|
|
2472
|
+
border-radius: 8px;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
.video-avatar-placeholder-icon {
|
|
2476
|
+
color: rgba(255, 255, 255, 0.3);
|
|
2477
|
+
width: 80px;
|
|
2478
|
+
height: 80px;
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
.video-avatar-placeholder-fallback {
|
|
2482
|
+
display: none;
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
/* Video avatar idle disconnect overlay */
|
|
2486
|
+
.video-avatar-idle-overlay {
|
|
2487
|
+
position: absolute;
|
|
2488
|
+
top: 0;
|
|
2489
|
+
left: 0;
|
|
2490
|
+
width: 100%;
|
|
2491
|
+
height: 100%;
|
|
2492
|
+
display: flex;
|
|
2493
|
+
align-items: center;
|
|
2494
|
+
justify-content: center;
|
|
2495
|
+
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
2496
|
+
z-index: 1;
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
.video-avatar-idle-content {
|
|
2500
|
+
display: flex;
|
|
2501
|
+
flex-direction: column;
|
|
2502
|
+
align-items: center;
|
|
2503
|
+
gap: 20px;
|
|
2504
|
+
padding: 30px;
|
|
2505
|
+
text-align: center;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
.video-avatar-idle-message {
|
|
2509
|
+
color: #e0e0e0;
|
|
2510
|
+
font-size: 1.1rem;
|
|
2511
|
+
margin: 0;
|
|
2512
|
+
max-width: 300px;
|
|
2513
|
+
line-height: 1.5;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
.video-avatar-reconnect-btn {
|
|
2517
|
+
background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
|
|
2518
|
+
color: white;
|
|
2519
|
+
border: none;
|
|
2520
|
+
padding: 12px 28px;
|
|
2521
|
+
border-radius: 25px;
|
|
2522
|
+
font-size: 1rem;
|
|
2523
|
+
font-weight: 500;
|
|
2524
|
+
cursor: pointer;
|
|
2525
|
+
transition: all 0.2s ease;
|
|
2526
|
+
box-shadow: 0 4px 15px rgba(74, 144, 217, 0.3);
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
.video-avatar-reconnect-btn:hover {
|
|
2530
|
+
transform: translateY(-2px);
|
|
2531
|
+
box-shadow: 0 6px 20px rgba(74, 144, 217, 0.4);
|
|
2532
|
+
background: linear-gradient(135deg, #5a9fe9 0%, #4589cd 100%);
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
.video-avatar-reconnect-btn:active {
|
|
2536
|
+
transform: translateY(0);
|
|
2537
|
+
box-shadow: 0 2px 10px rgba(74, 144, 217, 0.3);
|
|
2538
|
+
}
|
|
2539
|
+
`,ee=b`
|
|
2540
|
+
|
|
2541
|
+
#chat-page {
|
|
2542
|
+
height: 100%;
|
|
2543
|
+
width: 100%;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
.chat-wrapper {
|
|
2547
|
+
display: flex;
|
|
2548
|
+
flex-direction: column;
|
|
2549
|
+
justify-content: space-between;
|
|
2550
|
+
height: 100%;
|
|
2551
|
+
position: relative;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
.chat-start-container {
|
|
2555
|
+
padding: 20px;
|
|
2556
|
+
display: flex;
|
|
2557
|
+
align-items: center;
|
|
2558
|
+
width: 100%;
|
|
2559
|
+
position: absolute;
|
|
2560
|
+
bottom: 0px;
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
.chatbot .chatbox {
|
|
2564
|
+
overflow-y: auto;
|
|
2565
|
+
padding: 30px 20px 10px;
|
|
2566
|
+
flex-grow: 1;
|
|
2567
|
+
min-height: 0;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
|
|
2571
|
+
.chatbox .chat {
|
|
2572
|
+
display: flex;
|
|
2573
|
+
list-style: none;
|
|
2574
|
+
margin-bottom: 1rem;
|
|
2575
|
+
align-items: flex-end;
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
#no-msgs-head {
|
|
2579
|
+
color: #ccc;
|
|
2580
|
+
font-size: 20px;
|
|
2581
|
+
text-align: center;
|
|
2582
|
+
width: 100%;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
.chatbox .user {
|
|
2586
|
+
margin: 20px 0;
|
|
2587
|
+
justify-content: flex-end;
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
.chatbox .assistant {
|
|
2591
|
+
justify-content: flex-start;
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
/* Assistant Icon Styling */
|
|
2595
|
+
.chatbox .assistant span:first-child {
|
|
2596
|
+
width: 32px;
|
|
2597
|
+
height: 32px;
|
|
2598
|
+
color: #fff;
|
|
2599
|
+
cursor: default;
|
|
2600
|
+
text-align: center;
|
|
2601
|
+
line-height: 32px;
|
|
2602
|
+
background: var(--secondary-color, #801bea);
|
|
2603
|
+
border-radius: 4px;
|
|
2604
|
+
margin: 0 10px 0 0;
|
|
2605
|
+
flex-shrink: 0;
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
.chatbox .assistant span.chat-bubble-icon {
|
|
2609
|
+
flex-shrink: 0;
|
|
2610
|
+
flex-grow: 0;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
.material-icons.chat-bubble-icon {
|
|
2614
|
+
font-size: 1.3rem;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
/* Message Container - controls max width and relative positioning context */
|
|
2618
|
+
.message-container {
|
|
2619
|
+
display: block;
|
|
2620
|
+
max-width: 75%;
|
|
2621
|
+
position: relative; /* Establish positioning context for the timestamp */
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
.chatbox .chat .message-bubble {
|
|
2625
|
+
max-width: 100%;
|
|
2626
|
+
white-space: pre-wrap;
|
|
2627
|
+
word-wrap: break-word;
|
|
2628
|
+
word-break: break-word;
|
|
2629
|
+
padding: 12px 16px; /* Original padding */
|
|
2630
|
+
padding-bottom: 24px;
|
|
2631
|
+
min-height: 1.2em; /* Approx 1 line height + timestamp space */
|
|
2632
|
+
min-width: 80px;
|
|
2633
|
+
border-radius: 10px;
|
|
2634
|
+
font-size: 0.95em;
|
|
2635
|
+
box-sizing: border-box;
|
|
2636
|
+
position: relative; /* Needed if any ::before/::after are used */
|
|
2637
|
+
/* Base styles */
|
|
2638
|
+
background: #f0f0f0;
|
|
2639
|
+
color: #333;
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
/* Markdown-formatted bubbles: let HTML handle whitespace */
|
|
2643
|
+
.chatbox .chat .message-bubble.md-formatted {
|
|
2644
|
+
white-space: normal;
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
/* Timestamp Span (Absolute Positioned) */
|
|
2648
|
+
.message-container .message-time { /* Target based on container */
|
|
2649
|
+
position: absolute;
|
|
2650
|
+
bottom: 5px; /* Position from bottom */
|
|
2651
|
+
font-size: 0.7rem;
|
|
2652
|
+
color: #aaa; /* Default time color */
|
|
2653
|
+
white-space: nowrap;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
/* Timestamp alignment classes */
|
|
2657
|
+
.message-container .message-time.time-right {
|
|
2658
|
+
right: 10px; /* Align to right */
|
|
2659
|
+
}
|
|
2660
|
+
.message-container .message-time.time-left {
|
|
2661
|
+
left: 10px; /* Align to left */
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
/* USER specific bubble styles */
|
|
2665
|
+
.chatbox .user .message-bubble {
|
|
2666
|
+
border-radius: 10px 10px 0 10px;
|
|
2667
|
+
background: var(--secondary-color, #801bea);
|
|
2668
|
+
color: var(--text-color-secondary-bg, #fff);
|
|
2669
|
+
}
|
|
2670
|
+
/* User timestamp color (slightly lighter) */
|
|
2671
|
+
.chatbox .user .message-container .message-time {
|
|
2672
|
+
color: #eee;
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
/* ASSISTANT specific bubble styles */
|
|
2676
|
+
.chatbox .assistant .message-bubble {
|
|
2677
|
+
border-radius: 10px 10px 10px 0;
|
|
2678
|
+
color: #000 !important;
|
|
2679
|
+
background: #f2f2f2 !important;
|
|
2680
|
+
}
|
|
2681
|
+
.chatbox .assistant .message-container .message-time {
|
|
2682
|
+
color: #aaa;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
/* Error Styling */
|
|
2686
|
+
.chatbox .chat .error.message-bubble {
|
|
2687
|
+
color: #721c24 !important;
|
|
2688
|
+
background: #f8d7da !important;
|
|
2689
|
+
}
|
|
2690
|
+
/* Error timestamp color */
|
|
2691
|
+
.chatbox .chat .error.message-bubble + .message-time { /* Select sibling time */
|
|
2692
|
+
color: #b85c65 !important;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
/* ===== Markdown Formatting Styles ===== */
|
|
2696
|
+
|
|
2697
|
+
/* Inline code */
|
|
2698
|
+
.message-bubble .md-code-inline {
|
|
2699
|
+
background: rgba(0, 0, 0, 0.06);
|
|
2700
|
+
padding: 1px 5px;
|
|
2701
|
+
border-radius: 4px;
|
|
2702
|
+
font-family: 'Courier New', Courier, monospace;
|
|
2703
|
+
font-size: 0.9em;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
/* Code blocks */
|
|
2707
|
+
.message-bubble .md-code-block {
|
|
2708
|
+
background: #1e1e1e;
|
|
2709
|
+
color: #d4d4d4;
|
|
2710
|
+
padding: 12px 14px;
|
|
2711
|
+
border-radius: 8px;
|
|
2712
|
+
overflow-x: auto;
|
|
2713
|
+
font-family: 'Courier New', Courier, monospace;
|
|
2714
|
+
font-size: 0.85em;
|
|
2715
|
+
line-height: 1.5;
|
|
2716
|
+
margin: 8px 0;
|
|
2717
|
+
white-space: pre;
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
/* Headings */
|
|
2721
|
+
.message-bubble .md-heading {
|
|
2722
|
+
font-weight: 600;
|
|
2723
|
+
margin: 10px 0 4px 0;
|
|
2724
|
+
line-height: 1.3;
|
|
2725
|
+
}
|
|
2726
|
+
.message-bubble h3.md-heading { font-size: 1.1em; }
|
|
2727
|
+
.message-bubble h4.md-heading { font-size: 1.05em; }
|
|
2728
|
+
.message-bubble h5.md-heading { font-size: 1em; }
|
|
2729
|
+
.message-bubble h6.md-heading { font-size: 0.95em; }
|
|
2730
|
+
|
|
2731
|
+
/* Lists */
|
|
2732
|
+
.message-bubble .md-list {
|
|
2733
|
+
margin: 6px 0;
|
|
2734
|
+
padding-left: 22px;
|
|
2735
|
+
}
|
|
2736
|
+
.message-bubble .md-list li {
|
|
2737
|
+
margin: 2px 0;
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
/* Links */
|
|
2741
|
+
.message-bubble a {
|
|
2742
|
+
color: #1a73e8;
|
|
2743
|
+
text-decoration: underline;
|
|
2744
|
+
word-break: break-all;
|
|
2745
|
+
}
|
|
2746
|
+
.message-bubble a:hover {
|
|
2747
|
+
color: #1558b0;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
/* Bold & italic */
|
|
2751
|
+
.message-bubble strong { font-weight: 600; }
|
|
2752
|
+
.message-bubble em { font-style: italic; }
|
|
2753
|
+
|
|
2754
|
+
.chatbot .chat-input {
|
|
2755
|
+
display: flex;
|
|
2756
|
+
gap: 5px;
|
|
2757
|
+
position: relative;
|
|
2758
|
+
width: 100%;
|
|
2759
|
+
background: #fff;
|
|
2760
|
+
padding: 3px 10px;
|
|
2761
|
+
border-top: 1px solid #ddd;
|
|
2762
|
+
flex-shrink: 0;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
.chat-input textarea {
|
|
2766
|
+
height: 55px;
|
|
2767
|
+
width: 100%;
|
|
2768
|
+
border: none;
|
|
2769
|
+
outline: none;
|
|
2770
|
+
resize: none;
|
|
2771
|
+
max-height: 180px;
|
|
2772
|
+
padding: 15px 15px 15px 0;
|
|
2773
|
+
font-size: 0.95em;
|
|
2774
|
+
cursor: text;
|
|
2775
|
+
caret-color: auto;
|
|
2776
|
+
background: transparent;
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
.chat-input.input-blocked textarea {
|
|
2780
|
+
padding-left: 45px;
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
.chat-input #chat_send_button {
|
|
2784
|
+
visibility: visible;
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
.chat-input #chat_send_button span {
|
|
2788
|
+
align-self: flex-end;
|
|
2789
|
+
color: var(--secondary-color, #801bea);
|
|
2790
|
+
cursor: pointer;
|
|
2791
|
+
height: 55px;
|
|
2792
|
+
display: flex;
|
|
2793
|
+
align-items: center;
|
|
2794
|
+
font-size: 1.35rem;
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
/* Disabled input styles */
|
|
2798
|
+
.chat-input.input-blocked {
|
|
2799
|
+
opacity: 0.6;
|
|
2800
|
+
background-color: #f5f5f5;
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
.chat-input.input-blocked textarea {
|
|
2804
|
+
cursor: not-allowed;
|
|
2805
|
+
background-color: #f5f5f5;
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
.chat-input .send-button-disabled {
|
|
2809
|
+
pointer-events: none;
|
|
2810
|
+
opacity: 0.5;
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
.chat-input .send-button-disabled span {
|
|
2814
|
+
color: #ccc !important;
|
|
2815
|
+
cursor: not-allowed !important;
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2818
|
+
/* Loading dots animation in input */
|
|
2819
|
+
.chat-input .input-loading-dots {
|
|
2820
|
+
position: absolute;
|
|
2821
|
+
left: 15px;
|
|
2822
|
+
top: 50%;
|
|
2823
|
+
transform: translateY(-50%);
|
|
2824
|
+
display: flex;
|
|
2825
|
+
gap: 4px;
|
|
2826
|
+
pointer-events: none;
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
.chat-input .input-loading-dots .dot {
|
|
2830
|
+
width: 6px;
|
|
2831
|
+
height: 6px;
|
|
2832
|
+
background: var(--secondary-color, #801bea);
|
|
2833
|
+
border-radius: 50%;
|
|
2834
|
+
animation: dot-bounce 1.4s infinite ease-in-out both;
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
.chat-input .input-loading-dots .dot:nth-child(1) {
|
|
2838
|
+
animation-delay: -0.32s;
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
.chat-input .input-loading-dots .dot:nth-child(2) {
|
|
2842
|
+
animation-delay: -0.16s;
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
@keyframes dot-bounce {
|
|
2846
|
+
0%, 80%, 100% {
|
|
2847
|
+
transform: scale(0.6);
|
|
2848
|
+
opacity: 0.5;
|
|
2849
|
+
}
|
|
2850
|
+
40% {
|
|
2851
|
+
transform: scale(1);
|
|
2852
|
+
opacity: 1;
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
@media (max-width: 768px) {
|
|
2857
|
+
.chatbot .chatbox {
|
|
2858
|
+
flex-grow: 1;
|
|
2859
|
+
padding: 25px 15px;
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
.chatbot .chat-input {
|
|
2863
|
+
padding: 5px 15px;
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
.message-container {
|
|
2867
|
+
max-width: 85%;
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
/* Chat Placeholder Styles */
|
|
2872
|
+
.chat-placeholder-container {
|
|
2873
|
+
display: flex;
|
|
2874
|
+
flex-direction: column;
|
|
2875
|
+
justify-content: space-between;
|
|
2876
|
+
align-items: center;
|
|
2877
|
+
height: 100%;
|
|
2878
|
+
padding: 40px 20px 20px;
|
|
2879
|
+
box-sizing: border-box;
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
.chat-placeholder-content {
|
|
2883
|
+
display: flex;
|
|
2884
|
+
flex-direction: column;
|
|
2885
|
+
align-items: center;
|
|
2886
|
+
justify-content: center;
|
|
2887
|
+
flex-grow: 1;
|
|
2888
|
+
text-align: center;
|
|
2889
|
+
max-width: 300px;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
.chat-placeholder-icon {
|
|
2893
|
+
color: var(--primary-color, #00bfdb);
|
|
2894
|
+
margin-bottom: 24px;
|
|
2895
|
+
opacity: 0.9;
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
.chat-placeholder-icon svg {
|
|
2899
|
+
width: 80px;
|
|
2900
|
+
height: 80px;
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
.chat-placeholder-title {
|
|
2904
|
+
font-size: 1.4rem;
|
|
2905
|
+
font-weight: 600;
|
|
2906
|
+
color: var(--secondary-color, #333);
|
|
2907
|
+
margin: 0 0 12px 0;
|
|
2908
|
+
letter-spacing: -0.02em;
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
.chat-placeholder-description {
|
|
2912
|
+
font-size: 0.95rem;
|
|
2913
|
+
color: #666;
|
|
2914
|
+
margin: 0;
|
|
2915
|
+
line-height: 1.5;
|
|
2916
|
+
opacity: 0.85;
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
.chat-placeholder-button {
|
|
2920
|
+
width: 100%;
|
|
2921
|
+
padding-top: 20px;
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2924
|
+
.chat-placeholder-button .button-container {
|
|
2925
|
+
width: 100%;
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
.chat-placeholder-button .start-button {
|
|
2929
|
+
width: 100%;
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
.chat-wrapper.placeholder-mode {
|
|
2933
|
+
height: 100%;
|
|
2934
|
+
}
|
|
2935
|
+
|
|
2936
|
+
@media (max-width: 500px) {
|
|
2937
|
+
.chat-placeholder-container {
|
|
2938
|
+
padding: 30px 15px 15px;
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
.chat-placeholder-icon svg {
|
|
2942
|
+
width: 60px;
|
|
2943
|
+
height: 60px;
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
.chat-placeholder-title {
|
|
2947
|
+
font-size: 1.2rem;
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
.chat-placeholder-description {
|
|
2951
|
+
font-size: 0.9rem;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
.floating-avatar-button {
|
|
2956
|
+
position: absolute;
|
|
2957
|
+
bottom: 80px;
|
|
2958
|
+
right: 16px;
|
|
2959
|
+
width: 40px;
|
|
2960
|
+
height: 40px;
|
|
2961
|
+
border-radius: 50%;
|
|
2962
|
+
background-color: var(--secondary-color, #801bea);
|
|
2963
|
+
color: white;
|
|
2964
|
+
border: none;
|
|
2965
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
|
2966
|
+
display: flex;
|
|
2967
|
+
align-items: center;
|
|
2968
|
+
justify-content: center;
|
|
2969
|
+
cursor: pointer;
|
|
2970
|
+
z-index: 100;
|
|
2971
|
+
transition: transform 0.2s, box-shadow 0.2s;
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2974
|
+
.floating-avatar-button:hover {
|
|
2975
|
+
transform: scale(1.05);
|
|
2976
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
.floating-avatar-button svg,
|
|
2980
|
+
.floating-avatar-button svg g,
|
|
2981
|
+
.floating-avatar-button svg path {
|
|
2982
|
+
width: 24px;
|
|
2983
|
+
height: 24px;
|
|
2984
|
+
fill: currentColor;
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
/* Ensure floating button is visible on mobile */
|
|
2988
|
+
.chatbot.mobile .floating-avatar-button {
|
|
2989
|
+
bottom: 100px;
|
|
2990
|
+
right: 20px;
|
|
2991
|
+
z-index: 1000;
|
|
2992
|
+
}
|
|
2993
|
+
`,ae=b`
|
|
2994
|
+
.chatbot footer {
|
|
2995
|
+
text-align: center;
|
|
2996
|
+
padding: 5px;
|
|
2997
|
+
background-color: var(--primary-color, #00bfdb);
|
|
2998
|
+
color: var(--text-color-primary-bg, #fff);
|
|
2999
|
+
border-top: 1px solid #ddd;
|
|
3000
|
+
border-bottom-left-radius: var(--corner-radius, 10px);
|
|
3001
|
+
border-bottom-right-radius: var(--corner-radius, 10px);
|
|
3002
|
+
width: 100%;
|
|
3003
|
+
min-height: 30px;
|
|
3004
|
+
flex: none;
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
.chatbot footer.page {
|
|
3008
|
+
border-bottom-left-radius: 0px;
|
|
3009
|
+
border-bottom-right-radius: 0px;
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
/* Small screens: hide footer to maximize usable space */
|
|
3013
|
+
@media (max-width: 768px) {
|
|
3014
|
+
.chatbot footer {
|
|
3015
|
+
display: none;
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
/* Landscape small screens (mobile/tablet rotated): hide footer too */
|
|
3020
|
+
@media (max-height: 500px) and (min-width: 769px) {
|
|
3021
|
+
.chatbot footer {
|
|
3022
|
+
display: none;
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
`,ie=b`
|
|
3026
|
+
.form-group {
|
|
3027
|
+
display: flex;
|
|
3028
|
+
flex-direction: column;
|
|
3029
|
+
margin-bottom: 15px;
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
.radio-group {
|
|
3033
|
+
margin: 20px 0;
|
|
3034
|
+
display: flex;
|
|
3035
|
+
justify-content: space-between;
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
label {
|
|
3039
|
+
margin-bottom: 5px;
|
|
3040
|
+
font-weight: bold;
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
input, select {
|
|
3044
|
+
width: 100%;
|
|
3045
|
+
max-width: 300px;
|
|
3046
|
+
padding: 8px;
|
|
3047
|
+
border: 1px solid #ccc;
|
|
3048
|
+
border-radius: 4px;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
.checkbox-group {
|
|
3052
|
+
display: flex;
|
|
3053
|
+
align-items: center;
|
|
3054
|
+
margin-top: 15px;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
|
|
3058
|
+
|
|
3059
|
+
.checkbox-label {
|
|
3060
|
+
display: block;
|
|
3061
|
+
padding-left: 15px;
|
|
3062
|
+
text-indent: -15px;
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
.checkbox-input {
|
|
3066
|
+
width: 15px;
|
|
3067
|
+
height: 15px;
|
|
3068
|
+
padding: 0;
|
|
3069
|
+
margin: 0;
|
|
3070
|
+
vertical-align: bottom;
|
|
3071
|
+
position: relative;
|
|
3072
|
+
top: -1px;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
.dialog-overlay {
|
|
3076
|
+
/* Constrain overlay to the chatbot container to avoid leaking outside */
|
|
3077
|
+
position: absolute;
|
|
3078
|
+
inset: 0;
|
|
3079
|
+
background: rgba(0, 0, 0, 0.5);
|
|
3080
|
+
display: flex;
|
|
3081
|
+
justify-content: center;
|
|
3082
|
+
align-items: center;
|
|
3083
|
+
z-index: var(--z-overlay, 1200);
|
|
3084
|
+
pointer-events: auto;
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
.dialog {
|
|
3088
|
+
width: 60%;
|
|
3089
|
+
max-width: 400px;
|
|
3090
|
+
min-width: 200px;
|
|
3091
|
+
height: auto;
|
|
3092
|
+
background: white;
|
|
3093
|
+
border-radius: 10px;
|
|
3094
|
+
padding: 15px;
|
|
3095
|
+
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.08), 0px 4px 8px rgba(0, 0, 0, 0.12);
|
|
3096
|
+
display: flex;
|
|
3097
|
+
flex-direction: column;
|
|
3098
|
+
justify-content: space-between;
|
|
3099
|
+
z-index: calc(var(--z-overlay, 1200) + 1);
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
.dialog p {
|
|
3103
|
+
overflow: hidden;
|
|
3104
|
+
text-overflow: ellipsis;
|
|
3105
|
+
white-space: normal;
|
|
3106
|
+
text-align: center;
|
|
3107
|
+
max-height: 220px;
|
|
3108
|
+
margin-bottom: 15px;
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
.dialog .dialog-button-wrapper {
|
|
3112
|
+
display: flex;
|
|
3113
|
+
justify-content: center;
|
|
3114
|
+
flex-wrap: wrap;
|
|
3115
|
+
gap: 10px;
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
.dialog button {
|
|
3119
|
+
border: none;
|
|
3120
|
+
padding: 10px 25px;
|
|
3121
|
+
border-radius: 5px;
|
|
3122
|
+
cursor: pointer;
|
|
3123
|
+
transition: transform 0.3s;
|
|
3124
|
+
width: 100px;
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
.dialog button:hover {
|
|
3128
|
+
transform: scale(1.05);
|
|
3129
|
+
}
|
|
3130
|
+
|
|
3131
|
+
.dialog button.confirm-button {
|
|
3132
|
+
background-color: var(--secondary-color, #801bea);
|
|
3133
|
+
color: white;
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
.dialog button.cancel-button {
|
|
3137
|
+
background-color: #ccc;
|
|
3138
|
+
color: black;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
/* Styles for radio labels */
|
|
3142
|
+
.radio-label {
|
|
3143
|
+
display: flex;
|
|
3144
|
+
align-items: center;
|
|
3145
|
+
font-size: 16px;
|
|
3146
|
+
cursor: pointer;
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
/* Styles for radio inputs */
|
|
3150
|
+
.radio-input {
|
|
3151
|
+
margin-right: 8px;
|
|
3152
|
+
cursor: pointer;
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
.dialog-button-group {
|
|
3156
|
+
display: flex;
|
|
3157
|
+
justify-content: center;
|
|
3158
|
+
flex-wrap: wrap;
|
|
3159
|
+
gap: 10px;
|
|
3160
|
+
margin-top: 20px;
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
.button-save {
|
|
3164
|
+
margin-top: .6rem;
|
|
3165
|
+
padding: 15px 32px;
|
|
3166
|
+
border-radius: 5%;
|
|
3167
|
+
background-color: var(--secondary-color, #801bea);
|
|
3168
|
+
color: #fff;
|
|
3169
|
+
border: none;
|
|
3170
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
3171
|
+
position: relative;
|
|
3172
|
+
transition: transform 0.3s, box-shadow 0.3s;
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
.button-save:active {
|
|
3176
|
+
transform: translateY(2px);
|
|
3177
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
.button-save:active:hover {
|
|
3181
|
+
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
.button-save:disabled {
|
|
3185
|
+
opacity: 0.5;
|
|
3186
|
+
cursor: not-allowed;
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
.button-cancel {
|
|
3190
|
+
margin-top: .6rem;
|
|
3191
|
+
padding: 15px 32px;
|
|
3192
|
+
border-radius: 5%;
|
|
3193
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
3194
|
+
border: none;
|
|
3195
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
3196
|
+
position: relative;
|
|
3197
|
+
transition: transform 0.3s, box-shadow 0.3s;
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
/* Consent dialog specific adjustments */
|
|
3201
|
+
.consent-dialog {
|
|
3202
|
+
/* Inherit base .dialog sizing, just allow vertical scrolling region and spacing */
|
|
3203
|
+
gap: 0.75rem; /* rely on flex column from base .dialog */
|
|
3204
|
+
max-height: 80vh;
|
|
3205
|
+
width: 75%;
|
|
3206
|
+
max-width: 500px;
|
|
3207
|
+
}
|
|
3208
|
+
/* Compact mode overrides when chatbot has compact class */
|
|
3209
|
+
.chatbot.compact .consent-dialog {
|
|
3210
|
+
max-height: 70vh;
|
|
3211
|
+
}
|
|
3212
|
+
/* Consent title styling - ensure it doesn't get cut off */
|
|
3213
|
+
.consent-dialog #chat-consent-title {
|
|
3214
|
+
max-height: none;
|
|
3215
|
+
white-space: normal;
|
|
3216
|
+
overflow: visible;
|
|
3217
|
+
text-overflow: unset;
|
|
3218
|
+
flex-shrink: 0;
|
|
3219
|
+
margin-bottom: 0.5rem;
|
|
3220
|
+
}
|
|
3221
|
+
/* Scrollable consent text area */
|
|
3222
|
+
.consent-dialog .consent-text.scrollable {
|
|
3223
|
+
flex: 1 1 auto;
|
|
3224
|
+
overflow-y: auto;
|
|
3225
|
+
max-height: 60vh;
|
|
3226
|
+
padding-right: 4px; /* space for scrollbar */
|
|
3227
|
+
}
|
|
3228
|
+
.chatbot.compact .consent-dialog .consent-text.scrollable {
|
|
3229
|
+
max-height: 40vh;
|
|
3230
|
+
font-size: 0.85rem;
|
|
3231
|
+
line-height: 1.3;
|
|
3232
|
+
}
|
|
3233
|
+
/* Improve focus visibility for scrollable region */
|
|
3234
|
+
.consent-dialog .consent-text.scrollable:focus {
|
|
3235
|
+
outline: 2px solid var(--secondary-color, #801bea);
|
|
3236
|
+
outline-offset: 2px;
|
|
3237
|
+
}
|
|
3238
|
+
/* Ensure buttons remain visible even if content overflows */
|
|
3239
|
+
.consent-dialog .dialog-button-group {
|
|
3240
|
+
margin-top: 0;
|
|
3241
|
+
padding-top: 0.25rem;
|
|
3242
|
+
}
|
|
3243
|
+
`;class ne extends(function(t=Object){return class extends t{constructor(...t){super(...t),this._eventBus=new bt,this._domDisposers=[]}get bus(){return this._eventBus}_onBus(t,e){return this._eventBus.on(t,e)}_onDom(t,e,a,i){t.addEventListener(e,a,i);const n=()=>t.removeEventListener(e,a,i);return this._domDisposers.push(n),n}pushDisposer(t){if("function"!=typeof t)throw new TypeError("Disposer must be a function");this._domDisposers.push(t)}_disposeListeners(){this._eventBus.dispose(),this._domDisposers.forEach((t=>{try{t()}catch(e){}})),this._domDisposers.length=0}_createChildBus(){return new bt}}}(_)){static#c=!1;static _injectFontLinks(){if(ne.#c)return;if("undefined"==typeof document||!document.head)return;ne.#c=!0;const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.googleapis.com",t.crossOrigin="anonymous",document.head.appendChild(t);const e=document.createElement("link");e.rel="preconnect",e.href="https://fonts.gstatic.com",e.crossOrigin="anonymous",document.head.appendChild(e);const a=document.createElement("link");a.href="https://fonts.googleapis.com/icon?family=Material+Icons&display=block",a.rel="stylesheet",document.head.appendChild(a);const i=document.createElement("link");i.href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap",i.rel="stylesheet",document.head.appendChild(i)}static get properties(){return{api_key:{type:String,attribute:"api-key"},token_endpoint:{type:String,attribute:"token-endpoint"},avatar_id:{type:String,attribute:"avatar-id"},toggler:{type:Boolean,reflect:!0,converter:t=>"false"!==t},barge_in:{type:Boolean,reflect:!0,attribute:"barge-in",converter:t=>"false"!==t},terms_href:{type:String,attribute:"terms-href"},privacy_href:{type:String,attribute:"privacy-href"},brand_name:{type:String,attribute:"brand-name"},brand_logo:{type:String,attribute:"brand-logo"},username:{type:String},phoneNumber:{type:String},email:{type:String},isTermsAccepted:{type:Boolean,attribute:"terms-accepted"},compact:{type:Boolean,reflect:!0,converter:t=>"false"!==t},target_app:{type:String,attribute:"target-app"},enable_captions:{type:Boolean,reflect:!0,attribute:"enable-captions",converter:t=>"false"!==t},uiLanguage:{type:String,attribute:"ui-language"},canvasWidth:{type:Number,reflect:!0,attribute:"canvas-width"},canvasHeight:{type:Number,reflect:!0,attribute:"canvas-height"},chatbotHeight:{type:Number,reflect:!0,attribute:"chatbot-height"},avatarBackground:{type:String,reflect:!0,attribute:"avatar-background"},cornerRadius:{type:String,reflect:!0,attribute:"corner-radius"},_canvasWidth:{type:Number,attribute:!1},_canvasHeight:{type:Number,attribute:!1},_chatbotHeight:{type:Number,attribute:!1},_language:{type:String,attribute:!1},_avatarName:{type:String,attribute:!1},_currentMessage:{type:Object,attribute:!1},_actorSnapshot:{type:Object,attribute:!1},_conversationTranscript:{type:Array,attribute:!1},_showConversationPanel:{type:Boolean,attribute:!1},_showChatbot:{type:Boolean,attribute:!1},_showMenu:{type:Boolean,attribute:!1},_shownPage:{type:String,attribute:!1},_showUserData:{type:Boolean,attribute:!1},_showSatisfactionScore:{type:Boolean,attribute:!1},_showLastMessage:{type:Boolean,attribute:!1},_satisfactionScore:{type:Number,attribute:!1},_lastMessageText:{type:String,attribute:!1},_liveCaption:{type:String,attribute:!1},_liveCaptionSpeaker:{type:String,attribute:!1},_isLiveCaptionsVisible:{type:Boolean,attribute:!1,reflect:!1},_showConfirmationDialog:{type:Boolean,attribute:!1},_dialogMessage:{type:String,attribute:!1},_confirmButtonLabel:{type:String,attribute:!1},_cancelButtonLabel:{type:String,attribute:!1},_showCopyTick:{type:Boolean,attribute:!1},_isFullBody:{type:Boolean,attribute:!1},_isVideoAvatar:{type:Boolean,attribute:!1},_isVideoAvatarIdleDisconnected:{type:Boolean,attribute:!1},_isVideoAvatarReconnecting:{type:Boolean,attribute:!1},_videoAvatarPlaceholderImageUrl:{type:String,attribute:!1},_showTyping:{type:Boolean,attribute:!1},_statusBarStatus:{type:String,attribute:!1},_inputsBlocked:{type:Boolean,attribute:!1},_isThinking:{type:Boolean,attribute:!1},_isListening:{type:Boolean,attribute:!1},_isSpeaking:{type:Boolean,attribute:!1},_isConversationInProgress:{type:Boolean,attribute:!1},_isConversationPaused:{type:Boolean,attribute:!1},_isAutoResuming:{type:Boolean,attribute:!1},_isCheckingResume:{type:Boolean,attribute:!1},_isResumeExpired:{type:Boolean,attribute:!1},_isInitializingConversation:{type:Boolean,attribute:!1},_isConversationTimedOut:{type:Boolean,attribute:!1},_isStartingConversation:{type:Boolean,attribute:!1},_isConversationStopped:{type:Boolean,attribute:!1},_isDisconnected:{type:Boolean,attribute:!1},_isFailed:{type:Boolean,attribute:!1},_avatarRunning:{type:Boolean,attribute:!1},_avatarResuming:{type:Boolean,attribute:!1},_showChatConsentDialog:{type:Boolean,attribute:!1}}}static get observedAttributes(){const t=super.observedAttributes??[];return[...new Set([...t,"api_key","token_endpoint","avatar_id","terms_href","privacy_href","brand_name","brand_logo","target_app","enable_captions","barge_in"])]}attributeChangedCallback(t,e,a){if(super.attributeChangedCallback&&super.attributeChangedCallback(t,e,a),t in{api_key:"api-key",token_endpoint:"token-endpoint",avatar_id:"avatar-id",terms_href:"terms-href",privacy_href:"privacy-href",brand_name:"brand-name",brand_logo:"brand-logo",target_app:"target-app",enable_captions:"enable-captions",barge_in:"barge-in",avatar_background:"avatar-background"}){try{this._deprecatedAttrWarnings=this._deprecatedAttrWarnings||new Set,this._deprecatedAttrWarnings.has(t)||this._deprecatedAttrWarnings.add(t)}catch(i){}switch(t){case"enable_captions":case"barge_in":{const e=null!==a&&"false"!==a;this[t]=e;break}case"avatar_background":this.avatarBackground=a;break;default:this[t]=a}}}static styles=[Xt,Zt,Jt,ee,te,ie,ae];constructor(){super(),this.api_key="",this.token_endpoint="",this.avatar_id="",this.toggler=!0,this.barge_in=!1,this.terms_href="",this.privacy_href="",this.brand_name="",this.brand_logo="",this.compact=!1,this.target_app="web",this.enable_captions=!0,this.uiLanguage=_t,this.canvasWidth=T.dom.canvasWidth,this.canvasHeight=T.dom.canvasHeight,this.chatbotHeight=T.dom.canvasHeight+T.dom.headerAndFooterHeight,this._canvasWidth=T.dom.canvasWidth,this._canvasHeight=T.dom.canvasHeight,this._chatbotHeight=T.dom.canvasHeight+T.dom.headerAndFooterHeight,this._speakingAvatar=null,this._language="",this.username="",this.phoneNumber="",this.email="",this.isTermsAccepted=!1,this._avatarName="Assistant",this._conversationTranscript=[],this._currentMessage=null,this._actorSnapshot={value:"initializing",context:{transcript:[]},matches:()=>!1},this._showConversationPanel=!1,this._showChatbot=!1,this._showMenu=!1,this._shownPage="LoaderPage",this._savedChatbotMode=null,(this.api_key||this.token_endpoint)&&this.avatar_id?this._statusBarStatus="initializing":(this._shownPage="ErrorPage",this._statusBarStatus="invalidConfiguration"),this._showUserData=!1,this._showSatisfactionScore=!1,this._showLastMessage=!1,this._satisfactionScore=null,this._lastMessageText="",this._liveCaption="",this._liveCaptionSpeaker="",this._isLiveCaptionsVisible=!0,this._alerts=null,this._showConfirmationDialog=!1,this._dialogMessage="",this._confirmButtonLabel=this._t("confirm"),this._cancelButtonLabel=this._t("cancel"),this._stateTestMode=T.test.stateTestMode,this._showCopyTick=!1,this._isFullBody=!0,this._isVideoAvatar=!1,this._isVideoAvatarIdleDisconnected=!1,this._isVideoAvatarReconnecting=!1,this._videoAvatarReconnectTimeoutId=null,this._videoAvatarReconnectAttempt=0,this._videoAvatarReconnectCooldownUntil=0,this._videoAvatarPlaceholderImageUrl=null,this._showTyping=!1,this._wakeLock=new Ct,this._focusTimeoutId=null,this.captionsTimeoutId=null,this._userCaptionClearTimeoutId=null,this._fontRevealTimeoutId=null,this._captionSwitchTimeoutId=null,this._menuHideTimeoutId=null,this._showUserDataTimeoutId=null,this._connection="unknown",this._initTriggered=!1,this._initInProgress=!1,this._initPromise=null,this._inputsBlocked=!1,this._isThinking=!1,this._isListening=!1,this._isSpeaking=!1,this._isConversationInProgress=!1,this._isConversationPaused=!1,this._isAutoResuming=!1,this._isResumeExpired=!1,this._isInitializingConversation=!1,this._isConversationTimedOut=!1,this._isStartingConversation=!1,this._isConversationStopped=!1,this._isDisconnected=!1,this._isFailed=!1,this._avatarRunning=!1,this._avatarResuming=!1,this._showChatConsentDialog=!1,this.avatarBackground="",this.cornerRadius=void 0,this._dirManagedByUiLanguage=!1,this._lastUiChatbotMode={isShown:null,chatbotMode:null},this._chatScrollTimeoutId=null,this._speakingAvatar=new mt(this.bus),this._applyBargeInPreference(),this._setupAvatarStateSubscription()}_requestUserDataDialog(){"mobile"!==this.target_app?(this._showMenu=!1,this._showUserData||(this._showUserDataTimeoutId&&(clearTimeout(this._showUserDataTimeoutId),this._showUserDataTimeoutId=null),"ChatPage"===this._shownPage?this._showUserDataTimeoutId=setTimeout((()=>{this._showUserDataTimeoutId=null,"mobile"!==this.target_app&&(this._showUserData||(this._showUserData=!0))}),2e3):this._showUserData=!0)):this.bus.emit("event_command_Alerts_ShowDismissableAlert",{errorMessage:this._t("enterInfoOnMobile"),className:"alert-warning"})}_t(t){return yt(this.uiLanguage,t)}_applyUiLanguage(){this._confirmButtonLabel=this._t("confirm"),this._cancelButtonLabel=this._t("cancel")}_applyDirectionFromUiLanguage(){const t=!0===this._dirManagedByUiLanguage,e=this.getAttribute("dir");if(!t&&("rtl"===e||"ltr"===e||"auto"===e))return;const a=(this.uiLanguage||_t).toLowerCase().split("-")[0],i=["ar","he","fa","ur"].includes(a)?"rtl":"ltr";this.dir!==i?(this.dir=i,this._dirManagedByUiLanguage=!0):t||(this._dirManagedByUiLanguage=!0)}_getAvatarBackgroundStyleObj(){const t=(this.avatarBackground??"").toString().trim();if(!t)return{};const e=t.toLowerCase();if(e.includes("url(")||e.includes("expression(")||e.includes("@import")||e.includes("@supports")||e.includes("@media"))return{};if(this._bgTestEl??="undefined"!=typeof document&&document?.createElement?document.createElement("div"):null,!this._bgTestEl)return{};const a=this._bgTestEl;if(/^(linear-gradient|radial-gradient|conic-gradient)\(/i.test(t)){if("undefined"!=typeof CSS&&CSS.supports?.("background-image",t))return a.style.backgroundImage="",a.style.backgroundImage=t,a.style.backgroundImage?{backgroundImage:a.style.backgroundImage}:{};try{return a.style.backgroundImage="",a.style.backgroundImage=t,a.style.backgroundImage?{backgroundImage:a.style.backgroundImage}:{}}catch(i){return{}}}if("undefined"!=typeof CSS&&CSS.supports?.("color",t))return a.style.backgroundColor="",a.style.backgroundColor=t,a.style.backgroundColor?{backgroundColor:a.style.backgroundColor}:{};try{return a.style.backgroundColor="",a.style.backgroundColor=t,a.style.backgroundColor?{backgroundColor:a.style.backgroundColor}:{}}catch(i){return{}}}_applyBargeInPreference(){const t=!1!==this.barge_in;try{T?.speech?.bargeIn&&(T.speech.bargeIn.enabled=t)}catch(e){}if(this._speakingAvatar?.setBargeInEnabled)try{const e=this._speakingAvatar.setBargeInEnabled(t);e&&"function"==typeof e.catch&&e.catch((t=>{}))}catch(e){}}firstUpdated(){const t=this.renderRoot.querySelector("#toastify-dismissable-alerts");this._alerts=new wt(this.bus,t,(()=>this.uiLanguage));try{const t=()=>{this._fontRevealTimeoutId=null,this.classList.add("icons-ready")};document.fonts&&document.fonts.ready?document.fonts.ready.then(t).catch((()=>t())):this._fontRevealTimeoutId=setTimeout(t,300)}catch(e){}this._unlockAudioHandler=()=>{this._unlockAudioContext()},window.addEventListener("click",this._unlockAudioHandler,{once:!0}),window.addEventListener("touchstart",this._unlockAudioHandler,{once:!0}),window.addEventListener("keydown",this._unlockAudioHandler,{once:!0})}_unlockAudioContext(){this._unlockAudioHandler&&(window.removeEventListener("click",this._unlockAudioHandler),window.removeEventListener("touchstart",this._unlockAudioHandler),window.removeEventListener("keydown",this._unlockAudioHandler),this._unlockAudioHandler=null),this._speakingAvatar?.avatarModule?.resumeAudioContext?.()}_setupAvatarStateSubscription(){if(this._speakingAvatar?.avatarOrchestrator){if(this._orchestratorUnsub){try{this._orchestratorUnsub()}catch{}this._orchestratorUnsub=null}this._orchestratorUnsub=this._speakingAvatar.avatarOrchestrator.subscribeProjected(((t,e)=>{if(!e)return;const a=this._actorSnapshot;this._actorSnapshot=e;let i=!1;const n=(t,e)=>{this[t]!==e&&(this[t]=e,i=!0)};try{n("_isConversationInProgress",!!e.hasTag?.("conversation_in_progress")),n("_isConversationPaused",!!e.hasTag?.("conversation_paused")),n("_isSpeaking",!!e.hasTag?.("speaking")),n("_isListening",!!e.hasTag?.("listening")),n("_isThinking",!!e.hasTag?.("thinking")),n("_inputsBlocked",!!e.hasTag?.("inputs_blocked")),n("_isAutoResuming",!!e.matches?.("lifecycle.conversation.autoResuming")),n("_isCheckingResume",!!e.matches?.("lifecycle.checkingResume")),n("_isResumeExpired",!!e.matches?.("lifecycle.conversation.resumeExpired")),n("_isInitializingConversation",!(!e.matches?.("lifecycle.conversation.initializingConversation")&&!e.matches?.("lifecycle.conversation.initializing"))),n("_isConversationTimedOut",!!e.matches?.("lifecycle.conversation.timedOut")),n("_isStartingConversation",!!(e.matches?.("lifecycle.conversation.inProgress.startingConversation")||e.matches?.("lifecycle.conversation.starting")||e.matches?.("lifecycle.conversation.autoResuming"))),n("_isConversationStopped",!!e.matches?.("lifecycle.conversation.stopped")),n("_isDisconnected",!!e.matches?.("connection.disconnected")),n("_isFailed",!(!e.matches?.("lifecycle.init.failed")&&!e.matches?.("lifecycle.failed")))}catch(s){}(i||a!==e)&&this.updateAlertStatus()}))}}updated(t){if(this.__postUpdateQueue||(this.__postUpdateQueue=[]),(t.has("toggler")||t.has("compact"))&&this.toggler&&this.compact&&(this.compact=!1),(t.has("target_app")||t.has("toggler"))&&"mobile"===this.target_app&&this.toggler&&(this.toggler=!1),t.has("uiLanguage")&&(this._applyUiLanguage(),this._applyDirectionFromUiLanguage()),t.has("barge_in")&&this.__postUpdateQueue.push((()=>this._applyBargeInPreference())),this.isInitialized()&&this._speakingAvatar?.sessionData&&(t.has("username")&&this.username!==this._speakingAvatar.sessionData.username&&(this._speakingAvatar.sessionData.username=this.username),t.has("phoneNumber")&&this.phoneNumber!==this._speakingAvatar.sessionData.phoneNumber&&(this._speakingAvatar.sessionData.phoneNumber=this.phoneNumber),t.has("email")&&this.email!==this._speakingAvatar.sessionData.email&&(this._speakingAvatar.sessionData.email=this.email),t.has("isTermsAccepted")&&this.isTermsAccepted!==this._speakingAvatar.sessionData.isTermsAccepted&&(this._speakingAvatar.sessionData.isTermsAccepted=this.isTermsAccepted)),t.has("api_key")||t.has("token_endpoint")||t.has("avatar_id")){const t=!(!this.api_key&&!this.token_endpoint||!this.avatar_id);t&&!this._initTriggered?(this._initTriggered=!0,this.__postUpdateQueue.push((()=>this._initialize()))):t||(this._initTriggered=!1,this.__postUpdateQueue.push((()=>this.updateAlertStatus("ErrorPage"))))}if((t.has("_showChatbot")||t.has("_shownPage"))&&(this.__postUpdateQueue.push((()=>{this._speakingAvatar?.chatSocket&&this._syncUiChatbotMode()})),t.has("_shownPage")&&this.__postUpdateQueue.push((()=>this._speakingAvatar?.avatarOrchestrator?.sendEvent("PAGE_CHANGED",{newPage:this._shownPage}))),t.has("_showChatbot")&&this.__postUpdateQueue.push((()=>{if(!("mobile"===this.target_app||this.toggler&&window.innerWidth<T.dom.smallDisplayWidth))try{this.style.removeProperty("--chatbot-dynamic-height")}catch(t){}requestAnimationFrame((()=>{this.updateSize(),requestAnimationFrame((()=>{try{this._speakingAvatar?.avatarModule?.onResize?.()}catch(t){}}))}))}))),this.toggler&&t.has("_showChatbot")&&this._showChatbot&&!this._isConversationInProgress&&!this._isAutoResuming&&!this._isResumeExpired&&this._startOrResumeConversation(!0),t.has("_shownPage")&&("ChatPage"===this._shownPage?(this._scheduleInputFocus("chat"),this._scheduleChatScroll(),this._chatScrollTimeoutId&&clearTimeout(this._chatScrollTimeoutId),this._chatScrollTimeoutId=setTimeout((()=>{this._chatScrollTimeoutId=null,this._scheduleChatScroll()}),80)):"AvatarPage"===this._shownPage&&this._showTyping&&this._scheduleInputFocus("typing")),t.has("_showTyping")&&"AvatarPage"===this._shownPage&&this._showTyping&&this._scheduleInputFocus("typing"),t.has("_inputsBlocked")&&!this._inputsBlocked&&!0===t.get("_inputsBlocked")&&(this._scheduleInputFocus(null,{skipOnMobile:!0}),"ChatPage"===this._shownPage&&(this._scheduleChatScroll(),this._chatScrollTimeoutId&&clearTimeout(this._chatScrollTimeoutId),this._chatScrollTimeoutId=setTimeout((()=>{this._chatScrollTimeoutId=null,this._scheduleChatScroll()}),150))),t.has("canvasWidth")||t.has("canvasHeight")||t.has("chatbotHeight")){const t=()=>this.updateSize();this.__postUpdateQueue.push((()=>requestAnimationFrame(t)))}if(this.__postUpdateQueue.length){const t=this.__postUpdateQueue.splice(0);Promise.resolve().then((()=>{for(const a of t)try{a()}catch(e){}}))}if(t.has("_showChatConsentDialog")&&(this._showChatConsentDialog?this._activateConsentFocusTrap():this._deactivateConsentFocusTrap()),t.has("cornerRadius"))try{const t=this.cornerRadius;if(null==t||""===t)this.style.removeProperty("--corner-radius");else{const e=String(t).trim(),a=/^-?\d+(?:\.\d+)?$/.test(e)?`${e}px`:e;this.style.setProperty("--corner-radius",a)}}catch(e){}}render(){return Yt(this)}_scheduleInputFocus(t=null,e={}){const{skipOnMobile:a=!1}=e;this._focusTimeoutId&&(cancelAnimationFrame(this._focusTimeoutId),this._focusTimeoutId=null),this._focusTimeoutId=requestAnimationFrame((()=>{try{if(a&&this._isMobileOrTouchDevice())return void(this._focusTimeoutId=null);const e=t||this._getCurrentInputType();if(!e)return void(this._focusTimeoutId=null);const i="chat"===e?"#message_input":"#typed_input",n=this.shadowRoot.querySelector(i);n&&!n.disabled&&this._isElementFocusable(n)&&document.activeElement!==n&&n.focus()}catch(e){}finally{this._focusTimeoutId=null}}))}_isMobileOrTouchDevice(){const t="ontouchstart"in window||navigator.maxTouchPoints>0,e=window.innerWidth<T.dom.smallDisplayWidth,a=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return t||e||a}_getCurrentInputType(){return"ChatPage"===this._shownPage?"chat":"AvatarPage"===this._shownPage&&this._showTyping?"typing":null}_isElementFocusable(t){if(!t)return!1;if(null===t.offsetParent)return!1;if("none"===t.style.display||"hidden"===t.style.visibility)return!1;try{const e=window.getComputedStyle(t);return"none"!==e.display&&"hidden"!==e.visibility}catch(e){return!0}}async connectedCallback(){super.connectedCallback(),ne._injectFontLinks(),["visibilitychange","pagehide","freeze"].forEach((t=>{this._onDom(document,t,(t=>this._handleVisibilityChange(t)))})),this._onDom(window,"focus",(t=>this._handleVisibilityChange(t))),this._onDom(window,"pageshow",(t=>this._handleVisibilityChange(t))),this._handleVisibilityChange({type:"init"}),requestAnimationFrame((()=>{this.updateSize(),requestAnimationFrame((()=>this.updateSize()))})),this._onBus("event_command_UI_UpdateCurrentMessage",(t=>{this._currentMessage={speaker:t.speaker,messageText:t.messageText,time:(new Date).toLocaleTimeString("en-US",{hour12:!1})}})),this._onBus("event_command_UI_UpdateSTTCaption",(t=>{if(this.enable_captions){const e=(t=>{if(t.length<=40)return t;const e=t.length-40,a=t.indexOf(" ",e);return-1!==a?t.slice(a).trim():t.slice(0,e).trim()})(t.STTCaption);this._updateLiveCaption(!0,e,"user")}})),this._onBus("event_command_UI_PlayCaptions",(t=>{if(this.enable_captions){const e=this._speakingAvatar?.avatarModule?.liveCaptions;e&&e.playCaptions(((t,e="",a=!1)=>{this._updateLiveCaption(t,e,"assistant",a)}),t.audioStartTime)}})),this._onBus("event_command_UI_ClearCaptions",(()=>{this._updateLiveCaption(!1,"","")})),this._onBus("event_command_UI_ClearConversation",(()=>{document.hidden||this._idleSpeakingAvatar(),this._speakingAvatar?.sessionData?.conversation?.transcript&&(this._conversationTranscript=[...this._speakingAvatar.sessionData.conversation.transcript]),this._updateLiveCaption(!1),this._currentMessage=null})),this._onBus("event_status_Conversation_MessageAppended",(t=>{try{this._speakingAvatar?.sessionData?.conversation?.transcript&&(this._conversationTranscript=[...this._speakingAvatar.sessionData.conversation.transcript])}catch(e){}if("user"===t?.speaker){this._userCaptionClearTimeoutId&&clearTimeout(this._userCaptionClearTimeoutId);const t=T?.captions?.captionTimeout;this._userCaptionClearTimeoutId=setTimeout((()=>{try{"user"===this._liveCaptionSpeaker&&this._updateLiveCaption(!1,"","")}finally{this._userCaptionClearTimeoutId=null}}),t)}this._scheduleChatScroll(),this._chatScrollTimeoutId&&clearTimeout(this._chatScrollTimeoutId),this._chatScrollTimeoutId=setTimeout((()=>{this._chatScrollTimeoutId=null,this._scheduleChatScroll()}),150)})),this._onBus("event_status_Conversation_TimedOut",(t=>{this.showConfirmationDialog(this._t("conversationExpiredPrompt"),(()=>{this._callDownloadTranscript(),this._speakingAvatar?.avatarOrchestrator?.sendEvent("CLEAR_CONVERSATION",{conversationId:t.conversationId})}),(()=>{this._speakingAvatar?.avatarOrchestrator?.sendEvent("CLEAR_CONVERSATION",{conversationId:t.conversationId})}),this._t("downloadAndClear"),this._t("onlyClear"))})),this._onBus("event_status_Conversation_StartFailed",(t=>{const e=t?.message||this._t("conversationStartFailed"),a=e.includes("403")||e.includes("permission")||e.includes("balance");this.bus.emit("event_command_Alerts_ShowDismissableAlert",{errorMessage:a?this._t("insufficientBalanceError"):e,className:"alert-danger"})})),this._onBus("event_status_Conversation_ResumedSuccessfully",(()=>{try{const t=this._speakingAvatar?.sessionData?.conversation;this._conversationTranscript=Array.isArray(t?.transcript)?t.transcript:[]}catch(t){this._conversationTranscript=[]}})),this._onBus("event_status_Conversation_ResumeFailedAndRestarted",(()=>{try{const t=this._speakingAvatar?.sessionData?.conversation;this._conversationTranscript=Array.isArray(t?.transcript)?t.transcript:[]}catch(t){this._conversationTranscript=[]}this.bus.emit("event_command_Alerts_ShowDismissableAlert",{errorMessage:this._t("resumeConversationFailedNewStarted"),className:"alert-warning"})})),this._onBus("event_status_Conversation_ResumeExpired",(()=>{this.showConfirmationDialog(this._t("conversationExpiredResumePrompt"),(()=>{this._callDownloadTranscript(),this._speakingAvatar?.avatarOrchestrator?.sendEvent("DISMISS")}),(()=>{this._speakingAvatar?.avatarOrchestrator?.sendEvent("DISMISS")}),this._t("download"),this._t("ok"))})),this._onBus("event_command_UI_RequestUserData",(()=>{this._requestUserDataDialog()})),this._onBus("event_command_UI_EnableCaptions",(()=>{this.enable_captions=!0})),this._onBus("event_command_UI_DisableCaptions",(()=>{this.enable_captions=!1})),this._onBus("event_status_Avatar_RenderingStateChanged",(t=>{const e=!!t?.running,a=t?.reason;"resume_start"===a?this._avatarResuming=!0:"resume"===a&&(this._avatarResuming=!1),e&&this._avatarResuming&&(this._avatarResuming=!1),this._avatarRunning!==e&&(this._avatarRunning=e),e&&(this._videoAvatarReconnectAttempt=0,this._videoAvatarReconnectCooldownUntil=0,this._isVideoAvatarIdleDisconnected&&(this._isVideoAvatarIdleDisconnected=!1),this._isVideoAvatarReconnecting&&(this._isVideoAvatarReconnecting=!1,this._clearVideoAvatarReconnectTimeout()))})),this._onBus("event_status_VideoAvatar_IdleDisconnected",(()=>{this._isVideoAvatarIdleDisconnected=!0,this._isVideoAvatarReconnecting=!1})),this._onBus("event_status_Avatar_Error",(t=>{this._isVideoAvatarReconnecting&&this._isConversationInProgress&&(this._isVideoAvatarReconnecting=!1,this._isVideoAvatarIdleDisconnected=!0)})),this._onBus("event_command_UI_SwitchToChatMode",(()=>{"ChatPage"!==this._shownPage?this._shownPage="ChatPage":this._syncUiChatbotMode()})),this._onBus("event_command_UI_SwitchToAvatarMode",(()=>{"AvatarPage"!==this._shownPage?this._shownPage="AvatarPage":this._syncUiChatbotMode();try{this._startListening()}catch(t){}})),this._onBus("event_command_UI_EndConversation",(()=>{this._endConversation()})),this._onDom(window,"resize",this.handleWindowResize.bind(this));try{const t="undefined"!=typeof window&&window.visualViewport?window.visualViewport:null;t&&(this._onDom(t,"resize",this.handleWindowResize.bind(this)),this._onDom(t,"scroll",this.handleWindowResize.bind(this)))}catch(e){}this.resizeObserver=new ResizeObserver((t=>{if(!t||!t.length)return;const a=t[0],{width:i,height:n}=a.contentRect||{};if((!this.toggler||!1!==this._showChatbot)&&i>120&&n>120&&(T.dom.canvasWidth=Math.round(i),T.dom.canvasHeight=Math.round(n),this._speakingAvatar&&this._speakingAvatar.avatarModule))try{this._speakingAvatar.avatarModule.onResize()}catch(e){}}));const t=this.renderRoot.querySelector("#avatar-container");t&&(this.resizeObserver.observe(t),this._avatarContainerClickHandler=()=>{this._speakingAvatar?.avatarModule?.resumeAudioContext?.()},t.addEventListener("click",this._avatarContainerClickHandler));try{this.hostResizeObserver=new ResizeObserver((()=>{requestAnimationFrame((()=>this.updateSize()))})),this.hostResizeObserver.observe(this)}catch(e){}}disconnectedCallback(){if(super.disconnectedCallback(),this._unlockAudioHandler&&(window.removeEventListener("click",this._unlockAudioHandler),window.removeEventListener("touchstart",this._unlockAudioHandler),window.removeEventListener("keydown",this._unlockAudioHandler),this._unlockAudioHandler=null),this._disposeListeners(),this.captionsTimeoutId&&(clearTimeout(this.captionsTimeoutId),this.captionsTimeoutId=null),this._userCaptionClearTimeoutId&&(clearTimeout(this._userCaptionClearTimeoutId),this._userCaptionClearTimeoutId=null),this._fontRevealTimeoutId&&(clearTimeout(this._fontRevealTimeoutId),this._fontRevealTimeoutId=null),this._captionSwitchTimeoutId&&(clearTimeout(this._captionSwitchTimeoutId),this._captionSwitchTimeoutId=null),this._menuHideTimeoutId&&(clearTimeout(this._menuHideTimeoutId),this._menuHideTimeoutId=null),this._showUserDataTimeoutId&&(clearTimeout(this._showUserDataTimeoutId),this._showUserDataTimeoutId=null),this._chatScrollTimeoutId&&(clearTimeout(this._chatScrollTimeoutId),this._chatScrollTimeoutId=null),this._clearVideoAvatarReconnectTimeout(),this._orchestratorUnsub){try{this._orchestratorUnsub()}catch{}this._orchestratorUnsub=null}if(this._focusTimeoutId&&(cancelAnimationFrame(this._focusTimeoutId),this._focusTimeoutId=null),this._bgTestEl=null,this._speakingAvatar?.destroy?.(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.hostResizeObserver){try{this.hostResizeObserver.disconnect()}catch(t){}this.hostResizeObserver=null}if(this._avatarContainerClickHandler){const t=this.renderRoot?.querySelector("#avatar-container");t?.removeEventListener("click",this._avatarContainerClickHandler),this._avatarContainerClickHandler=null}this._deactivateConsentFocusTrap()}updateSize(){const t="undefined"!=typeof window&&window.visualViewport?window.visualViewport:null,e=t?Math.round(t.width):window.innerWidth,a=t?Math.round(t.height):window.innerHeight,i=t?Math.round(t.offsetTop):0,n=e<T.dom.smallDisplayWidth,s=a<=T.dom.shortDisplayHeight;let o,r;const c=t=>{const e=Number(t);return Number.isFinite(e)&&e>0?e:null},l=c(this.canvasWidth),h=c(this.canvasHeight),d=c(this.chatbotHeight),u=(this.compact?0:T.dom.headerAndFooterHeight)+T.dom.controlsHeight;if("mobile"===this.target_app){o=e,r=a;try{this.style.setProperty("--chatbot-dynamic-height",`${a}px`),this.style.setProperty("--chatbot-dynamic-top",`${i}px`)}catch(p){}}else if(this.toggler)if(n||s){o=e,r=a;try{this.style.setProperty("--chatbot-dynamic-height",`${a}px`),this.style.setProperty("--chatbot-dynamic-top",`${i}px`)}catch(p){}}else{const t=Math.max(120,l??(T.dom.canvasWidth||400)),e=Math.max(120,h??(T.dom.canvasHeight||500));o=t,r=Math.max(120,d??e+u)}else{const t=this.getBoundingClientRect?.()||{},i=Math.round(t.width||this.offsetWidth||this.clientWidth||e),n=Math.round(t.height||this.offsetHeight||this.clientHeight||a),s=Math.max(120,l??i),c=Math.max(120,h??(T.dom.canvasHeight||n));o=s;const p=n>=120?n:c+u;r=Math.max(120,d??(h?c+u:p))}this._canvasWidth===o&&this._chatbotHeight===r||(this._canvasWidth=o,this._chatbotHeight=r)}async _initialize(){if(this._initInProgress&&this._initPromise)return this._initPromise;this._initInProgress=!0;const t=(async()=>{if(""===this.api_key&&""===this.token_endpoint||""===this.avatar_id)this.updateAlertStatus("ErrorPage");else{this.updateAlertStatus("LoaderPage");try{const t=await this._getChatbotState();this._showChatbot=t.isVisible,this._savedChatbotMode=t.mode,null!==t.enableCaptions&&(this.enable_captions=t.enableCaptions),await this.updateComplete,await this._initializeSpeakingAvatar()}catch(t){this.updateAlertStatus("DisconnectedPage")}}})();this._initPromise=t;try{await this._initPromise}finally{this._initInProgress=!1,this._initPromise=null}}async _initializeSpeakingAvatar(){const t={avatarAPIKey:this.api_key,avatarId:this.avatar_id,avatarContainer:this.renderRoot.querySelector("#avatar-container"),tokenEndpoint:this.token_endpoint,targetApp:this.target_app};this._wakeLock.request();try{if(!(await this._speakingAvatar.init(t)))throw new Error("Initialization failed");this._avatarName=this._speakingAvatar.sessionData.avatarName,this._language=this._speakingAvatar.sessionData.language,this.username=this._speakingAvatar.sessionData.username,this.phoneNumber=this._speakingAvatar.sessionData.phoneNumber,this.email=this._speakingAvatar.sessionData.email,!0===this.isTermsAccepted?this._speakingAvatar.sessionData.isTermsAccepted=!0:this.isTermsAccepted=this._speakingAvatar.sessionData.isTermsAccepted,this._isFullBody=this._speakingAvatar?.avatarModule?.isFullBody,this._isVideoAvatar=this._speakingAvatar?.isVideoAvatar?.()??!1,this._isVideoAvatar&&(this._videoAvatarPlaceholderImageUrl=this._getVideoAvatarPlaceholderImageUrl(),null===(await this._getChatbotState().catch((()=>({enableCaptions:null})))).enableCaptions&&(this.enable_captions=!1)),this._setupAvatarStateSubscription();const e=null!==this._speakingAvatar?.sessionData?.trainingId;e&&(this._initConversation(),this._syncUiChatbotMode()),e?"CHAT"===this._savedChatbotMode?this._shownPage="ChatPage":this._shownPage="AvatarPage":this._shownPage="ErrorPage"}catch(e){throw e}}handleWindowResize(){this.updateSize()}_handleVisibilityChange(t){let e=!0;try{const a="string"==typeof t?t:t?.type;e=!(document.hidden||"hidden"===document.visibilityState),"pagehide"!==a&&"freeze"!==a||(e=!1),"pageshow"!==a&&"focus"!==a||(e=!0)}catch(i){e=!0}const a=this._speakingAvatar?.avatarOrchestrator;a&&"function"==typeof a.sendEvent?a.sendEvent("VISIBILITY_CHANGED",{isVisible:e}):e?this._resumeAfterForeground():this._pauseAvatarForBackground()}_pauseAvatarForBackground(){this._speakingAvatar?.avatarOrchestrator?(this._speakingAvatar.avatarOrchestrator.is("speaking")&&this._speakingAvatar.avatarOrchestrator.sendEvent("INTERRUPT"),this._speakingAvatar.avatarOrchestrator.is("listening")&&this._speakingAvatar.avatarOrchestrator.sendEvent("IDLE"),this._speakingAvatar.avatarOrchestrator.is("idle")||this._speakingAvatar.avatarOrchestrator.is("stopped")||this._idleSpeakingAvatar(),this._wakeLock.release()):this._wakeLock.release()}_resumeAfterForeground(){}_idleSpeakingAvatar(){this._speakingAvatar&&this._speakingAvatar.avatarOrchestrator&&(this._speakingAvatar.avatarOrchestrator.is("idle")||this._speakingAvatar.avatarOrchestrator.is("stopped")||this._speakingAvatar.avatarOrchestrator.sendEvent("IDLE"))}_startListening(){this._inputsBlocked||this._isConversationInProgress&&this._speakingAvatar?.avatarOrchestrator?.is("idle")&&this._speakingAvatar?.avatarOrchestrator?.sendEvent("LISTEN")}_initConversation(){this.isInitialized()&&this._speakingAvatar?.avatarOrchestrator?.sendEvent("INIT_CONVERSATION")}_startOrResumeConversation(t=!1){Promise.resolve(this._hasChatConsent()).then((e=>{e?this._proceedStartConversation(t):this._showChatConsentDialog=!0})).catch((()=>{this._showChatConsentDialog=!0}))}_proceedStartConversation(t){try{const t=!(document.hidden||"hidden"===document.visibilityState);this._speakingAvatar?.avatarOrchestrator?.sendEvent("VISIBILITY_CHANGED",{isVisible:t})}catch(e){}this._speakingAvatar?.sessionData&&!0===this.isTermsAccepted&&(this._speakingAvatar.sessionData.isTermsAccepted=!0),this._speakingAvatar?.avatarOrchestrator?.sendEvent("START_CONVERSATION",{fresh:t,termsAccepted:!0===this.isTermsAccepted})}_endConversation(t=!0){t?this._showSatisfactionScore=!0:this._speakingAvatar?.avatarOrchestrator?.sendEvent("END_CONVERSATION",{satisfactionScore:0})}_updateLiveCaption(t,e="",a="",i=!1,n=!1){const s=T?.captions??{},o=s.captionChangeDelay??200,r=s.captionTimeout??1500,c=this._liveCaptionSpeaker;t&&"user"===a&&this._userCaptionClearTimeoutId&&(clearTimeout(this._userCaptionClearTimeoutId),this._userCaptionClearTimeoutId=null),n?(this._isLiveCaptionsVisible=!1,this._captionSwitchTimeoutId&&clearTimeout(this._captionSwitchTimeoutId),this._captionSwitchTimeoutId=setTimeout((()=>{this._captionSwitchTimeoutId=null,this._isLiveCaptionsVisible=t,this._liveCaption=e,this._liveCaptionSpeaker=a}),o)):(this.captionsTimeoutId&&(clearTimeout(this.captionsTimeoutId),this.captionsTimeoutId=null),this._isLiveCaptionsVisible=t,this._liveCaption=e,this._liveCaptionSpeaker=a),t||"user"===(a||c)&&this._userCaptionClearTimeoutId&&(clearTimeout(this._userCaptionClearTimeoutId),this._userCaptionClearTimeoutId=null),i&&(this.captionsTimeoutId=setTimeout((()=>{this._isLiveCaptionsVisible=!1,this._liveCaption="",this._liveCaptionSpeaker="",this._userCaptionClearTimeoutId&&(clearTimeout(this._userCaptionClearTimeoutId),this._userCaptionClearTimeoutId=null),this.captionsTimeoutId=null}),r))}updateAlertStatus(t=null){const e=this._actorSnapshot,a=!(!this.api_key&&!this.token_endpoint||!this.avatar_id),i=this._speakingAvatar?.sessionData&&null===this._speakingAvatar.sessionData.trainingId,n=!0===this._avatarResuming,s=(()=>{try{const t=this._speakingAvatar?.avatarModule;if(t?.isVideoAvatar&&t?.isRenderingActive?.())return!0}catch(t){}return!1})();let o=null;if(o=a?e?.matches?.("lifecycle.init.initializing")?s?"connected":"initializing":e?.matches?.("lifecycle.init.failed")?"failed":i?"invalidConfiguration":e?.matches?.("connection.connected")?"connected":"recovering":"invalidConfiguration","initializing"===o&&!e?.matches?.("lifecycle.init.initializing")&&e?.matches?.("connection.connected"))try{const t=this._speakingAvatar?.avatarModule?.isRenderingActive?.();!0===t&&(o="connected",this._avatarResuming=!1)}catch(r){}n||"initializing"!==o||"connected"!==this._statusBarStatus&&"recovering"!==this._statusBarStatus||(o=this._statusBarStatus),this._isVideoAvatarIdleDisconnected&&"recovering"===o&&(o="connected"),this._isVideoAvatar&&!this._isConversationInProgress&&"recovering"===o&&(o="connected"),this._statusBarStatus!==o&&(this._statusBarStatus=o),null!==t&&this._shownPage!==t&&(this._shownPage=t)}get initStatusValue(){return this.initStatus()}initStatus(){const t=this._actorSnapshot;if(!t)return"INITIALIZING";if(!this.api_key&&!this.token_endpoint||!this.avatar_id)return"INVALID";if(t.matches?.("lifecycle.init.failed"))return"FAILED";if(t.context?.initFailed&&t.matches?.("lifecycle.init.initializing"))return"FAILED";if(t.matches?.("lifecycle.init.initializing"))return"INITIALIZING";const e=this._speakingAvatar?.sessionData;return e&&e.avatarId&&null===e.trainingId?"INVALID":"COMPLETED"}isInitialized(){return"COMPLETED"===this.initStatus()}isInitializing(){return"INITIALIZING"===this.initStatus()}_handleToggleChatbot(){this._showChatbot||this._isConversationInProgress||this._isInitializingConversation?this._updateChatbotVisibility(!this._showChatbot):(this._updateChatbotVisibility(!0),this.isInitialized()&&this._startOrResumeConversation())}_updateChatbotVisibility(t){this._showChatbot=t,this._saveChatbotState()}_saveChatbotState(){const t="ChatPage"===this._shownPage?"CHAT":"AVATAR",e={isVisible:this._showChatbot,mode:t,enableCaptions:this.enable_captions};at.setItem("chatbotState_"+this.avatar_id,JSON.stringify(e))}async _getChatbotState(){try{const t=await at.getItem("chatbotState_"+this.avatar_id);if(t){const e=JSON.parse(t);return{isVisible:!0===e.isVisible,mode:e.mode||"AVATAR",enableCaptions:void 0!==e.enableCaptions?e.enableCaptions:null}}}catch(t){}return{isVisible:!1,mode:"AVATAR",enableCaptions:null}}_openLastMessage(t){this._lastMessageText=this._currentMessage.messageText,this._showLastMessage=!0}_closeLastMessage(){this._showLastMessage=!1}_showMenuOnHover(){window.matchMedia("(hover: hover)").matches&&(this._showMenu=!0,this.shadowRoot.getElementById("menu").classList.remove("hidden"))}_handleChatbotClick(){if(!this.compact){const t=this.shadowRoot.getElementById("menu");t?.classList.add("hide"),this._menuHideTimeoutId&&clearTimeout(this._menuHideTimeoutId),this._menuHideTimeoutId=setTimeout((()=>{this._menuHideTimeoutId=null,t?.classList.contains("hide")&&(this._showMenu=!1)}),500)}}_closeChatbot(){this._updateChatbotVisibility(!1)}_handleToggleMenu(){this._showMenu=!this._showMenu}_handleMicBtn(){const t=this._speakingAvatar?.avatarOrchestrator;t&&(this._isConversationInProgress||this._isStartingConversation)?(this._speakingAvatar?.avatarModule?.resumeAudioContext?.(),t.sendEvent("MIC_BUTTON")):this.bus.emit("event_command_Alerts_ShowDismissableAlert",{errorMessage:this._t("startConversationReminder")})}_handleShowChatPage(){this.isInitialized()&&(this._shownPage="ChatPage",this._showMenu=!1,this._saveChatbotState())}_handleShowAvatarPage(){this.isInitialized()&&(this._shownPage="AvatarPage",this._showMenu=!1,this._saveChatbotState())}_handleBackToAvatar(){this._handleShowAvatarPage()}_handleSwitchToChat(){this._handleShowChatPage()}_handleShowUserData(t){t.preventDefault(),this._requestUserDataDialog()}_handleEndConversationBtn(t){t&&(t.preventDefault(),t.stopPropagation()),this.showConfirmationDialog(this._t("endConversationPrompt"),(()=>{this._endConversation()}),(()=>{}),this._t("end"),this._t("cancel")),this._showMenu=!1}_handleStartConversationMenuBtn(t){t.preventDefault(),t.stopPropagation(),this._shouldConfirmRestart()?this._handleRestartConversation():(this._startOrResumeConversation(!0),this._showMenu=!1)}_handleStartConversationBtn(t){t.preventDefault(),this._shouldConfirmRestart()?this._handleRestartConversation():this._startOrResumeConversation(!0)}_handleRestartConversation(){this.showConfirmationDialog(this._t("restartConversationPrompt"),(()=>{this._idleSpeakingAvatar(),this._startOrResumeConversation(!0)}),(()=>{}),this._t("newConversation"),this._t("cancel"))}_consentStorageKey(){return`chatConsent_${this.avatar_id||"unknown"}`}async _hasChatConsent(){if(!0===this.isTermsAccepted)return!0;try{return"accepted"===await at.getItem(this._consentStorageKey())}catch(t){return!1}}async _handleConsentAccept(){try{await at.setItem(this._consentStorageKey(),"accepted")}catch(t){}this._showChatConsentDialog=!1;try{this.isTermsAccepted=!0,this._speakingAvatar?.sessionData&&(this._speakingAvatar.sessionData.isTermsAccepted=!0)}catch(t){}this._shouldConfirmRestart()?this._handleRestartConversation():this._startOrResumeConversation(!0)}async _handleConsentDecline(){try{await at.setItem(this._consentStorageKey(),"declined")}catch(t){}this._showChatConsentDialog=!1}_activateConsentFocusTrap(){requestAnimationFrame((()=>{try{this.shadowRoot?.querySelector(".dialog .button-save")?.focus()}catch(t){}}));const t=t=>{if(this._showChatConsentDialog&&("Escape"===t.key&&(this._showChatConsentDialog=!1,t.stopPropagation()),"Tab"===t.key)){const e=Array.from(this.shadowRoot.querySelectorAll(".dialog button"));if(!e.length)return;const a=e.indexOf(document.activeElement);t.preventDefault(),(t.shiftKey?a<=0?e[e.length-1]:e[a-1]:a===e.length-1?e[0]:e[a+1]).focus()}};this._consentKeyHandler=t,this.addEventListener("keydown",t)}_deactivateConsentFocusTrap(){this._consentKeyHandler&&(this.removeEventListener("keydown",this._consentKeyHandler),this._consentKeyHandler=null)}_canDownloadTranscript(){return this._conversationTranscript.length>0}_handleDownloadTranscriptMenuBtn(t){t.preventDefault(),this._callDownloadTranscript(),this._showMenu=!1}_callDownloadTranscript(){((t,e,a,i)=>{const n=(new Date).toLocaleString().replace(/[/:, ]/g,"-");let s=`\ufeff\nCONVERSATION TRANSCRIPT\n\n\n📅 Date: ${(new Date).toLocaleString()}\n🤖 Assistant: ${e}\n👤 User: ${a||"User"}${t?`\n⚡ Powered by ${t}`:""}\n\n`;i.forEach((t=>{const{speaker:i,messageText:n,time:o}=t;let r,c;if("user"===i)r=a||"User",c="👤";else{if("assistant"!==i)return;r=e,c="🤖"}s+=`${c} ${r} [${o}]\n${n}\n\n─────────────────────\n\n`}));const o=new Blob([s],{type:"text/plain;charset=utf-8"}),r=document.createElement("a");r.href=URL.createObjectURL(o),r.download=`transcript-${e}-${n}.txt`,document.body.appendChild(r),r.click(),document.body.removeChild(r)})(this.brand_name,this._speakingAvatar.sessionData.avatarName,this._speakingAvatar.sessionData.username,this._conversationTranscript)}async _handleSaveClick(){this._speakingAvatar.sessionData.username=this.username,this._speakingAvatar.sessionData.phoneNumber=this.phoneNumber,this._speakingAvatar.sessionData.email=this.email,this._speakingAvatar.sessionData.isTermsAccepted=this.isTermsAccepted,this._inputsBlocked=!0,this._showUserData=!1;try{this._speakingAvatar?.chatSocket?.sendUserData()}catch(t){this._inputsBlocked=!1,this.bus.emit("event_command_Alerts_ShowDismissableAlert",{errorMessage:t?.message||this._t("genericError")})}}_handleCancelClick(){this._showUserData=!1}_handleChatKeyUp(t){"Enter"!==t.key&&13!==t.keyCode||(t.preventDefault(),this._handleSendTextMessage())}_handleSendTextMessage(){if(this._inputsBlocked||this._isThinking||this._isStartingConversation)return void this.bus.emit("event_command_Alerts_ShowDismissableAlert",{errorMessage:this._t("waitCurrentResponse")});const t=this.renderRoot.querySelector("#message_input"),e=t.value;e&&""!==e.trim()&&(this._speakingAvatar?.avatarModule?.resumeAudioContext?.(),t.value="",this._speakingAvatar?.avatarOrchestrator?.sendEvent("SEND_TEXT_MESSAGE",{message:e}))}_handleTypingKeyUp(t){"Enter"!==t.key&&13!==t.keyCode||(t.preventDefault(),this._handleSendTypedInput())}_handleSendTypedInput(){if(this._inputsBlocked||this._isThinking||this._isStartingConversation)return void this.bus.emit("event_command_Alerts_ShowDismissableAlert",{errorMessage:this._t("waitCurrentResponse")});const t=this.renderRoot.querySelector("#typed_input"),e=t.value;e&&""!==e.trim()&&(this._speakingAvatar?.avatarModule?.resumeAudioContext?.(),t.value="",this._speakingAvatar?.avatarOrchestrator?.sendEvent("SEND_TEXT_MESSAGE",{message:e,chatbotMode:"AVATAR"}))}showConfirmationDialog(t,e,a,i,n){this._dialogMessage=t,this._confirmDialog=e,this._cancelDialog=a,this._confirmButtonLabel=i??this._t("confirm"),this._cancelButtonLabel=n??this._t("cancel"),this._showConfirmationDialog=!0}_handleConfirm(){this._confirmDialog&&this._confirmDialog(),this._resetDialog()}_handleCancel(){this._cancelDialog&&this._cancelDialog(),this._resetDialog()}_resetDialog(){this._showConfirmationDialog=!1,this._confirmDialog=()=>{},this._cancelDialog=()=>{},this._dialogMessage="",this._confirmButtonLabel=this._t("confirm"),this._cancelButtonLabel=this._t("cancel")}_handleToggleCaptionsSwitch(t){this.enable_captions=t.target.checked,this._saveChatbotState()}_handleVisemeButtonClick(t){this.bus.emit("event_command_visemeButtonClick",{visemeId:t.target.getAttribute("data-viseme-id")})}_handleFacialButtonClick(t){this.bus.emit("event_command_facialButtonClick",{facialId:t.target.getAttribute("data-facial-id")})}_handleConnectBtn(){"COMPLETED"!==this.initStatus()?this._initialize():this._speakingAvatar?.isVideoAvatar?.()?this.bus.emit("event_command_Avatar_UserReconnect"):this.bus.emit("event_command_ConnectionManager_ReconnectFailedModules")}_handleUpperBodyIcon(){this._speakingAvatar?.avatarModule?.setView("upper")}_handleFullBodyIcon(){this._speakingAvatar?.avatarModule?.setView("full")}_handleMidBodyIcon(){this._speakingAvatar?.avatarModule?.setView("mid")}_handleHeadBodyIcon(){this._speakingAvatar?.avatarModule?.setView("head")}_handlePlaceholderImageError(t){const e=t?.target;if(!(e instanceof HTMLImageElement&&e.classList.contains("video-avatar-placeholder-image")))return;e.style.display="none";const a=this.renderRoot?.querySelector(".video-avatar-placeholder-fallback");a&&(a.style.display="block")}_handleVideoAvatarReconnect(){if(this._isVideoAvatarReconnecting)return;const t=Date.now();if(t<(this._videoAvatarReconnectCooldownUntil||0))return;this._videoAvatarReconnectAttempt=(this._videoAvatarReconnectAttempt||0)+1;const e=Math.min(3e4,2e3*2**(this._videoAvatarReconnectAttempt-1));this._videoAvatarReconnectCooldownUntil=t+e,this._speakingAvatar?.avatarModule?.resumeAudioContext?.(),this._isVideoAvatarIdleDisconnected=!1,this._isVideoAvatarReconnecting=!0,this._clearVideoAvatarReconnectTimeout(),this._videoAvatarReconnectTimeoutId=setTimeout((()=>{this._isVideoAvatarReconnecting&&!this._avatarRunning&&(this._isVideoAvatarReconnecting=!1,this._isVideoAvatarIdleDisconnected=!0)}),3e4),this.bus.emit("event_command_Avatar_UserReconnect")}_clearVideoAvatarReconnectTimeout(){this._videoAvatarReconnectTimeoutId&&(clearTimeout(this._videoAvatarReconnectTimeoutId),this._videoAvatarReconnectTimeoutId=null)}_getVideoAvatarPlaceholderImageUrl(){try{const t=this._speakingAvatar?.auth?.getAvatarParameters?.();if(!t)return null;const e=t.avatarSource?.toLowerCase?.();if("azure"!==e)return null;const a=t.avatarSourceId;if(!a)return null;const[i,n]=a.includes(":")?a.split(":"):[a,"casual-sitting"];return i&&n?`https://sentifydavatars.blob.core.windows.net/azure/${i}-${n}.png`:null}catch(t){return null}}_handleSubmitScoreClick(){this._speakingAvatar?.avatarOrchestrator?.sendEvent("END_CONVERSATION",{satisfactionScore:this._satisfactionScore}),this._showSatisfactionScore=!1}_handleCancelScoreClick(){this._speakingAvatar?.avatarOrchestrator?.sendEvent("END_CONVERSATION",{satisfactionScore:0}),this._showSatisfactionScore=!1}_scheduleChatScroll(){try{if("ChatPage"!==this._shownPage)return;requestAnimationFrame((()=>{try{const t=this.shadowRoot?.querySelector(".chatbox");t&&(t.scrollTop=t.scrollHeight)}catch(t){}}))}catch(t){}}_syncUiChatbotMode(){if(!this._speakingAvatar?.avatarOrchestrator||!this._speakingAvatar?.chatSocket)return;const t={isShown:!this.toggler||this._showChatbot,chatbotMode:"AvatarPage"===this._shownPage?"AVATAR":"CHAT"};t.isShown===this._lastUiChatbotMode.isShown&&t.chatbotMode===this._lastUiChatbotMode.chatbotMode||(this._speakingAvatar.avatarOrchestrator.sendEvent("UI_CHATBOT_MODE",t),this._lastUiChatbotMode=t)}_handleToggleTyping(){this._showTyping=!this._showTyping}_testSetAuthConnected(t="connected"){this._speakingAvatar?.connectionManager?.connectionModules.authentication.updateConnectionState(t)}_testSetSocketConnected(t="connected"){this._speakingAvatar?.connectionManager?.connectionModules.chatSocket.updateConnectionState(t)}_testSetSpeechConnected(t="connected"){this._speakingAvatar?.connectionManager?.connectionModules["speech-token"].updateConnectionState(t)}_shouldConfirmRestart(){return!!(this._isConversationInProgress||this._isConversationPaused||this._isAutoResuming||this._isConversationTimedOut||this._isInitializingConversation)}}const se="undefined"!=typeof window&&void 0!==window.sessionStorage,oe={getItem:t=>Promise.resolve(se?window.sessionStorage.getItem(t):null),setItem:(t,e)=>Promise.resolve(se?window.sessionStorage.setItem(t,e):void 0),removeItem:t=>Promise.resolve(se?window.sessionStorage.removeItem(t):void 0)};function re(t){at.setInstance(t)}function ce(){"undefined"!=typeof window&&void 0!==window.customElements&&(customElements.get("sentifyd-bot")||customElements.define("sentifyd-bot",ne))}function le(t){if(ce(),t.containerId&&document.querySelector(`#${t.containerId} sentifyd-bot`))return document.querySelector(`#${t.containerId} sentifyd-bot`);let e=document.body;if(t.containerId){const a=document.getElementById(t.containerId);a&&(e=a)}const a=document.createElement("sentifyd-bot");return Object.keys(t).forEach((e=>{if("containerId"===e||"customAttributes"===e)return;const i=t[e];if(null!=i&&""!==i){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();a.setAttribute(t,"boolean"==typeof i?String(i):i)}})),t.customAttributes&&Object.keys(t.customAttributes).forEach((e=>{const i=t.customAttributes[e];null!=i&&""!==i&&a.setAttribute(e,String(i))})),e.appendChild(a),a}at.setInstance(oe),"undefined"!=typeof window&&ce();export{F as C,ne as S,le as a,T as c,re as i,ce as r};
|