1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-Bby97VBM.js","assets/livekit-B7TXWVV8.js","assets/rolldown-runtime-B0Z9INg1.js","assets/livekit-protocol-Cy_JL3XK.js"])))=>i.map(i=>d[i]); 2import{i as e}from"./dist-V0wV9pPA.js";import{t}from"./preload-helper-CwIXHf_L.js";import{g as n,vn as r}from"./runtime-core.esm-bundler-DPmoNEl9.js";import{n as i}from"./pinia-Bk4qx9O9.js";import{t as a}from"./ssr-F9GWYbf6.js";import{i as o,n as s,r as c}from"./useTracking-DPVxoASA.js";import{n as l}from"./wayfinder-Dp7PqxvV.js";var u=({visitorIp:e,device:t}={})=>{if(!a)return;let n={gclid:o(globalThis.location.search),ga_client_id:c(),path:globalThis.location.pathname,host:globalThis.location.hostname,device:t?.trim(),visitor_ip:e?.trim()},r={};for(let[e,t]of Object.entries(n))t&&(r[e]=t);return Object.keys(r).length>0?r:void 0},d=async(e,n,r,i,a)=>{let{Conversation:o}=await t(async()=>{let{Conversation:e}=await import(`./web-Bby97VBM.js`);return{Conversation:e}},__vite__mapDeps([0,1,2,3]));return await o.startSession({agentId:e,textOnly:r,...i?{overrides:i}:{},...a?{dynamicVariables:a}:{},...n})},f=e=>{if(!(!e||typeof e.message!=`string`||e.message.length===0))return{source:e.role??(e.source===`ai`?`agent`:`user`),text:e.message}},p=e=>({agent:{language:e}}),m=async(e,t,n,r,i,a)=>{if(a.forceVoice)try{return{kind:`started`,conversation:await i(e,t,!1,n,r),voiceEnabled:!0,voiceUnavailableReason:null,error:null,statusIfError:`connecting`}}catch(o){return a.onVoiceStartFailed?.(),{kind:`started`,conversation:await i(e,t,!0,n,r),voiceEnabled:!1,voiceUnavailableReason:o instanceof Error?o.message:`Microphone access unavailable. Continuing with text chat.`,error:null,statusIfError:`connecting`}}try{return{kind:`started`,conversation:await i(e,t,!0,n,r),voiceEnabled:!1,voiceUnavailableReason:null,error:null,statusIfError:`connecting`}}catch{return a.onTextStartFailed?.(),{kind:`started`,conversation:await i(e,t,!1,n,r),voiceEnabled:!0,voiceUnavailableReason:null,error:null,statusIfError:`connecting`}}},h=async(e,t=d)=>{let{agentId:n,callbacks:r,language:i,dynamicVariables:a,onTextStartFailed:o,onVoiceStartFailed:s,forceVoice:c=!1}=e,l=i?p(i):void 0,u={forceVoice:c,onTextStartFailed:o,onVoiceStartFailed:s};try{try{return await m(n,r,l,a,t,u)}catch{return await m(n,r,void 0,a,t,u)}}catch(e){return{kind:`failed`,error:e instanceof Error?e.message:`Failed to start ElevenLabs session.`}}},g=e=>({url:g.url(e),method:`get`});g.definition={methods:[`get`,`head`],url:`/api/viewer-ip`},g.url=e=>g.definition.url+l(e),g.get=e=>({url:g.url(e),method:`get`}),g.head=e=>({url:g.url(e),method:`head`});var _=async(e=fetch)=>{try{let t=await e(g().url,{headers:{Accept:`application/json`}});if(!t.ok)return null;let n=await t.json();return typeof n.ip==`string`&&n.ip.length>0?n.ip:null}catch{return null}},v={Idle:`idle`,Connecting:`connecting`,Connected:`connected`,Error:`error`,Disconnected:`disconnected`},y={Speaking:`speaking`,Listening:`listening`,Idle:`idle`},b={User:`user`,Agent:`agent`},x=e=>e?.toLowerCase().startsWith(`en`)?`en`:`de`,S=i(`elevenlabs`,()=>{let{trackEvent:t}=s(),i=e(),o=r(v.Idle),c=r(y.Idle),l=r([]),d=r(!1),p=r(null),m=r(!1),g=r(null),S=r(`de`),C=r(null),w=r(null),T=r(!1),E=null,D=!1,O=n(()=>o.value===v.Connected||o.value===v.Connecting),k=n(()=>o.value===v.Connecting||o.value===v.Connected||o.value===v.Error),A=n(()=>C.value?`https://storage.googleapis.com/eleven-public-cdn/convai/${C.value}/avatar.png`:null),j=e=>{o.value=e},M=e=>{p.value=e,e&&(o.value=v.Error)},N=()=>{E=null,m.value=!1,g.value=null,C.value=null},P=()=>({onConnect:({conversationId:e})=>{j(v.Connected),t(`elevenlabs_session_started`,{conversation_id:e})},onDisconnect:()=>{j(v.Disconnected),N()},onMessage:(e=>{let t=f(e);
2if(!t)return;let n=t.source===`agent`?b.Agent:b.User;if(n===b.User){let e=l.value.at(-1);if(e?.source===b.User&&e.text===t.text)return}l.value=[...l.value,{source:n,text:t.text,timestamp:Date.now()}]}),onError:e=>{M(typeof e==`string`?e:`ElevenLabs session error.`),t(`elevenlabs_error`,{reason:`session_error`})},onStatusChange:({status:e})=>{e===v.Connected?j(v.Connected):e===v.Connecting?j(v.Connecting):(e===v.Disconnected||e===`disconnecting`)&&j(v.Disconnected)},onModeChange:({mode:e})=>{(e===y.Speaking||e===y.Listening)&&(c.value=e)}}),F=async e=>{if(!a||D||O.value)return;e?.language&&(S.value=x(e.language));let n=e?.agentId??null;if(!n){M(`ElevenLabs agent ID is not configured.`),t(`elevenlabs_error`,{reason:`missing_agent_id`});return}C.value=n,D=!0,j(v.Connecting),M(null),l.value=[],c.value=y.Idle,d.value=!1,m.value=!1,g.value=null;let r=P();try{let a=u({visitorIp:await _(),device:i.props.userAgent}),s=await h({agentId:n,callbacks:r,language:S.value,dynamicVariables:a,forceVoice:e?.forceVoice,onTextStartFailed:()=>{t(`elevenlabs_error`,{reason:`text_start_failed`})},onVoiceStartFailed:()=>{t(`elevenlabs_error`,{reason:`voice_start_failed`})}});if(s.kind===`failed`){M(s.error),t(`elevenlabs_error`,{reason:`start_failed`}),N();return}E=s.conversation,m.value=s.voiceEnabled,g.value=s.voiceUnavailableReason,c.value=s.voiceEnabled?y.Listening:y.Idle,p.value=s.error,o.value===v.Error&&j(s.statusIfError)}finally{D=!1}},I=async()=>{if(!E){N(),j(v.Disconnected);return}try{await E.endSession()}catch{t(`elevenlabs_error`,{reason:`end_failed`})}finally{N(),j(v.Disconnected)}};return{status:o,mode:c,messages:l,isMuted:d,error:p,isVoiceEnabled:m,voiceUnavailableReason:g,language:S,agentId:C,pendingChatRequest:w,isChatConsentOpen:T,isOpen:O,isPanelVisible:k,avatarUrl:A,startSession:F,endSession:I,switchToVoice:async()=>{let e=C.value;await I(),await F({agentId:e,forceVoice:!0})},switchToText:async()=>{let e=C.value;await I(),await F({agentId:e})},changeLanguage:async e=>{let t=x(e);if(t===S.value)return;let n=o.value===v.Connected||o.value===v.Connecting||o.value===v.Error,r=C.value;S.value=t,n&&(await I(),await F({agentId:r}))},sendUserMessage:e=>{let t=e.trim();!t||!E||(E.sendUserMessage(t),l.value=[...l.value,{source:b.User,text:t,timestamp:Date.now()}])},sendUserActivity:()=>
2{if(E)try{E.sendUserActivity()}catch{}},setMuted:e=>{if(m.value&&(d.value=e,E&&typeof E.setMicMuted==`function`))try{E.setMicMuted(e)}catch{}},parkChatRequest:e=>{w.value=e,T.value=!0},acceptChatRequest:e=>{T.value=!1;let t=w.value;if(w.value=null,t)return F({agentId:t.agentId,language:e?.language}),t.trackingSource},dismissChatRequest:()=>{w.value=null,T.value=!1}}});export{v as n,S as r,y as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.