@helpai/elements 0.70.3 → 0.70.4
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/elements-web-component.esm.js +22 -22
- package/elements-web-component.esm.js.map +3 -3
- package/elements.cjs.js +22 -22
- package/elements.cjs.js.map +3 -3
- package/elements.esm.js +22 -22
- package/elements.esm.js.map +3 -3
- package/elements.js +19 -19
- package/elements.js.map +3 -3
- package/index.mjs +3 -3
- package/package.json +1 -1
- package/web-component.mjs +4 -4
package/web-component.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{Component as e,h as t,render as n}from"preact";import{useCallback as r,useEffect as i,useLayoutEffect as a,useMemo as o,useRef as s,useState as c}from"preact/hooks";import{batch as l,effect as u,signal as d,useComputed as f,useSignal as p}from"@preact/signals";import{Fragment as m,jsx as h,jsxs as g}from"preact/jsx-runtime";import{memo as _}from"preact/compat";import*as v from"streaming-markdown";const y={id:`help-ai`,name:`@helpai/elements`,global:`HelpAI`,tagName:`web-ai-chat`,cssPrefix:`helpai`,defaultBaseUrl:`https://help.ai`,displayName:`Help AI`,domain:`help.ai`,siteUrl:`https://help.ai`},b={attach:`Attach files`,attachmentMimeRejected:`File type not supported`,attachmentTooLarge:`File is too large`,attachmentTooMany:`Attachment limit reached`,conversationClosed:`This chat is closed`,conversationLoading:`Loading chat…`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRetry:`Retry`,expand:`Expand`,expandSidebar:`Expand sidebar`,exitFullscreen:`Exit fullscreen`,fullscreen:`Fullscreen`,history:`History`,historyBack:`Back to chat`,historyEmpty:`No previous chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,language:`Language`,launcherOpen:`Open chat`,launcherLabel:`Chat with us`,micStart:`Start voice input`,micStop:`Stop voice input`,micUnsupported:`Voice input is not supported in this browser`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,soundOff:`Sound off`,soundOn:`Sound on`,startNewConversation:`Start a new chat`,talkToOperator:`Talk to an operator`,connectingOperator:`Connecting you to an operator…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,cancelOperatorRequest:`Keep chatting with the AI`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,thinking:`Thinking…`,thoughts:`Thoughts`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,moduleBack:`Back`,contentLoading:`Loading…`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results found`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsBack:`Back to news`,newsPublishedAt:`Published {date}`,formSubmit:`Submit`,formSkip:`Maybe later`,formSubmitted:`Completed`,formSkipped:`Maybe later`,formFillOut:`Fill out`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidUrl:`Enter a valid URL`,formInvalidNumber:`Enter a valid number`,formTooShort:`Too short (min {min} characters)`,formTooLong:`Too long (max {max} characters)`,formNumberTooSmall:`Must be at least {min}`,formNumberTooLarge:`Must be at most {max}`,formPatternMismatch:`Please match the requested format`,formChooseAtLeast:`Choose at least {min}`,formChooseAtMost:`Choose at most {max}`,formOther:`Other`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,reject:`Reject`,approvalPrompt:`{tool} requires your approval to execute.`,approvalBody:`Review the tool input above and decide whether to allow this action.`,approvalYourResponse:`Your response: {decision}`,approvalEditHint:`You can edit this response until this step continues.`,approvalSubmitting:`Response submitted. Request in progress…`,edit:`Edit`,toolParameters:`Parameters`,statusAwaiting:`Awaiting Approval`,statusResponded:`Responded`,statusRunning:`Running`,statusCompleted:`Completed`,statusDenied:`Denied`,statusError:`Error`,statusSuperseded:`Skipped`},x={en:b,fr:{attach:`Joindre des fichiers`,attachmentMimeRejected:`Type de fichier non pris en charge`,attachmentTooLarge:`Le fichier est trop volumineux`,attachmentTooMany:`Limite de pièces jointes atteinte`,conversationClosed:`Ce chat est fermé`,conversationLoading:`Chargement du chat…`,close:`Fermer`,collapse:`Réduire`,collapseSidebar:`Réduire la barre latérale`,composerPlaceholder:`Écrivez un message…`,dateLastWeek:`7 derniers jours`,dateOlder:`Plus ancien`,dateToday:`Aujourd'hui`,dateYesterday:`Hier`,dropZone:`Déposez les fichiers à joindre`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRetry:`Réessayer`,expand:`Agrandir`,expandSidebar:`Développer la barre latérale`,exitFullscreen:`Quitter le plein écran`,fullscreen:`Plein écran`,history:`Historique`,historyBack:`Retour au chat`,historyEmpty:`Aucun chat pour le moment`,historyContinue:`Poursuivre le chat`,historyLoading:`Chargement de vos chats…`,historyTitle:`Historique des chats`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherLabel:`Discuter avec nous`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,micUnsupported:`La saisie vocale n'est pas prise en charge par ce navigateur`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,soundOff:`Son désactivé`,soundOn:`Son activé`,startNewConversation:`Démarrer un nouveau chat`,talkToOperator:`Parler à un opérateur`,connectingOperator:`Mise en relation avec un opérateur…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,cancelOperatorRequest:`Continuer avec l'IA`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,thinking:`Réflexion…`,thoughts:`Réflexions`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeContentTitle:`Articles populaires`,homeStatus:`Statut`,helpTitle:`Aide`,helpSearchPlaceholder:`Rechercher de l'aide`,helpEmpty:`Aucun article d'aide pour le moment`,helpLoading:`Chargement de l'aide…`,helpSearchEmpty:`Aucun résultat trouvé`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsBack:`Retour aux actualités`,newsPublishedAt:`Publié le {date}`,formSubmit:`Envoyer`,formSkip:`Plus tard`,formSubmitted:`Terminé`,formSkipped:`Plus tard`,formFillOut:`Remplir`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidUrl:`Saisissez une URL valide`,formInvalidNumber:`Saisissez un nombre valide`,formTooShort:`Trop court (min. {min} caractères)`,formTooLong:`Trop long (max. {max} caractères)`,formNumberTooSmall:`Doit être au moins {min}`,formNumberTooLarge:`Doit être au plus {max}`,formPatternMismatch:`Veuillez respecter le format demandé`,formChooseAtLeast:`Choisissez au moins {min}`,formChooseAtMost:`Choisissez au plus {max}`,formOther:`Autre`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,inputBadge:`Questions`,inputAnswered:`Répondu`,inputSkipped:`Ignoré`,showOptions:`Afficher les options`,hideOptions:`Masquer les options`,qtypeText:`Votre réponse`,qtypeEmail:`Adresse e-mail`,qtypePhone:`Numéro de téléphone`,qtypeNumber:`Nombre`,qtypeDate:`Date`,qtypeChooseOne:`Choisir une`,qtypeChooseAny:`Choisir plusieurs`,qtypeBoolean:`Oui / Non`,inputSubmit:`Envoyer les réponses`,inputSubmitHint:`Entrée pour envoyer · Maj+Entrée = saut de ligne`,inputSkip:`Ignorer`,confirmYes:`Oui`,confirmNo:`Non`,approve:`Approuver`,reject:`Refuser`,approvalPrompt:`{tool} nécessite votre approbation pour s'exécuter.`,approvalBody:`Vérifiez les paramètres ci-dessus et décidez d'autoriser ou non cette action.`,approvalYourResponse:`Votre réponse : {decision}`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,approvalSubmitting:`Réponse envoyée. Traitement en cours…`,edit:`Modifier`,toolParameters:`Paramètres`,statusAwaiting:`En attente d'approbation`,statusResponded:`Répondu`,statusRunning:`En cours`,statusCompleted:`Terminé`,statusDenied:`Refusé`,statusError:`Erreur`,statusSuperseded:`Ignoré`},ar:{attach:`إرفاق ملفات`,attachmentMimeRejected:`نوع الملف غير مدعوم`,attachmentTooLarge:`حجم الملف كبير جدًا`,attachmentTooMany:`تم بلوغ الحد الأقصى للمرفقات`,conversationClosed:`تم إغلاق هذه الدردشة`,conversationLoading:`جارٍ تحميل الدردشة…`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherLabel:`تحدث معنا`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,micUnsupported:`الإدخال الصوتي غير مدعوم في هذا المتصفح`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,startNewConversation:`بدء دردشة جديدة`,talkToOperator:`التحدث إلى موظف`,connectingOperator:`جاري توصيلك بأحد الموظفين…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,thinking:`يفكّر…`,thoughts:`الأفكار`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا توجد نتائج`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsBack:`العودة إلى الأخبار`,newsPublishedAt:`نُشر في {date}`,formSubmit:`إرسال`,formSkip:`لاحقًا`,formSubmitted:`تم`,formSkipped:`لاحقًا`,formFillOut:`تعبئة`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidUrl:`أدخل رابطًا صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formTooShort:`قصير جدًا (الحد الأدنى {min} حرفًا)`,formTooLong:`طويل جدًا (الحد الأقصى {max} حرفًا)`,formNumberTooSmall:`يجب ألا يقل عن {min}`,formNumberTooLarge:`يجب ألا يزيد عن {max}`,formPatternMismatch:`يرجى مطابقة الصيغة المطلوبة`,formChooseAtLeast:`اختر {min} على الأقل`,formChooseAtMost:`اختر {max} على الأكثر`,formOther:`أخرى`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,reject:`رفض`,approvalPrompt:`تتطلب {tool} موافقتك للتنفيذ.`,approvalBody:`راجع مُعطيات الأداة أعلاه وقرّر السماح بهذا الإجراء أو رفضه.`,approvalYourResponse:`ردّك: {decision}`,approvalEditHint:`يمكنك تعديل ردّك حتى تستأنف هذه الخطوة.`,approvalSubmitting:`تم إرسال الرد. جارٍ التنفيذ…`,edit:`تعديل`,toolParameters:`المعطيات`,statusAwaiting:`بانتظار الموافقة`,statusResponded:`تم الرد`,statusRunning:`قيد التنفيذ`,statusCompleted:`مكتمل`,statusDenied:`مرفوض`,statusError:`خطأ`,statusSuperseded:`تم التخطي`},es:{attach:`Adjuntar archivos`,attachmentMimeRejected:`Tipo de archivo no admitido`,attachmentTooLarge:`El archivo es demasiado grande`,attachmentTooMany:`Se alcanzó el límite de adjuntos`,conversationClosed:`Este chat está cerrado`,conversationLoading:`Cargando chat…`,close:`Cerrar`,collapse:`Contraer`,collapseSidebar:`Contraer la barra lateral`,composerPlaceholder:`Escribe un mensaje…`,dateLastWeek:`Últimos 7 días`,dateOlder:`Anteriores`,dateToday:`Hoy`,dateYesterday:`Ayer`,dropZone:`Suelta los archivos para adjuntarlos`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRetry:`Reintentar`,expand:`Ampliar`,expandSidebar:`Expandir la barra lateral`,exitFullscreen:`Salir de pantalla completa`,fullscreen:`Pantalla completa`,history:`Historial`,historyBack:`Volver al chat`,historyEmpty:`Aún no tienes chats`,historyContinue:`Continuar el chat`,historyLoading:`Cargando tus chats…`,historyTitle:`Historial de chats`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherLabel:`Chatea con nosotros`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,micUnsupported:`Este navegador no admite la entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,startNewConversation:`Iniciar un chat nuevo`,talkToOperator:`Hablar con un operador`,connectingOperator:`Conectándote con un operador…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,cancelOperatorRequest:`Seguir con la IA`,stop:`Detener`,theme:`Tema`,themeAuto:`Automático`,themeDark:`Oscuro`,themeLight:`Claro`,textSize:`Tamaño del texto`,textSizeSmall:`Pequeño`,textSizeNormal:`Normal`,textSizeLarge:`Grande`,loading:`Cargando…`,thinking:`Pensando…`,thoughts:`Razonamiento`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,moduleBack:`Atrás`,contentLoading:`Cargando…`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeContentTitle:`Artículos populares`,homeStatus:`Estado`,helpTitle:`Ayuda`,helpSearchPlaceholder:`Buscar ayuda`,helpEmpty:`Aún no hay artículos de ayuda`,helpLoading:`Cargando la ayuda…`,helpSearchEmpty:`No se encontraron resultados`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsBack:`Volver a novedades`,newsPublishedAt:`Publicado el {date}`,formSubmit:`Enviar`,formSkip:`Quizá más tarde`,formSubmitted:`Completado`,formSkipped:`Quizá más tarde`,formFillOut:`Completar`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidUrl:`Introduce una URL válida`,formInvalidNumber:`Introduce un número válido`,formTooShort:`Demasiado corto (mín. {min} caracteres)`,formTooLong:`Demasiado largo (máx. {max} caracteres)`,formNumberTooSmall:`Debe ser al menos {min}`,formNumberTooLarge:`Debe ser como máximo {max}`,formPatternMismatch:`Respeta el formato solicitado`,formChooseAtLeast:`Elige al menos {min}`,formChooseAtMost:`Elige como máximo {max}`,formOther:`Otro`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,inputBadge:`Preguntas`,inputAnswered:`Respondido`,inputSkipped:`Omitido`,showOptions:`Mostrar opciones`,hideOptions:`Ocultar opciones`,qtypeText:`Tu respuesta`,qtypeEmail:`Correo electrónico`,qtypePhone:`Número de teléfono`,qtypeNumber:`Número`,qtypeDate:`Fecha`,qtypeChooseOne:`Elige una`,qtypeChooseAny:`Elige varias`,qtypeBoolean:`Sí / No`,inputSubmit:`Enviar respuestas`,inputSubmitHint:`Enter para enviar · Mayús+Enter = nueva línea`,inputSkip:`Omitir`,confirmYes:`Sí`,confirmNo:`No`,approve:`Aprobar`,reject:`Rechazar`,approvalPrompt:`{tool} requiere tu aprobación para ejecutarse.`,approvalBody:`Revisa los parámetros de arriba y decide si permites esta acción.`,approvalYourResponse:`Tu respuesta: {decision}`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,approvalSubmitting:`Respuesta enviada. Procesando…`,edit:`Editar`,toolParameters:`Parámetros`,statusAwaiting:`Esperando aprobación`,statusResponded:`Respondido`,statusRunning:`En curso`,statusCompleted:`Completado`,statusDenied:`Denegado`,statusError:`Error`,statusSuperseded:`Omitido`},he:{attach:`צירוף קבצים`,attachmentMimeRejected:`סוג הקובץ אינו נתמך`,attachmentTooLarge:`הקובץ גדול מדי`,attachmentTooMany:`הגעת למספר המרבי של קבצים מצורפים`,conversationClosed:`הצ׳אט הזה נסגר`,conversationLoading:`טוען צ׳אט…`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherLabel:`דברו איתנו`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,micUnsupported:`קלט קולי אינו נתמך בדפדפן זה`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,startNewConversation:`התחלת צ׳אט חדש`,talkToOperator:`דבר עם נציג`,connectingOperator:`מחבר אותך לנציג…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,thinking:`חושב…`,thoughts:`מחשבות`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,moduleBack:`חזרה`,contentLoading:`טוען…`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`לא נמצאו תוצאות`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsBack:`חזרה לחדשות`,newsPublishedAt:`פורסם ב-{date}`,formSubmit:`שליחה`,formSkip:`אחר כך`,formSubmitted:`נשלח`,formSkipped:`דולג`,formFillOut:`מילוי`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidUrl:`הזן כתובת URL תקינה`,formInvalidNumber:`הזן מספר תקין`,formTooShort:`קצר מדי (לפחות {min} תווים)`,formTooLong:`ארוך מדי (לכל היותר {max} תווים)`,formNumberTooSmall:`חייב להיות לפחות {min}`,formNumberTooLarge:`חייב להיות לכל היותר {max}`,formPatternMismatch:`התאם לתבנית הנדרשת`,formChooseAtLeast:`בחר לפחות {min}`,formChooseAtMost:`בחר לכל היותר {max}`,formOther:`אחר`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,reject:`דחייה`,approvalPrompt:`הכלי {tool} דורש את אישורך כדי לפעול.`,approvalBody:`בדוק את פרמטרי הכלי שלמעלה והחלט אם לאשר פעולה זו.`,approvalYourResponse:`התגובה שלך: {decision}`,approvalEditHint:`ניתן לערוך את תגובתך עד שהשלב הזה יתחדש.`,approvalSubmitting:`התגובה נשלחה. מבצע…`,edit:`עריכה`,toolParameters:`פרמטרים`,statusAwaiting:`ממתין לאישור`,statusResponded:`נענה`,statusRunning:`פועל`,statusCompleted:`הושלם`,statusDenied:`נדחה`,statusError:`שגיאה`,statusSuperseded:`דולג`}};function S(e,t){let n=C(e),r=D(t),i=n===`en`?{}:x[n]??{},a=r?t[n]??{}:t??{},o=r?t.en??{}:{};return{...b,...i,...o,...a}}function C(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const w=new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function T(e){return w.has(C(e))}function E(e,t){return e[t]??t}function D(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}function O(e,t){if(!(!e?.length||!t))return e.find(e=>e.locale===t)}function k(e,t){let{translations:n,defaultLocale:r,...i}=e,a=O(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function A(e,t){let{translations:n,defaultLocale:r,...i}=e,a=O(n,t);if(!a)return i;let o=new Map((a.fields??[]).map(e=>[e.name,e])),s=i.fields.map(e=>{let t=o.get(e.name);if(!t)return e;let n=new Map((t.options??[]).map(e=>[e.value,e]));return{...e,label:t.label??e.label,placeholder:t.placeholder??e.placeholder,validationHint:t.validationHint??e.validationHint,options:e.options?.map(e=>{let t=n.get(e.value);return t?{...e,label:t.label??e.label,description:t.description??e.description}:e})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}const ee=new class{get(e){try{return localStorage.getItem(e)}catch{return null}}set(e,t){try{localStorage.setItem(e,t)}catch{}}remove(e){try{localStorage.removeItem(e)}catch{}}},te=[`off`,`error`,`warn`,`info`,`debug`,`trace`],ne=y.cssPrefix,j=`${ne}.debug`,re=`__${y.global}_DEBUG__`,ie=`${ne}-debug`;let ae=2;function oe(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(ie);if(e!==null){let t=se(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(j);if(e){let t=se(e);if(t>=0)return t}}catch{}return Reflect.get(window,re)?4:2}function se(e){if(e===!0||e===`1`||e===`true`)return 4;if(e===!1||e===`0`||e===`false`||e===`off`)return 0;if(typeof e==`number`)return Math.max(0,Math.min(5,Math.floor(e)));if(typeof e==`string`){let t=te.indexOf(e);if(t>=0)return t}return-1}ae=oe();function ce(e){let t=`[${ne}:${e}]`,n=(e,n,r)=>(r,i)=>{ae<e||(i===void 0?console[n](t,r):console[n](t,r,i))};return{error:n(1,`error`,`error`),warn:n(2,`warn`,`warn`),info:n(3,`info`,`info`),debug:n(4,`debug`,`debug`),trace:n(5,`debug`,`trace`),scope:t=>ce(`${e}:${t}`)}}const M=ce(`core`),N=M.scope(`context`),le=new Set([`visitorId`,`conversationId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),ue=1024,de=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function P(e){return pe(e,`userContext`,!0)}function fe(e){return pe(e,`pageContext`,!1)}function pe(e,t,n){if(e==null)return;if(typeof e!=`object`||Array.isArray(e)){N.warn(`ignored ${t} — expected an object`,{type:Array.isArray(e)?`array`:typeof e});return}let r={},i=0;for(let[n,a]of Object.entries(e)){if(le.has(n)){N.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){N.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=me(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!de.test(r.email)&&(N.warn(`dropped malformed ${t}.email "${r.email}"`),delete r.email),Object.keys(r).length>0?r:void 0}function me(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){N.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>ue?(N.warn(`truncated ${e}.${t} to ${ue} chars`),r.slice(0,ue)):r}N.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}const he={maxBytes:10*1024*1024,maxCount:10,accept:`*/*`},ge={voice:`local`},_e={list:[],byTrigger:{}},ve={enabled:!0,sampleRate:1},ye={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`,submitForm:`/pai/submit-form`},be={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},xe={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`sound`,`language`]},Se={enabled:!0,volume:.3,events:void 0},F={enabled:!0,events:void 0},Ce=[{label:`tabConversations`,layout:`chat`}];function we(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},o=t.footer??{},s=t.header??{},{themeMode:c,themeOverrides:l}=Te(t.theme),u=n.mode??`floating`,d=Ee(i.defaultLocale),f=i.availableLocales??[i.locale??d],p=De(i.locale??d,f,d),m=(t.baseUrl??y.defaultBaseUrl).replace(/\/$/,``),h=(t.agentApiBaseUrl??`${m}/api/agent`).replace(/\/$/,``),g=(t.dataApiBaseUrl??`${m}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:m,agentApiBaseUrl:h,dataApiBaseUrl:g,userContext:P(t.userContext),pageContext:fe(t.pageContext),position:n.position??`bottom-right`,themeMode:c,textSize:`normal`,themeOverrides:l,mode:u,iframe:n.iframe??!1,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,features:{voice:t.features?.voice??ge.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),operatorRequest:t.features?.enableOperatorRequest===!0,tools:t.features?.tools},forms:Fe(t.forms,p),endpoints:{upload:t.endpoints?.upload??ye.upload,transcribe:t.endpoints?.transcribe??ye.transcribe,submitForm:t.endpoints?.submitForm??ye.submitForm},attachments:{accept:t.composer?.attachments?.accept??he.accept,maxBytes:t.composer?.attachments?.maxBytes??he.maxBytes,maxCount:t.composer?.attachments?.maxCount??he.maxCount},locale:p,defaultLocale:d,availableLocales:f,startMinimized:r.startMinimized??!0,actions:Oe(u,s.actions),size:n.size??{},launcher:Le(t.launcher),sound:ke(a.sound),haptics:Ae(a.haptics),strings:S(p,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,poweredBy:Me(o.poweredBy),composer:Ne(t.composer),modules:Pe(t.modules),tracking:je(t.tracking,g),storage:t.storage??ee,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Te(e){return typeof e==`string`?{themeMode:e,themeOverrides:{}}:e&&typeof e==`object`?{themeMode:`auto`,themeOverrides:e}:{themeMode:`auto`,themeOverrides:{}}}function Ee(e){return e&&e!==`auto`?e:typeof navigator<`u`&&navigator.language?navigator.language:`en`}function De(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function Oe(e,t){return t??xe[e]}function ke(e){return{enabled:e?.enabled??Se.enabled,volume:e?.volume??Se.volume,events:e?.events}}function Ae(e){return{enabled:e?.enabled??F.enabled,events:e?.events}}function je(e,t){let n=e?.sampleRate??ve.sampleRate;return{enabled:e?.enabled??ve.enabled,endpoint:e?.endpoint??`${t}/pai/elements-px.gif`,sampleRate:Math.min(1,Math.max(0,Number.isFinite(n)?n:1)),token:e?.token}}function Me(e){let t={text:`Powered by ${y.displayName}`,href:y.siteUrl,...e};return t.text||t.logoUrl?t:null}function Ne(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function Pe(e){let t=e===void 0?Ce:e,n=new Set,r=[];for(let e of t.slice(0,4)){if(!e?.label||!e?.layout)continue;let t=e.contentTags?.filter(Boolean),i=e.id??t?.[0]??e.layout;for(;n.has(i);)i=`${i}-${r.length}`;n.add(i);let a={id:i,label:e.label,layout:e.layout};t&&t.length>0&&(a.contentTags=t),e.layout===`home`&&(a.brandName=e.brandName,a.greetingText=e.greetingText,a.showGreeting=!(e.hideGreeting??!1),a.showSearchBar=!(e.hideSearchBar??!1),a.showRecentConversations=!(e.hideRecentConversations??!1),e.userAvatars&&e.userAvatars.length>0&&(a.userAvatars=e.userAvatars),e.status&&(a.status=e.status),a.contentBlockTitle=e.contentBlockTitle),r.push(a)}return{list:r,byId:Object.fromEntries(r.map(e=>[e.id,e]))}}function Fe(e,t){if(!e?.length)return _e;let n=[],r=new Set;for(let i of e){if(!i?.id||r.has(i.id))continue;let e=A(i,t),a=(e.fields??[]).filter(e=>!!(e&&e.name&&e.label&&e.type)),o=(Array.isArray(e.on)?e.on:[e.on]).map(Ie).filter(e=>e!==null);a.length===0||o.length===0||(r.add(e.id),n.push({id:e.id,triggers:o,when:e.when,fields:a,title:e.title,description:e.description,submitLabel:e.submitLabel,skippable:e.skippable??!1,frequency:e.frequency??`once`,mirrorToContext:e.mirrorToContext??!0,reopenable:e.reopenable??!0,reviewable:e.reviewable??!0}))}let i={};for(let e of n){var a;for(let t of e.triggers)(i[a=t.kind]??(i[a]=[])).push(e)}return{list:n,byTrigger:i}}function Ie(e){if(typeof e!=`string`)return null;if(e===`pre-chat`||e===`conversation-closed`||e===`panel-close`||e===`manual`)return{kind:e};let[t,n]=e.split(`:`,2);if(t===`after-messages`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`after-messages`,param:e}:null}if(t===`idle`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`idle`,param:e}:null}return t===`page-area`&&n?{kind:`page-area`,param:n}:null}function Le(e){let t=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??be.variant,size:e?.size??be.size,label:e?.label??be.label,icon:e?.icon??be.icon,hidden:e?.hidden??be.hidden,callout:t}}function Re(e,t,n,r){let i=De(t,e.availableLocales,e.defaultLocale);if(i===e.locale&&n===e.themeMode&&r===e.textSize)return e;let a={...e};return i!==e.locale&&(a.locale=i,a.strings=S(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}const ze=[`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`];function Be(e,t){if(!t)return e;let n={...e};for(let r of ze){let i=t[r];if(i===void 0)continue;let a=e[r];if(r===`theme`){a===void 0&&(n[r]=i);continue}r!==`i18n`&&(n[r]=Ve(i,a))}t.modules!==void 0&&e.modules===void 0&&(n.modules=t.modules),t.dataApiBaseUrl!==void 0&&e.dataApiBaseUrl===void 0&&(n.dataApiBaseUrl=t.dataApiBaseUrl);let r=e.i18n,i=t.i18n;if(r||i){let e=Ve(i??{},r);i?.availableLocales!==void 0&&(e.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(e.defaultLocale=i.defaultLocale);let t=r?.strings,a=i?.strings;(t||a)&&(e.strings=He(a,t)),n.i18n=e}return n}function Ve(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function He(e,t){if(!e)return t;if(!t)return e;let n=D(e),r=D(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},o=r?t:{en:t};for(let[e,t]of Object.entries(a))i[e]={...t};for(let[e,t]of Object.entries(o))i[e]={...i[e],...t};return i}const I=[`clear`,`expand`,`fullscreen`,`sound`,`history`,`language`,`theme`,`textSize`,`close`],L=e=>e!==`false`,Ue=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),We=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`theme`,`theme`,e=>e]],Ge=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e],[`iframe`,`iframe`,L]],Ke=[[`width`,`width`],[`height`,`height`]],qe=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,L],[`show-reasoning`,`showReasoning`,L],[`show-tool-calls`,`showToolCalls`,L],[`show-sources`,`showSources`,L],[`disable-message-feedback`,`disableMessageFeedback`,L],[`auto-send-suggestions`,`autoSendSuggestions`,L]],Je=[[`locale`,`locale`]],Ye=new Set(I),Xe=e=>Ue(e).filter(e=>Ye.has(e)),Ze=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,L]],Qe=[[`features-disable-file-upload`,`disableFileUpload`,L],[`features-voice`,`voice`,e=>e],[`features-tools`,`tools`,Ue]],$e=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],et=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],tt=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],nt=[`launcher-label`,`callout-text`,`callout-delay`,`actions-main`,`actions-overflow`,`user-context`,`page-context`],rt=[We,Ge,Ke,qe,Je,Ze,Qe,$e,et,tt],it=new Set([`iframe`,`start-minimized`]),at=[...rt.flatMap(e=>e.map(([e])=>e).filter(e=>!it.has(e))),...nt];function ot(e){let t={},n=t=>{let n=e(t);return n===null||n===``?void 0:n};for(let[e,r,i]of We){let a=n(e);a!==void 0&&(t[r]=i?i(a):a)}let r=st(n,Ge),i=st(n,Ke);(r||i)&&(t.presentation={...r,...i?{size:i}:{}});let a=st(n,qe);a&&(t.behavior=a);let o=st(n,Je);o&&(t.i18n=o);let s=lt(e,n);s&&(t.launcher=s);let c=st(n,Qe);c&&(t.features=c);let l=st(n,$e);l&&(t.endpoints=l);let u=ct(n,et,`user-context`);u&&(t.userContext=u);let d=ct(n,tt,`page-context`);d&&(t.pageContext=d);let f=n(`actions`);return f!==void 0&&(t.header={actions:Xe(f)}),t}function st(e,t){let n={};for(let[r,i,a]of t){let t=e(r);t!==void 0&&(n[i]=a?a(t):t)}return Object.keys(n).length>0?n:null}function ct(e,t,n){let r={};for(let[n,i]of t){let t=e(n);t!==void 0&&(r[i]=t)}let i={},a=e(n);if(a)try{let e=JSON.parse(a);e&&typeof e==`object`&&!Array.isArray(e)&&(i=e)}catch{}let o={...i,...r};return Object.keys(o).length>0?o:null}function lt(e,t){let n=st(t,Ze)??{},r=e(`launcher-label`);r!==null&&(n.label=r);let i=t(`callout-text`);if(i){let e=Number.parseInt(t(`callout-delay`)??``,10);n.callout={text:i,...Number.isFinite(e)?{delayMs:e}:{}}}return Object.keys(n).length>0?n:null}function ut(){let e=Date.now(),t=new Uint8Array(16);t[0]=Math.floor(e/2**40)&255,t[1]=Math.floor(e/2**32)&255,t[2]=e>>>24&255,t[3]=e>>>16&255,t[4]=e>>>8&255,t[5]=e&255,dt(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function dt(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){crypto.getRandomValues(e);return}for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const ft=M.scope(`persistence`);function pt(e,t=ee,n){let r=n?`${e}.${n}`:e,i=`${y.cssPrefix}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${y.cssPrefix}.${r}${o}`,c=`${y.cssPrefix}${o}.visitorId`,l=`${s}.conversationId`,u=`${s}.userPrefs`,d=`${s}.panelOpen`,f=`${s}.panelSize`,p=`${s}.calloutDismissed`,m=`${s}.sidebarCollapsed`,h=`${s}.activeModule`,g=`${s}.historyCount`,_=`${s}.formsDone`,v={getVisitorId(){let e=t.get(c);if(e)return e;let n=ut();return t.set(c,n),n},setVisitorId(e){ft.debug(`setVisitorId (rebind)`,{id:e,scope:r}),t.set(c,e)},loadConversationId(){return t.get(l)??void 0},saveConversationId(e){ft.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(l,e):t.remove(l)},loadUserPrefs(){let e=t.get(u);if(!e)return{};try{let t=JSON.parse(e);return mt(t)?t:{}}catch(e){return ft.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(u,JSON.stringify(e))}catch(e){ft.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=v.loadUserPrefs();v.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(d);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(d,e?`1`:`0`)},loadPanelSize(){let e=t.get(f);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(f,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(p);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(p,e):t.remove(p)},loadSidebarCollapsed(){let e=t.get(m);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(m,e?`1`:`0`)},loadActiveModule(){return t.get(h)||null},saveActiveModule(e){t.set(h,e)},loadHistoryCount(){let e=t.get(g);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(g,String(e))},loadFormsDone(){let e=t.get(_);if(!e)return{};try{let t=JSON.parse(e);return mt(t)?t:{}}catch(e){return ft.warn(`loadFormsDone parse failed`,{error:e}),{}}},saveFormDone(e){try{let n=v.loadFormsDone();n[e]=Date.now(),t.set(_,JSON.stringify(n))}catch(e){ft.warn(`saveFormDone serialise failed`,{error:e})}},rememberStorageVersion(e){e&&e!==t.get(i)&&(ft.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},clearConversation(){t.remove(l)}};return v}function mt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ht=[`:host{--__P__-accent-user: __BRAND_ACCENT__;--__P__-accent: var(--__P__-accent-user);--__P__-accent-text-user: __BRAND_ACCENT_TEXT__;--__P__-accent-text: var(--__P__-accent-text-user);--__P__-accent-fg: var(--__P__-accent);--__P__-radius: __BRAND_RADIUS__;--__P__-radius-sm: 8px;--__P__-radius-md: 10px;--__P__-radius-lg: 16px;--__P__-font: __BRAND_FONT__;--__P__-font-display: var(--__P__-font);--__P__-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;--__P__-bg: oklch(1 0 0);--__P__-bg-elevated: oklch(.9789 .0029 278.3);--__P__-surface: var(--__P__-bg-elevated);--__P__-muted: var(--__P__-fg-muted);--__P__-hover: oklch(.1686 .011 278.3 / .06);--__P__-fg: oklch(.1686 .011 278.3);--__P__-fg-muted: oklch(.4932 .0301 278.3);--__P__-border: oklch(.9312 .0084 278.3);--__P__-border-strong: oklch(.8757 .0131 278.3);--__P__-bubble-user: var(--__P__-accent);--__P__-bubble-user-text: var(--__P__-accent-text);--__P__-bubble-assistant: oklch(.9638 .0058 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-on-accent: var(--__P__-accent-text);--__P__-success: oklch(.6456 .1654 151.53);--__P__-warning: oklch(.7135 .1494 74.05);--__P__-danger: oklch(.5966 .1818 24.51);--__P__-danger-text: oklch(.5054 .1905 27.52);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .1);--__P__-neutral: oklch(.7137 .0192 278.3);--__P__-pill-l-min: .3;--__P__-pill-l-max: .46;--__P__-focus: var(--__P__-accent);--__P__-shadow-panel: 0 8px 24px -8px rgba(13, 15, 20, .18), 0 24px 64px -24px rgba(13, 15, 20, .24);--__P__-shadow-card: 0 1px 2px rgba(13, 15, 20, .06), 0 4px 12px -6px rgba(13, 15, 20, .12);--__P__-backdrop: oklch(.1686 .011 278.3 / .55);--__P__-shadow-fab: 0 6px 16px -4px color-mix(in oklch, var(--__P__-accent) 45%, transparent), 0 12px 32px -12px rgba(13, 15, 20, .25);--__P__-z-fab: 2147483600;--__P__-z-panel: 2147483601;--__P__-panel-w: 380px;--__P__-panel-h: 600px;--__P__-fab-size: 56px;--__P__-conversation-max: 768px;--__P__-space-1: 4px;--__P__-space-2: 8px;--__P__-space-3: 12px;--__P__-space-4: 16px;--__P__-space-5: 20px;--__P__-space-6: 24px;--__P__-space-8: 32px;--__P__-text-scale: 1;--__P__-text-xs: calc(12px * var(--__P__-text-scale));--__P__-text-sm: calc(13px * var(--__P__-text-scale));--__P__-text-base: calc(15px * var(--__P__-text-scale));--__P__-text-md: calc(16px * var(--__P__-text-scale));--__P__-text-lg: calc(18px * var(--__P__-text-scale));--__P__-text-xl: calc(22px * var(--__P__-text-scale));--__P__-text-2xl: calc(30px * var(--__P__-text-scale))}:host([data-mode="modal"]),:host([data-mode="drawer"]){--__P__-conversation-max: 100%}:host([data-text-size="small"]){--__P__-text-scale: .9}:host([data-text-size="large"]){--__P__-text-scale: 1.15}:host{--__P__-ease: cubic-bezier(.2, .7, .2, 1);--__P__-ease-out: cubic-bezier(.2, .7, .2, 1);--__P__-ease-in: cubic-bezier(.4, 0, 1, 1);--__P__-ease-in-out: cubic-bezier(.65, 0, .35, 1);--__P__-dur-quick: .12s;--__P__-dur-base: .22s;--__P__-dur-slow: .32s;font-family:var(--__P__-font);color:var(--__P__-fg);color-scheme:light;--__P__-color-scheme: light}:host([data-theme="dark"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-danger-text: oklch(.8077 .1035 19.57);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .18);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);--__P__-shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px -6px rgba(0, 0, 0, .5);--__P__-backdrop: rgba(0, 0, 0, .65);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;color-scheme:dark;--__P__-color-scheme: dark}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);color-scheme:dark;--__P__-color-scheme: dark}}@supports (color: oklch(from red l c h)){:host{--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.3, l, .62) c h);--__P__-accent-text: oklch(from var(--__P__-accent) clamp(0, (l / .623 - 1) * -infinity, 1) 0 h);--__P__-accent-fg: oklch(from var(--__P__-accent-user) clamp(.3, l, .46) c h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
|
|
1
|
+
import{Component as e,h as t,render as n}from"preact";import{useCallback as r,useEffect as i,useLayoutEffect as a,useMemo as o,useRef as s,useState as c}from"preact/hooks";import{batch as l,effect as u,signal as d,useComputed as f,useSignal as p}from"@preact/signals";import{Fragment as m,jsx as h,jsxs as g}from"preact/jsx-runtime";import{memo as _}from"preact/compat";import*as v from"streaming-markdown";const y={id:`help-ai`,name:`@helpai/elements`,global:`HelpAI`,tagName:`web-ai-chat`,cssPrefix:`helpai`,defaultBaseUrl:`https://help.ai`,displayName:`Help AI`,domain:`help.ai`,siteUrl:`https://help.ai`},b={attach:`Attach files`,attachmentMimeRejected:`File type not supported`,attachmentTooLarge:`File is too large`,attachmentTooMany:`Attachment limit reached`,conversationClosed:`This chat is closed`,conversationLoading:`Loading chat…`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRetry:`Retry`,expand:`Expand`,expandSidebar:`Expand sidebar`,exitFullscreen:`Exit fullscreen`,fullscreen:`Fullscreen`,history:`History`,historyBack:`Back to chat`,historyEmpty:`No previous chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,language:`Language`,launcherOpen:`Open chat`,launcherLabel:`Chat with us`,micStart:`Start voice input`,micStop:`Stop voice input`,micUnsupported:`Voice input is not supported in this browser`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,soundOff:`Sound off`,soundOn:`Sound on`,startNewConversation:`Start a new chat`,talkToOperator:`Talk to an operator`,connectingOperator:`Connecting you to an operator…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,cancelOperatorRequest:`Keep chatting with the AI`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,thinking:`Thinking…`,thoughts:`Thoughts`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,moduleBack:`Back`,contentLoading:`Loading…`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results found`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsBack:`Back to news`,newsPublishedAt:`Published {date}`,formSubmit:`Submit`,formSkip:`Maybe later`,formSubmitted:`Completed`,formSkipped:`Maybe later`,formFillOut:`Fill out`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidUrl:`Enter a valid URL`,formInvalidNumber:`Enter a valid number`,formTooShort:`Too short (min {min} characters)`,formTooLong:`Too long (max {max} characters)`,formNumberTooSmall:`Must be at least {min}`,formNumberTooLarge:`Must be at most {max}`,formPatternMismatch:`Please match the requested format`,formChooseAtLeast:`Choose at least {min}`,formChooseAtMost:`Choose at most {max}`,formOther:`Other`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,reject:`Reject`,approvalPrompt:`{tool} requires your approval to execute.`,approvalBody:`Review the tool input above and decide whether to allow this action.`,approvalYourResponse:`Your response: {decision}`,approvalEditHint:`You can edit this response until this step continues.`,approvalSubmitting:`Response submitted. Request in progress…`,edit:`Edit`,toolParameters:`Parameters`,statusAwaiting:`Awaiting Approval`,statusResponded:`Responded`,statusRunning:`Running`,statusCompleted:`Completed`,statusDenied:`Denied`,statusError:`Error`,statusSuperseded:`Skipped`},x={en:b,fr:{attach:`Joindre des fichiers`,attachmentMimeRejected:`Type de fichier non pris en charge`,attachmentTooLarge:`Le fichier est trop volumineux`,attachmentTooMany:`Limite de pièces jointes atteinte`,conversationClosed:`Ce chat est fermé`,conversationLoading:`Chargement du chat…`,close:`Fermer`,collapse:`Réduire`,collapseSidebar:`Réduire la barre latérale`,composerPlaceholder:`Écrivez un message…`,dateLastWeek:`7 derniers jours`,dateOlder:`Plus ancien`,dateToday:`Aujourd'hui`,dateYesterday:`Hier`,dropZone:`Déposez les fichiers à joindre`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRetry:`Réessayer`,expand:`Agrandir`,expandSidebar:`Développer la barre latérale`,exitFullscreen:`Quitter le plein écran`,fullscreen:`Plein écran`,history:`Historique`,historyBack:`Retour au chat`,historyEmpty:`Aucun chat pour le moment`,historyContinue:`Poursuivre le chat`,historyLoading:`Chargement de vos chats…`,historyTitle:`Historique des chats`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherLabel:`Discuter avec nous`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,micUnsupported:`La saisie vocale n'est pas prise en charge par ce navigateur`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,soundOff:`Son désactivé`,soundOn:`Son activé`,startNewConversation:`Démarrer un nouveau chat`,talkToOperator:`Parler à un opérateur`,connectingOperator:`Mise en relation avec un opérateur…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,cancelOperatorRequest:`Continuer avec l'IA`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,thinking:`Réflexion…`,thoughts:`Réflexions`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeContentTitle:`Articles populaires`,homeStatus:`Statut`,helpTitle:`Aide`,helpSearchPlaceholder:`Rechercher de l'aide`,helpEmpty:`Aucun article d'aide pour le moment`,helpLoading:`Chargement de l'aide…`,helpSearchEmpty:`Aucun résultat trouvé`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsBack:`Retour aux actualités`,newsPublishedAt:`Publié le {date}`,formSubmit:`Envoyer`,formSkip:`Plus tard`,formSubmitted:`Terminé`,formSkipped:`Plus tard`,formFillOut:`Remplir`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidUrl:`Saisissez une URL valide`,formInvalidNumber:`Saisissez un nombre valide`,formTooShort:`Trop court (min. {min} caractères)`,formTooLong:`Trop long (max. {max} caractères)`,formNumberTooSmall:`Doit être au moins {min}`,formNumberTooLarge:`Doit être au plus {max}`,formPatternMismatch:`Veuillez respecter le format demandé`,formChooseAtLeast:`Choisissez au moins {min}`,formChooseAtMost:`Choisissez au plus {max}`,formOther:`Autre`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,inputBadge:`Questions`,inputAnswered:`Répondu`,inputSkipped:`Ignoré`,showOptions:`Afficher les options`,hideOptions:`Masquer les options`,qtypeText:`Votre réponse`,qtypeEmail:`Adresse e-mail`,qtypePhone:`Numéro de téléphone`,qtypeNumber:`Nombre`,qtypeDate:`Date`,qtypeChooseOne:`Choisir une`,qtypeChooseAny:`Choisir plusieurs`,qtypeBoolean:`Oui / Non`,inputSubmit:`Envoyer les réponses`,inputSubmitHint:`Entrée pour envoyer · Maj+Entrée = saut de ligne`,inputSkip:`Ignorer`,confirmYes:`Oui`,confirmNo:`Non`,approve:`Approuver`,reject:`Refuser`,approvalPrompt:`{tool} nécessite votre approbation pour s'exécuter.`,approvalBody:`Vérifiez les paramètres ci-dessus et décidez d'autoriser ou non cette action.`,approvalYourResponse:`Votre réponse : {decision}`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,approvalSubmitting:`Réponse envoyée. Traitement en cours…`,edit:`Modifier`,toolParameters:`Paramètres`,statusAwaiting:`En attente d'approbation`,statusResponded:`Répondu`,statusRunning:`En cours`,statusCompleted:`Terminé`,statusDenied:`Refusé`,statusError:`Erreur`,statusSuperseded:`Ignoré`},ar:{attach:`إرفاق ملفات`,attachmentMimeRejected:`نوع الملف غير مدعوم`,attachmentTooLarge:`حجم الملف كبير جدًا`,attachmentTooMany:`تم بلوغ الحد الأقصى للمرفقات`,conversationClosed:`تم إغلاق هذه الدردشة`,conversationLoading:`جارٍ تحميل الدردشة…`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherLabel:`تحدث معنا`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,micUnsupported:`الإدخال الصوتي غير مدعوم في هذا المتصفح`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,startNewConversation:`بدء دردشة جديدة`,talkToOperator:`التحدث إلى موظف`,connectingOperator:`جاري توصيلك بأحد الموظفين…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,thinking:`يفكّر…`,thoughts:`الأفكار`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا توجد نتائج`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsBack:`العودة إلى الأخبار`,newsPublishedAt:`نُشر في {date}`,formSubmit:`إرسال`,formSkip:`لاحقًا`,formSubmitted:`تم`,formSkipped:`لاحقًا`,formFillOut:`تعبئة`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidUrl:`أدخل رابطًا صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formTooShort:`قصير جدًا (الحد الأدنى {min} حرفًا)`,formTooLong:`طويل جدًا (الحد الأقصى {max} حرفًا)`,formNumberTooSmall:`يجب ألا يقل عن {min}`,formNumberTooLarge:`يجب ألا يزيد عن {max}`,formPatternMismatch:`يرجى مطابقة الصيغة المطلوبة`,formChooseAtLeast:`اختر {min} على الأقل`,formChooseAtMost:`اختر {max} على الأكثر`,formOther:`أخرى`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,reject:`رفض`,approvalPrompt:`تتطلب {tool} موافقتك للتنفيذ.`,approvalBody:`راجع مُعطيات الأداة أعلاه وقرّر السماح بهذا الإجراء أو رفضه.`,approvalYourResponse:`ردّك: {decision}`,approvalEditHint:`يمكنك تعديل ردّك حتى تستأنف هذه الخطوة.`,approvalSubmitting:`تم إرسال الرد. جارٍ التنفيذ…`,edit:`تعديل`,toolParameters:`المعطيات`,statusAwaiting:`بانتظار الموافقة`,statusResponded:`تم الرد`,statusRunning:`قيد التنفيذ`,statusCompleted:`مكتمل`,statusDenied:`مرفوض`,statusError:`خطأ`,statusSuperseded:`تم التخطي`},es:{attach:`Adjuntar archivos`,attachmentMimeRejected:`Tipo de archivo no admitido`,attachmentTooLarge:`El archivo es demasiado grande`,attachmentTooMany:`Se alcanzó el límite de adjuntos`,conversationClosed:`Este chat está cerrado`,conversationLoading:`Cargando chat…`,close:`Cerrar`,collapse:`Contraer`,collapseSidebar:`Contraer la barra lateral`,composerPlaceholder:`Escribe un mensaje…`,dateLastWeek:`Últimos 7 días`,dateOlder:`Anteriores`,dateToday:`Hoy`,dateYesterday:`Ayer`,dropZone:`Suelta los archivos para adjuntarlos`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRetry:`Reintentar`,expand:`Ampliar`,expandSidebar:`Expandir la barra lateral`,exitFullscreen:`Salir de pantalla completa`,fullscreen:`Pantalla completa`,history:`Historial`,historyBack:`Volver al chat`,historyEmpty:`Aún no tienes chats`,historyContinue:`Continuar el chat`,historyLoading:`Cargando tus chats…`,historyTitle:`Historial de chats`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherLabel:`Chatea con nosotros`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,micUnsupported:`Este navegador no admite la entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,startNewConversation:`Iniciar un chat nuevo`,talkToOperator:`Hablar con un operador`,connectingOperator:`Conectándote con un operador…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,cancelOperatorRequest:`Seguir con la IA`,stop:`Detener`,theme:`Tema`,themeAuto:`Automático`,themeDark:`Oscuro`,themeLight:`Claro`,textSize:`Tamaño del texto`,textSizeSmall:`Pequeño`,textSizeNormal:`Normal`,textSizeLarge:`Grande`,loading:`Cargando…`,thinking:`Pensando…`,thoughts:`Razonamiento`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,moduleBack:`Atrás`,contentLoading:`Cargando…`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeContentTitle:`Artículos populares`,homeStatus:`Estado`,helpTitle:`Ayuda`,helpSearchPlaceholder:`Buscar ayuda`,helpEmpty:`Aún no hay artículos de ayuda`,helpLoading:`Cargando la ayuda…`,helpSearchEmpty:`No se encontraron resultados`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsBack:`Volver a novedades`,newsPublishedAt:`Publicado el {date}`,formSubmit:`Enviar`,formSkip:`Quizá más tarde`,formSubmitted:`Completado`,formSkipped:`Quizá más tarde`,formFillOut:`Completar`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidUrl:`Introduce una URL válida`,formInvalidNumber:`Introduce un número válido`,formTooShort:`Demasiado corto (mín. {min} caracteres)`,formTooLong:`Demasiado largo (máx. {max} caracteres)`,formNumberTooSmall:`Debe ser al menos {min}`,formNumberTooLarge:`Debe ser como máximo {max}`,formPatternMismatch:`Respeta el formato solicitado`,formChooseAtLeast:`Elige al menos {min}`,formChooseAtMost:`Elige como máximo {max}`,formOther:`Otro`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,inputBadge:`Preguntas`,inputAnswered:`Respondido`,inputSkipped:`Omitido`,showOptions:`Mostrar opciones`,hideOptions:`Ocultar opciones`,qtypeText:`Tu respuesta`,qtypeEmail:`Correo electrónico`,qtypePhone:`Número de teléfono`,qtypeNumber:`Número`,qtypeDate:`Fecha`,qtypeChooseOne:`Elige una`,qtypeChooseAny:`Elige varias`,qtypeBoolean:`Sí / No`,inputSubmit:`Enviar respuestas`,inputSubmitHint:`Enter para enviar · Mayús+Enter = nueva línea`,inputSkip:`Omitir`,confirmYes:`Sí`,confirmNo:`No`,approve:`Aprobar`,reject:`Rechazar`,approvalPrompt:`{tool} requiere tu aprobación para ejecutarse.`,approvalBody:`Revisa los parámetros de arriba y decide si permites esta acción.`,approvalYourResponse:`Tu respuesta: {decision}`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,approvalSubmitting:`Respuesta enviada. Procesando…`,edit:`Editar`,toolParameters:`Parámetros`,statusAwaiting:`Esperando aprobación`,statusResponded:`Respondido`,statusRunning:`En curso`,statusCompleted:`Completado`,statusDenied:`Denegado`,statusError:`Error`,statusSuperseded:`Omitido`},he:{attach:`צירוף קבצים`,attachmentMimeRejected:`סוג הקובץ אינו נתמך`,attachmentTooLarge:`הקובץ גדול מדי`,attachmentTooMany:`הגעת למספר המרבי של קבצים מצורפים`,conversationClosed:`הצ׳אט הזה נסגר`,conversationLoading:`טוען צ׳אט…`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherLabel:`דברו איתנו`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,micUnsupported:`קלט קולי אינו נתמך בדפדפן זה`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,startNewConversation:`התחלת צ׳אט חדש`,talkToOperator:`דבר עם נציג`,connectingOperator:`מחבר אותך לנציג…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,thinking:`חושב…`,thoughts:`מחשבות`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,moduleBack:`חזרה`,contentLoading:`טוען…`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`לא נמצאו תוצאות`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsBack:`חזרה לחדשות`,newsPublishedAt:`פורסם ב-{date}`,formSubmit:`שליחה`,formSkip:`אחר כך`,formSubmitted:`נשלח`,formSkipped:`דולג`,formFillOut:`מילוי`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidUrl:`הזן כתובת URL תקינה`,formInvalidNumber:`הזן מספר תקין`,formTooShort:`קצר מדי (לפחות {min} תווים)`,formTooLong:`ארוך מדי (לכל היותר {max} תווים)`,formNumberTooSmall:`חייב להיות לפחות {min}`,formNumberTooLarge:`חייב להיות לכל היותר {max}`,formPatternMismatch:`התאם לתבנית הנדרשת`,formChooseAtLeast:`בחר לפחות {min}`,formChooseAtMost:`בחר לכל היותר {max}`,formOther:`אחר`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,reject:`דחייה`,approvalPrompt:`הכלי {tool} דורש את אישורך כדי לפעול.`,approvalBody:`בדוק את פרמטרי הכלי שלמעלה והחלט אם לאשר פעולה זו.`,approvalYourResponse:`התגובה שלך: {decision}`,approvalEditHint:`ניתן לערוך את תגובתך עד שהשלב הזה יתחדש.`,approvalSubmitting:`התגובה נשלחה. מבצע…`,edit:`עריכה`,toolParameters:`פרמטרים`,statusAwaiting:`ממתין לאישור`,statusResponded:`נענה`,statusRunning:`פועל`,statusCompleted:`הושלם`,statusDenied:`נדחה`,statusError:`שגיאה`,statusSuperseded:`דולג`}};function S(e,t){let n=C(e),r=D(t),i=n===`en`?{}:x[n]??{},a=r?t[n]??{}:t??{},o=r?t.en??{}:{};return{...b,...i,...o,...a}}function C(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const w=new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function T(e){return w.has(C(e))}function E(e,t){return e[t]??t}function D(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}function O(e,t){if(!(!e?.length||!t))return e.find(e=>e.locale===t)}function k(e,t){let{translations:n,defaultLocale:r,...i}=e,a=O(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function A(e,t){let{translations:n,defaultLocale:r,...i}=e,a=O(n,t);if(!a)return i;let o=new Map((a.fields??[]).map(e=>[e.name,e])),s=i.fields.map(e=>{let t=o.get(e.name);if(!t)return e;let n=new Map((t.options??[]).map(e=>[e.value,e]));return{...e,label:t.label??e.label,placeholder:t.placeholder??e.placeholder,validationHint:t.validationHint??e.validationHint,options:e.options?.map(e=>{let t=n.get(e.value);return t?{...e,label:t.label??e.label,description:t.description??e.description}:e})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}const ee=new class{get(e){try{return localStorage.getItem(e)}catch{return null}}set(e,t){try{localStorage.setItem(e,t)}catch{}}remove(e){try{localStorage.removeItem(e)}catch{}}},te=[`off`,`error`,`warn`,`info`,`debug`,`trace`],ne=y.cssPrefix,j=`${ne}.debug`,re=`__${y.global}_DEBUG__`,ie=`${ne}-debug`;let ae=2;function oe(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(ie);if(e!==null){let t=se(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(j);if(e){let t=se(e);if(t>=0)return t}}catch{}return Reflect.get(window,re)?4:2}function se(e){if(e===!0||e===`1`||e===`true`)return 4;if(e===!1||e===`0`||e===`false`||e===`off`)return 0;if(typeof e==`number`)return Math.max(0,Math.min(5,Math.floor(e)));if(typeof e==`string`){let t=te.indexOf(e);if(t>=0)return t}return-1}ae=oe();function M(e){let t=`[${ne}:${e}]`,n=(e,n,r)=>(r,i)=>{ae<e||(i===void 0?console[n](t,r):console[n](t,r,i))};return{error:n(1,`error`,`error`),warn:n(2,`warn`,`warn`),info:n(3,`info`,`info`),debug:n(4,`debug`,`debug`),trace:n(5,`debug`,`trace`),scope:t=>M(`${e}:${t}`)}}const N=M(`core`),ce=N.scope(`context`),le=new Set([`visitorId`,`conversationId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),ue=1024,de=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function P(e){return pe(e,`userContext`,!0)}function fe(e){return pe(e,`pageContext`,!1)}function pe(e,t,n){if(e==null)return;if(typeof e!=`object`||Array.isArray(e)){ce.warn(`ignored ${t} — expected an object`,{type:Array.isArray(e)?`array`:typeof e});return}let r={},i=0;for(let[n,a]of Object.entries(e)){if(le.has(n)){ce.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){ce.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=me(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!de.test(r.email)&&(ce.warn(`dropped malformed ${t}.email "${r.email}"`),delete r.email),Object.keys(r).length>0?r:void 0}function me(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){ce.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>ue?(ce.warn(`truncated ${e}.${t} to ${ue} chars`),r.slice(0,ue)):r}ce.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}const he={maxBytes:10*1024*1024,maxCount:10,accept:`*/*`},ge={voice:`local`},_e={list:[],byTrigger:{}},ve={enabled:!0,sampleRate:1},ye={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`,submitForm:`/pai/submit-form`},be={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},xe={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`sound`,`language`]},Se={enabled:!0,volume:.3,events:void 0},F={enabled:!0,events:void 0},Ce=[{label:`tabConversations`,layout:`chat`}];function we(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},o=t.footer??{},s=t.header??{},{themeMode:c,themeOverrides:l}=Te(t.theme),u=n.mode??`floating`,d=Ee(i.defaultLocale),f=i.availableLocales??[i.locale??d],p=De(i.locale??d,f,d),m=(t.baseUrl??y.defaultBaseUrl).replace(/\/$/,``),h=(t.agentApiBaseUrl??`${m}/api/agent`).replace(/\/$/,``),g=(t.dataApiBaseUrl??`${m}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:m,agentApiBaseUrl:h,dataApiBaseUrl:g,userContext:P(t.userContext),pageContext:fe(t.pageContext),position:n.position??`bottom-right`,themeMode:c,textSize:`normal`,themeOverrides:l,mode:u,iframe:n.iframe??!1,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,features:{voice:t.features?.voice??ge.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),operatorRequest:t.features?.enableOperatorRequest===!0,tools:t.features?.tools},forms:Fe(t.forms,p),endpoints:{upload:t.endpoints?.upload??ye.upload,transcribe:t.endpoints?.transcribe??ye.transcribe,submitForm:t.endpoints?.submitForm??ye.submitForm},attachments:{accept:t.composer?.attachments?.accept??he.accept,maxBytes:t.composer?.attachments?.maxBytes??he.maxBytes,maxCount:t.composer?.attachments?.maxCount??he.maxCount},locale:p,defaultLocale:d,availableLocales:f,startMinimized:r.startMinimized??!0,actions:Oe(u,s.actions),size:n.size??{},launcher:Le(t.launcher),sound:ke(a.sound),haptics:Ae(a.haptics),strings:S(p,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,poweredBy:Me(o.poweredBy),composer:Ne(t.composer),modules:Pe(t.modules),tracking:je(t.tracking,g),storage:t.storage??ee,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Te(e){return typeof e==`string`?{themeMode:e,themeOverrides:{}}:e&&typeof e==`object`?{themeMode:`auto`,themeOverrides:e}:{themeMode:`auto`,themeOverrides:{}}}function Ee(e){return e&&e!==`auto`?e:typeof navigator<`u`&&navigator.language?navigator.language:`en`}function De(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function Oe(e,t){return t??xe[e]}function ke(e){return{enabled:e?.enabled??Se.enabled,volume:e?.volume??Se.volume,events:e?.events}}function Ae(e){return{enabled:e?.enabled??F.enabled,events:e?.events}}function je(e,t){let n=e?.sampleRate??ve.sampleRate;return{enabled:e?.enabled??ve.enabled,endpoint:e?.endpoint??`${t}/pai/elements-px.gif`,sampleRate:Math.min(1,Math.max(0,Number.isFinite(n)?n:1)),token:e?.token}}function Me(e){let t={text:`Powered by ${y.displayName}`,href:y.siteUrl,...e};return t.text||t.logoUrl?t:null}function Ne(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function Pe(e){let t=e===void 0?Ce:e,n=new Set,r=[];for(let e of t.slice(0,4)){if(!e?.label||!e?.layout)continue;let t=e.contentTags?.filter(Boolean),i=e.id??t?.[0]??e.layout;for(;n.has(i);)i=`${i}-${r.length}`;n.add(i);let a={id:i,label:e.label,layout:e.layout};t&&t.length>0&&(a.contentTags=t),e.layout===`home`&&(a.brandName=e.brandName,a.greetingText=e.greetingText,a.showGreeting=!(e.hideGreeting??!1),a.showSearchBar=!(e.hideSearchBar??!1),a.showRecentConversations=!(e.hideRecentConversations??!1),e.userAvatars&&e.userAvatars.length>0&&(a.userAvatars=e.userAvatars),e.status&&(a.status=e.status),a.contentBlockTitle=e.contentBlockTitle),r.push(a)}return{list:r,byId:Object.fromEntries(r.map(e=>[e.id,e]))}}function Fe(e,t){if(!e?.length)return _e;let n=[],r=new Set;for(let i of e){if(!i?.id||r.has(i.id))continue;let e=A(i,t),a=(e.fields??[]).filter(e=>!!(e&&e.name&&e.label&&e.type)),o=(Array.isArray(e.on)?e.on:[e.on]).map(Ie).filter(e=>e!==null);a.length===0||o.length===0||(r.add(e.id),n.push({id:e.id,triggers:o,when:e.when,fields:a,title:e.title,description:e.description,submitLabel:e.submitLabel,skippable:e.skippable??!1,frequency:e.frequency??`once`,mirrorToContext:e.mirrorToContext??!0,reopenable:e.reopenable??!0,reviewable:e.reviewable??!0}))}let i={};for(let e of n){var a;for(let t of e.triggers)(i[a=t.kind]??(i[a]=[])).push(e)}return{list:n,byTrigger:i}}function Ie(e){if(typeof e!=`string`)return null;if(e===`pre-chat`||e===`conversation-closed`||e===`panel-close`||e===`manual`)return{kind:e};let[t,n]=e.split(`:`,2);if(t===`after-messages`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`after-messages`,param:e}:null}if(t===`idle`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`idle`,param:e}:null}return t===`page-area`&&n?{kind:`page-area`,param:n}:null}function Le(e){let t=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??be.variant,size:e?.size??be.size,label:e?.label??be.label,icon:e?.icon??be.icon,hidden:e?.hidden??be.hidden,callout:t}}function Re(e,t,n,r){let i=De(t,e.availableLocales,e.defaultLocale);if(i===e.locale&&n===e.themeMode&&r===e.textSize)return e;let a={...e};return i!==e.locale&&(a.locale=i,a.strings=S(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}const ze=[`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`];function Be(e,t){if(!t)return e;let n={...e};for(let r of ze){let i=t[r];if(i===void 0)continue;let a=e[r];if(r===`theme`){a===void 0&&(n[r]=i);continue}r!==`i18n`&&(n[r]=Ve(i,a))}t.modules!==void 0&&e.modules===void 0&&(n.modules=t.modules),t.dataApiBaseUrl!==void 0&&e.dataApiBaseUrl===void 0&&(n.dataApiBaseUrl=t.dataApiBaseUrl);let r=e.i18n,i=t.i18n;if(r||i){let e=Ve(i??{},r);i?.availableLocales!==void 0&&(e.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(e.defaultLocale=i.defaultLocale);let t=r?.strings,a=i?.strings;(t||a)&&(e.strings=He(a,t)),n.i18n=e}return n}function Ve(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function He(e,t){if(!e)return t;if(!t)return e;let n=D(e),r=D(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},o=r?t:{en:t};for(let[e,t]of Object.entries(a))i[e]={...t};for(let[e,t]of Object.entries(o))i[e]={...i[e],...t};return i}const I=[`clear`,`expand`,`fullscreen`,`sound`,`history`,`language`,`theme`,`textSize`,`close`],L=e=>e!==`false`,Ue=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),We=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`theme`,`theme`,e=>e]],Ge=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e],[`iframe`,`iframe`,L]],Ke=[[`width`,`width`],[`height`,`height`]],qe=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,L],[`show-reasoning`,`showReasoning`,L],[`show-tool-calls`,`showToolCalls`,L],[`show-sources`,`showSources`,L],[`disable-message-feedback`,`disableMessageFeedback`,L],[`auto-send-suggestions`,`autoSendSuggestions`,L]],Je=[[`locale`,`locale`]],Ye=new Set(I),Xe=e=>Ue(e).filter(e=>Ye.has(e)),Ze=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,L]],Qe=[[`features-disable-file-upload`,`disableFileUpload`,L],[`features-voice`,`voice`,e=>e],[`features-tools`,`tools`,Ue]],$e=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],et=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],tt=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],nt=[`launcher-label`,`callout-text`,`callout-delay`,`actions-main`,`actions-overflow`,`user-context`,`page-context`],rt=[We,Ge,Ke,qe,Je,Ze,Qe,$e,et,tt],it=new Set([`iframe`,`start-minimized`]),at=[...rt.flatMap(e=>e.map(([e])=>e).filter(e=>!it.has(e))),...nt];function ot(e){let t={},n=t=>{let n=e(t);return n===null||n===``?void 0:n};for(let[e,r,i]of We){let a=n(e);a!==void 0&&(t[r]=i?i(a):a)}let r=st(n,Ge),i=st(n,Ke);(r||i)&&(t.presentation={...r,...i?{size:i}:{}});let a=st(n,qe);a&&(t.behavior=a);let o=st(n,Je);o&&(t.i18n=o);let s=lt(e,n);s&&(t.launcher=s);let c=st(n,Qe);c&&(t.features=c);let l=st(n,$e);l&&(t.endpoints=l);let u=ct(n,et,`user-context`);u&&(t.userContext=u);let d=ct(n,tt,`page-context`);d&&(t.pageContext=d);let f=n(`actions`);return f!==void 0&&(t.header={actions:Xe(f)}),t}function st(e,t){let n={};for(let[r,i,a]of t){let t=e(r);t!==void 0&&(n[i]=a?a(t):t)}return Object.keys(n).length>0?n:null}function ct(e,t,n){let r={};for(let[n,i]of t){let t=e(n);t!==void 0&&(r[i]=t)}let i={},a=e(n);if(a)try{let e=JSON.parse(a);e&&typeof e==`object`&&!Array.isArray(e)&&(i=e)}catch{}let o={...i,...r};return Object.keys(o).length>0?o:null}function lt(e,t){let n=st(t,Ze)??{},r=e(`launcher-label`);r!==null&&(n.label=r);let i=t(`callout-text`);if(i){let e=Number.parseInt(t(`callout-delay`)??``,10);n.callout={text:i,...Number.isFinite(e)?{delayMs:e}:{}}}return Object.keys(n).length>0?n:null}function ut(){let e=Date.now(),t=new Uint8Array(16);t[0]=Math.floor(e/2**40)&255,t[1]=Math.floor(e/2**32)&255,t[2]=e>>>24&255,t[3]=e>>>16&255,t[4]=e>>>8&255,t[5]=e&255,dt(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function dt(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){crypto.getRandomValues(e);return}for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const ft=N.scope(`persistence`);function pt(e,t=ee,n){let r=n?`${e}.${n}`:e,i=`${y.cssPrefix}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${y.cssPrefix}.${r}${o}`,c=`${y.cssPrefix}${o}.visitorId`,l=`${s}.conversationId`,u=`${s}.userPrefs`,d=`${s}.panelOpen`,f=`${s}.panelSize`,p=`${s}.calloutDismissed`,m=`${s}.sidebarCollapsed`,h=`${s}.activeModule`,g=`${s}.historyCount`,_=`${s}.formsDone`,v={getVisitorId(){let e=t.get(c);if(e)return e;let n=ut();return t.set(c,n),n},setVisitorId(e){ft.debug(`setVisitorId (rebind)`,{id:e,scope:r}),t.set(c,e)},loadConversationId(){return t.get(l)??void 0},saveConversationId(e){ft.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(l,e):t.remove(l)},loadUserPrefs(){let e=t.get(u);if(!e)return{};try{let t=JSON.parse(e);return mt(t)?t:{}}catch(e){return ft.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(u,JSON.stringify(e))}catch(e){ft.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=v.loadUserPrefs();v.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(d);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(d,e?`1`:`0`)},loadPanelSize(){let e=t.get(f);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(f,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(p);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(p,e):t.remove(p)},loadSidebarCollapsed(){let e=t.get(m);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(m,e?`1`:`0`)},loadActiveModule(){return t.get(h)||null},saveActiveModule(e){t.set(h,e)},loadHistoryCount(){let e=t.get(g);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(g,String(e))},loadFormsDone(){let e=t.get(_);if(!e)return{};try{let t=JSON.parse(e);return mt(t)?t:{}}catch(e){return ft.warn(`loadFormsDone parse failed`,{error:e}),{}}},saveFormDone(e){try{let n=v.loadFormsDone();n[e]=Date.now(),t.set(_,JSON.stringify(n))}catch(e){ft.warn(`saveFormDone serialise failed`,{error:e})}},rememberStorageVersion(e){e&&e!==t.get(i)&&(ft.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},clearConversation(){t.remove(l)}};return v}function mt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ht=[`:host{--__P__-accent-user: __BRAND_ACCENT__;--__P__-accent: var(--__P__-accent-user);--__P__-accent-text-user: __BRAND_ACCENT_TEXT__;--__P__-accent-text: var(--__P__-accent-text-user);--__P__-accent-fg: var(--__P__-accent);--__P__-radius: __BRAND_RADIUS__;--__P__-radius-sm: 8px;--__P__-radius-md: 10px;--__P__-radius-lg: 16px;--__P__-font: __BRAND_FONT__;--__P__-font-display: var(--__P__-font);--__P__-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;--__P__-bg: oklch(1 0 0);--__P__-bg-elevated: oklch(.9789 .0029 278.3);--__P__-surface: var(--__P__-bg-elevated);--__P__-muted: var(--__P__-fg-muted);--__P__-hover: oklch(.1686 .011 278.3 / .06);--__P__-fg: oklch(.1686 .011 278.3);--__P__-fg-muted: oklch(.4932 .0301 278.3);--__P__-border: oklch(.9312 .0084 278.3);--__P__-border-strong: oklch(.8757 .0131 278.3);--__P__-bubble-user: var(--__P__-accent);--__P__-bubble-user-text: var(--__P__-accent-text);--__P__-bubble-assistant: oklch(.9638 .0058 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-on-accent: var(--__P__-accent-text);--__P__-success: oklch(.6456 .1654 151.53);--__P__-warning: oklch(.7135 .1494 74.05);--__P__-danger: oklch(.5966 .1818 24.51);--__P__-danger-text: oklch(.5054 .1905 27.52);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .1);--__P__-neutral: oklch(.7137 .0192 278.3);--__P__-pill-l-min: .3;--__P__-pill-l-max: .46;--__P__-focus: var(--__P__-accent);--__P__-shadow-panel: 0 8px 24px -8px rgba(13, 15, 20, .18), 0 24px 64px -24px rgba(13, 15, 20, .24);--__P__-shadow-card: 0 1px 2px rgba(13, 15, 20, .06), 0 4px 12px -6px rgba(13, 15, 20, .12);--__P__-backdrop: oklch(.1686 .011 278.3 / .55);--__P__-shadow-fab: 0 6px 16px -4px color-mix(in oklch, var(--__P__-accent) 45%, transparent), 0 12px 32px -12px rgba(13, 15, 20, .25);--__P__-z-fab: 2147483600;--__P__-z-panel: 2147483601;--__P__-panel-w: 380px;--__P__-panel-h: 600px;--__P__-fab-size: 56px;--__P__-conversation-max: 768px;--__P__-space-1: 4px;--__P__-space-2: 8px;--__P__-space-3: 12px;--__P__-space-4: 16px;--__P__-space-5: 20px;--__P__-space-6: 24px;--__P__-space-8: 32px;--__P__-text-scale: 1;--__P__-text-xs: calc(12px * var(--__P__-text-scale));--__P__-text-sm: calc(13px * var(--__P__-text-scale));--__P__-text-base: calc(15px * var(--__P__-text-scale));--__P__-text-md: calc(16px * var(--__P__-text-scale));--__P__-text-lg: calc(18px * var(--__P__-text-scale));--__P__-text-xl: calc(22px * var(--__P__-text-scale));--__P__-text-2xl: calc(30px * var(--__P__-text-scale))}:host([data-mode="modal"]),:host([data-mode="drawer"]){--__P__-conversation-max: 100%}:host([data-text-size="small"]){--__P__-text-scale: .9}:host([data-text-size="large"]){--__P__-text-scale: 1.15}:host{--__P__-ease: cubic-bezier(.2, .7, .2, 1);--__P__-ease-out: cubic-bezier(.2, .7, .2, 1);--__P__-ease-in: cubic-bezier(.4, 0, 1, 1);--__P__-ease-in-out: cubic-bezier(.65, 0, .35, 1);--__P__-dur-quick: .12s;--__P__-dur-base: .22s;--__P__-dur-slow: .32s;font-family:var(--__P__-font);color:var(--__P__-fg);color-scheme:light;--__P__-color-scheme: light}:host([data-theme="dark"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-danger-text: oklch(.8077 .1035 19.57);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .18);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);--__P__-shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px -6px rgba(0, 0, 0, .5);--__P__-backdrop: rgba(0, 0, 0, .65);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;color-scheme:dark;--__P__-color-scheme: dark}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);color-scheme:dark;--__P__-color-scheme: dark}}@supports (color: oklch(from red l c h)){:host{--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.3, l, .62) c h);--__P__-accent-text: oklch(from var(--__P__-accent) clamp(0, (l / .623 - 1) * -infinity, 1) 0 h);--__P__-accent-fg: oklch(from var(--__P__-accent-user) clamp(.3, l, .46) c h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
|
|
2
2
|
`,`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0;border:0}button{font:inherit;color:inherit;background:none;cursor:pointer;-webkit-appearance:none;appearance:none;line-height:1}button:focus-visible,[tabindex]:focus-visible,textarea:focus-visible,input:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}textarea,input{font:inherit;color:inherit;background:none;border:0;outline:0;resize:none}a{color:var(--__P__-accent-fg);text-decoration:underline;text-underline-offset:2px}img,svg{display:block;max-width:100%}ul,ol{list-style:none}.__P__-app{display:block;width:100%;height:100%;font-family:var(--__P__-font);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-feature-settings:"cv11","ss01","ss03"}.__P__-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
|
|
3
3
|
`,`.__P__-anchor{color-scheme:var(--__P__-color-scheme, light);right:16px;bottom:16px}.__P__-surface{display:contents}.__P__-surface[hidden]{display:none}:host([data-position="bottom-left"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{right:auto;left:16px}:host([data-position="top-right"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{bottom:auto;top:16px}.__P__-anchor{position:fixed;display:flex;flex-direction:column;align-items:flex-end;gap:var(--__P__-space-3);pointer-events:none}.__P__-anchor{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=sm]{--__P__-fab-size: 44px}.__P__-anchor[data-launcher-size=md]{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=lg]{--__P__-fab-size: 68px}.__P__-anchor>*{pointer-events:auto}.__P__-fab[data-size=sm]{--__P__-fab-size: 44px;font-size:var(--__P__-text-sm)}.__P__-fab[data-size=md]{--__P__-fab-size: 56px;font-size:calc(14px * var(--__P__-text-scale))}.__P__-fab[data-size=lg]{--__P__-fab-size: 68px;font-size:var(--__P__-text-base)}.__P__-fab{display:inline-flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);color:var(--__P__-accent-text);background:var(--__P__-accent);box-shadow:var(--__P__-shadow-fab);font-weight:600;line-height:1;transform-origin:bottom right;animation:__P__-fab-in var(--__P__-dur-base) var(--__P__-ease) both;transition:transform var(--__P__-dur-base) var(--__P__-ease),opacity var(--__P__-dur-base) var(--__P__-ease),box-shadow var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab:hover{transform:translateY(-2px)}.__P__-fab:active{transform:translateY(0)}.__P__-fab:focus-visible{outline:2px solid var(--__P__-on-accent);outline-offset:3px}.__P__-fab svg{width:24px;height:24px;flex-shrink:0}@keyframes __P__-fab-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:none}}.__P__-fab[data-leaving]{position:absolute;right:0;bottom:0;animation:__P__-fab-out var(--__P__-dur-quick) var(--__P__-ease) forwards;pointer-events:none}:host([data-position^="top-"]) .__P__-fab[data-leaving]{bottom:auto;top:0}:host([data-position$="-left"]) .__P__-fab[data-leaving]{right:auto;left:0}@keyframes __P__-fab-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.85)}}.__P__-fab[data-variant=circle]{width:var(--__P__-fab-size);height:var(--__P__-fab-size);border-radius:999px}.__P__-fab[data-variant=circle] .__P__-fab-label{display:none}.__P__-fab[data-variant=pill]{height:var(--__P__-fab-size);padding:0 18px 0 16px;border-radius:999px}.__P__-fab[data-variant=bar]{height:var(--__P__-fab-size);padding:0 22px;border-radius:var(--__P__-radius)}.__P__-fab[data-variant=minimal]{height:var(--__P__-fab-size);padding:0 var(--__P__-space-4);border-radius:999px;background:transparent;color:var(--__P__-accent-fg);box-shadow:none;border:1px solid currentColor}.__P__-fab[data-variant=minimal]:hover{background:color-mix(in srgb,var(--__P__-accent) 12%,transparent)}.__P__-callout{--__P__-callout-fab-h: var(--__P__-fab-size, 56px);--__P__-callout-gap: clamp(12px, calc(var(--__P__-callout-fab-h) * .25), 22px);--__P__-callout-nudge-direction: -1;position:absolute;display:inline-flex;align-items:center;gap:var(--__P__-space-2);padding:10px 14px;background:var(--__P__-fg);color:var(--__P__-bg);border-radius:999px;font-size:var(--__P__-text-sm);font-weight:600;line-height:1.2;box-shadow:0 10px 30px -8px #00000059;pointer-events:auto;animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease);z-index:1;max-width:240px;white-space:nowrap}.__P__-callout[data-position=left]{right:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%)}.__P__-callout[data-position=right]{left:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%);--__P__-callout-nudge-direction: 1}.__P__-callout[data-position=top]{bottom:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-position=bottom]{top:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}:host([data-position$="-left"]) .__P__-callout[data-position=top],:host([data-position$="-left"]) .__P__-callout[data-position=bottom]{right:auto;left:0}.__P__-callout[data-shape=bubble]{border-radius:var(--__P__-radius-md);white-space:normal;width:max-content;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-shape=callout]{padding:12px 18px;font-size:calc(14px * var(--__P__-text-scale));background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-callout:after{content:"";position:absolute;width:12px;height:12px;background:inherit;border-radius:2px;transform:rotate(45deg)}.__P__-callout[data-position=left]:after{right:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=right]:after{left:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=top]:after{bottom:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-position=bottom]:after{top:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}:host([data-position$="-left"]) .__P__-callout[data-position=top]:after,:host([data-position$="-left"]) .__P__-callout[data-position=bottom]:after{right:auto;left:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-animated]{animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease),__P__-callout-nudge 1.6s var(--__P__-ease-in-out) var(--__P__-dur-slow) infinite}@keyframes __P__-callout-in{0%{opacity:0}to{opacity:1}}@keyframes __P__-callout-nudge{0%,to{margin-left:0;margin-right:0}50%{margin-left:calc(6px * var(--__P__-callout-nudge-direction));margin-right:calc(-6px * var(--__P__-callout-nudge-direction))}}@media(prefers-reduced-motion:reduce){.__P__-callout[data-animated]{animation:__P__-callout-in 1ms var(--__P__-ease)}.__P__-icon-btn[data-recording=true],.__P__-typing span{animation:none}}.__P__-callout-close{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:999px;color:inherit;opacity:.7;cursor:pointer}.__P__-callout-close:hover{opacity:1;background:color-mix(in srgb,currentColor 15%,transparent)}.__P__-callout-close:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-callout-close svg{width:12px;height:12px}.__P__-panel{width:var(--__P__-panel-w);height:var(--__P__-panel-h);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);background:var(--__P__-bg);color:var(--__P__-fg);border-radius:var(--__P__-radius-lg);box-shadow:var(--__P__-shadow-panel);display:flex;flex-direction:column;overflow:hidden;transform-origin:bottom right;animation:__P__-panel-in var(--__P__-dur-slow) var(--__P__-ease);border:1px solid var(--__P__-border)}@media(prefers-reduced-motion:no-preference){.__P__-panel{transition:width var(--__P__-dur-base) var(--__P__-ease),height var(--__P__-dur-base) var(--__P__-ease),max-width var(--__P__-dur-base) var(--__P__-ease),max-height var(--__P__-dur-base) var(--__P__-ease)}.__P__-panel[data-resizing]{transition:none}}:host([data-mode="open"]) .__P__-panel{width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));min-width:var(--__P__-resize-min-w, auto);min-height:var(--__P__-resize-min-h, auto);max-width:var(--__P__-resize-max-w, calc(100vw - 32px) );max-height:var(--__P__-resize-max-h, calc(100dvh - 32px) )}@keyframes __P__-panel-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}:host([data-mode="expanded"]) .__P__-panel{width:var(--__P__-expanded-w, 640px);height:var(--__P__-expanded-h, 820px);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px)}:host([data-mode="fullscreen"]){z-index:var(--__P__-z-panel)!important}:host([data-mode="fullscreen"]) .__P__-anchor{inset:0;padding:0;justify-content:flex-end;align-items:flex-end}:host([data-mode="fullscreen"][data-position*="top"]) .__P__-anchor{justify-content:flex-start}:host([data-mode="fullscreen"][data-position*="left"]) .__P__-anchor{align-items:flex-start}:host([data-mode="fullscreen"]) .__P__-panel{width:100vw;height:100dvh;max-width:none;max-height:none;border-radius:0;border:0}:host([data-mode="fullscreen"]) .__P__-fab{display:none}@media(max-width:640px){:host([data-mode="open"]) .__P__-anchor,:host([data-mode="expanded"]) .__P__-anchor{inset:0;align-items:stretch;padding:0}:host([data-mode="open"]) .__P__-panel,:host([data-mode="expanded"]) .__P__-panel{width:100vw;height:100dvh;max-width:none;max-height:none;border-radius:0;border:0}}:host([data-mode="inline"]) .__P__-anchor,:host([data-mode="standalone"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-height:0}:host([data-mode="inline"]) .__P__-panel,:host([data-mode="standalone"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;animation:none}:host([data-mode="inline"]) .__P__-fab,:host([data-mode="standalone"]) .__P__-fab{display:none}:host([data-mode="inline"]){min-height:320px}:host([data-mode="inline"]) .__P__-panel{border-radius:var(--__P__-radius)}:host([data-mode="standalone"]) .__P__-panel{border-radius:0;border:0;box-shadow:none}:host([data-mode="modal"]){position:fixed!important;inset:0!important;z-index:var(--__P__-z-panel)!important;display:block!important;width:100vw;height:100dvh;background:var(--__P__-modal-backdrop, var(--__P__-backdrop));animation:__P__-backdrop-in var(--__P__-dur-base) var(--__P__-ease) both;--__P__-panel-w: min(960px, 92vw);--__P__-panel-h: min(720px, 88dvh)}:host([data-mode="modal"]) .__P__-anchor{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:var(--__P__-space-6);pointer-events:none}:host([data-mode="modal"]) .__P__-panel{pointer-events:auto;width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));max-width:calc(100vw - 48px);max-height:calc(100dvh - 48px);min-width:0;min-height:0;border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-panel);animation:__P__-modal-in var(--__P__-dur-base) var(--__P__-ease);translate:var(--__P__-modal-dx, 0px) var(--__P__-modal-dy, 0px)}:host([data-mode="modal"]) .__P__-header,:host([data-mode="modal"]) .__P__-back-header,:host([data-mode="modal"]) .__P__-home-hero{cursor:grab;touch-action:none}:host([data-mode="modal"]) .__P__-panel[data-dragging]{cursor:grabbing;user-select:none}:host([data-mode="modal"]) .__P__-panel[data-dragging] *{cursor:grabbing}:host([data-mode="modal"]) .__P__-fab{display:none}@keyframes __P__-backdrop-in{0%{background:#0000}to{background:var(--__P__-modal-backdrop, var(--__P__-backdrop))}}@keyframes __P__-modal-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}:host([data-mode="drawer"]){--__P__-panel-w: min(440px, calc(100vw - 32px) );--__P__-panel-h: 100dvh}:host([data-mode="drawer"]) .__P__-anchor{position:fixed;--__P__-inset-x: var(--__P__-panel-inset, 12px);--__P__-inset-y: var(--__P__-panel-inset, 3dvh);top:var(--__P__-inset-y);bottom:auto;right:var(--__P__-inset-x);left:auto;width:min(var(--__P__-widget-w, var(--__P__-panel-w)),calc(100vw - var(--__P__-inset-x) * 2));height:min(var(--__P__-widget-h, var(--__P__-panel-h)),calc(100dvh - var(--__P__-inset-y) * 2));padding:0;display:block;pointer-events:auto}:host([data-mode="drawer"][data-position$="-left"]) .__P__-anchor{right:auto;left:var(--__P__-inset-x)}:host([data-mode="drawer"][data-position^="bottom-"]) .__P__-anchor{top:auto;bottom:var(--__P__-inset-y)}:host([data-mode="drawer"]) .__P__-panel{width:100%;height:100%;max-width:none;max-height:none;min-width:0;min-height:0;border-radius:var(--__P__-radius, 12px);border:1px solid var(--__P__-border);box-shadow:-8px 16px 32px -12px #00000038;animation:__P__-drawer-in var(--__P__-dur-base) var(--__P__-ease)}:host([data-mode="drawer"][data-position$="-left"]) .__P__-panel{box-shadow:8px 16px 32px -12px #00000038;animation:__P__-drawer-in-left var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab[data-edge-tab]{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-2);position:fixed;top:50%;height:140px;width:auto;min-width:0;padding:10px 8px;writing-mode:vertical-rl;text-orientation:mixed;transform:translateY(-50%);transform-origin:center;animation:__P__-edge-tab-in var(--__P__-dur-base) var(--__P__-ease) both}.__P__-fab[data-edge-tab] svg{writing-mode:horizontal-tb}.__P__-fab[data-edge-tab]:hover{transform:translateY(-50%) scale(1.03)}.__P__-fab[data-edge-tab]:active{transform:translateY(-50%) scale(.97)}:host([data-position$="-right"]) .__P__-fab[data-edge-tab]{right:0;left:auto;border-radius:12px 0 0 12px;box-shadow:-6px 0 18px -8px #0000004d}:host([data-position$="-left"]) .__P__-fab[data-edge-tab]{left:0;right:auto;border-radius:0 12px 12px 0;box-shadow:6px 0 18px -8px #0000004d}.__P__-fab[data-edge-tab][data-leaving]{position:fixed;top:50%;bottom:auto;animation:__P__-edge-tab-out var(--__P__-dur-quick) var(--__P__-ease) forwards}@keyframes __P__-edge-tab-in{0%{opacity:0;transform:translateY(-50%) scale(.9)}to{opacity:1;transform:translateY(-50%) scale(1)}}@keyframes __P__-edge-tab-out{0%{opacity:1;transform:translateY(-50%) scale(1)}to{opacity:0;transform:translateY(-50%) scale(.85)}}@keyframes __P__-drawer-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes __P__-drawer-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@media(prefers-reduced-motion:reduce){:host([data-mode="drawer"]) .__P__-panel,.__P__-fab[data-edge-tab]{animation:none}}.__P__-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);background:var(--__P__-bg)}.__P__-header h1{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;flex:1;letter-spacing:-.01em}.__P__-header-actions{margin-inline-start:auto;display:flex;align-items:center;gap:var(--__P__-space-1);flex-shrink:0}.__P__-agent{flex:1;display:inline-flex;align-items:center;gap:10px;min-width:0}.__P__-agent-avatar{position:relative;width:32px;height:32px;border-radius:999px;background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:var(--__P__-text-xs);overflow:hidden;flex-shrink:0}.__P__-agent-avatar img{width:100%;height:100%;object-fit:cover}.__P__-agent-avatar:after{content:"";position:absolute;right:-1px;bottom:-1px;width:10px;height:10px;border-radius:999px;border:2px solid var(--__P__-bg);background:var(--__P__-neutral)}.__P__-agent-avatar[data-status=online]:after{background:var(--__P__-success)}.__P__-agent-avatar[data-status=away]:after{background:var(--__P__-warning)}.__P__-agent-avatar[data-status=offline]:after{background:var(--__P__-neutral)}.__P__-agent-meta{display:flex;flex-direction:column;line-height:1.15;min-width:0}.__P__-agent-meta strong{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-agent-meta span{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-suggestions{display:flex;flex-wrap:nowrap;gap:var(--__P__-space-2);padding:6px 14px 10px;overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scroll-snap-type:x proximity;scrollbar-width:none;-ms-overflow-style:none;min-width:0}.__P__-suggestions::-webkit-scrollbar{display:none}.__P__-suggestions:before,.__P__-suggestions:after{content:"";flex:1 1 0;min-width:0}.__P__-suggestion{flex:0 0 auto;scroll-snap-align:center;padding:7px 14px;border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg);font-size:var(--__P__-text-sm);font-weight:500;white-space:nowrap;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-suggestion:hover{border-color:var(--__P__-accent);color:var(--__P__-accent-fg);transform:translateY(-1px)}.__P__-suggestion:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-color:var(--__P__-accent)}.__P__-suggestion:active{transform:translateY(0)}.__P__-icon-btn{width:32px;height:32px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);transition:background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-icon-btn:hover{background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-icon-btn:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-icon-btn:active{background:var(--__P__-border)}.__P__-icon-btn:disabled{opacity:.45;cursor:not-allowed}.__P__-icon-btn:before{content:"";position:absolute;inset:-6px}.__P__-icon-btn{position:relative}.__P__-icon-btn svg{width:18px;height:18px}.__P__-icon-btn[data-recording=true]{color:var(--__P__-accent-fg);background:color-mix(in srgb,var(--__P__-accent) 12%,transparent);animation:__P__-pulse 1.2s var(--__P__-ease) infinite}@keyframes __P__-pulse{0%,to{box-shadow:0 0 color-mix(in srgb,var(--__P__-accent) 40%,transparent)}50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--__P__-accent) 0%,transparent)}}.__P__-list,.__P__-history,.__P__-module-scroll,.__P__-home-scroll,.__P__-help-list,.__P__-toolui-code,.__P__-sidebar-conversations{scrollbar-width:thin;scrollbar-color:var(--__P__-border-strong) transparent;overscroll-behavior:contain;scrollbar-gutter:stable}.__P__-list::-webkit-scrollbar,.__P__-history::-webkit-scrollbar,.__P__-module-scroll::-webkit-scrollbar,.__P__-home-scroll::-webkit-scrollbar,.__P__-help-list::-webkit-scrollbar,.__P__-toolui-code::-webkit-scrollbar,.__P__-sidebar-conversations::-webkit-scrollbar{width:8px}.__P__-list::-webkit-scrollbar-thumb,.__P__-history::-webkit-scrollbar-thumb,.__P__-module-scroll::-webkit-scrollbar-thumb,.__P__-home-scroll::-webkit-scrollbar-thumb,.__P__-help-list::-webkit-scrollbar-thumb,.__P__-toolui-code::-webkit-scrollbar-thumb,.__P__-sidebar-conversations::-webkit-scrollbar-thumb{background:var(--__P__-border-strong);border-radius:8px}.__P__-list-wrap{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}.__P__-jump{position:absolute;inset-inline-end:14px;bottom:14px;z-index:2;display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:999px;border:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:var(--__P__-shadow-panel);cursor:pointer;opacity:.85;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease);animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-jump:hover{opacity:1}.__P__-jump:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-jump:active{transform:translateY(1px)}.__P__-jump svg{width:18px;height:18px}.__P__-list{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-4);padding-bottom:var(--__P__-space-8);display:flex;flex-direction:column;gap:14px}.__P__-list--fade{--__P__-fade-size: 20px;--__P__-fade-top: 0px;--__P__-fade-bottom: 0px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%)}.__P__-list--fade[data-fade-top=true]{--__P__-fade-top: var(--__P__-fade-size)}.__P__-list--fade[data-fade-bottom=true]{--__P__-fade-bottom: var(--__P__-fade-size)}.__P__-list>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-date-divider{display:flex;justify-content:center;margin-block:var(--__P__-space-3)}.__P__-date-pill{padding:3px 10px;border-radius:999px;font-size:calc(11px * var(--__P__-text-scale));font-weight:600;color:var(--__P__-fg-muted);background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);box-shadow:var(--__P__-shadow-card)}.__P__-bubble-row{display:flex}.__P__-bubble-row[data-role=user]{justify-content:flex-end}.__P__-bubble-row[data-role=assistant]{justify-content:flex-start}.__P__-bubble{max-width:100%;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);line-height:1.6;font-size:calc(14px * var(--__P__-text-scale));word-wrap:break-word;overflow-wrap:break-word;box-shadow:0 1px 2px #0000000a,0 1px 8px -4px #0000000f;animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-bubble ::selection{background:color-mix(in srgb,var(--__P__-accent) 30%,transparent)}.__P__-bubble-row[data-role=user] .__P__-bubble ::selection{background:#fff6;color:var(--__P__-bubble-user-text)}@keyframes __P__-bubble-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-bubble-row[data-role=user] .__P__-bubble{background:var(--__P__-bubble-user);color:var(--__P__-bubble-user-text);border-end-end-radius:5px}.__P__-bubble-row[data-role=assistant] .__P__-bubble{background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border:1px solid var(--__P__-border);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble{display:flex;align-items:stretch;padding:0;overflow:hidden;background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-author{display:flex;flex:0 0 auto;align-items:center;padding:0 .875rem;border-inline-end:1px solid color-mix(in oklab,var(--__P__-accent),transparent 60%);color:var(--__P__-accent);font-size:calc(13px * var(--__P__-text-scale));font-weight:600;letter-spacing:.025em;user-select:none}.__P__-bubble-row[data-role=operator] .__P__-bubble-body{flex:1 1 auto;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4)}.__P__-bubble-col{display:flex;flex-direction:column;max-width:85%;min-width:0}.__P__-bubble-row[data-role=user] .__P__-bubble-col{align-items:flex-end}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui) .__P__-bubble{width:100%}@media(max-width:640px){.__P__-bubble-col{max-width:92%}.__P__-toolui:not(.__P__-toolui-collapsible){padding:var(--__P__-space-3);gap:var(--__P__-space-2)}details.__P__-toolui-collapsible>summary{padding:var(--__P__-space-2) var(--__P__-space-3)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-3)}.__P__-toolui-section,.__P__-toolui-desc{padding:var(--__P__-space-2) var(--__P__-space-3)}}.__P__-bubble-meta{display:flex;align-items:center;gap:8px;margin-top:2px;padding:0 2px;min-height:24px}.__P__-bubble-actions{display:flex;align-items:center;gap:2px}.__P__-bubble-time{font-size:calc(11px * var(--__P__-text-scale));line-height:1;color:var(--__P__-fg-muted);user-select:none}.__P__-feedback{display:flex;align-items:center;gap:2px}.__P__-msg-action{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:0;border-radius:var(--__P__-radius-sm);background:transparent;color:var(--__P__-fg-muted);cursor:pointer;opacity:.65;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-msg-action:hover{opacity:1;background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-msg-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-msg-action[data-active=true]{opacity:1;color:var(--__P__-accent-fg)}.__P__-msg-action svg{width:15px;height:15px}.__P__-md>*:first-child{margin-top:0}.__P__-md>*:last-child{margin-bottom:0}.__P__-md p{margin:10px 0}.__P__-md h1,.__P__-md h2,.__P__-md h3,.__P__-md h4,.__P__-md h5,.__P__-md h6{margin:18px 0 8px;line-height:1.3;letter-spacing:-.01em;font-weight:700}.__P__-md h1{font-size:1.4em}.__P__-md h2{font-size:1.22em}.__P__-md h3{font-size:1.08em}.__P__-md h4,.__P__-md h5,.__P__-md h6{font-size:1em}.__P__-md>h1:first-child,.__P__-md>h2:first-child,.__P__-md>h3:first-child,.__P__-md>h4:first-child,.__P__-md>h5:first-child,.__P__-md>h6:first-child{margin-top:0}.__P__-md ul,.__P__-md ol{padding-inline-start:1.5em;margin:10px 0}.__P__-md ul{list-style:disc}.__P__-md ol{list-style:decimal}.__P__-md li{margin:6px 0;padding-inline-start:2px}.__P__-md li::marker{color:var(--__P__-fg-muted)}.__P__-md li>p{margin:6px 0}.__P__-md li>ul,.__P__-md li>ol{margin:6px 0}.__P__-md strong,.__P__-md b{font-weight:650;letter-spacing:-.005em}.__P__-md em,.__P__-md i{font-style:italic}.__P__-md code{font-family:var(--__P__-font-mono);font-size:.86em;padding:1px 6px;border-radius:5px;background:color-mix(in srgb,var(--__P__-accent) 10%,transparent);color:var(--__P__-fg);border:1px solid color-mix(in srgb,var(--__P__-accent) 16%,transparent)}.__P__-md pre{font-family:var(--__P__-font-mono);font-size:calc(12.5px * var(--__P__-text-scale));padding:12px 14px;border-radius:var(--__P__-radius-sm);background:#7f7f7f1f;overflow-x:auto;margin:var(--__P__-space-3) 0;line-height:1.5}.__P__-md pre code{padding:0;background:none}.__P__-md a{color:inherit;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.__P__-md a:hover{text-decoration-thickness:2px}.__P__-md blockquote{margin:14px 0;padding:6px 14px;border-inline-start:3px solid color-mix(in srgb,var(--__P__-accent) 50%,transparent);background:color-mix(in srgb,var(--__P__-accent) 5%,transparent);border-start-end-radius:var(--__P__-radius-sm);border-end-end-radius:var(--__P__-radius-sm);color:var(--__P__-fg-muted)}.__P__-md blockquote>:first-child{margin-top:0}.__P__-md blockquote>:last-child{margin-bottom:0}.__P__-md hr{border:0;height:1px;background:color-mix(in srgb,currentColor 18%,transparent);margin:var(--__P__-space-4) 0}.__P__-md table{border-collapse:collapse;margin:var(--__P__-space-3) 0;font-size:.95em;display:block;overflow-x:auto;max-width:100%;font-variant-numeric:tabular-nums}.__P__-md th,.__P__-md td{padding:6px 10px;border-bottom:1px solid color-mix(in srgb,currentColor 12%,transparent);text-align:start}.__P__-md th{font-weight:700;background:color-mix(in srgb,currentColor 6%,transparent)}.__P__-md h1+ul,.__P__-md h1+ol,.__P__-md h2+ul,.__P__-md h2+ol,.__P__-md h3+ul,.__P__-md h3+ol,.__P__-md h4+ul,.__P__-md h4+ol{margin-top:var(--__P__-space-1)}.__P__-loading{display:inline-flex;align-items:center;gap:var(--__P__-space-2);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-loading-spinner{width:14px;height:14px;border-radius:999px;border:2px solid currentColor;border-top-color:transparent;animation:__P__-spin .8s linear infinite}@keyframes __P__-spin{to{transform:rotate(1turn)}}.__P__-typing{display:inline-flex;gap:var(--__P__-space-1);padding:var(--__P__-space-1) 0}.__P__-typing span{width:5px;height:5px;border-radius:999px;background:currentColor;opacity:.4;animation:__P__-blink 1.2s var(--__P__-ease) infinite}.__P__-typing span:nth-child(2){animation-delay:.2s}.__P__-typing span:nth-child(3){animation-delay:.4s}@keyframes __P__-blink{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}.__P__-reasoning{margin:var(--__P__-space-1) 0 var(--__P__-space-2);padding-inline-start:var(--__P__-space-3);border-inline-start:2px solid var(--__P__-border-strong)}.__P__-reasoning-summary{display:inline-flex;align-items:center;gap:var(--__P__-space-1);cursor:pointer;list-style:none;user-select:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-reasoning-summary:hover{color:var(--__P__-fg)}.__P__-reasoning-summary:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-reasoning-summary::-webkit-details-marker{display:none}.__P__-reasoning-summary:before{content:"";width:5px;height:5px;border-inline-end:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(-45deg);opacity:.7;transition:transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-reasoning[open] .__P__-reasoning-summary:before{transform:rotate(45deg)}.__P__-reasoning[data-active=true] .__P__-reasoning-label{animation:__P__-reasoning-pulse 1.4s var(--__P__-ease) infinite}@keyframes __P__-reasoning-pulse{0%,to{opacity:.5}50%{opacity:1}}@media(prefers-reduced-motion:reduce){.__P__-reasoning[data-active=true] .__P__-reasoning-label{animation:none}}.__P__-reasoning-body{margin-top:var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-reasoning-body>:first-child{margin-top:0}.__P__-reasoning-body>:last-child{margin-bottom:0}.__P__-source{display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:6px;margin-inline-end:6px;padding:var(--__P__-space-1) var(--__P__-space-2);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);text-decoration:none}a.__P__-source:hover{color:var(--__P__-fg);border-color:var(--__P__-accent)}.__P__-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-composer{border-top:1px solid var(--__P__-border);padding:10px 12px;background:var(--__P__-bg);display:flex;flex-direction:column;gap:var(--__P__-space-2)}.__P__-composer>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-composer-row{display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;height:40px;max-height:160px;padding:10px 12px;border-radius:var(--__P__-radius);background:var(--__P__-bg-elevated);border:1px solid transparent;font-size:calc(14px * var(--__P__-text-scale));line-height:1.4;transition:height var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease),box-shadow var(--__P__-dur-quick) var(--__P__-ease)}.__P__-textarea:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:1px;border-color:var(--__P__-focus)}@media(pointer:coarse){.__P__-textarea,.__P__-home-search-input{font-size:max(16px,calc(16px * var(--__P__-text-scale)))}.__P__-textarea{height:44px}}.__P__-send{width:40px;height:40px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease)}.__P__-send[data-shape=circle]{border-radius:999px}.__P__-send[data-shape=square]{border-radius:var(--__P__-radius-sm)}.__P__-send[data-shape=pill]{width:auto;padding:0 18px;border-radius:999px}.__P__-send[data-variant=filled]{background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-send[data-variant=outline]{background:transparent;color:var(--__P__-accent-fg);border-color:var(--__P__-accent)}.__P__-send[data-variant=outline]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 10%,transparent)}.__P__-send[data-variant=ghost]{background:transparent;color:var(--__P__-accent-fg)}.__P__-send[data-variant=ghost]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 8%,transparent)}.__P__-send:disabled{opacity:.4;cursor:not-allowed}.__P__-send:not(:disabled):hover{transform:translateY(-1px)}.__P__-send:not(:disabled):active{transform:translateY(0)}.__P__-send:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-send svg{width:18px;height:18px}.__P__-composer-actions{display:flex;gap:var(--__P__-space-1);flex-wrap:wrap}.__P__-attachments{display:flex;flex-wrap:wrap;gap:6px}.__P__-attachment-chip{display:inline-flex;align-items:center;gap:6px;padding:var(--__P__-space-1) var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-1);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);font-size:var(--__P__-text-xs);max-width:200px}.__P__-attachment-thumb{width:24px;height:24px;border-radius:999px;object-fit:cover;background:var(--__P__-border)}.__P__-attachment-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-attachment-remove{width:18px;height:18px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-remove:hover{background:var(--__P__-border);color:var(--__P__-fg)}.__P__-dropzone{position:absolute;inset:8px;border:2px dashed var(--__P__-accent);border-radius:var(--__P__-radius);background:color-mix(in srgb,var(--__P__-accent) 8%,transparent);display:flex;align-items:center;justify-content:center;font-weight:600;color:var(--__P__-accent-fg);pointer-events:none;z-index:10;animation:__P__-fade-in var(--__P__-dur-quick) var(--__P__-ease)}@keyframes __P__-fade-in{0%{opacity:0}to{opacity:1}}.__P__-error{margin-top:var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-danger) 8%,var(--__P__-bg-elevated));border:1px solid color-mix(in oklab,var(--__P__-danger) 20%,transparent);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);display:flex;align-items:center;gap:var(--__P__-space-2)}.__P__-error span{min-width:0}.__P__-error button{margin-inline-start:auto;flex-shrink:0;border:0;background:none;padding:0;color:var(--__P__-accent-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:underline;white-space:nowrap;cursor:pointer}.__P__-history{flex:1;overflow-y:auto;padding:var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-3)}.__P__-history-footer{flex:none;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);border-top:1px solid var(--__P__-border);background:var(--__P__-surface)}.__P__-history-new{width:100%;display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);padding:var(--__P__-space-2) var(--__P__-space-3);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-on-accent);cursor:pointer;font-size:var(--__P__-text-sm);font-weight:600;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-history-new svg{width:16px;height:16px}.__P__-history-new:hover{filter:brightness(1.08)}.__P__-history-new:active{transform:translateY(1px)}.__P__-history-new:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-history-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:40px 16px;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));text-align:center}.__P__-history-group{display:flex;flex-direction:column;padding:0 var(--__P__-space-3)}.__P__-history-heading{font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);padding:14px 4px 8px;text-transform:uppercase;letter-spacing:.04em}.__P__-history-card{display:flex;flex-direction:column;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);overflow:hidden}.__P__-history-item{all:unset;display:flex;align-items:center;gap:var(--__P__-space-3);padding:12px var(--__P__-space-3);cursor:pointer;transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-history-item+.__P__-history-item{border-top:1px solid var(--__P__-border)}.__P__-history-item:hover{background:var(--__P__-bg-elevated)}.__P__-history-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-history-avatar{flex:none;display:grid;place-items:center;width:36px;height:36px;border-radius:50%;background:color-mix(in oklab,var(--__P__-accent) 12%,transparent);color:var(--__P__-accent-fg)}.__P__-history-avatar svg{width:18px;height:18px}.__P__-history-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.__P__-history-row{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-history-title{flex:1;min-width:0;font-size:calc(14px * var(--__P__-text-scale));font-weight:500;color:var(--__P__-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-time{flex:none;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-history-preview{flex:1;min-width:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-dot{flex:none;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-history-item[data-unread=true] .__P__-history-title{font-weight:600}.__P__-history-item[data-closed=true] .__P__-history-title{color:var(--__P__-fg-muted)}.__P__-history-item-skeleton{cursor:default;pointer-events:none}.__P__-skeleton{display:block;border-radius:4px;background:linear-gradient(90deg,color-mix(in oklab,var(--__P__-fg) 9%,transparent) 30%,color-mix(in oklab,var(--__P__-fg) 17%,transparent),color-mix(in oklab,var(--__P__-fg) 9%,transparent) 70%);background-size:200% 100%;animation:__P__-skeleton-shimmer 1.8s ease-in-out infinite}.__P__-history-avatar.__P__-skeleton{border-radius:50%}.__P__-skeleton-heading{width:52px;height:8px}.__P__-skeleton-title{width:55%;height:12px}.__P__-skeleton-time{width:34px;height:10px}.__P__-skeleton-preview{width:80%;height:10px}@keyframes __P__-skeleton-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-skeleton{animation:none}}.__P__-list-loading{margin:auto;padding:var(--__P__-space-6) var(--__P__-space-4);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);text-align:center}.__P__-readonly-banner{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 12px;margin:0 var(--__P__-space-3) var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);text-align:center;font-size:var(--__P__-text-sm)}.__P__-readonly-label{line-height:1.4}.__P__-readonly-cta{appearance:none;border:0;cursor:pointer;padding:var(--__P__-space-2) var(--__P__-space-4);border-radius:999px;background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-readonly-cta:hover,.__P__-readonly-cta:focus-visible{filter:brightness(1.1)}.__P__-operator-banner{display:flex;align-items:center;justify-content:center;gap:8px;margin:0 var(--__P__-space-3) var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg-elevated),var(--__P__-accent) 6%);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);line-height:1.3;text-align:center}.__P__-operator-pulse{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-operator-banner[data-mode=awaiting_operator] .__P__-operator-pulse{animation:__P__-operator-pulse 1.4s var(--__P__-ease-out) infinite}.__P__-operator-cancel{flex:0 0 auto;padding:0;border:0;background:none;color:var(--__P__-accent);font:inherit;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.__P__-operator-cancel:hover{opacity:.8}.__P__-operator-cancel:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-radius:var(--__P__-radius-sm)}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__P__-readonly-cta:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}.__P__-composer-footer{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px 16px;margin:0 var(--__P__-space-3);border-top:1px solid var(--__P__-border);text-align:center;font-size:calc(11px * var(--__P__-text-scale));line-height:1.4;color:var(--__P__-fg-muted)}.__P__-disclaimer{max-width:320px;margin:0 auto;opacity:.9;letter-spacing:.01em}.__P__-poweredby{display:inline-flex;align-items:center;justify-content:center;gap:6px;color:inherit;text-decoration:none;opacity:.7;transition:opacity var(--__P__-dur-base) var(--__P__-ease);font-size:calc(11px * var(--__P__-text-scale));letter-spacing:.02em}.__P__-poweredby:hover{opacity:1}.__P__-poweredby-logo{height:12px;width:auto;display:inline-block;vertical-align:middle}.__P__-poweredby-bar{flex:none;display:flex;align-items:center;justify-content:center;padding:6px 16px;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated)}.__P__-menu-wrap{position:relative;display:inline-flex}.__P__-menu{position:absolute;top:100%;inset-inline-end:0;margin-top:6px;min-width:200px;padding:6px;background:var(--__P__-bg);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);box-shadow:var(--__P__-shadow-panel);z-index:10;display:flex;flex-direction:column;gap:2px;animation:__P__-menu-in var(--__P__-dur-base) var(--__P__-ease)}@media(prefers-reduced-motion:reduce){.__P__-menu{animation:none}}@keyframes __P__-menu-in{0%{opacity:0;transform:translateY(-4px) scale(.98);transform-origin:top right}to{opacity:1;transform:none}}.__P__-menu-item{all:unset;display:flex;align-items:center;gap:10px;padding:8px 10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);border-radius:var(--__P__-radius-sm);cursor:pointer;user-select:none}.__P__-menu-item:hover{background:var(--__P__-bg-elevated)}.__P__-menu-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-menu-item[disabled]{opacity:.45;cursor:not-allowed}.__P__-menu-icon{display:inline-flex;width:16px;height:16px;color:var(--__P__-fg-muted)}.__P__-menu-icon svg{width:16px;height:16px}.__P__-menu-label{flex:1}.__P__-menu-check{display:inline-flex;color:var(--__P__-accent-fg)}.__P__-menu-check svg{width:14px;height:14px}.__P__-menu-item-segmented{cursor:default}.__P__-menu-item-segmented:hover{background:transparent}.__P__-segmented{display:inline-flex;gap:2px;padding:2px;background:var(--__P__-bg-elevated);border-radius:var(--__P__-radius-sm)}.__P__-segment{all:unset;min-width:26px;padding:3px 8px;font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.02em;text-align:center;color:var(--__P__-fg-muted);border-radius:calc(var(--__P__-radius-sm) - 2px);cursor:pointer;transition:color .12s ease,background .12s ease}.__P__-segment:hover{color:var(--__P__-fg)}.__P__-segment[data-on=true]{background:var(--__P__-bg);color:var(--__P__-accent-fg);box-shadow:var(--__P__-shadow-card)}.__P__-segment:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-resize-grip{position:absolute;width:18px;height:18px;display:flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);opacity:.45;transition:opacity var(--__P__-dur-base) var(--__P__-ease);z-index:2;touch-action:none;user-select:none}.__P__-resize-grip:hover,.__P__-resize-grip:focus-visible{opacity:1}.__P__-resize-grip svg{width:10px;height:10px}.__P__-resize-grip--bottom-left{bottom:2px;left:2px;cursor:nesw-resize;transform:scaleX(-1)}.__P__-resize-grip--bottom-right{bottom:2px;right:2px;cursor:nwse-resize}.__P__-resize-grip--top-left{top:2px;left:2px;cursor:nwse-resize;transform:rotate(180deg)}.__P__-resize-grip--top-right{top:2px;right:2px;cursor:nesw-resize;transform:scaleY(-1)}:host(:not([data-mode="open"])) .__P__-resize-grip{display:none}.__P__-messenger{display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-body,.__P__-messenger-pane{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-pane[hidden]{display:none}@keyframes __P__-view-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-module{display:flex;flex-direction:column;height:100%;min-height:0}@media(prefers-reduced-motion:no-preference){.__P__-module,.__P__-history{animation:__P__-view-in .18s var(--__P__-ease-out)}}.__P__-module-scroll{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-3);display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-home{container-type:inline-size;background:radial-gradient(125% 65% at 88% 0%,color-mix(in srgb,#fff 16%,transparent),transparent 55%),linear-gradient(180deg,var(--__P__-accent) 0%,var(--__P__-accent) 22%,color-mix(in srgb,var(--__P__-accent) 28%,var(--__P__-surface)) 44%,var(--__P__-surface) 70%);border-radius:var(--__P__-radius-lg) var(--__P__-radius-lg) 0 0}.__P__-home-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;background:transparent}.__P__-home-cards{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:4px 14px 16px}.__P__-module-pad{padding:var(--__P__-space-3) var(--__P__-space-3) 0}.__P__-module-empty{display:flex;flex-direction:column;align-items:center;gap:var(--__P__-space-3);padding:var(--__P__-space-8) var(--__P__-space-4);text-align:center;color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-module-retry{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border-strong);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);font-weight:600;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-module-retry:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}.__P__-module-retry:active{background:var(--__P__-border)}.__P__-module-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-help-list{flex:1;min-height:0;overflow-y:auto;padding-bottom:var(--__P__-space-3)}.__P__-help-group{display:flex;flex-direction:column}.__P__-help-section-title{position:sticky;top:0;z-index:1;margin:0;padding:var(--__P__-space-3) var(--__P__-space-5) var(--__P__-space-2);font-size:var(--__P__-text-xs);font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--__P__-fg-muted);background:var(--__P__-bg)}.__P__-help-card{margin:0 var(--__P__-space-3) var(--__P__-space-3);background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden}.__P__-help-card .__P__-list-row{border-bottom:0;border-radius:0}.__P__-help-card .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-tabbar{display:flex;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);flex-shrink:0}.__P__-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-1);min-height:48px;padding:var(--__P__-space-2) var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;transition:color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-tab:hover{color:var(--__P__-fg)}.__P__-tab[aria-selected=true]{color:var(--__P__-accent-fg)}.__P__-tab:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-tab:active{background:var(--__P__-hover)}.__P__-tab-icon{position:relative;display:inline-flex}.__P__-tab-icon svg{width:22px;height:22px}.__P__-tab-badge{position:absolute;top:-2px;left:calc(50% + 6px);width:8px;height:8px;border-radius:50%;background:var(--__P__-accent);box-shadow:0 0 0 2px var(--__P__-bg-elevated)}.__P__-home-hero{flex-shrink:0;padding:var(--__P__-space-5) var(--__P__-space-5) var(--__P__-space-3);color:var(--__P__-on-accent);--__P__-focus: var(--__P__-on-accent)}.__P__-home-hero-top{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);min-height:32px}.__P__-home-brand{font-size:clamp(calc(12px * var(--__P__-text-scale)),calc(3.2cqi * var(--__P__-text-scale)),calc(14px * var(--__P__-text-scale)));font-weight:600;letter-spacing:.01em;color:color-mix(in srgb,#fff 82%,transparent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.__P__-home-brand-spacer{flex:1}.__P__-home-hero-actions{display:flex;align-items:center;gap:var(--__P__-space-2);flex-shrink:0}.__P__-home-hero-actions .__P__-icon-btn{color:#fff}.__P__-home-hero-actions .__P__-icon-btn:hover{background:color-mix(in srgb,#fff 18%,transparent);color:#fff}.__P__-home-hero-actions .__P__-icon-btn:active{background:color-mix(in srgb,#fff 26%,transparent)}.__P__-home-greeting{margin:28px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(19px * var(--__P__-text-scale)),calc(5.5cqi * var(--__P__-text-scale)),var(--__P__-text-2xl));font-weight:800;line-height:1.18;letter-spacing:-.01em;overflow-wrap:anywhere}.__P__-home-lead{margin:10px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(15px * var(--__P__-text-scale)),calc(4.2cqi * var(--__P__-text-scale)),var(--__P__-text-xl));font-weight:600;line-height:1.25;letter-spacing:-.005em;color:color-mix(in srgb,var(--__P__-on-accent) 78%,transparent);overflow-wrap:anywhere}.__P__-home-avatars{display:flex}.__P__-home-avatar{width:30px;height:30px;border-radius:999px;overflow:hidden;margin-inline-start:-10px;border:2px solid color-mix(in srgb,#fff 92%,transparent);box-shadow:0 1px 3px #0000002e;background:var(--__P__-surface);display:inline-flex;align-items:center;justify-content:center;font-size:var(--__P__-text-xs);font-weight:700;color:var(--__P__-fg)}.__P__-home-avatar:first-child{margin-inline-start:0}.__P__-home-avatar img{width:100%;height:100%;object-fit:cover}.__P__-home-content{background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-card);overflow:hidden}.__P__-home-content-title{padding:var(--__P__-space-4) var(--__P__-space-4) var(--__P__-space-3);font-size:var(--__P__-text-sm);font-weight:700}.__P__-home-content-list{display:flex;flex-direction:column;padding:0 var(--__P__-space-2) var(--__P__-space-2)}.__P__-home-content-list .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-home-card{display:block;width:100%;text-align:start;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);padding:var(--__P__-space-4);box-shadow:var(--__P__-shadow-card)}.__P__-home-card[data-interactive=true]{cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-home-card[data-interactive=true]:hover{background:var(--__P__-bg-elevated)}.__P__-home-card[data-interactive=true]:active{transform:translateY(1px)}.__P__-home-card[data-interactive=true]:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-recent-row{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-recent-avatar{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex-shrink:0;border-radius:999px;background:color-mix(in oklch,var(--__P__-accent) 14%,transparent);color:var(--__P__-accent-fg)}.__P__-home-recent-avatar svg{width:20px;height:20px}.__P__-home-recent-body{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}.__P__-home-recent-title{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-recent-preview{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-home-recent-dot{width:8px;height:8px;border-radius:999px;background:var(--__P__-accent);flex-shrink:0}.__P__-home-recent-row[data-unread=true] .__P__-home-recent-title{font-weight:700}.__P__-home-status{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-status-icon svg{width:22px;height:22px;color:var(--__P__-success)}.__P__-home-status[data-level=degraded] .__P__-home-status-icon svg{color:var(--__P__-warning)}.__P__-home-status[data-level=down] .__P__-home-status-icon svg{color:var(--__P__-danger)}.__P__-home-status-text{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search{display:flex;align-items:center;gap:var(--__P__-space-2);width:100%;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);border:1px solid var(--__P__-border);background:var(--__P__-surface);text-align:start}.__P__-home-search[data-input=true]{background:var(--__P__-bg-elevated)}.__P__-home-search:hover{border-color:var(--__P__-border-strong)}.__P__-home-search:focus-visible,.__P__-home-search:focus-within{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search-text{flex:1;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search-input{flex:1;border:0;background:transparent;font-size:calc(14px * var(--__P__-text-scale));color:var(--__P__-fg);outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent-fg)}.__P__-list-row{display:flex;align-items:center;gap:var(--__P__-space-3);width:100%;min-height:44px;text-align:start;padding:var(--__P__-space-3) var(--__P__-space-2);border-radius:var(--__P__-radius-sm)}.__P__-list-row:hover{background:var(--__P__-hover)}.__P__-list-row:active{background:var(--__P__-border)}.__P__-list-row:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-list-row-body{display:flex;flex-direction:column;min-width:0;flex:1}.__P__-list-row-title{font-weight:600;font-size:var(--__P__-text-md);line-height:1.35}.__P__-list-row-sub{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);margin-top:var(--__P__-space-1);line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-list-row-chevron svg{width:18px;height:18px;color:var(--__P__-accent-fg);flex-shrink:0}.__P__-back-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);flex-shrink:0}.__P__-back-title{flex:1;text-align:center;font-size:var(--__P__-text-md);font-weight:700;margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-back-spacer{width:32px;height:1px}.__P__-history>*,.__P__-home-scroll>*,.__P__-module-scroll>*,.__P__-help-list>*,.__P__-history-footer>*,.__P__-module-pad{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-header,.__P__-back-header{padding-inline:max(12px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-tabbar{padding-inline:max(0px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-content{display:flex;flex-direction:column;gap:14px;width:100%;max-width:68ch;margin:0 auto}.__P__-content-hero{width:100%;border-radius:var(--__P__-radius)}.__P__-content-subtitle{color:var(--__P__-fg-muted);margin:0}.__P__-content-frame{flex:1;min-height:0;width:100%;border:0;background:#fff}.__P__-news-list{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-news-card{display:block;width:100%;text-align:start;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface)}.__P__-news-card{transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-news-card:hover{background:var(--__P__-bg-elevated)}.__P__-news-card:active{transform:translateY(1px)}.__P__-news-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-hero{width:100%;display:block}.__P__-news-body{display:flex;flex-direction:column;gap:6px;padding:14px 16px}.__P__-news-title{font-weight:700;font-size:var(--__P__-text-md)}.__P__-news-summary{color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-modules-empty{display:flex;align-items:center;justify-content:center;position:relative}.__P__-modules-empty-close{position:absolute;top:12px;inset-inline-end:12px}.__P__-modules-empty-text{color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-form{display:flex;flex-direction:column;gap:var(--__P__-space-4)}.__P__-field{display:flex;flex-direction:column;gap:6px}.__P__-field-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:var(--__P__-space-2)}.__P__-field-label{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-field-req{color:var(--__P__-danger)}.__P__-field-type{flex-shrink:0;align-self:center;margin-inline-start:auto;border:1px solid var(--__P__-border);border-radius:5px;background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);padding:1px 7px;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);white-space:nowrap}.__P__-field-input{width:100%;min-width:0;max-width:100%;box-sizing:border-box;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);resize:vertical;transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-field-input:focus-visible{outline:none;border-color:var(--__P__-accent)}.__P__-field[data-invalid=true] .__P__-field-input{border-color:var(--__P__-danger)}.__P__-field-input[type=date],.__P__-field-input[type=time]{appearance:none;-webkit-appearance:none}@media(pointer:coarse){.__P__-field-input{font-size:max(16px,calc(16px * var(--__P__-text-scale)))}}.__P__-field-hint{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-field-error{font-size:var(--__P__-text-xs);color:var(--__P__-danger)}.__P__-field-choices{display:flex;flex-direction:column;gap:10px;padding-top:2px}.__P__-choice{display:flex;align-items:flex-start;gap:10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);cursor:pointer}.__P__-choice input{margin-top:2px;accent-color:var(--__P__-accent)}.__P__-form-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}.__P__-form-hint{flex:1 1 auto;min-width:6rem;margin-inline-end:auto;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-form-submit{padding:var(--__P__-space-2) var(--__P__-space-4);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-submit:hover:not(:disabled){filter:brightness(1.06)}.__P__-form-submit:disabled{opacity:.6;cursor:default}.__P__-form-skip{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:transparent;color:var(--__P__-fg-muted);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-skip:hover:not(:disabled){background:var(--__P__-bg-elevated)}@media(max-width:640px){.__P__-form-hint{flex-basis:100%;margin-inline-end:0;font-size:var(--__P__-text-xs)}.__P__-form-submit,.__P__-form-skip{flex:1 1 0;text-align:center}}.__P__-form-gate{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated)}.__P__-form-gate-title{margin:0;font-size:var(--__P__-text-base);font-weight:700;color:var(--__P__-fg)}.__P__-form-gate-desc{margin:0 0 var(--__P__-space-1);font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted)}.__P__-form-done{display:flex;align-items:center;justify-content:center;gap:6px;padding:6px 12px;border:1px dashed var(--__P__-border);border-radius:999px;align-self:center;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted)}.__P__-form-done svg{width:14px;height:14px;color:var(--__P__-success, #22c55e)}.__P__-form-done[data-outcome=skipped] svg{color:var(--__P__-fg-muted)}.__P__-form-done-fill{border:0;background:none;padding:0 2px;cursor:pointer;font:inherit;font-weight:600;color:var(--__P__-accent-fg)}.__P__-form-done-fill:hover{text-decoration:underline}details.__P__-form-done{display:block;padding:0;border-radius:var(--__P__-radius-md)}details[open].__P__-form-done{width:min(100%,420px);background:var(--__P__-surface)}.__P__-form-done-summary{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;cursor:pointer;list-style:none}.__P__-form-done-summary::-webkit-details-marker{display:none}.__P__-form-done-summary>svg:last-child{color:var(--__P__-fg-muted);transition:transform .15s var(--__P__-ease)}details[open]>.__P__-form-done-summary>svg:last-child{transform:rotate(90deg)}.__P__-form-answers{margin:0;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);display:grid;gap:var(--__P__-space-3);text-align:start}.__P__-form-answer{display:grid;gap:6px}.__P__-form-answer dt{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-form-answer dd{margin:0;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);font-size:var(--__P__-text-sm);font-weight:400;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui{margin-block:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);background:var(--__P__-bg-elevated);font-size:var(--__P__-text-sm)}.__P__-toolui:not(.__P__-toolui-collapsible){display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-group{display:flex;flex-direction:column;gap:var(--__P__-space-3);margin-block:var(--__P__-space-3)}.__P__-toolui-group>.__P__-toolui{margin-block:0}.__P__-toolui-stale{opacity:.7}details.__P__-toolui-collapsible>summary{display:flex;align-items:center;gap:var(--__P__-space-2);padding:var(--__P__-space-3) var(--__P__-space-4);cursor:pointer;list-style:none;-webkit-tap-highlight-color:transparent;user-select:none}details.__P__-toolui-collapsible>summary::-webkit-details-marker{display:none}details.__P__-toolui-collapsible[open]>summary{border-bottom:1px solid var(--__P__-border)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-4)}details.__P__-toolui-collapsible>.__P__-toolui-section~.__P__-toolui-section{margin-top:calc(-1 * var(--__P__-space-2))}.__P__-toolui-name-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-chevron{display:inline-flex;color:var(--__P__-fg-muted);transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}details.__P__-toolui-collapsible>summary .__P__-toolui-status{margin-inline-start:auto}.__P__-toolui-chevron svg{width:16px;height:16px}details.__P__-toolui-collapsible[open]>summary .__P__-toolui-chevron{transform:rotate(180deg)}.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{--__P__-pill: var(--__P__-fg-muted);display:inline-flex;min-width:0;align-items:center;gap:5px;padding:3px 7px;border-radius:5px;border:1px solid var(--__P__-border);background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);color:var(--__P__-pill);font-size:var(--__P__-text-xs);font-weight:600;white-space:nowrap}.__P__-toolui-badge svg,.__P__-toolui-name-pill svg,.__P__-toolui-q-pill svg{flex-shrink:0;width:14px;height:14px}.__P__-toolui-status-icon{display:inline-flex}.__P__-toolui-name-pill{--__P__-pill: oklch(.68 .13 233)}.__P__-toolui-q-pill{--__P__-pill: oklch(.66 .12 195)}.__P__-toolui-status[data-status=completed]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=responded]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=awaiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=denied]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=error]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=superseded]{--__P__-pill: var(--__P__-fg-muted)}@supports (color: oklch(from red l c h)){.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{color:oklch(from var(--__P__-pill) clamp(var(--__P__-pill-l-min),l,var(--__P__-pill-l-max)) c h)}}.__P__-toolui-head{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2)}.__P__-toolui-head-end{display:inline-flex;align-items:center;gap:var(--__P__-space-2);margin-inline-start:auto}.__P__-toolui-collapse-body{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-summary{display:flex;flex-direction:column;gap:var(--__P__-space-4)}.__P__-toolui-answer{margin:0;font-size:var(--__P__-text-sm);color:var(--__P__-fg);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-toolui-footer{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);margin-inline:calc(-1 * var(--__P__-space-4));padding:var(--__P__-space-3) var(--__P__-space-4) 0;border-top:1px solid var(--__P__-border)}.__P__-toolui-options-toggle{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;padding:0;cursor:pointer;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);transition:color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-toolui-options-toggle:hover{color:var(--__P__-fg)}.__P__-toolui-options-chevron{display:inline-flex;transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-toolui-options-chevron svg{width:14px;height:14px}.__P__-toolui-options-chevron.__P__-open{transform:rotate(180deg)}.__P__-toolui-desc{margin:0;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-section{display:flex;flex-direction:column;gap:8px;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border)}.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-section,.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-desc{padding:0;background:none;border:0;border-radius:0}.__P__-toolui-label{font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--__P__-fg-muted)}.__P__-toolui-code{margin:0;max-height:240px;overflow:auto;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);font-size:var(--__P__-text-xs);line-height:1.5;white-space:pre-wrap;word-break:break-word}.__P__-toolui-code[data-error=true]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-body{gap:6px}.__P__-toolui-prompt{margin:0;font-weight:600;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui-subtle{margin:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}:host([dir="rtl"]) .__P__-icon-dir{transform:scaleX(-1)}:host([dir="rtl"]) .__P__-field-input[type=date],:host([dir="rtl"]) .__P__-field-input[type=time]{position:relative;text-align:right;padding-left:34px}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-datetime-edit,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-datetime-edit{text-align:right}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-calendar-picker-indicator,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-calendar-picker-indicator{position:absolute;left:var(--__P__-space-3);margin:0}
|
|
4
4
|
`,`.__P__-standalone-page{margin:0;height:100vh;background:var(--__P__-bg, #fff);display:grid;place-items:stretch}
|
|
5
5
|
`,`:host([data-mode="page"]){min-height:0}:host([data-mode="page"]) .__P__-page-shell{display:grid;grid-template-columns:280px 1fr;width:100%;height:100%;min-height:0;background:var(--__P__-bg);color:var(--__P__-fg);transition:grid-template-columns var(--__P__-dur-base) var(--__P__-ease-in-out)}:host([data-mode="page"]) .__P__-page-shell[data-sidebar-collapsed=true]{grid-template-columns:48px 1fr}:host([data-mode="page"]) .__P__-page-chat{display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden}:host([data-mode="page"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-width:0;min-height:0;flex:1 1 0}:host([data-mode="page"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;border-radius:0;border:0;box-shadow:none;animation:none}:host([data-mode="page"]) .__P__-sidebar{border-inline-end:1px solid var(--__P__-border);display:flex;flex-direction:column;overflow:hidden;background:var(--__P__-surface)}:host([data-mode="page"]) .__P__-sidebar-header{padding:var(--__P__-space-4) var(--__P__-space-5);border-bottom:1px solid var(--__P__-border);display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2);min-height:56px;box-sizing:border-box}:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-header{padding:var(--__P__-space-4) var(--__P__-space-2);justify-content:center}:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-logo,:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-title{display:none}:host([data-mode="page"]) .__P__-sidebar-toggle{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid var(--__P__-border);border-radius:6px;background:transparent;color:var(--__P__-fg);cursor:pointer;transition:background .12s,border-color .12s}:host([data-mode="page"]) .__P__-sidebar-toggle:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}:host([data-mode="page"]) .__P__-sidebar-toggle:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}:host([data-mode="page"]) .__P__-sidebar-logo{height:32px;display:block}:host([data-mode="page"]) .__P__-sidebar-title{font-size:var(--__P__-text-md);font-weight:600}:host([data-mode="page"]) .__P__-sidebar-section{padding:var(--__P__-space-3) var(--__P__-space-4);border-bottom:1px solid var(--__P__-border)}:host([data-mode="page"]) .__P__-sidebar-nav{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}:host([data-mode="page"]) .__P__-sidebar-nav-item{display:flex;align-items:center;gap:10px;padding:var(--__P__-space-2) var(--__P__-space-3);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);text-decoration:none;font-size:calc(14px * var(--__P__-text-scale));transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}:host([data-mode="page"]) .__P__-sidebar-nav-item:hover{background:var(--__P__-hover)}:host([data-mode="page"]) .__P__-sidebar-nav-item:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}:host([data-mode="page"]) .__P__-sidebar-cards{display:grid;grid-template-columns:1fr;gap:var(--__P__-space-2)}:host([data-mode="page"]) .__P__-sidebar-card{display:block;padding:10px 12px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);text-decoration:none;color:var(--__P__-fg);transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}:host([data-mode="page"]) .__P__-sidebar-card:hover{border-color:var(--__P__-accent)}:host([data-mode="page"]) .__P__-sidebar-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}:host([data-mode="page"]) .__P__-sidebar-card-label{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}:host([data-mode="page"]) .__P__-sidebar-card-desc{font-size:var(--__P__-text-xs);color:var(--__P__-muted);margin-top:2px}:host([data-mode="page"]) .__P__-sidebar-conversations{flex:1 1 auto;overflow-y:auto;padding:var(--__P__-space-3) var(--__P__-space-4)}:host([data-mode="page"]) .__P__-page-chat{display:flex;flex-direction:column;overflow:hidden}@media(max-width:768px){:host([data-mode="page"]) .__P__-page-shell{grid-template-columns:1fr}:host([data-mode="page"]) .__P__-sidebar{display:none}}
|
|
6
6
|
`].join(`
|
|
7
|
-
`).replace(/__P__/g,`helpai`).replaceAll(`__BRAND_ACCENT_TEXT__`,`#FFFFFF`).replaceAll(`__BRAND_ACCENT__`,`#5B5BD6`).replaceAll(`__BRAND_RADIUS__`,`12px`).replaceAll(`__BRAND_FONT__`,`Inter, system-ui, -apple-system, 'Segoe UI', sans-serif`),gt=
|
|
7
|
+
`).replace(/__P__/g,`helpai`).replaceAll(`__BRAND_ACCENT_TEXT__`,`#FFFFFF`).replaceAll(`__BRAND_ACCENT__`,`#5B5BD6`).replaceAll(`__BRAND_RADIUS__`,`12px`).replaceAll(`__BRAND_FONT__`,`Inter, system-ui, -apple-system, 'Segoe UI', sans-serif`),gt=N.scope(`mount`),_t=new WeakMap,vt={floating:`all: initial; position: fixed; z-index: 2147483600;`,flow:`all: initial; display: block; position: relative; width: 100%; height: 100%; z-index: 1; contain: size;`,viewport:`all: initial; display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;`};function yt(e,t){e.style.cssText=vt[t]}function bt(e){return e===`floating`||e===`modal`||e===`drawer`?`floating`:e===`standalone`||e===`page`?`viewport`:`flow`}function xt(e={}){let t=e.position??`flow`;gt.debug(`createShadowMount`,{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${y.cssPrefix}-chat-host`;typeof customElements<`u`&&!customElements.get(n)&&customElements.define(n,class extends HTMLElement{});let r;e.existingHost?r=e.existingHost:(r=document.createElement(n),(e.target??document.body).appendChild(r)),r.setAttribute(`data-brand`,y.id),r.style.cssText=vt[t];let i=r.shadowRoot??r.attachShadow({mode:`open`}),a=r.ownerDocument;if(!St(i,a)){let e=a.createElement(`style`);e.textContent=ht,i.appendChild(e)}let o=document.createElement(`div`);return o.className=`${y.cssPrefix}-app`,i.appendChild(o),{appRoot:o,destroy:()=>r.remove(),hostElement:r,shadowRoot:i}}function St(e,t){if(!(`adoptedStyleSheets`in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!=`function`)return!1;let r=_t.get(t);if(!r)try{r=new n.CSSStyleSheet,r.replaceSync(ht),_t.set(t,r)}catch{return!1}try{return e.adoptedStyleSheets=[r],!0}catch{return!1}}function Ct(e,t){let n=y.cssPrefix;t.accent&&e.style.setProperty(`--${n}-accent-user`,t.accent),t.accentText&&e.style.setProperty(`--${n}-accent-text-user`,t.accentText),t.radius&&e.style.setProperty(`--${n}-radius`,t.radius),t.fontFamily&&e.style.setProperty(`--${n}-font`,t.fontFamily),t.contentMaxWidth&&e.style.setProperty(`--${n}-conversation-max`,t.contentMaxWidth)}function wt(e,t){e.dataset.theme=t}function Tt(e,t){let n=y.cssPrefix;t.width!==void 0&&e.style.setProperty(`--${n}-panel-w`,t.width),t.height!==void 0&&e.style.setProperty(`--${n}-panel-h`,t.height),t.expanded?.width!==void 0&&e.style.setProperty(`--${n}-expanded-w`,t.expanded.width),t.expanded?.height!==void 0&&e.style.setProperty(`--${n}-expanded-h`,t.expanded.height),t.inset!==void 0&&e.style.setProperty(`--${n}-panel-inset`,t.inset)}function Et(e,t){e.dataset.position=t}function Dt(e,t){e.dataset.mode=t}function Ot(e,t){wt(e,t.themeMode),Ct(e,t.themeOverrides),Et(e,t.position),Tt(e,t.size)}function kt(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function At(e){return kt(e)}function jt(e){return!(!kt(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function Mt(e){return`${y.cssPrefix}:${e}`}function Nt(e,t){let n=Object.entries(t).map(([t,n])=>{let r=Mt(t),i=e=>n(e.detail);return e.addEventListener(r,i),[r,i]});return()=>{for(let[t,r]of n)e.removeEventListener(t,r)}}function Pt(e,t,n){return e===`page`?`page`:e===`standalone`?`standalone`:e===`inline`?t===`fullscreen`?`fullscreen`:`inline`:e===`modal`||e===`drawer`?n?t===`fullscreen`?`fullscreen`:e:`closed`:n?t===`fullscreen`?`fullscreen`:t===`expanded`?`expanded`:`open`:`closed`}function Ft(e,t,n){if(e===`standalone`||e===`page`)return`fullscreen`;let r=t.initialSize;return r===`expanded`||r===`fullscreen`||r===`normal`?r:n>0&&n<640?`fullscreen`:n>=(t.autoSizeBreakpoint??900)?`expanded`:`normal`}function It(e,t,n,r=null){return{panelOpen:e.mode===`inline`||e.mode===`standalone`||e.mode===`page`||(n??!e.startMinimized),panelSize:e.mode!==`standalone`&&e.mode!==`page`&&e.mode!==`inline`&&r?r:Ft(e.mode,e.size,t)}}function Lt(){return typeof window>`u`?0:window.innerWidth}function Rt(e){return{headers(){let t={};return e.aiAgentDeploymentId&&(t[`x-ai-agent-deployment-id`]=e.aiAgentDeploymentId),e.publicKey&&(t[e.publicKeyHeader??`x-public-key`]=e.publicKey),t}}}function zt(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e),i=()=>a();t?.addEventListener(`abort`,i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener(`abort`,i),n()}})}const Bt=`0.70.4`;function Vt(e){"@babel/helpers - typeof";return Vt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Vt(e)}function Ht(e,t){if(Vt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Vt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function R(e){var t=Ht(e,`string`);return Vt(t)==`symbol`?t:t+``}function z(e,t,n){return(t=R(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ut=class extends Error{constructor(e,t,n,r){super(e),this.code=t,this.status=n,this.cause=r,this.name=`StreamError`}};const Wt=N.scope(`parser`);async function*Gt(e,t){if(!e.ok){let t=await e.text().catch(()=>``);throw new Ut(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let n of Kt(e,t)){let e=qt(n);if(e===`done`)return;e&&(yield e)}}async function*Kt(e,t){if(!e.body)throw new Ut(`response has no body`,`no-body`);let n=e.body.pipeThrough(new TextDecoderStream).getReader(),r=``;try{for(;;){if(t.aborted)throw new DOMException(`aborted`,`AbortError`);let{done:e,value:i}=await n.read();if(e){let e=r.trim();e&&(yield e);return}r+=i;let a;for(;(a=r.indexOf(`
|
|
8
8
|
|
|
9
9
|
`))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function qt(e){let t=``,n;for(let r of e.split(`
|
|
10
|
-
`))if(!(r===``||r.startsWith(`:`))){if(r.startsWith(`data:`)){let e=r.slice(5).replace(/^ /,``);t=t?`${t}\n${e}`:e;continue}r.startsWith(`id:`)&&(n=r.slice(3).trim())}if(t===`[DONE]`)return`done`;if(!t)return null;try{let e=JSON.parse(t);return Wt.trace(`chunk`,{type:e.type,eventId:n}),{chunk:e,eventId:n}}catch(e){return Wt.trace(`frame parse failed`,{err:e,payload:t.slice(0,200)}),null}}function Jt(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const Yt=e=>e&&Object.keys(e).length>0?e:void 0;function Xt(e,t){let n=Yt(e),r=Yt(t);if(!n&&!r)return;let i={};return n&&(i.user=n),r&&(i.page=r),Jt(JSON.stringify(i))}function Zt(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Qt(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function $t(e){return e.startsWith(`tool-`)?e.slice(5):e}const B={handshake:`/pai/handshake`,streamMessage:`/pai/stream-message`,streamResume:`/pai/stream-resume`,cancelStream:`/pai/cancel-stream`,listConversations:`/pai/list-conversations`,listMessages:`/pai/list-messages`,updateSettings:`/pai/update-settings`,markRead:`/pai/mark-read`,messageFeedback:`/pai/message-feedback`,requestOperator:`/pai/request-operator`,cancelRequestOperator:`/pai/cancel-request-operator`,bootstrap:`/pai/bootstrap`,content:`/pai/content`,submitForm:`/pai/submit-form`};function en(e){let t=e??{},n=t.controlMode;return{controlMode:n===`awaiting_operator`||n===`operator`?n:`ai-agent`,assignedOperatorInitials:typeof t.assignedOperatorInitials==`string`&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function tn(e){let t=e?.suggestions;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let{id:t,label:r,text:i}=e;typeof r!=`string`||!r||n.push({id:typeof t==`string`&&t?t:`s${n.length}`,label:r,text:typeof i==`string`&&i?i:r})}return n}function nn(e){let t=e.messages.map(e=>({id:e.serverMessageId??e.id,parts:on(e),role:e.role,createdAt:e.createdAt===void 0?void 0:new Date(e.createdAt).toISOString()})),n={messages:t,conversationId:e.conversationId,trigger:e.trigger??`submit-message`,responseType:`ack`},r=t.at(-1)?.id;r&&(n.messageId=r),e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let i=e.tools?.map(an).filter(e=>e!==null);return i?.length&&(n.data={tools:i}),n}function rn(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function an(e){return typeof e==`string`?e?{code:e}:null:e?.code?e:null}function on(e){let t=[];for(let n of e.parts)if(n.kind===`step-start`&&t.push({type:`step-start`}),n.kind===`reasoning`&&n.text&&t.push({type:`reasoning`,text:n.text,state:n.done?`done`:`streaming`}),n.kind===`text`&&n.text&&t.push({text:n.text,type:`text`}),n.kind===`file`&&n.url&&t.push({mediaType:n.mediaType,type:`file`,url:n.url}),n.kind===`tool`&&rn(n)){let e={type:Qt(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(e.input=n.input),n.output!==void 0&&(e.output=n.output),n.error!==void 0&&(e.errorText=n.error),n.approval&&n.approval.approved!==void 0&&(e.approval=n.approval),t.push(e)}for(let n of e.attachments??[])n.url&&t.push({type:`file`,url:n.url,mediaType:n.mediaType,filename:n.name,fileId:n.id,fileSize:n.size});return t}const V=M.scope(`transport`),sn=new Set([408,425,429,500,502,503,504]);function H(e){return 400*2**e+Math.floor(Math.random()*250)}function cn(e){let t=e.get(`retry-after`);if(!t)return null;let n=Number(t),r=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(r)&&r>=0?Math.min(r,3e4):null}var ln=class{constructor(e){this.ttlMs=e,z(this,`map`,new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&Date.now()-n.at<this.ttlMs)return n.result;let r={at:Date.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.delete(e),t})};return this.map.set(e,r),r.result}peek(e){let t=this.map.get(e);if(t?.value!==void 0&&Date.now()-t.at<this.ttlMs)return t.value}clear(){this.map.clear()}},un=class{constructor(e){this.opts=e,z(this,`visitorId`,void 0),z(this,`conversationId`,void 0),z(this,`userContext`,void 0),z(this,`pageContext`,void 0),z(this,`locale`,void 0),z(this,`conversationsCache`,new ln(1e4)),z(this,`loadConversationInflight`,new Map),z(this,`contentCache`,new ln(6e4))}setContext(e,t){this.userContext=e,this.pageContext=t}setLocale(e){this.locale=e}primeIdentity(e,t){e&&(this.visitorId=e),t&&(this.conversationId=t)}envelope(){let e={_ev:Bt};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=Xt(this.userContext,this.pageContext);return t&&(e.context=t),e}withEnvelope(e){return{...this.envelope(),...e}}appendEnvelope(e){for(let[t,n]of Object.entries(this.envelope()))e.append(t,n);return e}withEnvelopeQuery(e){let t=new URL(this.url(e));for(let[e,n]of Object.entries(this.envelope()))t.searchParams.has(e)||t.searchParams.set(e,n);return t.toString()}async handshake(e){V.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale});let t=await this.postJson(B.handshake,e,`handshake`);return V.debug(`handshake ←`,{visitorId:t.visitorId,conversationId:t.conversationId,hasWelcome:!!t.welcome,hasConfig:!!t.config,rebind:t.rebind}),fn(t)||V.warn(`handshake response did not match expected shape; using raw response`,{response:t}),this.visitorId=t.visitorId??e.visitorId,this.conversationId=t.conversationId,t}async uploadFile(e){V.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let t=new FormData;t.append(`file`,e,e.name);let n=await this.postForm(this.uploadPath,t,`upload`);return V.debug(`uploadFile ←`,{id:n.id,url:n.url}),n}async transcribe(e,t=`audio/webm`){V.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${dn(t)}`),n.append(`mimeType`,t);let r=await this.postForm(this.transcribePath,n,`transcribe`);return V.debug(`transcribe ←`,{textLen:r.text.length}),r}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={}){return this.conversationsCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchConversations(e))}async fetchConversations(e){let t=new URL(this.url(B.listConversations));e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.cursor&&t.searchParams.set(`cursor`,e.cursor),V.debug(`listConversations →`,{visitorId:e.visitorId??this.visitorId,limit:e.limit,cursor:e.cursor});let n=await this.getJson(t.toString(),`listConversations`),r=n.conversations??[];return V.debug(`listConversations ←`,{count:r.length,nextCursor:n.nextCursor}),{conversations:r,nextCursor:n.nextCursor}}async loadConversation(e){let t=this.loadConversationInflight.get(e);if(t)return t;let n=this.loadConversationDirect(e).finally(()=>this.loadConversationInflight.delete(e));return this.loadConversationInflight.set(e,n),n}async loadConversationDirect(e){let t=new URL(this.url(B.listMessages));t.searchParams.set(`conversationId`,e),V.debug(`loadConversation →`,{conversationId:e,visitorId:this.visitorId});let n=await this.getJson(t.toString(),`loadConversation`),r=n.messages??[];return V.debug(`loadConversation ←`,{conversationId:n.conversationId,canContinue:n.canContinue,messageCount:r.length,hasSuggestions:!!n.suggestions}),{...n,messages:r,canContinue:n.canContinue??!0}}async markRead(e){if(!(!this.visitorId||!e)){this.conversationsCache.clear(),V.debug(`markRead →`,{conversationId:e,visitorId:this.visitorId});try{await this.postJson(B.markRead,{conversationId:e},`markRead`)}catch(e){V.debug(`markRead failed (non-fatal)`,{err:e})}}}async requestOperator(){if(!(!this.visitorId||!this.conversationId)){V.debug(`requestOperator →`,{conversationId:this.conversationId,visitorId:this.visitorId});try{return(await this.postJson(B.requestOperator,{},`requestOperator`)).controlState}catch(e){V.debug(`requestOperator failed (non-fatal)`,{err:e});return}}}async cancelRequestOperator(){if(!(!this.visitorId||!this.conversationId)){V.debug(`cancelRequestOperator →`,{conversationId:this.conversationId,visitorId:this.visitorId});try{return(await this.postJson(B.cancelRequestOperator,{},`cancelRequestOperator`)).controlState}catch(e){V.debug(`cancelRequestOperator failed (non-fatal)`,{err:e});return}}}listContent(e={}){return this.contentCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchContent(e))}async fetchContent(e){let t=new URL(this.dataUrl(B.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));V.debug(`listContent →`,e);let n=await this.getJson(t.toString(),`listContent`),r=(n.items??[]).map(e=>k(e,this.locale));return V.debug(`listContent ←`,{count:r.length,total:n.pagination?.total}),{...n,items:r}}async bootstrap(e){let t=new URL(this.dataUrl(B.bootstrap));e&&t.searchParams.set(`conversationId`,e),V.debug(`bootstrap →`,{conversationId:e??this.conversationId});let n=await this.getJson(t.toString(),`bootstrap`),r=n.forms??[],i=n.formSubmissions??[];return V.debug(`bootstrap ←`,{forms:r.length,formSubmissions:i.length}),{forms:r,formSubmissions:i}}async saveUserPrefs(e){V.debug(`saveUserPrefs →`,{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(e)});let t=await this.postJson(B.updateSettings,{userPrefs:e},`saveUserPrefs`);return V.debug(`saveUserPrefs ←`,{success:t.success}),t}get uploadPath(){return this.opts.endpoints?.upload??`/pai/upload-file`}get transcribePath(){return this.opts.endpoints?.transcribe??`/pai/transcribe-audio`}get submitFormPath(){return this.opts.endpoints?.submitForm??B.submitForm}async submitForm(e){V.debug(`submitForm →`,{formId:e.formId,trigger:e.trigger,fields:Object.keys(e.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),e,`submitForm`)}catch(e){V.debug(`submitForm failed (non-fatal)`,{err:e})}}async submitFeedback(e){V.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(B.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){V.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e){this.conversationsCache.clear(),V.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageId:e.messageId,messageCount:e.messages.length,trigger:e.trigger,tools:e.data?.tools?.map(e=>e.code)});let t=await this.fetchImpl(this.url(B.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(e))});return{status:`accepted`,conversationId:(await this.assertOk(t,`sendTurn`)).conversationId??e.conversationId}}cancelTurn(e){!this.visitorId||!e||(V.debug(`cancel stream`,{conversationId:e,visitorId:this.visitorId}),this.fetchImpl(this.url(B.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(e=>V.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t;try{t=await this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,headers:{accept:`text/event-stream`,...this.opts.auth.headers()},signal:e.signal})}catch(t){return e.signal.aborted||V.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!t.ok||!t.body)return V.debug(`resume-stream → endpoint unavailable`,{status:t.status}),`unavailable`;if(!(t.headers.get(`content-type`)??``).includes(`text/event-stream`))return V.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;e.onConnected();try{for await(let{chunk:n}of Gt(t,e.signal)){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;V.debug(`resume-stream segment dropped — reconnecting`,{err:t})}return`held`}resumeUrl(){return this.withEnvelopeQuery(B.streamResume)}async postJson(e,t,n){let r=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(t))}],n);return this.assertOk(r,n)}async postForm(e,t,n){let r=await this.fetchImpl(this.url(e),{method:`POST`,credentials:`omit`,headers:this.opts.auth.headers(),body:this.appendEnvelope(t)});return this.assertOk(r,n)}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.opts.auth.headers()}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let[r,i]=e(),a;try{a=await this.fetchImpl(r,i)}catch(e){if(n>=3)throw new Ut(`${t} failed: network error`,`network`,void 0,e);V.debug(`request network error — retrying`,{label:t,attempt:n}),await zt(H(n));continue}if(a.ok||!sn.has(a.status)||n>=3)return a;let o=cn(a.headers)??H(n);V.debug(`request retryable status — retrying`,{label:t,status:a.status,attempt:n,wait:o}),await zt(o)}}async assertOk(e,t){if(!e.ok)throw new Ut(`${t} failed: ${e.status}`,`server`,e.status);return await e.json()}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return/^https?:\/\//i.test(e)?e:`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function dn(e){return e.includes(`webm`)?`webm`:e.includes(`ogg`)?`ogg`:e.includes(`mp4`)||e.includes(`m4a`)?`m4a`:e.includes(`mpeg`)?`mp3`:e.includes(`wav`)?`wav`:`bin`}function fn(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.visitorId==`string`&&typeof t.conversationId==`string`}function pn(e,t){let n=e?[{kind:`text`,id:`t0`,textSig:d(e),doneSig:d(!0)}]:[];return{id:ut(),role:`user`,createdAt:Date.now(),status:`complete`,attachments:t,partsSig:d(n)}}function mn(){return{id:ut(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:d([])}}function hn(e){let t=ut();return gn({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function gn(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,feedback:e.feedback,partsSig:d(e.parts.map(In))}}const _n=new Set([`completed`,`failed`,`canceled`]);function vn(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status!=null&&!_n.has(e.status)?`streaming`:`complete`}function yn(e){let t=new Set,n=e.parts.map((t,n)=>t.type===`text`?{kind:`text`,id:`${e.id}-t${n}`,textSig:d(t.text),doneSig:d(!0)}:t.type===`reasoning`?{kind:`reasoning`,id:`${e.id}-r${n}`,textSig:d(t.text),doneSig:d(t.state!==`streaming`)}:t.type===`step-start`?{kind:`step-start`,id:`${e.id}-ss${n}`}:t.type===`file`?{kind:`file`,url:t.url,mediaType:t.mediaType}:t.type===`source-url`?{kind:`source`,sourceId:t.sourceId,url:t.url,title:t.title}:t.type===`source-document`?{kind:`source`,sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType}:t.type===`data-suggestions`?null:t.type.startsWith(`tool-`)?{kind:`tool`,toolCallId:t.toolCallId,toolName:$t(t.type),inputPartialSig:d(``),inputSig:d(t.input),outputSig:d(t.output),errorSig:d(t.errorText),stateSig:d(t.state),approvalSig:d(t.approval)}:null).filter(e=>e!==null).filter(e=>e.kind===`source`?t.has(e.sourceId)?!1:(t.add(e.sourceId),!0):!0),r=e.parts.find(e=>e.type===`data-suggestions`);return{id:e.id,role:e.role,operatorInitials:e.operatorInitials,suggestions:r?.type===`data-suggestions`?tn(r.data):void 0,serverMessageId:e.id,createdAt:Zt(e.createdAt)??Date.now(),status:vn(e),canceled:e.status===`canceled`,feedback:e.feedback??null,partsSig:d(n)}}function bn(e){return!e.parts.some(e=>e.type===`text`&&e.text.trim()!==``||e.type.startsWith(`tool-`)||e.type===`file`||e.type===`source-url`||e.type===`source-document`)}function xn(e){return e.role===`assistant`&&e.status!=null&&!_n.has(e.status)&&bn(e)}function Sn(e){let t=e.length-1;return e.filter((e,n)=>n===t||!xn(e)).map(yn)}function Cn(e,t){return(!t&&e.at(-1)?.role===`assistant`?e.slice(0,-1):e).filter(e=>!e.ephemeral)}function wn(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,parts:e.partsSig.value.map(Ln)}}function Tn(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function En(e){return Tn(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Dn(e){return Tn(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function On(e){return e.status!==`streaming`&&En(e)}function kn(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function An(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value,n=t.filter(e=>e.kind===`tool`);if(n.length===0||!n.every(e=>kn(e.stateSig.value)))return!1;let r=t.findLastIndex(e=>e.kind===`tool`);return!t.slice(r+1).some(e=>e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`||e.kind===`source`)}function jn(e,t){let n=t.filter(e=>!e.ephemeral&&(e.status===`streaming`||En(e))),r=new Map(n.filter(e=>e.serverMessageId!==void 0).map(e=>[e.serverMessageId,e])),i=new Set,a=e.map(e=>{let t=e.serverMessageId===void 0?void 0:r.get(e.serverMessageId);return t===void 0||(i.add(e.serverMessageId),t.role!==e.role)?e:t.status===`streaming`||Tn(t).length>=Tn(e).length?t:(e.id=t.id,e)}),o=n.filter(e=>e.serverMessageId===void 0||!i.has(e.serverMessageId));return[...a,...o]}function Mn(e,t){let n=new Map(t.filter(e=>e.serverMessageId!==void 0).map(e=>[e.serverMessageId,e])),r=new Set(e.flatMap(e=>[e.serverMessageId,e.id].filter(e=>e!==void 0))),i=!1,a=e.map(e=>{if(e.serverMessageId===void 0)return e;let t=n.get(e.serverMessageId);return t!==void 0&&t.role===e.role&&Tn(t).length>Tn(e).length?(i=!0,t.id=e.id,t):e}),o=[...n.values()].filter(e=>!r.has(e.serverMessageId));return{messages:i||o.length?[...a,...o]:e,changed:i||o.length>0}}function Nn(e){return e.role===`assistant`&&e.status!==`streaming`&&!En(e)}function Pn(e){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Dn(e)}function Fn(e,t){return e.operatorRoutedTurn?Nn(e)?`drop`:`complete-operator-routed`:t||Nn(e)?`error`:`complete`}function In(e){return e.kind===`text`||e.kind===`reasoning`?{kind:e.kind,id:e.id,textSig:d(e.text),doneSig:d(e.done)}:e.kind===`tool`?{kind:`tool`,toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:d(e.inputPartial),inputSig:d(e.input),outputSig:d(e.output),errorSig:d(e.error),stateSig:d(e.state),approvalSig:d(e.approval)}:e}function Ln(e){return e.kind===`text`||e.kind===`reasoning`?{kind:e.kind,id:e.id,text:e.textSig.value,done:e.doneSig.value}:e.kind===`tool`?{kind:`tool`,toolCallId:e.toolCallId,toolName:e.toolName,inputPartial:e.inputPartialSig.value,input:e.inputSig.value,output:e.outputSig.value,error:e.errorSig.value,state:e.stateSig.value,approval:e.approvalSig.value}:e}const Rn=M.scope(`feedback:audio`);var zn=class{constructor(){z(this,`ctx`,null),z(this,`master`,null),z(this,`buffers`,new Map)}unlock(){if(this.ctx){this.ctx.state===`suspended`&&this.ctx.resume();return}let e=globalThis.AudioContext??globalThis.webkitAudioContext;if(e)try{this.ctx=new e,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(e){Rn.warn(`AudioContext init failed`,{err:e})}}setVolume(e){if(!this.master||!this.ctx)return;let t=Math.max(0,Math.min(1,e));this.master.gain.setTargetAtTime(t,this.ctx.currentTime,.01)}playTone(e){let t=this.ctx,n=this.master;if(!t||!n||t.state!==`running`)return;let r=t.currentTime,i=e.noteMs/1e3;e.notes.forEach((a,o)=>{let s=t.createOscillator();s.type=e.type,s.frequency.value=a;let c=t.createGain(),l=r+o*i;c.gain.setValueAtTime(1e-4,l),c.gain.exponentialRampToValueAtTime(e.peakGain,l+.005),c.gain.exponentialRampToValueAtTime(1e-4,l+i),s.connect(c).connect(n),s.start(l),s.stop(l+i+.01)})}async playUrl(e){let t=this.ctx,n=this.master;if(!t||!n||t.state!==`running`)return;let r=await this.getBuffer(e);if(!r)return;let i=t.createBufferSource();i.buffer=r,i.connect(n),i.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>void 0),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(e){if(!this.ctx)return null;let t=this.buffers.get(e);if(t)return t instanceof Promise,t;let n=this.ctx,r=fetch(e).then(e=>e.ok?e.arrayBuffer():Promise.reject(Error(`fetch ${e.status}`))).then(e=>n.decodeAudioData(e)).then(t=>(this.buffers.set(e,t),t)).catch(t=>(Rn.warn(`audio fetch/decode failed`,{url:e,err:t}),this.buffers.delete(e),null));return this.buffers.set(e,r),r}};const Bn={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Vn={messageReceived:{notes:[880,1318.51],noteMs:90,type:`sine`,peakGain:.45},messageSent:{notes:[1568],noteMs:60,type:`sine`,peakGain:.25},error:{notes:[523.25,392],noteMs:120,type:`triangle`,peakGain:.55},voiceStart:{notes:[1318.51],noteMs:50,type:`sine`,peakGain:.3},voiceStop:{notes:[880],noteMs:50,type:`sine`,peakGain:.3}};let Hn=null,Un=0;function Wn(){return typeof navigator<`u`&&typeof navigator.vibrate==`function`}function Gn(){if(typeof document>`u`)return null;let e=document.createElement(`input`);e.type=`checkbox`,e.setAttribute(`switch`,``),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.id=`__${y.cssPrefix}_haptic_${Math.random().toString(36).slice(2)}`;let t=document.createElement(`label`);t.htmlFor=e.id,t.setAttribute(`aria-hidden`,`true`);let n=`position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;opacity:0!important;pointer-events:none!important;`;return e.style.cssText=n,t.style.cssText=n,document.body.append(e,t),{input:e,label:t}}function Kn(e){if(!(e===0||Array.isArray(e)&&e.every(e=>e===0))){if(Wn())try{navigator.vibrate(e);return}catch{}if(Hn||(Hn=Gn()),Hn)try{Hn.label.click()}catch{}}}function qn(){Un++;let e=!1;return()=>{e||(e=!0,Un=Math.max(0,Un-1),Un===0&&Hn&&(Hn.input.remove(),Hn.label.remove(),Hn=null))}}const Jn=M.scope(`feedback`);var Yn=class{constructor(e,t){z(this,`mutedSig`,d(!1)),z(this,`audio`,new zn),z(this,`releaseHaptics`,void 0),z(this,`sound`,void 0),z(this,`haptics`,void 0),z(this,`lastPlayed`,new Map),z(this,`reducedMotionMq`,null),this.sound=e,this.haptics=t,this.releaseHaptics=qn(),this.audio.setVolume(this.effectiveVolume()),typeof matchMedia<`u`&&(this.reducedMotionMq=matchMedia(`(prefers-reduced-motion: reduce)`))}unlock(){this.audio.unlock(),this.audio.setVolume(this.effectiveVolume())}update(e,t){this.sound=e,this.haptics=t,this.audio.setVolume(this.effectiveVolume())}setMuted(e){this.mutedSig.value!==e&&(this.mutedSig.value=e)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(e){this.mutedSig.value||this.isDeduped(e)||(this.lastPlayed.set(e,performance.now()),this.sound.enabled&&this.playSound(e),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(e))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(e){let t=this.lastPlayed.get(e);return t!==void 0&&performance.now()-t<100}playSound(e){let t=this.sound.events?.[e];if(t===!1)return;if(typeof t==`string`){this.audio.playUrl(t).catch(e=>Jn.warn(`audio play failed`,{err:e,url:t}));return}let n=Vn[e];n&&this.audio.playTone(n)}playHaptic(e){if(this.reducedMotionMq?.matches)return;let t=this.haptics.events?.[e];t!==!1&&Kn(t===!0||t===void 0?Bn[e]:t)}effectiveVolume(){let e=this.sound.volume??.3;return this.reducedMotionMq?.matches?e*.5:e}isTouchDevice(){return typeof window>`u`?!1:matchMedia(`(hover: none) and (pointer: coarse)`).matches}};const U={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},Xn=`${y.cssPrefix}-icon-dir`,Zn=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})}),Qn=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M18 6 6 18M6 6l12 12`})}),$n=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M12 5v14M5 12h14`})}),er=()=>g(`svg`,{...U,class:Xn,"aria-hidden":`true`,children:[h(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),h(`path`,{d:`M22 2 11 13`})]}),tr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M12 19V5M5 12l7-7 7 7`})}),nr=()=>h(`svg`,{...U,class:Xn,"aria-hidden":`true`,children:h(`path`,{d:`M3 20V4l18 8-18 8Z`})}),rr=()=>h(`svg`,{...U,class:Xn,"aria-hidden":`true`,children:h(`path`,{d:`m9 18 6-6-6-6`})}),ir=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})}),ar=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78`})}),or=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),h(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]}),sr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})}),cr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})}),lr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})}),ur=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})}),dr=()=>h(`svg`,{...U,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:h(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})}),fr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),h(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),h(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]}),pr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})}),mr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})}),hr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),h(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]}),gr=()=>h(`svg`,{...U,class:Xn,"aria-hidden":`true`,children:h(`path`,{d:`m5 6 6 6-6 6M13 6l6 6-6 6`})}),_r=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M20 6 9 17l-5-5`})}),vr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M3 3v6h6`}),h(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),h(`path`,{d:`M12 7v5l3 2`})]}),yr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`10`}),h(`path`,{d:`M2 12h20`}),h(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]}),br=()=>h(`svg`,{...U,class:Xn,"aria-hidden":`true`,children:h(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})}),xr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M12 20h9`}),h(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),Sr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`m6 9 6 6 6-6`})}),Cr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),h(`path`,{d:`M14 2v6h6`})]}),wr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),h(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]}),Tr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})}),Er=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`10`}),h(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),h(`path`,{d:`M12 17h.01`})]}),Dr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`m15 4 3 3-9 9-3-3z`}),h(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]}),Or=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),h(`path`,{d:`M12 8V4`}),h(`circle`,{cx:`12`,cy:`3`,r:`1`}),h(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]}),kr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),h(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),h(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),h(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]}),Ar=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`10`}),h(`circle`,{cx:`12`,cy:`12`,r:`4`}),h(`path`,{d:`m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24`})]}),jr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`11`,cy:`11`,r:`7`}),h(`path`,{d:`m21 21-4.3-4.3`})]}),Mr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]}),Nr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M3 9.5 12 3l9 6.5`}),h(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]}),Pr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`m3 11 15-5v12L3 13z`}),h(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),h(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),h(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]}),Fr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),h(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]}),Ir=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`4`}),h(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41`})]}),Lr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})}),Rr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`M12 3v18`}),h(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]}),zr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),h(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),h(`path`,{d:`m20 20-4.4-4.4`})]}),Br=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z`}),h(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]}),Vr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M4 18h16`}),h(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),h(`path`,{d:`M12 8V6`}),h(`path`,{d:`M10 6h4`})]}),Hr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),h(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),h(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),h(`path`,{d:`M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11`})]}),Ur=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),h(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]}),Wr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),h(`path`,{d:`M7 10l4-7a2.5 2.5 0 0 1 2.5 2.5V8h5a2 2 0 0 1 2 2.3l-1.2 8A2 2 0 0 1 17.3 20H7`})]}),Gr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),h(`path`,{d:`M17 14l-4 7a2.5 2.5 0 0 1-2.5-2.5V16h-5a2 2 0 0 1-2-2.3l1.2-8A2 2 0 0 1 6.7 4H17`})]}),Kr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),h(`path`,{d:`M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9l-2.1 2.1M7 17l-2.1 2.1`})]}),qr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`M12 7v5l3 2`})]}),Jr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]}),Yr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`m15 9-6 6M9 9l6 6`})]}),Xr={chat:Zn,message:Tr,bubbles:Fr,spark:wr,wand:Dr,bot:Or,help:Er,lifebuoy:Ar,headset:kr,search:zr,sparkles:Br,concierge:Vr,wave:Hr},W=y.cssPrefix,G={launcher:`${W}-launcher`,callout:`${W}-callout`,calloutDismiss:`${W}-callout-dismiss`,panel:`${W}-panel`,panelHeader:`${W}-panel-header`,resizeGrip:`${W}-resize-grip`,scrollToBottom:`${W}-scroll-to-bottom`,actionHistory:`${W}-action-history`,actionClose:`${W}-action-close`,langSegment:`${W}-lang-segment`,composer:`${W}-composer`,composerInput:`${W}-composer-input`,composerSend:`${W}-composer-send`,composerStop:`${W}-composer-stop`,composerAttach:`${W}-composer-attach`,composerFileInput:`${W}-composer-file-input`,composerVoice:`${W}-composer-voice`,attachmentChip:`${W}-attachment-chip`,attachmentRemove:`${W}-attachment-remove`,suggestion:`${W}-suggestion`,messageBubble:`${W}-message`,messageRetry:`${W}-message-retry`,messageFeedback:`${W}-message-feedback`,feedbackUp:`${W}-feedback-up`,feedbackDown:`${W}-feedback-down`,messageCopy:`${W}-message-copy`,historyPane:`${W}-history-pane`,historyBack:`${W}-history-back`,historyItem:`${W}-history-item`,sidebar:`${W}-sidebar`,sidebarToggle:`${W}-sidebar-toggle`,sidebarNewConversation:`${W}-sidebar-new-conversation`,sidebarItem:`${W}-sidebar-item`,messengerHome:`${W}-messenger-home`,modulesEmpty:`${W}-modules-empty`,tab:`${W}-tab`,tabBadge:`${W}-tab-badge`,homeView:`${W}-home-view`,homeGreeting:`${W}-home-greeting`,homeBrand:`${W}-home-brand`,backHeader:`${W}-back-header`,contentView:`${W}-content-view`,contentScroll:`${W}-content-scroll`,homeSearch:`${W}-home-search`,helpSearch:`${W}-help-search`,homeRecent:`${W}-home-recent`,homeContentRow:`${W}-home-content-row`,helpArticle:`${W}-help-article`,newsItem:`${W}-news-item`,formGate:`${W}-form-gate`,formDone:`${W}-form-done`,formDoneToggle:`${W}-form-done-toggle`,formAnswers:`${W}-form-answers`,formFill:`${W}-form-fill`,formSubmit:`${W}-form-submit`,formSkip:`${W}-form-skip`,formField:`${W}-form-field`,toolAskQuestions:`${W}-tool-ask-questions`,toolInputSubmit:`${W}-tool-input-submit`,toolInputSkip:`${W}-tool-input-skip`,toolApproval:`${W}-tool-approval`,toolApprove:`${W}-tool-approve`,toolReject:`${W}-tool-reject`,toolEdit:`${W}-tool-edit`,toolDecision:`${W}-tool-decision`,toolAskSummary:`${W}-ask-questions-summary`,toolAskOptions:`${W}-ask-questions-options-toggle`,toolCall:`${W}-tool-call`,source:`${W}-source`,operatorRequest:`${W}-operator-request`,operatorBanner:`${W}-operator-banner`,operatorCancelRequest:`${W}-operator-cancel-request`};function Zr(e,t){return`${e}-${t}`}const Qr=y.cssPrefix;function $r({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!==`circle`&&!!t.label;return g(`button`,{type:`button`,class:`${Qr}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?`true`:void 0,"data-leaving":r?`true`:void 0,"data-testid":G.launcher,onClick:e,"aria-label":n.launcherOpen,children:[ei(t.icon),a?h(`span`,{class:`${Qr}-fab-label`,children:E(n,t.label??``)}):null]})}function ei(e){let t=Xr[e];return t?h(t,{}):h(ti,{source:e})}function ti({source:e}){return h(`span`,{ref:t=>{t&&ni(t,e)},"aria-hidden":`true`})}function ni(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n&&n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function ri({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:a}){let[o,s]=c(!1);return i(()=>{let t=setTimeout(()=>s(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),i(()=>{if(!o||e.autoDismissMs<=0)return;let t=setTimeout(a,e.autoDismissMs);return()=>clearTimeout(t)},[o,e.autoDismissMs,a]),o?g(`div`,{class:`${Qr}-callout`,role:`status`,"data-shape":e.shape,"data-position":ii(e.position,t),"data-animated":e.animated?`true`:void 0,"data-testid":G.callout,children:[h(`span`,{children:E(n,e.text)}),h(`button`,{type:`button`,class:`${Qr}-callout-close`,onClick:a,"aria-label":r,title:r,"data-testid":G.calloutDismiss,children:h(Qn,{})})]}):null}function ii(e,t){let n=t.endsWith(`-right`),r=t.startsWith(`bottom-`);return e===`vertical`?r?`top`:`bottom`:n?`left`:`right`}function ai({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:a,strings:o}){let c=y.cssPrefix,l=s(null);if(i(()=>{if(!e)return;let n=e.style;t.minWidth&&n.setProperty(`--${c}-resize-min-w`,t.minWidth),t.maxWidth&&n.setProperty(`--${c}-resize-max-w`,t.maxWidth),t.minHeight&&n.setProperty(`--${c}-resize-min-h`,t.minHeight),t.maxHeight&&n.setProperty(`--${c}-resize-max-h`,t.maxHeight),r&&(n.setProperty(`--${c}-widget-w`,`${r.width}px`),n.setProperty(`--${c}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,c,r]),!e)return null;let u=n.startsWith(`top-`),d=n.endsWith(`-right`),f=`${c}-resize-grip ${c}-resize-grip--${u?`bottom`:`top`}-${d?`left`:`right`}`,p=t=>{if(!e)return;let n=t.currentTarget,r=e.getBoundingClientRect();l.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:r.width,startH:r.height,dirX:d?-1:1,dirY:u?1:-1},n.setPointerCapture(t.pointerId),e.setAttribute(`data-resizing`,``),t.preventDefault()},m=t=>{let n=l.current;if(!n||t.pointerId!==n.pointerId||!e)return;let r=(t.clientX-n.startX)*n.dirX,i=(t.clientY-n.startY)*n.dirY;e.style.setProperty(`--${c}-widget-w`,`${n.startW+r}px`),e.style.setProperty(`--${c}-widget-h`,`${n.startH+i}px`)},g=t=>{let n=l.current;if(!n||t.pointerId!==n.pointerId||!e)return;t.currentTarget.releasePointerCapture(t.pointerId),e.removeAttribute(`data-resizing`);let r=e.getBoundingClientRect();a({width:Math.round(r.width),height:Math.round(r.height)}),l.current=null};return h(`div`,{class:f,role:`separator`,"aria-orientation":`vertical`,"aria-label":o.resizeHandle,title:o.resizeHandle,onPointerDown:p,onPointerMove:m,onPointerUp:g,onPointerCancel:g,"data-testid":G.resizeGrip,children:h(dr,{})})}const oi=y.cssPrefix,si=`.${oi}-header, .${oi}-back-header, .${oi}-home-hero`;function ci(e,t){i(()=>{if(!t||!e)return;let n=e=>Number.parseFloat(e)||0,r=(e,t)=>Math.min(t,Math.max(-t,e)),i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(si)||r.closest(`button, a, input, textarea, select, [role="tab"], [contenteditable]`))return;let a=e.getBoundingClientRect();i={id:t.pointerId,x:t.clientX,y:t.clientY,dx:n(e.style.getPropertyValue(`--${oi}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${oi}-modal-dy`)),maxX:(window.innerWidth+a.width)/2-56,maxY:(window.innerHeight+a.height)/2-56},e.dataset.dragging=`true`,t.preventDefault()},o=t=>{if(!i||t.pointerId!==i.id)return;let n=r(i.dx+t.clientX-i.x,i.maxX),a=r(i.dy+t.clientY-i.y,i.maxY);e.style.setProperty(`--${oi}-modal-dx`,`${n}px`),e.style.setProperty(`--${oi}-modal-dy`,`${a}px`)},s=t=>{!i||t.pointerId!==i.id||(i=null,delete e.dataset.dragging)};return e.addEventListener(`pointerdown`,a),window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e,t])}function li(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function ui(e,t,n){return li(`close`,e,t)?n.includes(`close`):!1}function di(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function fi(e){let t=t=>{if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])`)].filter(e=>e.offsetParent!==null||e===document.activeElement);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1];if(!r||!i)return;let a=e.getRootNode().activeElement;t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}function pi(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const mi=y.cssPrefix;function hi({agent:e,strings:t}){let n=e.status??`online`,r=E(t,e.name),i=e.title?E(t,e.title):null;return g(`div`,{class:`${mi}-agent`,children:[h(`div`,{class:`${mi}-agent-avatar`,"data-status":n,children:e.avatar?h(`img`,{src:e.avatar,alt:``}):h(`span`,{children:pi(r)})}),g(`div`,{class:`${mi}-agent-meta`,children:[h(`strong`,{children:r}),i?h(`span`,{children:i}):null]})]})}const gi=M.scope(`attachments`);function _i(e,t,n){let r=bi(e),i=[],a=[],o=Ci(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=yi(e,c,s,n,o);if(t){a.push({file:e,reason:t});continue}i.push(Si(e)),s+=e.size,c+=1}return(i.length||a.length)&&gi.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function vi(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){gi.debug(`revokeObjectURL failed`,{error:e})}}function yi(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:wi(e,i)?null:`mime`}function bi(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:xi(e)).filter(e=>e!==null):[]}function xi(e){let t=e;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function Si(e){return{file:e,id:ut(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function Ci(e){return e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>{if(e.startsWith(`.`))return{kind:`ext`,ext:e};let[t=`*`,n=`*`]=e.split(`/`);return{kind:`mime`,type:t,subtype:n}})}function wi(e,t){if(t.length===0)return!0;let[n=`*`,r=`*`]=(e.type||``).toLowerCase().split(`/`),i=(e.name||``).toLowerCase();return t.some(e=>e.kind===`ext`?i.endsWith(e.ext):(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const Ti=y.cssPrefix;function Ei({attachment:e,onRemove:t}){let n=e.mediaType.startsWith(`image/`);return g(`span`,{class:`${Ti}-attachment-chip`,title:e.name,"data-testid":Zr(G.attachmentChip,e.id),children:[n?h(`img`,{class:`${Ti}-attachment-thumb`,src:e.previewUrl,alt:``}):h(`span`,{class:`${Ti}-attachment-thumb`,"aria-hidden":`true`,children:h(Cr,{})}),h(`span`,{class:`${Ti}-attachment-name`,children:e.name}),h(`button`,{type:`button`,class:`${Ti}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":Zr(G.attachmentRemove,e.id),children:h(Qn,{})})]})}const Di={isSupported:!1,start:()=>void 0,stop:()=>void 0};function Oi(e,t,n){return e===`disabled`?Di:e===`server`?Mi(n):ki(t)}function ki(e){let t=Ai();if(!t)return Di;let n=null;return{isSupported:!0,start(r,i){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener(`result`,e=>{let t=e,n=``,i=!1;for(let e=t.resultIndex;e<t.results.length;e++){let r=t.results[e];r&&(n+=r[0].transcript,r.isFinal&&(i=!0))}r(n,i)});let a=()=>{n=null,i()};n.addEventListener(`end`,a),n.addEventListener(`error`,a),n.start()},stop(){n?.stop()}}}function Ai(){return window.SpeechRecognition??window.webkitSpeechRecognition}const ji=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Mi(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return Di;let t=null,n=null,r=[],i=()=>{for(let e of n?.getTracks()??[])e.stop();n=null};return{isSupported:!0,async start(a,o){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let s=Ni();t=new MediaRecorder(n,s?{mimeType:s}:void 0),r=[],t.addEventListener(`dataavailable`,e=>{e.data.size>0&&r.push(e.data)}),t.addEventListener(`stop`,async()=>{let n=t?.mimeType??`audio/webm`;i();let s=new Blob(r,{type:n});r=[];try{let{text:t}=await e(s,n);t&&a(t,!0)}catch{}finally{o()}}),t.start()}catch{i(),o()}},stop(){t?.stop()}}}function Ni(){for(let e of ji)if(MediaRecorder.isTypeSupported(e))return e}const K=y.cssPrefix,Pi=M.scope(`composer`);function Fi(e){return e.reduce((e,t)=>e+t.size,0)}const Ii={arrowUp:tr,paperPlane:er,send:nr,chevron:rr};function Li({options:e,transport:t,feedback:n,bus:r,isStreaming:a,operatorRequestEnabled:o,controlMode:l,onRequestOperator:u,onSend:d,onStop:f,attachApiRef:p}){let m=e.strings,[_,v]=c(``),[y,b]=c([]),[x,S]=c(!1),C=s(null),w=s(null),T=e.features.fileUpload,E=e.features.voice,[D,O]=c(()=>Oi(E,e.locale,(e,n)=>t.transcribe(e,n)));i(()=>{x||E===`disabled`||O(Oi(E,e.locale,(e,n)=>t.transcribe(e,n)))},[e.locale,E,t,x]),i(()=>{let e=C.current;if(!e)return;let t=e.getRootNode(),n=`activeElement`in t?t.activeElement:null;n&&e.closest(`.${K}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),i(()=>{let e=C.current;if(!e)return;if(_.length===0){e.style.height=``;return}e.style.height=`auto`;let t=parseFloat(getComputedStyle(e).fontSize)*.7,n=Math.min(e.scrollHeight,160);e.style.height=`${n<40+t?40:n}px`},[_]);let k=s(y);k.current=y,i(()=>()=>k.current.forEach(vi),[]),i(()=>{if(p)return p.current={attachFromDrop:t=>{let n=_i(t,k.current,e.attachments);n.accepted.length!==0&&(Pi.info(`attach (drop)`,{count:n.accepted.length,totalBytes:Fi(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:Fi(n.accepted)}),b(e=>[...e,...n.accepted]))},fill:e=>{v(e);let t=C.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))}},()=>{p.current&&(p.current=null)}},[p,e.attachments]),i(()=>{let t=C.current;if(!t)return;let n=t.closest(`.${K}-panel`);if(!n)return;let i=n=>{let i=n.clipboardData;if(!i)return;let a=n.target?.closest?.(`input, textarea, [contenteditable]:not([contenteditable='false'])`);if(a&&a!==t)return;if(T){let t=_i(i.items,k.current,e.attachments);if(t.accepted.length>0){n.preventDefault(),Pi.info(`attach (paste)`,{count:t.accepted.length,totalBytes:Fi(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:Fi(t.accepted)}),b(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),v(e=>e+o),t.focus())};return n.addEventListener(`paste`,i),()=>n.removeEventListener(`paste`,i)},[T,e.attachments,K]);let A=()=>{let e=_.trim();!e&&y.length===0||a||(d(e,y),v(``),b([]))},ee=e=>{e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),a?f():A())},te=t=>{let n=t.target,i=_i(n.files,y,e.attachments);i.accepted.length>0&&(Pi.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:Fi(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:Fi(i.accepted)}),b(e=>[...e,...i.accepted])),n.value=``},ne=e=>{Pi.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),b(t=>{let n=t.find(t=>t.id===e);return n&&vi(n),t.filter(t=>t.id!==e)})},j=s(null),re=()=>{if(D.isSupported){if(x){let e=j.current?Date.now()-j.current:0;Pi.info(`voiceStop`,{durationMs:e}),r.emit(`voiceStop`,{durationMs:e}),D.stop(),S(!1),n.play(`voiceStop`),j.current=null;return}j.current=Date.now(),Pi.info(`voiceStart`),r.emit(`voiceStart`,void 0),S(!0),n.play(`voiceStart`),D.start((e,t)=>v(n=>t?`${n}${e} `:n),()=>{if(S(!1),j.current){let e=Date.now()-j.current;Pi.debug(`voiceStop (auto)`,{durationMs:e}),r.emit(`voiceStop`,{durationMs:e}),j.current=null}})}},ie=Ii[e.composer.sendButton.icon];return g(`div`,{class:`${K}-composer`,"data-testid":G.composer,children:[y.length>0?h(`div`,{class:`${K}-attachments`,children:y.map(e=>h(Ei,{attachment:e,onRemove:()=>ne(e.id)},e.id))}):null,g(`div`,{class:`${K}-composer-row`,children:[g(`div`,{class:`${K}-composer-actions`,children:[T?h(`button`,{type:`button`,class:`${K}-icon-btn`,onClick:()=>w.current?.click(),"aria-label":m.attach,"data-testid":G.composerAttach,children:h(ar,{})}):null,D.isSupported?h(`button`,{type:`button`,class:`${K}-icon-btn`,onClick:re,"aria-label":x?m.micStop:m.micStart,"aria-pressed":x,"data-recording":x?`true`:void 0,"data-testid":G.composerVoice,children:h(or,{})}):null,o&&l===`ai-agent`&&u?h(`button`,{type:`button`,class:`${K}-icon-btn`,onClick:u,"aria-label":m.talkToOperator,title:m.talkToOperator,"data-testid":G.operatorRequest,children:h(kr,{})}):null]}),h(`textarea`,{ref:C,class:`${K}-textarea`,rows:1,value:_,placeholder:m.composerPlaceholder,onInput:e=>v(e.target.value),onKeyDown:ee,"aria-label":m.composerPlaceholder,"data-testid":G.composerInput}),a?h(`button`,{type:`button`,class:`${K}-send`,onClick:f,"aria-label":m.stop,"data-testid":G.composerStop,children:h(ir,{})}):h(`button`,{type:`button`,class:`${K}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:A,disabled:!_.trim()&&y.length===0,"aria-label":m.send,"data-testid":G.composerSend,children:h(ie,{})})]}),h(`input`,{ref:w,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:te,class:`${K}-sr-only`,"data-testid":G.composerFileInput})]})}const Ri=y.cssPrefix;function zi({visible:e,strings:t}){return e?h(`div`,{class:`${Ri}-dropzone`,role:`status`,"aria-live":`polite`,children:t.dropZone}):null}function Bi({containerRef:e,onDrop:t}){let[n,r]=c(!1);return i(()=>{let n=e.current;if(!n)return;let i=0,a=e=>{i+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),r(!0))},o=()=>{--i,!(i>0)&&(i=0,r(!1))},s=e=>{e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()},c=e=>{i=0,r(!1),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))};return n.addEventListener(`dragenter`,a),n.addEventListener(`dragleave`,o),n.addEventListener(`dragover`,s),n.addEventListener(`drop`,c),()=>{n.removeEventListener(`dragenter`,a),n.removeEventListener(`dragleave`,o),n.removeEventListener(`dragover`,s),n.removeEventListener(`drop`,c)}},[e,t]),{visible:n}}function Vi({itemCount:e,initialFocusIndex:t}){let[n,a]=c(!1),o=s(null),l=s(null),[u,d]=c(-1),f=r(()=>{a(!1),d(-1),o.current?.focus()},[]),p=r(()=>a(e=>!e),[]);return i(()=>{if(!n)return;let e=e=>{let t=l.current,n=o.current;if(!t||!n)return;let r=e.composedPath();r.includes(t)||r.includes(n)||(a(!1),d(-1))};return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),i(()=>{if(!n||e===0)return;let r=t?.()??0;d(r<0||r>=e?0:r)},[n,e,t]),i(()=>{!n||u<0||(l.current?.querySelectorAll(`[role='menuitem']`))?.[u]?.focus()},[n,u]),{open:n,focusIndex:u,triggerRef:o,menuRef:l,toggle:p,close:f,onTriggerKey:r(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a(!0))},[]),onMenuKey:r(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),f();return;case`ArrowDown`:t.preventDefault(),d(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),d(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),d(0);return;case`End`:t.preventDefault(),d(e-1)}},[e,f])}}function Hi({items:e,triggerLabel:t}){let n=y.cssPrefix,r=Vi({itemCount:e.length}),i=e=>{e.disabled||(e.onSelect?.(),e.keepOpen||r.close())},a=(e,t)=>e.onSelectValue?.(t),o=(e,t)=>{let n=t.segments;if(!n?.length)return;let r=Math.max(0,n.findIndex(e=>e.value===t.value)),i=-1;if(e.key===`ArrowRight`||e.key===`Enter`||e.key===` `)i=(r+1)%n.length;else if(e.key===`ArrowLeft`)i=(r-1+n.length)%n.length;else return;e.preventDefault(),e.stopPropagation(),a(t,n[i].value)};return g(`div`,{class:`${n}-menu-wrap`,children:[h(`button`,{ref:r.triggerRef,type:`button`,class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r.open,title:t,onClick:r.toggle,onKeyDown:r.onTriggerKey,children:h(fr,{})}),r.open?h(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?g(`div`,{role:`menuitem`,class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":e.label,tabIndex:-1,onKeyDown:t=>o(t,e),children:[e.icon?h(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,h(`span`,{class:`${n}-menu-label`,children:e.label}),h(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return h(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,class:`${n}-segment`,"data-on":r?`true`:void 0,lang:t.lang,title:t.value,tabIndex:-1,"data-testid":`${G.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):g(`button`,{type:`button`,role:`menuitem`,class:`${n}-menu-item`,"aria-pressed":e.type===`switch`?e.on:void 0,disabled:e.disabled,onClick:()=>i(e),children:[e.icon?h(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,h(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?h(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:h(_r,{})}):null]},e.id))}):null]})}const Ui=y.cssPrefix;function Wi(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const Gi={normal:`large`,large:`small`,small:`normal`};function Ki(e){return h(e===`light`?Ir:e===`dark`?Lr:Rr,{})}function qi(e){return(e.split(`-`)[0]??e).toUpperCase()}function Ji({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:o,onExpand:s,onFullscreen:c,onSoundToggle:l}=e,{onToggleHistory:u,onLocaleChange:d,onThemeChange:p,onTextSizeChange:m}=e,_=n.strings,v=n.mode,y=t===`chat`,b=f(()=>i.mutedSig.value).value,x=new Set(n.actions),S=e=>x.has(e),C=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches,w=e=>!C&&li(e,v,r),T=n.themeMode,E={auto:_.themeAuto,light:_.themeLight,dark:_.themeDark},D=n.textSize,O={small:_.textSizeSmall,normal:_.textSizeNormal,large:_.textSizeLarge},k=[];if(y&&S(`clear`)&&k.push({id:`clear`,icon:h(xr,{}),label:_.newConversation,onSelect:o}),S(`expand`)&&w(`expand`)){let e=r===`expanded`;k.push({id:`expand`,icon:h(e?cr:sr,{}),label:e?_.collapse:_.expand,type:`switch`,on:e,onSelect:s})}if(S(`fullscreen`)&&w(`fullscreen`)){let e=r===`fullscreen`;k.push({id:`fullscreen`,icon:h(e?ur:lr,{}),label:e?_.exitFullscreen:_.fullscreen,type:`switch`,on:e,onSelect:c})}y&&S(`sound`)&&k.push({id:`sound`,icon:h(b?mr:pr,{}),label:b?_.soundOff:_.soundOn,type:`switch`,on:!b,onSelect:l}),S(`theme`)&&k.push({id:`theme`,icon:Ki(T),label:`${_.theme}: ${E[T]}`,onSelect:()=>p(Wi(T)),keepOpen:!0}),S(`textSize`)&&k.push({id:`textSize`,icon:h(hr,{}),label:`${_.textSize}: ${O[D]}`,onSelect:()=>m(Gi[D]),keepOpen:!0}),S(`language`)&&n.availableLocales.length>1&&k.push({id:`language`,icon:h(yr,{}),label:_.language,segments:n.availableLocales.map(e=>({value:e,label:qi(e),lang:e})),value:n.locale,onSelectValue:d});let A=!!a&&ui(v,r,n.actions),ee=y&&S(`history`);return g(`div`,{class:`${Ui}-header-actions`,children:[ee?h(`button`,{type:`button`,class:`${Ui}-icon-btn`,onClick:u,"aria-label":_.history,title:_.history,"data-testid":G.actionHistory,children:h(vr,{})}):null,k.length>0?h(Hi,{items:k,triggerLabel:_.moreActions}):null,A?h(`button`,{type:`button`,class:`${Ui}-icon-btn`,onClick:a,"aria-label":_.close,title:_.close,"data-testid":G.actionClose,children:h(Qn,{})}):null]})}const Yi=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Xi=/^https?:\/\/[^\s.]+\.[^\s]+$/i,Zi=/^[+]?[\d\s().-]{6,}$/;function Qi(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}function $i(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function ea(e,t,n){let r=e.required??!0,i=e.validation;if(e.type===`multiselect`){let e=$i(t);return r&&e===0?n.formRequired:e===0?void 0:i?.minSelections!=null&&e<i.minSelections?Qi(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&e>i.maxSelections?Qi(n.formChooseAtMost,{max:i.maxSelections}):void 0}let a=typeof t==`string`?t.trim():``;if(!a)return r?n.formRequired:void 0;switch(e.type){case`email`:if(!Yi.test(a))return n.formInvalidEmail;break;case`url`:if(!Xi.test(a))return n.formInvalidUrl;break;case`tel`:if(!Zi.test(a))return n.formInvalidTel;break;case`number`:{let e=Number(a);if(!Number.isFinite(e))return n.formInvalidNumber;if(i?.min!=null&&e<i.min)return Qi(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&e>i.max)return Qi(n.formNumberTooLarge,{max:i.max});break}default:break}if(i?.minLength!=null&&a.length<i.minLength)return Qi(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return Qi(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function ta(e,t,n){let r={};for(let i of e){let e=ea(i,t[i.name],n);e&&(r[i.name]=e)}return r}function na(e){let t={};for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r.join(`, `):r;e&&e.trim()&&(t[n]=e.trim())}return t}const q=y.cssPrefix,ra=`__other__`;function ia({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:l,initialValues:u,hideActions:d,fieldTypeLabels:f,rootTestId:p,submitTestId:m,skipTestId:_}){let[v,y]=c(()=>({...ca(e),...u})),[b,x]=c({}),[S,C]=c({}),w=e=>{S[e]&&C(t=>({...t,[e]:``}))},T=(e,t)=>{y(n=>({...n,[e]:t})),w(e)},E=(e,t)=>{x(n=>({...n,[e]:t})),w(e)},D=n=>{if(n.preventDefault(),l)return;let i=la(e,v,b),a=ta(e,i,t);if(Object.keys(a).length>0){C(a);return}r(na(i))};return g(`form`,{class:`${q}-form`,onSubmit:D,onKeyDown:e=>{!s||e.key!==`Enter`||e.shiftKey||e.isComposing||e.target?.tagName===`TEXTAREA`&&D(e)},"data-testid":p,noValidate:!0,children:[e.map(e=>h(aa,{field:e,value:v[e.name],otherText:b[e.name]??``,error:S[e.name],disabled:l,typeLabel:f?.[e.name],strings:t,onChange:t=>T(e.name,t),onOtherChange:t=>E(e.name,t)},e.name)),d?null:g(`div`,{class:`${q}-form-actions`,children:[o?h(`span`,{class:`${q}-form-hint`,children:o}):null,i&&a?h(`button`,{type:`button`,class:`${q}-form-skip`,onClick:a,disabled:l,"data-testid":_,children:i}):null,h(`button`,{type:`submit`,class:`${q}-form-submit`,disabled:l,"data-testid":m,children:n})]})]})}function aa({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=oa({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:Zr(G.formField,e.name)});return g(`label`,{class:`${q}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[g(`span`,{class:`${q}-field-head`,children:[g(`span`,{class:`${q}-field-label`,children:[e.label,e.required??!0?h(`span`,{class:`${q}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?h(`span`,{class:`${q}-field-type`,children:a}):null]}),l,e.validationHint&&!r?h(`span`,{class:`${q}-field-hint`,children:e.validationHint}):null,r?h(`span`,{class:`${q}-field-error`,role:`alert`,children:r}):null]})}function oa(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c}=e,l=typeof n==`string`?n:``;switch(t.type){case`textarea`:return h(`textarea`,{class:`${q}-field-input`,rows:3,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.target.value),"data-testid":c});case`select`:return g(`select`,{class:`${q}-field-input`,value:l,disabled:i,onChange:e=>o(e.target.value),"data-testid":c,children:[h(`option`,{value:``,children:t.placeholder??`—`}),(t.options??[]).map(e=>h(`option`,{value:e.value,children:e.label??e.value},e.value))]});case`radio`:{let e=t.allowOther&&l===ra;return g(`div`,{class:`${q}-field-choices`,role:`radiogroup`,"data-testid":c,children:[(t.options??[]).map(e=>g(`label`,{class:`${q}-choice`,children:[h(`input`,{type:`radio`,name:`${q}-${t.name}`,checked:l===e.value,disabled:i,onChange:()=>o(e.value)}),h(`span`,{children:e.label??e.value})]},e.value)),t.allowOther?g(`label`,{class:`${q}-choice`,children:[h(`input`,{type:`radio`,name:`${q}-${t.name}`,checked:l===ra,disabled:i,onChange:()=>o(ra)}),h(`span`,{children:a.formOther})]}):null,e?h(`input`,{class:`${q}-field-input`,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.target.value)}):null]})}case`checkbox`:return g(`label`,{class:`${q}-choice`,children:[h(`input`,{type:`checkbox`,checked:l===`true`,disabled:i,onChange:e=>o(e.target.checked?`true`:``),"data-testid":c}),h(`span`,{children:t.placeholder??t.label})]});case`multiselect`:{let e=Array.isArray(n)?n:[],l=(t,n)=>o(n?[...e,t]:e.filter(e=>e!==t));return g(`div`,{class:`${q}-field-choices`,"data-testid":c,children:[(t.options??[]).map(t=>g(`label`,{class:`${q}-choice`,children:[h(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>l(t.value,e.target.checked)}),h(`span`,{children:t.label??t.value})]},t.value)),t.allowOther||(t.options??[]).length===0?h(`textarea`,{class:`${q}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.target.value)}):null]})}default:return h(`input`,{class:`${q}-field-input`,type:sa(t.type),value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.target.value),"data-testid":c})}}function sa(e){switch(e){case`number`:case`email`:case`tel`:case`url`:case`date`:case`time`:return e;default:return`text`}}function ca(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type===`multiselect`?n.defaultValue.split(`,`).map(e=>e.trim()).filter(Boolean):n.defaultValue);return t}function la(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if(i.type===`radio`&&i.allowOther&&t[i.name]===ra)r[i.name]=e??``;else if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=Array.isArray(t[i.name])?t[i.name]:[];r[i.name]=[...a,...n]}}return r}const ua=y.cssPrefix;function da({form:e,strings:t,onSubmit:n,onSkip:r}){return g(`div`,{class:`${ua}-form-gate`,"data-testid":G.formGate,children:[e.title?h(`h3`,{class:`${ua}-form-gate-title`,children:e.title}):null,e.description?h(`p`,{class:`${ua}-form-gate-desc`,children:e.description}):null,h(ia,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?r:void 0,submitTestId:G.formSubmit,skipTestId:G.formSkip})]})}function fa({marker:e,strings:t,onFill:n}){let r=e.outcome===`skipped`,i=r?t.formSkipped:t.formSubmitted,a=e.title?g(m,{children:[h(`span`,{children:e.title}),h(`span`,{class:`${ua}-sr-only`,children:i})]}):h(`span`,{children:i}),o=e.form?.reviewable??!1,s=!r&&o&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){let t=t=>e.form?.fields.find(e=>e.name===t)?.label??t;return g(`details`,{class:`${ua}-form-done`,"data-outcome":e.outcome,"data-testid":G.formDone,children:[g(`summary`,{class:`${ua}-form-done-summary`,"data-testid":G.formDoneToggle,children:[h(_r,{}),a,h(rr,{})]}),h(`dl`,{class:`${ua}-form-answers`,"data-testid":G.formAnswers,children:Object.entries(s).map(([e,n])=>g(`div`,{class:`${ua}-form-answer`,children:[h(`dt`,{children:t(e)}),h(`dd`,{children:n})]},e))})]})}return g(`div`,{class:`${ua}-form-done`,"data-outcome":e.outcome,"data-testid":G.formDone,role:`status`,children:[h(r?gr:_r,{}),a,r&&e.form?.reopenable&&n?h(`button`,{type:`button`,class:`${ua}-form-done-fill`,"data-testid":G.formFill,onClick:n,children:t.formFillOut}):null]})}function pa(e){if(!e)return!1;let t=e.startsWith(`tool:`)?e.slice(5):e;return t===`ask-user-questions`||t===`ask_user_questions`}function ma({textSig:e,doneSig:t}){let n=s(null);return a(()=>{let r=n.current;if(!r)return;r.classList.add(`${y.cssPrefix}-md`);let i=v.default_renderer(r),a=v.parser(i),o=0,s=u(()=>{let n=e.value,s=t.value;n.length<o&&(r.replaceChildren(),i=v.default_renderer(r),a=v.parser(i),o=0);let c=n.slice(o);c&&v.parser_write(a,c),o=n.length,s&&v.parser_end(a)}),c=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes){if(!(e instanceof HTMLElement))continue;let t=e.matches?.(`a`)?[e]:[...e.querySelectorAll?.(`a`)??[]];for(let e of t)ga(e)}});c.observe(r,{childList:!0,subtree:!0});for(let e of r.querySelectorAll(`a`))ga(e);let l=e=>{let t=e.target?.closest?.(`a`);if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;!n||n.startsWith(`#`)||(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))};return r.addEventListener(`click`,l),()=>{s(),c.disconnect(),r.removeEventListener(`click`,l)}},[e,t]),h(`div`,{ref:n})}function ha({text:e}){return h(ma,{textSig:o(()=>d(e),[e]),doneSig:o(()=>d(!0),[])})}function ga(e){let t=e.getAttribute(`href`)??``;if(!t||t.startsWith(`#`))return;e.target!==`_blank`&&(e.target=`_blank`);let n=new Set((e.rel||``).split(/\s+/).filter(Boolean));n.add(`noopener`),n.add(`noreferrer`),e.rel=[...n].join(` `)}const _a=y.cssPrefix;function va({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=c(t),o=t=>{let n=i===t?null:t;a(n),r(e,n)};return g(`div`,{class:`${_a}-feedback`,role:`group`,"data-testid":G.messageFeedback,children:[h(`button`,{type:`button`,class:`${_a}-msg-action`,"data-active":i===`up`?`true`:void 0,"aria-pressed":i===`up`,"aria-label":n.feedbackUp,title:n.feedbackUp,onClick:()=>o(`up`),"data-testid":G.feedbackUp,children:h(Wr,{})}),h(`button`,{type:`button`,class:`${_a}-msg-action`,"data-active":i===`down`?`true`:void 0,"aria-pressed":i===`down`,"aria-label":n.feedbackDown,title:n.feedbackDown,onClick:()=>o(`down`),"data-testid":G.feedbackDown,children:h(Gr,{})}),h(`span`,{class:`${_a}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}const ya=y.cssPrefix;function ba({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?g(`a`,{class:`${ya}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":G.source,children:[h(`span`,{class:`${ya}-source-icon`,"aria-hidden":`true`,children:`🔗`}),h(`span`,{class:`${ya}-source-label`,children:n})]}):g(`span`,{class:`${ya}-source`,"data-testid":G.source,children:[h(`span`,{class:`${ya}-source-icon`,"aria-hidden":`true`,children:`📄`}),h(`span`,{class:`${ya}-source-label`,children:n})]})}const xa=y.cssPrefix;function Sa(e){return e.startsWith(`tool:`)||e.startsWith(`tool-`)?e.slice(5):e}function Ca(e,t){let n=e===`output-available`||e===`output-error`||e===`output-denied`,r=e===`approval-responded`||t?.approved!==void 0;return{terminal:n,responded:r,decided:n||r}}function wa({status:e,icon:t,label:n}){return g(`span`,{class:`${xa}-toolui-badge ${xa}-toolui-status`,"data-status":e,children:[h(`span`,{class:`${xa}-toolui-status-icon`,children:t}),n]})}function Ta(e,t){return e===`output-error`?`error`:e===`output-denied`||t?.approved===!1?`denied`:e===`output-available`?`completed`:e===`approval-responded`||t?.approved===!0?`responded`:e===`approval-requested`?`awaiting`:`running`}function Ea({status:e}){return h(e===`denied`||e===`error`||e===`superseded`?Yr:e===`completed`||e===`responded`?Jr:qr,{})}function Da(e,t){switch(e){case`awaiting`:return t.statusAwaiting;case`responded`:return t.statusResponded;case`completed`:return t.statusCompleted;case`denied`:return t.statusDenied;case`error`:return t.statusError;case`superseded`:return t.statusSuperseded;default:return t.statusRunning}}function Oa(e,t,n){return t&&(e===`awaiting`||e===`running`)?`superseded`:!n&&e===`running`?`error`:e}function ka({state:e,approval:t,strings:n,superseded:r,live:i=!0}){let a=Oa(Ta(e,t),r,i);return h(wa,{status:a,icon:h(Ea,{status:a}),label:Da(a,n)})}function Aa({name:e,state:t,approval:n,strings:r,superseded:i,live:a}){return g(m,{children:[g(`span`,{class:`${xa}-toolui-name-pill`,children:[h(Kr,{}),h(`span`,{class:`${xa}-toolui-name-text`,children:e})]}),h(ka,{state:t,approval:n,strings:r,superseded:i,live:a}),h(`span`,{class:`${xa}-toolui-chevron`,children:h(Sr,{})})]})}function ja({part:e,strings:t,testid:n,superseded:r,live:i}){let a=f(()=>e.inputSig.value),o=f(()=>e.outputSig.value),s=f(()=>e.errorSig.value),c=f(()=>e.stateSig.value),l=f(()=>e.approvalSig.value);return g(`details`,{class:`${xa}-toolui ${xa}-toolui-collapsible`,"data-testid":n,children:[h(`summary`,{class:`${xa}-toolui-head`,children:h(Aa,{name:Sa(e.toolName),state:c.value,approval:l.value,strings:t,superseded:r,live:i})}),h(Ma,{label:t.toolParameters,value:a.value}),o.value===void 0?null:h(Ma,{label:t.toolResult,value:o.value}),s.value?h(Ma,{label:t.statusError,value:s.value,error:!0}):null]})}function Ma({label:e,value:t,error:n}){let r=n?String(t??``):Pa(Na(t));return r?g(`div`,{class:`${xa}-toolui-section`,children:[h(`span`,{class:`${xa}-toolui-label`,children:e}),h(`pre`,{class:`${xa}-toolui-code`,"data-error":n?`true`:void 0,children:r})]}):null}function Na(e){if(e&&typeof e==`object`){let t=e;if(t.storage===`tool-result-ref`&&`summary`in t)return t.summary}return e}function Pa(e){if(e==null)return``;try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return!t||t===`{}`||t===`[]`||t===`""`?``:t.length>800?`${t.slice(0,800)}…`:t}catch{return``}}const J=y.cssPrefix;function Fa({part:e,strings:t,active:n,superseded:r=!1,onDecision:i,onEdit:a}){let o=f(()=>e.approvalSig.value),s=f(()=>e.stateSig.value),c=Sa(e.toolName),l=o.value?.approved,{terminal:u,responded:d,decided:p}=Ca(s.value,o.value),_=d&&n&&!u,v=r&&!p,y=e.toolCallId;return g(`div`,{class:`${J}-toolui-group`,"data-testid":p?G.toolDecision:G.toolApproval,children:[h(ja,{part:e,strings:t,superseded:v}),v||u?null:g(`div`,{class:`${J}-toolui ${J}-toolui-body`,children:[d?g(m,{children:[g(`p`,{class:`${J}-toolui-prompt`,children:[t.approvalYourResponse.replace(`{decision}`,l?t.approve:t.reject),o.value?.reason?` — ${o.value.reason}`:``]}),_?h(`p`,{class:`${J}-toolui-subtle`,children:t.approvalEditHint}):null,!_&&!u?h(`p`,{class:`${J}-toolui-subtle`,children:t.approvalSubmitting}):null]}):g(m,{children:[h(`p`,{class:`${J}-toolui-prompt`,children:t.approvalPrompt.replace(`{tool}`,c)}),h(`p`,{class:`${J}-toolui-subtle`,children:t.approvalBody})]}),!p&&!r?g(`div`,{class:`${J}-toolui-actions`,children:[h(`button`,{type:`button`,class:`${J}-form-skip`,onClick:()=>i(y,!1),"data-testid":G.toolReject,children:t.reject}),h(`button`,{type:`button`,class:`${J}-form-submit`,onClick:()=>i(y,!0),"data-testid":G.toolApprove,children:t.approve})]}):null,_?h(`div`,{class:`${J}-toolui-actions`,children:h(`button`,{type:`button`,class:`${J}-form-skip`,onClick:()=>a(y),"data-testid":G.toolEdit,children:t.edit})}):null]})]})}const Ia=new Set([`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`]);function La(e){let t=e&&typeof e==`object`?e:{},n=(Array.isArray(t.questions)?t.questions:[]).map(Ra).filter(e=>e!==null);return{intro:Va(t.intro),questions:n}}function Ra(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=Ia.has(n.type)?n.type:`text`;return{key:Va(n.key)??`q${t+1}`,question:Va(n.question)??`Please provide the missing information.`,type:r,options:Array.isArray(n.options)?n.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof n.required==`boolean`?n.required:void 0,helpText:Va(n.helpText)}}function za(e){switch(e){case`text`:return`textarea`;case`phone`:return`tel`;case`single-select`:case`boolean`:return`radio`;case`multi-select`:return`multiselect`;default:return e}}function Ba(e,t,n){return e.questions.map(e=>{let r=za(e.type),i=e.type===`boolean`?[{value:`yes`,label:t},{value:`no`,label:n}]:(e.options??[]).map(e=>({value:e,label:e}));return{name:e.key,label:e.question,type:r,required:e.required??!1,options:i.length>0?i:void 0,validationHint:e.helpText}})}function Va(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const Y=y.cssPrefix,Ha={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function Ua(e,t){let n={};for(let r of e)n[r.key]=t[Ha[r.type]];return n}function Wa({part:e,strings:t,active:n,superseded:r=!1,onDecision:i,onEdit:a}){let o=f(()=>e.stateSig.value).value,s=f(()=>e.approvalSig.value).value,l=f(()=>La(e.inputSig.value)).value,{terminal:u,decided:d}=Ca(o,s),p=d&&s?.approved===!0,m=!d&&!r,_=!m&&!p,v=p&&n&&!u,y=l.questions,[b,x]=c(null),S=b??(m||p),[C,w]=c(!1),T=y.length>1?Zn:Er,E=m?t.inputRequired:t.inputBadge,D=m?h(Ga,{req:l,strings:t,active:n,resolve:(t,n)=>i(e.toolCallId,n,t)}):C?h(ia,{fields:Ba(l,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:Ua(y,t),initialValues:p?Za(y,s?.reason):void 0}):h(Ka,{questions:y,answers:p?Xa(s?.reason):{},strings:t});return g(`details`,{class:`${Y}-toolui ${Y}-toolui-collapsible${r?` ${Y}-toolui-stale`:``}`,open:S,onToggle:e=>{let t=e.currentTarget.open;t!==S&&x(t)},"data-testid":m?G.toolAskQuestions:G.toolDecision,children:[g(`summary`,{class:`${Y}-toolui-head`,children:[g(`span`,{class:`${Y}-toolui-q-pill`,children:[h(T,{}),E]}),g(`span`,{class:`${Y}-toolui-head-end`,children:[m?null:h(wa,{status:_?`superseded`:`completed`,icon:h(_?Yr:Jr,{}),label:_?t.inputSkipped:t.inputAnswered}),h(`span`,{class:`${Y}-toolui-chevron`,children:h(Sr,{})})]})]}),g(`div`,{class:`${Y}-toolui-collapse-body`,children:[l.intro?h(`div`,{class:`${Y}-toolui-desc`,children:l.intro}):null,D,m?null:g(`div`,{class:`${Y}-toolui-footer`,children:[g(`button`,{type:`button`,class:`${Y}-toolui-options-toggle`,onClick:()=>w(e=>!e),"data-testid":G.toolAskOptions,children:[h(`span`,{class:`${Y}-toolui-options-chevron${C?` ${Y}-open`:``}`,children:h(Sr,{})}),C?t.hideOptions:t.showOptions]}),v?h(`button`,{type:`button`,class:`${Y}-form-skip`,onClick:()=>a(e.toolCallId),"data-testid":G.toolEdit,children:t.edit}):null]})]})]})}function Ga({req:e,strings:t,active:n,resolve:r}){let i=Ba(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return h(ia,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(Ja(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:Ua(e.questions,t),submitTestId:G.toolInputSubmit,skipTestId:G.toolInputSkip})}function Ka({questions:e,answers:t,strings:n}){return h(`div`,{class:`${Y}-toolui-summary`,"data-testid":G.toolAskSummary,children:e.map(e=>g(`div`,{class:`${Y}-field`,children:[h(`span`,{class:`${Y}-field-head`,children:g(`span`,{class:`${Y}-field-label`,children:[e.question,e.required?h(`span`,{class:`${Y}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),h(`p`,{class:`${Y}-toolui-answer`,children:qa(e,t[e.key],n)||`—`})]},e.key))})}function qa(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function Ja(e,t){let n=e.flatMap(e=>{let n=t[e.key];if(n==null||n.trim()===``)return[];let r=e.type===`multi-select`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;return[{key:e.key,value:r}]});return JSON.stringify({answers:n})}function Ya(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})()?.answers;if(!Array.isArray(t))return{};let n={};for(let e of t)if(e&&typeof e==`object`&&`key`in e){let{key:t,value:r}=e;if(typeof t!=`string`)continue;typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.filter(e=>typeof e==`string`))}return n}function Xa(e){let t=Ya(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function Za(e,t){let n=Ya(t),r={};for(let t of e){let e=n[t.key];e!==void 0&&(t.type===`multi-select`?r[t.key]=Array.isArray(e)?e:[e]:r[t.key]=Array.isArray(e)?e[0]??``:e)}return r}function Qa({part:e,strings:t,live:n}){let r=f(()=>e.inputSig.value),i=f(()=>e.outputSig.value),a=f(()=>e.errorSig.value);return f(()=>!!Pa(r.value)||!!a.value||!!Pa(Na(i.value))).value?h(ja,{part:e,strings:t,testid:G.toolCall,live:n}):null}const X=y.cssPrefix,$a=_(eo);function eo({message:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:o=!1,superseded:s=!1,tool:c,onRetry:l,enableMessageFeedback:u=!1,onFeedback:d}){let p=f(()=>e.partsSig.value).value,m=f(()=>Nn(e)),_=f(()=>Pn(e)),v=f(()=>e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)),y=f(()=>r&&e.partsSig.value.some(e=>e.kind===`reasoning`)),b=f(()=>{let t=e.partsSig.value,n=-1;for(let e=0;e<t.length;e++){let r=t[e]?.kind;(r===`text`||r===`file`||r===`source`)&&(n=e)}return n}),x=e.role===`assistant`&&e.status===`streaming`,S=n===`buffered`&&x,C=x&&!v.value,w=x&&!S&&!(y.value&&C);if(_.value)return null;let T=no(e.createdAt),E=e.role===`assistant`||e.role===`operator`,D=u&&!!d&&!!e.serverMessageId&&E&&!x&&e.status!==`error`&&!m.value,O=p.filter(e=>e.kind===`text`).map(e=>e.textSig.value).join(`
|
|
10
|
+
`))if(!(r===``||r.startsWith(`:`))){if(r.startsWith(`data:`)){let e=r.slice(5).replace(/^ /,``);t=t?`${t}\n${e}`:e;continue}r.startsWith(`id:`)&&(n=r.slice(3).trim())}if(t===`[DONE]`)return`done`;if(!t)return null;try{let e=JSON.parse(t);return Wt.trace(`chunk`,{type:e.type,eventId:n}),{chunk:e,eventId:n}}catch(e){return Wt.trace(`frame parse failed`,{err:e,payload:t.slice(0,200)}),null}}function Jt(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const Yt=e=>e&&Object.keys(e).length>0?e:void 0;function Xt(e,t){let n=Yt(e),r=Yt(t);if(!n&&!r)return;let i={};return n&&(i.user=n),r&&(i.page=r),Jt(JSON.stringify(i))}function Zt(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Qt(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function $t(e){return e.startsWith(`tool-`)?e.slice(5):e}const B={handshake:`/pai/handshake`,streamMessage:`/pai/stream-message`,streamResume:`/pai/stream-resume`,cancelStream:`/pai/cancel-stream`,listConversations:`/pai/list-conversations`,listMessages:`/pai/list-messages`,updateSettings:`/pai/update-settings`,markRead:`/pai/mark-read`,messageFeedback:`/pai/message-feedback`,requestOperator:`/pai/request-operator`,cancelRequestOperator:`/pai/cancel-request-operator`,bootstrap:`/pai/bootstrap`,content:`/pai/content`,submitForm:`/pai/submit-form`};function en(e){let t=e??{},n=t.controlMode;return{controlMode:n===`awaiting_operator`||n===`operator`?n:`ai-agent`,assignedOperatorInitials:typeof t.assignedOperatorInitials==`string`&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function tn(e){let t=e?.suggestions;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let{id:t,label:r,text:i}=e;typeof r!=`string`||!r||n.push({id:typeof t==`string`&&t?t:`s${n.length}`,label:r,text:typeof i==`string`&&i?i:r})}return n}function nn(e){let t=e.messages.map(e=>({id:e.serverMessageId??e.id,parts:on(e),role:e.role,createdAt:e.createdAt===void 0?void 0:new Date(e.createdAt).toISOString()})),n={messages:t,conversationId:e.conversationId,trigger:e.trigger??`submit-message`,responseType:`ack`},r=t.at(-1)?.id;r&&(n.messageId=r),e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let i=e.tools?.map(an).filter(e=>e!==null);return i?.length&&(n.data={tools:i}),n}function rn(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function an(e){return typeof e==`string`?e?{code:e}:null:e?.code?e:null}function on(e){let t=[];for(let n of e.parts)if(n.kind===`step-start`&&t.push({type:`step-start`}),n.kind===`reasoning`&&n.text&&t.push({type:`reasoning`,text:n.text,state:n.done?`done`:`streaming`}),n.kind===`text`&&n.text&&t.push({text:n.text,type:`text`}),n.kind===`file`&&n.url&&t.push({mediaType:n.mediaType,type:`file`,url:n.url}),n.kind===`tool`&&rn(n)){let e={type:Qt(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(e.input=n.input),n.output!==void 0&&(e.output=n.output),n.error!==void 0&&(e.errorText=n.error),n.approval&&n.approval.approved!==void 0&&(e.approval=n.approval),t.push(e)}for(let n of e.attachments??[])n.url&&t.push({type:`file`,url:n.url,mediaType:n.mediaType,filename:n.name,fileId:n.id,fileSize:n.size});return t}const V=N.scope(`transport`),sn=new Set([408,425,429,500,502,503,504]);function H(e){return 400*2**e+Math.floor(Math.random()*250)}function cn(e){let t=e.get(`retry-after`);if(!t)return null;let n=Number(t),r=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(r)&&r>=0?Math.min(r,3e4):null}var ln=class{constructor(e){this.ttlMs=e,z(this,`map`,new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&Date.now()-n.at<this.ttlMs)return n.result;let r={at:Date.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.delete(e),t})};return this.map.set(e,r),r.result}peek(e){let t=this.map.get(e);if(t?.value!==void 0&&Date.now()-t.at<this.ttlMs)return t.value}clear(){this.map.clear()}},un=class{constructor(e){this.opts=e,z(this,`visitorId`,void 0),z(this,`conversationId`,void 0),z(this,`userContext`,void 0),z(this,`pageContext`,void 0),z(this,`locale`,void 0),z(this,`conversationsCache`,new ln(1e4)),z(this,`loadConversationInflight`,new Map),z(this,`contentCache`,new ln(6e4))}setContext(e,t){this.userContext=e,this.pageContext=t}setLocale(e){this.locale=e}primeIdentity(e,t){e&&(this.visitorId=e),t&&(this.conversationId=t)}envelope(){let e={_ev:Bt};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=Xt(this.userContext,this.pageContext);return t&&(e.context=t),e}withEnvelope(e){return{...this.envelope(),...e}}appendEnvelope(e){for(let[t,n]of Object.entries(this.envelope()))e.append(t,n);return e}withEnvelopeQuery(e){let t=new URL(this.url(e));for(let[e,n]of Object.entries(this.envelope()))t.searchParams.has(e)||t.searchParams.set(e,n);return t.toString()}async handshake(e){V.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale});let t=await this.postJson(B.handshake,e,`handshake`);return V.debug(`handshake ←`,{visitorId:t.visitorId,conversationId:t.conversationId,hasWelcome:!!t.welcome,hasConfig:!!t.config,rebind:t.rebind}),fn(t)||V.warn(`handshake response did not match expected shape; using raw response`,{response:t}),this.visitorId=t.visitorId??e.visitorId,this.conversationId=t.conversationId,t}async uploadFile(e){V.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let t=new FormData;t.append(`file`,e,e.name);let n=await this.postForm(this.uploadPath,t,`upload`);return V.debug(`uploadFile ←`,{id:n.id,url:n.url}),n}async transcribe(e,t=`audio/webm`){V.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${dn(t)}`),n.append(`mimeType`,t);let r=await this.postForm(this.transcribePath,n,`transcribe`);return V.debug(`transcribe ←`,{textLen:r.text.length}),r}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={}){return this.conversationsCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchConversations(e))}async fetchConversations(e){let t=new URL(this.url(B.listConversations));e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.cursor&&t.searchParams.set(`cursor`,e.cursor),V.debug(`listConversations →`,{visitorId:e.visitorId??this.visitorId,limit:e.limit,cursor:e.cursor});let n=await this.getJson(t.toString(),`listConversations`),r=n.conversations??[];return V.debug(`listConversations ←`,{count:r.length,nextCursor:n.nextCursor}),{conversations:r,nextCursor:n.nextCursor}}async loadConversation(e){let t=this.loadConversationInflight.get(e);if(t)return t;let n=this.loadConversationDirect(e).finally(()=>this.loadConversationInflight.delete(e));return this.loadConversationInflight.set(e,n),n}async loadConversationDirect(e){let t=new URL(this.url(B.listMessages));t.searchParams.set(`conversationId`,e),V.debug(`loadConversation →`,{conversationId:e,visitorId:this.visitorId});let n=await this.getJson(t.toString(),`loadConversation`),r=n.messages??[];return V.debug(`loadConversation ←`,{conversationId:n.conversationId,canContinue:n.canContinue,messageCount:r.length,hasSuggestions:!!n.suggestions}),{...n,messages:r,canContinue:n.canContinue??!0}}async markRead(e){if(!(!this.visitorId||!e)){this.conversationsCache.clear(),V.debug(`markRead →`,{conversationId:e,visitorId:this.visitorId});try{await this.postJson(B.markRead,{conversationId:e},`markRead`)}catch(e){V.debug(`markRead failed (non-fatal)`,{err:e})}}}async requestOperator(){if(!(!this.visitorId||!this.conversationId)){V.debug(`requestOperator →`,{conversationId:this.conversationId,visitorId:this.visitorId});try{return(await this.postJson(B.requestOperator,{},`requestOperator`)).controlState}catch(e){V.debug(`requestOperator failed (non-fatal)`,{err:e});return}}}async cancelRequestOperator(){if(!(!this.visitorId||!this.conversationId)){V.debug(`cancelRequestOperator →`,{conversationId:this.conversationId,visitorId:this.visitorId});try{return(await this.postJson(B.cancelRequestOperator,{},`cancelRequestOperator`)).controlState}catch(e){V.debug(`cancelRequestOperator failed (non-fatal)`,{err:e});return}}}listContent(e={}){return this.contentCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchContent(e))}async fetchContent(e){let t=new URL(this.dataUrl(B.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));V.debug(`listContent →`,e);let n=await this.getJson(t.toString(),`listContent`),r=(n.items??[]).map(e=>k(e,this.locale));return V.debug(`listContent ←`,{count:r.length,total:n.pagination?.total}),{...n,items:r}}async bootstrap(e){let t=new URL(this.dataUrl(B.bootstrap));e&&t.searchParams.set(`conversationId`,e),V.debug(`bootstrap →`,{conversationId:e??this.conversationId});let n=await this.getJson(t.toString(),`bootstrap`),r=n.forms??[],i=n.formSubmissions??[];return V.debug(`bootstrap ←`,{forms:r.length,formSubmissions:i.length}),{forms:r,formSubmissions:i}}async saveUserPrefs(e){V.debug(`saveUserPrefs →`,{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(e)});let t=await this.postJson(B.updateSettings,{userPrefs:e},`saveUserPrefs`);return V.debug(`saveUserPrefs ←`,{success:t.success}),t}get uploadPath(){return this.opts.endpoints?.upload??`/pai/upload-file`}get transcribePath(){return this.opts.endpoints?.transcribe??`/pai/transcribe-audio`}get submitFormPath(){return this.opts.endpoints?.submitForm??B.submitForm}async submitForm(e){V.debug(`submitForm →`,{formId:e.formId,trigger:e.trigger,fields:Object.keys(e.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),e,`submitForm`)}catch(e){V.debug(`submitForm failed (non-fatal)`,{err:e})}}async submitFeedback(e){V.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(B.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){V.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e){this.conversationsCache.clear(),V.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageId:e.messageId,messageCount:e.messages.length,trigger:e.trigger,tools:e.data?.tools?.map(e=>e.code)});let t=await this.fetchImpl(this.url(B.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(e))});return{status:`accepted`,conversationId:(await this.assertOk(t,`sendTurn`)).conversationId??e.conversationId}}cancelTurn(e){!this.visitorId||!e||(V.debug(`cancel stream`,{conversationId:e,visitorId:this.visitorId}),this.fetchImpl(this.url(B.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(e=>V.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t;try{t=await this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,headers:{accept:`text/event-stream`,...this.opts.auth.headers()},signal:e.signal})}catch(t){return e.signal.aborted||V.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!t.ok||!t.body)return V.debug(`resume-stream → endpoint unavailable`,{status:t.status}),`unavailable`;if(!(t.headers.get(`content-type`)??``).includes(`text/event-stream`))return V.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;e.onConnected();try{for await(let{chunk:n}of Gt(t,e.signal)){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;V.debug(`resume-stream segment dropped — reconnecting`,{err:t})}return`held`}resumeUrl(){return this.withEnvelopeQuery(B.streamResume)}async postJson(e,t,n){let r=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(t))}],n);return this.assertOk(r,n)}async postForm(e,t,n){let r=await this.fetchImpl(this.url(e),{method:`POST`,credentials:`omit`,headers:this.opts.auth.headers(),body:this.appendEnvelope(t)});return this.assertOk(r,n)}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.opts.auth.headers()}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let[r,i]=e(),a;try{a=await this.fetchImpl(r,i)}catch(e){if(n>=3)throw new Ut(`${t} failed: network error`,`network`,void 0,e);V.debug(`request network error — retrying`,{label:t,attempt:n}),await zt(H(n));continue}if(a.ok||!sn.has(a.status)||n>=3)return a;let o=cn(a.headers)??H(n);V.debug(`request retryable status — retrying`,{label:t,status:a.status,attempt:n,wait:o}),await zt(o)}}async assertOk(e,t){if(!e.ok)throw new Ut(`${t} failed: ${e.status}`,`server`,e.status);return await e.json()}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return/^https?:\/\//i.test(e)?e:`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function dn(e){return e.includes(`webm`)?`webm`:e.includes(`ogg`)?`ogg`:e.includes(`mp4`)||e.includes(`m4a`)?`m4a`:e.includes(`mpeg`)?`mp3`:e.includes(`wav`)?`wav`:`bin`}function fn(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.visitorId==`string`&&typeof t.conversationId==`string`}function pn(e,t){let n=e?[{kind:`text`,id:`t0`,textSig:d(e),doneSig:d(!0)}]:[];return{id:ut(),role:`user`,createdAt:Date.now(),status:`complete`,attachments:t,partsSig:d(n)}}function mn(){return{id:ut(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:d([])}}function hn(e){let t=ut();return gn({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function gn(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,feedback:e.feedback,partsSig:d(e.parts.map(Bn))}}const _n=new Set([`completed`,`failed`,`canceled`]);function vn(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status!=null&&!_n.has(e.status)?`streaming`:`complete`}function yn(e){let t=new Set,n=e.parts.map((t,n)=>t.type===`text`?{kind:`text`,id:`${e.id}-t${n}`,textSig:d(t.text),doneSig:d(!0)}:t.type===`reasoning`?{kind:`reasoning`,id:`${e.id}-r${n}`,textSig:d(t.text),doneSig:d(t.state!==`streaming`)}:t.type===`step-start`?{kind:`step-start`,id:`${e.id}-ss${n}`}:t.type===`file`?{kind:`file`,url:t.url,mediaType:t.mediaType}:t.type===`source-url`?{kind:`source`,sourceId:t.sourceId,url:t.url,title:t.title}:t.type===`source-document`?{kind:`source`,sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType}:t.type===`data-suggestions`?null:t.type.startsWith(`tool-`)?{kind:`tool`,toolCallId:t.toolCallId,toolName:$t(t.type),inputPartialSig:d(``),inputSig:d(t.input),outputSig:d(t.output),errorSig:d(t.errorText),stateSig:d(t.state),approvalSig:d(t.approval)}:null).filter(e=>e!==null).filter(e=>e.kind===`source`?t.has(e.sourceId)?!1:(t.add(e.sourceId),!0):!0),r=e.parts.find(e=>e.type===`data-suggestions`);return{id:e.id,role:e.role,operatorInitials:e.operatorInitials,suggestions:r?.type===`data-suggestions`?tn(r.data):void 0,serverMessageId:e.id,createdAt:Zt(e.createdAt)??Date.now(),status:vn(e),canceled:e.status===`canceled`,feedback:e.feedback??null,partsSig:d(n)}}function bn(e){return!e.parts.some(e=>e.type===`text`&&e.text.trim()!==``||e.type.startsWith(`tool-`)||e.type===`file`||e.type===`source-url`||e.type===`source-document`)}function xn(e){return e.role===`assistant`&&e.status!=null&&!_n.has(e.status)&&bn(e)}function Sn(e){let t=e.length-1;return e.filter((e,n)=>n===t||!xn(e)).map(yn)}function Cn(e,t){return(!t&&e.at(-1)?.role===`assistant`?e.slice(0,-1):e).filter(e=>!e.ephemeral)}function wn(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,parts:e.partsSig.value.map(Vn)}}function Tn(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function En(e){return Tn(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Dn(e){return Tn(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function On(e){return e.status!==`streaming`&&En(e)}function kn(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}const An=e=>e.kind===`tool`;function jn(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(e=>e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`||e.kind===`source`)}function Mn(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(An);return t.length>0&&t.every(e=>kn(e.stateSig.value))}function Nn(e){return e.partsSig.value.some(e=>An(e)&&!kn(e.stateSig.value))}function Pn(e){return Mn(e)&&!jn(e)}function Fn(e,t){let n=t.filter(e=>!e.ephemeral&&(e.status===`streaming`||En(e))),r=new Map(n.filter(e=>e.serverMessageId!==void 0).map(e=>[e.serverMessageId,e])),i=new Set,a=e.map(e=>{let t=e.serverMessageId===void 0?void 0:r.get(e.serverMessageId);return t===void 0||(i.add(e.serverMessageId),t.role!==e.role)?e:t.status===`streaming`||Tn(t).length>=Tn(e).length?t:(e.id=t.id,e)}),o=n.filter(e=>e.serverMessageId===void 0||!i.has(e.serverMessageId));return[...a,...o]}function In(e,t){let n=new Map(t.filter(e=>e.serverMessageId!==void 0).map(e=>[e.serverMessageId,e])),r=new Set(e.flatMap(e=>[e.serverMessageId,e.id].filter(e=>e!==void 0))),i=!1,a=e.map(e=>{if(e.serverMessageId===void 0)return e;let t=n.get(e.serverMessageId);if(t===void 0||t.role!==e.role)return e;let r=Tn(t).length,a=Tn(e).length,o=Nn(e)&&!Nn(t)&&r>=a;return r>a||o?(i=!0,t.id=e.id,t):e}),o=[...n.values()].filter(e=>!r.has(e.serverMessageId));return{messages:i||o.length?[...a,...o]:e,changed:i||o.length>0}}function Ln(e){return e.role===`assistant`&&e.status!==`streaming`&&!En(e)}function Rn(e){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Dn(e)}function zn(e,t){return e.operatorRoutedTurn?Ln(e)?`drop`:`complete-operator-routed`:t||Ln(e)?`error`:`complete`}function Bn(e){return e.kind===`text`||e.kind===`reasoning`?{kind:e.kind,id:e.id,textSig:d(e.text),doneSig:d(e.done)}:e.kind===`tool`?{kind:`tool`,toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:d(e.inputPartial),inputSig:d(e.input),outputSig:d(e.output),errorSig:d(e.error),stateSig:d(e.state),approvalSig:d(e.approval)}:e}function Vn(e){return e.kind===`text`||e.kind===`reasoning`?{kind:e.kind,id:e.id,text:e.textSig.value,done:e.doneSig.value}:e.kind===`tool`?{kind:`tool`,toolCallId:e.toolCallId,toolName:e.toolName,inputPartial:e.inputPartialSig.value,input:e.inputSig.value,output:e.outputSig.value,error:e.errorSig.value,state:e.stateSig.value,approval:e.approvalSig.value}:e}const Hn=N.scope(`feedback:audio`);var Un=class{constructor(){z(this,`ctx`,null),z(this,`master`,null),z(this,`buffers`,new Map)}unlock(){if(this.ctx){this.ctx.state===`suspended`&&this.ctx.resume();return}let e=globalThis.AudioContext??globalThis.webkitAudioContext;if(e)try{this.ctx=new e,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(e){Hn.warn(`AudioContext init failed`,{err:e})}}setVolume(e){if(!this.master||!this.ctx)return;let t=Math.max(0,Math.min(1,e));this.master.gain.setTargetAtTime(t,this.ctx.currentTime,.01)}playTone(e){let t=this.ctx,n=this.master;if(!t||!n||t.state!==`running`)return;let r=t.currentTime,i=e.noteMs/1e3;e.notes.forEach((a,o)=>{let s=t.createOscillator();s.type=e.type,s.frequency.value=a;let c=t.createGain(),l=r+o*i;c.gain.setValueAtTime(1e-4,l),c.gain.exponentialRampToValueAtTime(e.peakGain,l+.005),c.gain.exponentialRampToValueAtTime(1e-4,l+i),s.connect(c).connect(n),s.start(l),s.stop(l+i+.01)})}async playUrl(e){let t=this.ctx,n=this.master;if(!t||!n||t.state!==`running`)return;let r=await this.getBuffer(e);if(!r)return;let i=t.createBufferSource();i.buffer=r,i.connect(n),i.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>void 0),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(e){if(!this.ctx)return null;let t=this.buffers.get(e);if(t)return t instanceof Promise,t;let n=this.ctx,r=fetch(e).then(e=>e.ok?e.arrayBuffer():Promise.reject(Error(`fetch ${e.status}`))).then(e=>n.decodeAudioData(e)).then(t=>(this.buffers.set(e,t),t)).catch(t=>(Hn.warn(`audio fetch/decode failed`,{url:e,err:t}),this.buffers.delete(e),null));return this.buffers.set(e,r),r}};const Wn={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Gn={messageReceived:{notes:[880,1318.51],noteMs:90,type:`sine`,peakGain:.45},messageSent:{notes:[1568],noteMs:60,type:`sine`,peakGain:.25},error:{notes:[523.25,392],noteMs:120,type:`triangle`,peakGain:.55},voiceStart:{notes:[1318.51],noteMs:50,type:`sine`,peakGain:.3},voiceStop:{notes:[880],noteMs:50,type:`sine`,peakGain:.3}};let Kn=null,qn=0;function Jn(){return typeof navigator<`u`&&typeof navigator.vibrate==`function`}function Yn(){if(typeof document>`u`)return null;let e=document.createElement(`input`);e.type=`checkbox`,e.setAttribute(`switch`,``),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.id=`__${y.cssPrefix}_haptic_${Math.random().toString(36).slice(2)}`;let t=document.createElement(`label`);t.htmlFor=e.id,t.setAttribute(`aria-hidden`,`true`);let n=`position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;opacity:0!important;pointer-events:none!important;`;return e.style.cssText=n,t.style.cssText=n,document.body.append(e,t),{input:e,label:t}}function Xn(e){if(!(e===0||Array.isArray(e)&&e.every(e=>e===0))){if(Jn())try{navigator.vibrate(e);return}catch{}if(Kn||(Kn=Yn()),Kn)try{Kn.label.click()}catch{}}}function Zn(){qn++;let e=!1;return()=>{e||(e=!0,qn=Math.max(0,qn-1),qn===0&&Kn&&(Kn.input.remove(),Kn.label.remove(),Kn=null))}}const Qn=N.scope(`feedback`);var $n=class{constructor(e,t){z(this,`mutedSig`,d(!1)),z(this,`audio`,new Un),z(this,`releaseHaptics`,void 0),z(this,`sound`,void 0),z(this,`haptics`,void 0),z(this,`lastPlayed`,new Map),z(this,`reducedMotionMq`,null),this.sound=e,this.haptics=t,this.releaseHaptics=Zn(),this.audio.setVolume(this.effectiveVolume()),typeof matchMedia<`u`&&(this.reducedMotionMq=matchMedia(`(prefers-reduced-motion: reduce)`))}unlock(){this.audio.unlock(),this.audio.setVolume(this.effectiveVolume())}update(e,t){this.sound=e,this.haptics=t,this.audio.setVolume(this.effectiveVolume())}setMuted(e){this.mutedSig.value!==e&&(this.mutedSig.value=e)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(e){this.mutedSig.value||this.isDeduped(e)||(this.lastPlayed.set(e,performance.now()),this.sound.enabled&&this.playSound(e),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(e))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(e){let t=this.lastPlayed.get(e);return t!==void 0&&performance.now()-t<100}playSound(e){let t=this.sound.events?.[e];if(t===!1)return;if(typeof t==`string`){this.audio.playUrl(t).catch(e=>Qn.warn(`audio play failed`,{err:e,url:t}));return}let n=Gn[e];n&&this.audio.playTone(n)}playHaptic(e){if(this.reducedMotionMq?.matches)return;let t=this.haptics.events?.[e];t!==!1&&Xn(t===!0||t===void 0?Wn[e]:t)}effectiveVolume(){let e=this.sound.volume??.3;return this.reducedMotionMq?.matches?e*.5:e}isTouchDevice(){return typeof window>`u`?!1:matchMedia(`(hover: none) and (pointer: coarse)`).matches}};const U={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},er=`${y.cssPrefix}-icon-dir`,tr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})}),nr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M18 6 6 18M6 6l12 12`})}),rr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M12 5v14M5 12h14`})}),ir=()=>g(`svg`,{...U,class:er,"aria-hidden":`true`,children:[h(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),h(`path`,{d:`M22 2 11 13`})]}),ar=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M12 19V5M5 12l7-7 7 7`})}),or=()=>h(`svg`,{...U,class:er,"aria-hidden":`true`,children:h(`path`,{d:`M3 20V4l18 8-18 8Z`})}),sr=()=>h(`svg`,{...U,class:er,"aria-hidden":`true`,children:h(`path`,{d:`m9 18 6-6-6-6`})}),cr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})}),lr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78`})}),ur=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),h(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]}),dr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})}),fr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})}),pr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})}),mr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})}),hr=()=>h(`svg`,{...U,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:h(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})}),gr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),h(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),h(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]}),_r=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})}),vr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})}),yr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),h(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]}),br=()=>h(`svg`,{...U,class:er,"aria-hidden":`true`,children:h(`path`,{d:`m5 6 6 6-6 6M13 6l6 6-6 6`})}),xr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M20 6 9 17l-5-5`})}),Sr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M3 3v6h6`}),h(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),h(`path`,{d:`M12 7v5l3 2`})]}),Cr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`10`}),h(`path`,{d:`M2 12h20`}),h(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]}),wr=()=>h(`svg`,{...U,class:er,"aria-hidden":`true`,children:h(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})}),Tr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M12 20h9`}),h(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),Er=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`m6 9 6 6 6-6`})}),Dr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),h(`path`,{d:`M14 2v6h6`})]}),Or=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),h(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]}),kr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})}),Ar=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`10`}),h(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),h(`path`,{d:`M12 17h.01`})]}),jr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`m15 4 3 3-9 9-3-3z`}),h(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]}),Mr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),h(`path`,{d:`M12 8V4`}),h(`circle`,{cx:`12`,cy:`3`,r:`1`}),h(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]}),Nr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),h(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),h(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),h(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]}),Pr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`10`}),h(`circle`,{cx:`12`,cy:`12`,r:`4`}),h(`path`,{d:`m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24`})]}),Fr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`11`,cy:`11`,r:`7`}),h(`path`,{d:`m21 21-4.3-4.3`})]}),Ir=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]}),Lr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M3 9.5 12 3l9 6.5`}),h(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]}),Rr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`m3 11 15-5v12L3 13z`}),h(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),h(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),h(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]}),zr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),h(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]}),Br=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`4`}),h(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41`})]}),Vr=()=>h(`svg`,{...U,"aria-hidden":`true`,children:h(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})}),Hr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`M12 3v18`}),h(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]}),Ur=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),h(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),h(`path`,{d:`m20 20-4.4-4.4`})]}),Wr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z`}),h(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]}),Gr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M4 18h16`}),h(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),h(`path`,{d:`M12 8V6`}),h(`path`,{d:`M10 6h4`})]}),Kr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),h(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),h(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),h(`path`,{d:`M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11`})]}),qr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),h(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]}),Jr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),h(`path`,{d:`M7 10l4-7a2.5 2.5 0 0 1 2.5 2.5V8h5a2 2 0 0 1 2 2.3l-1.2 8A2 2 0 0 1 17.3 20H7`})]}),Yr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),h(`path`,{d:`M17 14l-4 7a2.5 2.5 0 0 1-2.5-2.5V16h-5a2 2 0 0 1-2-2.3l1.2-8A2 2 0 0 1 6.7 4H17`})]}),Xr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),h(`path`,{d:`M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9l-2.1 2.1M7 17l-2.1 2.1`})]}),Zr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`M12 7v5l3 2`})]}),Qr=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]}),$r=()=>g(`svg`,{...U,"aria-hidden":`true`,children:[h(`circle`,{cx:`12`,cy:`12`,r:`9`}),h(`path`,{d:`m15 9-6 6M9 9l6 6`})]}),ei={chat:tr,message:kr,bubbles:zr,spark:Or,wand:jr,bot:Mr,help:Ar,lifebuoy:Pr,headset:Nr,search:Ur,sparkles:Wr,concierge:Gr,wave:Kr},W=y.cssPrefix,G={launcher:`${W}-launcher`,callout:`${W}-callout`,calloutDismiss:`${W}-callout-dismiss`,panel:`${W}-panel`,panelHeader:`${W}-panel-header`,resizeGrip:`${W}-resize-grip`,scrollToBottom:`${W}-scroll-to-bottom`,actionHistory:`${W}-action-history`,actionClose:`${W}-action-close`,langSegment:`${W}-lang-segment`,composer:`${W}-composer`,composerInput:`${W}-composer-input`,composerSend:`${W}-composer-send`,composerStop:`${W}-composer-stop`,composerAttach:`${W}-composer-attach`,composerFileInput:`${W}-composer-file-input`,composerVoice:`${W}-composer-voice`,attachmentChip:`${W}-attachment-chip`,attachmentRemove:`${W}-attachment-remove`,suggestion:`${W}-suggestion`,messageBubble:`${W}-message`,messageRetry:`${W}-message-retry`,messageFeedback:`${W}-message-feedback`,feedbackUp:`${W}-feedback-up`,feedbackDown:`${W}-feedback-down`,messageCopy:`${W}-message-copy`,historyPane:`${W}-history-pane`,historyBack:`${W}-history-back`,historyItem:`${W}-history-item`,sidebar:`${W}-sidebar`,sidebarToggle:`${W}-sidebar-toggle`,sidebarNewConversation:`${W}-sidebar-new-conversation`,sidebarItem:`${W}-sidebar-item`,messengerHome:`${W}-messenger-home`,modulesEmpty:`${W}-modules-empty`,tab:`${W}-tab`,tabBadge:`${W}-tab-badge`,homeView:`${W}-home-view`,homeGreeting:`${W}-home-greeting`,homeBrand:`${W}-home-brand`,backHeader:`${W}-back-header`,contentView:`${W}-content-view`,contentScroll:`${W}-content-scroll`,homeSearch:`${W}-home-search`,helpSearch:`${W}-help-search`,homeRecent:`${W}-home-recent`,homeContentRow:`${W}-home-content-row`,helpArticle:`${W}-help-article`,newsItem:`${W}-news-item`,formGate:`${W}-form-gate`,formDone:`${W}-form-done`,formDoneToggle:`${W}-form-done-toggle`,formAnswers:`${W}-form-answers`,formFill:`${W}-form-fill`,formSubmit:`${W}-form-submit`,formSkip:`${W}-form-skip`,formField:`${W}-form-field`,toolAskQuestions:`${W}-tool-ask-questions`,toolInputSubmit:`${W}-tool-input-submit`,toolInputSkip:`${W}-tool-input-skip`,toolApproval:`${W}-tool-approval`,toolApprove:`${W}-tool-approve`,toolReject:`${W}-tool-reject`,toolEdit:`${W}-tool-edit`,toolDecision:`${W}-tool-decision`,toolAskSummary:`${W}-ask-questions-summary`,toolAskOptions:`${W}-ask-questions-options-toggle`,toolCall:`${W}-tool-call`,source:`${W}-source`,operatorRequest:`${W}-operator-request`,operatorBanner:`${W}-operator-banner`,operatorCancelRequest:`${W}-operator-cancel-request`};function ti(e,t){return`${e}-${t}`}const ni=y.cssPrefix;function ri({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!==`circle`&&!!t.label;return g(`button`,{type:`button`,class:`${ni}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?`true`:void 0,"data-leaving":r?`true`:void 0,"data-testid":G.launcher,onClick:e,"aria-label":n.launcherOpen,children:[ii(t.icon),a?h(`span`,{class:`${ni}-fab-label`,children:E(n,t.label??``)}):null]})}function ii(e){let t=ei[e];return t?h(t,{}):h(ai,{source:e})}function ai({source:e}){return h(`span`,{ref:t=>{t&&oi(t,e)},"aria-hidden":`true`})}function oi(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n&&n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function si({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:a}){let[o,s]=c(!1);return i(()=>{let t=setTimeout(()=>s(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),i(()=>{if(!o||e.autoDismissMs<=0)return;let t=setTimeout(a,e.autoDismissMs);return()=>clearTimeout(t)},[o,e.autoDismissMs,a]),o?g(`div`,{class:`${ni}-callout`,role:`status`,"data-shape":e.shape,"data-position":ci(e.position,t),"data-animated":e.animated?`true`:void 0,"data-testid":G.callout,children:[h(`span`,{children:E(n,e.text)}),h(`button`,{type:`button`,class:`${ni}-callout-close`,onClick:a,"aria-label":r,title:r,"data-testid":G.calloutDismiss,children:h(nr,{})})]}):null}function ci(e,t){let n=t.endsWith(`-right`),r=t.startsWith(`bottom-`);return e===`vertical`?r?`top`:`bottom`:n?`left`:`right`}function li({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:a,strings:o}){let c=y.cssPrefix,l=s(null);if(i(()=>{if(!e)return;let n=e.style;t.minWidth&&n.setProperty(`--${c}-resize-min-w`,t.minWidth),t.maxWidth&&n.setProperty(`--${c}-resize-max-w`,t.maxWidth),t.minHeight&&n.setProperty(`--${c}-resize-min-h`,t.minHeight),t.maxHeight&&n.setProperty(`--${c}-resize-max-h`,t.maxHeight),r&&(n.setProperty(`--${c}-widget-w`,`${r.width}px`),n.setProperty(`--${c}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,c,r]),!e)return null;let u=n.startsWith(`top-`),d=n.endsWith(`-right`),f=`${c}-resize-grip ${c}-resize-grip--${u?`bottom`:`top`}-${d?`left`:`right`}`,p=t=>{if(!e)return;let n=t.currentTarget,r=e.getBoundingClientRect();l.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:r.width,startH:r.height,dirX:d?-1:1,dirY:u?1:-1},n.setPointerCapture(t.pointerId),e.setAttribute(`data-resizing`,``),t.preventDefault()},m=t=>{let n=l.current;if(!n||t.pointerId!==n.pointerId||!e)return;let r=(t.clientX-n.startX)*n.dirX,i=(t.clientY-n.startY)*n.dirY;e.style.setProperty(`--${c}-widget-w`,`${n.startW+r}px`),e.style.setProperty(`--${c}-widget-h`,`${n.startH+i}px`)},g=t=>{let n=l.current;if(!n||t.pointerId!==n.pointerId||!e)return;t.currentTarget.releasePointerCapture(t.pointerId),e.removeAttribute(`data-resizing`);let r=e.getBoundingClientRect();a({width:Math.round(r.width),height:Math.round(r.height)}),l.current=null};return h(`div`,{class:f,role:`separator`,"aria-orientation":`vertical`,"aria-label":o.resizeHandle,title:o.resizeHandle,onPointerDown:p,onPointerMove:m,onPointerUp:g,onPointerCancel:g,"data-testid":G.resizeGrip,children:h(hr,{})})}const ui=y.cssPrefix,di=`.${ui}-header, .${ui}-back-header, .${ui}-home-hero`;function fi(e,t){i(()=>{if(!t||!e)return;let n=e=>Number.parseFloat(e)||0,r=(e,t)=>Math.min(t,Math.max(-t,e)),i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(di)||r.closest(`button, a, input, textarea, select, [role="tab"], [contenteditable]`))return;let a=e.getBoundingClientRect();i={id:t.pointerId,x:t.clientX,y:t.clientY,dx:n(e.style.getPropertyValue(`--${ui}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${ui}-modal-dy`)),maxX:(window.innerWidth+a.width)/2-56,maxY:(window.innerHeight+a.height)/2-56},e.dataset.dragging=`true`,t.preventDefault()},o=t=>{if(!i||t.pointerId!==i.id)return;let n=r(i.dx+t.clientX-i.x,i.maxX),a=r(i.dy+t.clientY-i.y,i.maxY);e.style.setProperty(`--${ui}-modal-dx`,`${n}px`),e.style.setProperty(`--${ui}-modal-dy`,`${a}px`)},s=t=>{!i||t.pointerId!==i.id||(i=null,delete e.dataset.dragging)};return e.addEventListener(`pointerdown`,a),window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e,t])}function pi(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function mi(e,t,n){return pi(`close`,e,t)?n.includes(`close`):!1}function hi(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function gi(e){let t=t=>{if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])`)].filter(e=>e.offsetParent!==null||e===document.activeElement);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1];if(!r||!i)return;let a=e.getRootNode().activeElement;t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}function _i(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const vi=y.cssPrefix;function yi({agent:e,strings:t}){let n=e.status??`online`,r=E(t,e.name),i=e.title?E(t,e.title):null;return g(`div`,{class:`${vi}-agent`,children:[h(`div`,{class:`${vi}-agent-avatar`,"data-status":n,children:e.avatar?h(`img`,{src:e.avatar,alt:``}):h(`span`,{children:_i(r)})}),g(`div`,{class:`${vi}-agent-meta`,children:[h(`strong`,{children:r}),i?h(`span`,{children:i}):null]})]})}const bi=N.scope(`attachments`);function xi(e,t,n){let r=wi(e),i=[],a=[],o=Di(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=Ci(e,c,s,n,o);if(t){a.push({file:e,reason:t});continue}i.push(Ei(e)),s+=e.size,c+=1}return(i.length||a.length)&&bi.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function Si(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){bi.debug(`revokeObjectURL failed`,{error:e})}}function Ci(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:Oi(e,i)?null:`mime`}function wi(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:Ti(e)).filter(e=>e!==null):[]}function Ti(e){let t=e;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function Ei(e){return{file:e,id:ut(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function Di(e){return e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>{if(e.startsWith(`.`))return{kind:`ext`,ext:e};let[t=`*`,n=`*`]=e.split(`/`);return{kind:`mime`,type:t,subtype:n}})}function Oi(e,t){if(t.length===0)return!0;let[n=`*`,r=`*`]=(e.type||``).toLowerCase().split(`/`),i=(e.name||``).toLowerCase();return t.some(e=>e.kind===`ext`?i.endsWith(e.ext):(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const ki=y.cssPrefix;function Ai({attachment:e,onRemove:t}){let n=e.mediaType.startsWith(`image/`);return g(`span`,{class:`${ki}-attachment-chip`,title:e.name,"data-testid":ti(G.attachmentChip,e.id),children:[n?h(`img`,{class:`${ki}-attachment-thumb`,src:e.previewUrl,alt:``}):h(`span`,{class:`${ki}-attachment-thumb`,"aria-hidden":`true`,children:h(Dr,{})}),h(`span`,{class:`${ki}-attachment-name`,children:e.name}),h(`button`,{type:`button`,class:`${ki}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":ti(G.attachmentRemove,e.id),children:h(nr,{})})]})}const ji={isSupported:!1,start:()=>void 0,stop:()=>void 0};function Mi(e,t,n){return e===`disabled`?ji:e===`server`?Ii(n):Ni(t)}function Ni(e){let t=Pi();if(!t)return ji;let n=null;return{isSupported:!0,start(r,i){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener(`result`,e=>{let t=e,n=``,i=!1;for(let e=t.resultIndex;e<t.results.length;e++){let r=t.results[e];r&&(n+=r[0].transcript,r.isFinal&&(i=!0))}r(n,i)});let a=()=>{n=null,i()};n.addEventListener(`end`,a),n.addEventListener(`error`,a),n.start()},stop(){n?.stop()}}}function Pi(){return window.SpeechRecognition??window.webkitSpeechRecognition}const Fi=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Ii(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return ji;let t=null,n=null,r=[],i=()=>{for(let e of n?.getTracks()??[])e.stop();n=null};return{isSupported:!0,async start(a,o){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let s=Li();t=new MediaRecorder(n,s?{mimeType:s}:void 0),r=[],t.addEventListener(`dataavailable`,e=>{e.data.size>0&&r.push(e.data)}),t.addEventListener(`stop`,async()=>{let n=t?.mimeType??`audio/webm`;i();let s=new Blob(r,{type:n});r=[];try{let{text:t}=await e(s,n);t&&a(t,!0)}catch{}finally{o()}}),t.start()}catch{i(),o()}},stop(){t?.stop()}}}function Li(){for(let e of Fi)if(MediaRecorder.isTypeSupported(e))return e}const K=y.cssPrefix,Ri=N.scope(`composer`);function zi(e){return e.reduce((e,t)=>e+t.size,0)}const Bi={arrowUp:ar,paperPlane:ir,send:or,chevron:sr};function Vi({options:e,transport:t,feedback:n,bus:r,isStreaming:a,operatorRequestEnabled:o,controlMode:l,onRequestOperator:u,onSend:d,onStop:f,attachApiRef:p}){let m=e.strings,[_,v]=c(``),[y,b]=c([]),[x,S]=c(!1),C=s(null),w=s(null),T=e.features.fileUpload,E=e.features.voice,[D,O]=c(()=>Mi(E,e.locale,(e,n)=>t.transcribe(e,n)));i(()=>{x||E===`disabled`||O(Mi(E,e.locale,(e,n)=>t.transcribe(e,n)))},[e.locale,E,t,x]),i(()=>{let e=C.current;if(!e)return;let t=e.getRootNode(),n=`activeElement`in t?t.activeElement:null;n&&e.closest(`.${K}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),i(()=>{let e=C.current;if(!e)return;if(_.length===0){e.style.height=``;return}e.style.height=`auto`;let t=parseFloat(getComputedStyle(e).fontSize)*.7,n=Math.min(e.scrollHeight,160);e.style.height=`${n<40+t?40:n}px`},[_]);let k=s(y);k.current=y,i(()=>()=>k.current.forEach(Si),[]),i(()=>{if(p)return p.current={attachFromDrop:t=>{let n=xi(t,k.current,e.attachments);n.accepted.length!==0&&(Ri.info(`attach (drop)`,{count:n.accepted.length,totalBytes:zi(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:zi(n.accepted)}),b(e=>[...e,...n.accepted]))},fill:e=>{v(e);let t=C.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))}},()=>{p.current&&(p.current=null)}},[p,e.attachments]),i(()=>{let t=C.current;if(!t)return;let n=t.closest(`.${K}-panel`);if(!n)return;let i=n=>{let i=n.clipboardData;if(!i)return;let a=n.target?.closest?.(`input, textarea, [contenteditable]:not([contenteditable='false'])`);if(a&&a!==t)return;if(T){let t=xi(i.items,k.current,e.attachments);if(t.accepted.length>0){n.preventDefault(),Ri.info(`attach (paste)`,{count:t.accepted.length,totalBytes:zi(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:zi(t.accepted)}),b(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),v(e=>e+o),t.focus())};return n.addEventListener(`paste`,i),()=>n.removeEventListener(`paste`,i)},[T,e.attachments,K]);let A=()=>{let e=_.trim();!e&&y.length===0||a||(d(e,y),v(``),b([]))},ee=e=>{e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),a?f():A())},te=t=>{let n=t.target,i=xi(n.files,y,e.attachments);i.accepted.length>0&&(Ri.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:zi(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:zi(i.accepted)}),b(e=>[...e,...i.accepted])),n.value=``},ne=e=>{Ri.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),b(t=>{let n=t.find(t=>t.id===e);return n&&Si(n),t.filter(t=>t.id!==e)})},j=s(null),re=()=>{if(D.isSupported){if(x){let e=j.current?Date.now()-j.current:0;Ri.info(`voiceStop`,{durationMs:e}),r.emit(`voiceStop`,{durationMs:e}),D.stop(),S(!1),n.play(`voiceStop`),j.current=null;return}j.current=Date.now(),Ri.info(`voiceStart`),r.emit(`voiceStart`,void 0),S(!0),n.play(`voiceStart`),D.start((e,t)=>v(n=>t?`${n}${e} `:n),()=>{if(S(!1),j.current){let e=Date.now()-j.current;Ri.debug(`voiceStop (auto)`,{durationMs:e}),r.emit(`voiceStop`,{durationMs:e}),j.current=null}})}},ie=Bi[e.composer.sendButton.icon];return g(`div`,{class:`${K}-composer`,"data-testid":G.composer,children:[y.length>0?h(`div`,{class:`${K}-attachments`,children:y.map(e=>h(Ai,{attachment:e,onRemove:()=>ne(e.id)},e.id))}):null,g(`div`,{class:`${K}-composer-row`,children:[g(`div`,{class:`${K}-composer-actions`,children:[T?h(`button`,{type:`button`,class:`${K}-icon-btn`,onClick:()=>w.current?.click(),"aria-label":m.attach,"data-testid":G.composerAttach,children:h(lr,{})}):null,D.isSupported?h(`button`,{type:`button`,class:`${K}-icon-btn`,onClick:re,"aria-label":x?m.micStop:m.micStart,"aria-pressed":x,"data-recording":x?`true`:void 0,"data-testid":G.composerVoice,children:h(ur,{})}):null,o&&l===`ai-agent`&&u?h(`button`,{type:`button`,class:`${K}-icon-btn`,onClick:u,"aria-label":m.talkToOperator,title:m.talkToOperator,"data-testid":G.operatorRequest,children:h(Nr,{})}):null]}),h(`textarea`,{ref:C,class:`${K}-textarea`,rows:1,value:_,placeholder:m.composerPlaceholder,onInput:e=>v(e.target.value),onKeyDown:ee,"aria-label":m.composerPlaceholder,"data-testid":G.composerInput}),a?h(`button`,{type:`button`,class:`${K}-send`,onClick:f,"aria-label":m.stop,"data-testid":G.composerStop,children:h(cr,{})}):h(`button`,{type:`button`,class:`${K}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:A,disabled:!_.trim()&&y.length===0,"aria-label":m.send,"data-testid":G.composerSend,children:h(ie,{})})]}),h(`input`,{ref:w,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:te,class:`${K}-sr-only`,"data-testid":G.composerFileInput})]})}const Hi=y.cssPrefix;function Ui({visible:e,strings:t}){return e?h(`div`,{class:`${Hi}-dropzone`,role:`status`,"aria-live":`polite`,children:t.dropZone}):null}function Wi({containerRef:e,onDrop:t}){let[n,r]=c(!1);return i(()=>{let n=e.current;if(!n)return;let i=0,a=e=>{i+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),r(!0))},o=()=>{--i,!(i>0)&&(i=0,r(!1))},s=e=>{e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()},c=e=>{i=0,r(!1),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))};return n.addEventListener(`dragenter`,a),n.addEventListener(`dragleave`,o),n.addEventListener(`dragover`,s),n.addEventListener(`drop`,c),()=>{n.removeEventListener(`dragenter`,a),n.removeEventListener(`dragleave`,o),n.removeEventListener(`dragover`,s),n.removeEventListener(`drop`,c)}},[e,t]),{visible:n}}function Gi({itemCount:e,initialFocusIndex:t}){let[n,a]=c(!1),o=s(null),l=s(null),[u,d]=c(-1),f=r(()=>{a(!1),d(-1),o.current?.focus()},[]),p=r(()=>a(e=>!e),[]);return i(()=>{if(!n)return;let e=e=>{let t=l.current,n=o.current;if(!t||!n)return;let r=e.composedPath();r.includes(t)||r.includes(n)||(a(!1),d(-1))};return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),i(()=>{if(!n||e===0)return;let r=t?.()??0;d(r<0||r>=e?0:r)},[n,e,t]),i(()=>{!n||u<0||(l.current?.querySelectorAll(`[role='menuitem']`))?.[u]?.focus()},[n,u]),{open:n,focusIndex:u,triggerRef:o,menuRef:l,toggle:p,close:f,onTriggerKey:r(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a(!0))},[]),onMenuKey:r(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),f();return;case`ArrowDown`:t.preventDefault(),d(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),d(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),d(0);return;case`End`:t.preventDefault(),d(e-1)}},[e,f])}}function Ki({items:e,triggerLabel:t}){let n=y.cssPrefix,r=Gi({itemCount:e.length}),i=e=>{e.disabled||(e.onSelect?.(),e.keepOpen||r.close())},a=(e,t)=>e.onSelectValue?.(t),o=(e,t)=>{let n=t.segments;if(!n?.length)return;let r=Math.max(0,n.findIndex(e=>e.value===t.value)),i=-1;if(e.key===`ArrowRight`||e.key===`Enter`||e.key===` `)i=(r+1)%n.length;else if(e.key===`ArrowLeft`)i=(r-1+n.length)%n.length;else return;e.preventDefault(),e.stopPropagation(),a(t,n[i].value)};return g(`div`,{class:`${n}-menu-wrap`,children:[h(`button`,{ref:r.triggerRef,type:`button`,class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r.open,title:t,onClick:r.toggle,onKeyDown:r.onTriggerKey,children:h(gr,{})}),r.open?h(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?g(`div`,{role:`menuitem`,class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":e.label,tabIndex:-1,onKeyDown:t=>o(t,e),children:[e.icon?h(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,h(`span`,{class:`${n}-menu-label`,children:e.label}),h(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return h(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,class:`${n}-segment`,"data-on":r?`true`:void 0,lang:t.lang,title:t.value,tabIndex:-1,"data-testid":`${G.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):g(`button`,{type:`button`,role:`menuitem`,class:`${n}-menu-item`,"aria-pressed":e.type===`switch`?e.on:void 0,disabled:e.disabled,onClick:()=>i(e),children:[e.icon?h(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,h(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?h(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:h(xr,{})}):null]},e.id))}):null]})}const qi=y.cssPrefix;function Ji(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const Yi={normal:`large`,large:`small`,small:`normal`};function Xi(e){return h(e===`light`?Br:e===`dark`?Vr:Hr,{})}function Zi(e){return(e.split(`-`)[0]??e).toUpperCase()}function Qi({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:o,onExpand:s,onFullscreen:c,onSoundToggle:l}=e,{onToggleHistory:u,onLocaleChange:d,onThemeChange:p,onTextSizeChange:m}=e,_=n.strings,v=n.mode,y=t===`chat`,b=f(()=>i.mutedSig.value).value,x=new Set(n.actions),S=e=>x.has(e),C=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches,w=e=>!C&&pi(e,v,r),T=n.themeMode,E={auto:_.themeAuto,light:_.themeLight,dark:_.themeDark},D=n.textSize,O={small:_.textSizeSmall,normal:_.textSizeNormal,large:_.textSizeLarge},k=[];if(y&&S(`clear`)&&k.push({id:`clear`,icon:h(Tr,{}),label:_.newConversation,onSelect:o}),S(`expand`)&&w(`expand`)){let e=r===`expanded`;k.push({id:`expand`,icon:h(e?fr:dr,{}),label:e?_.collapse:_.expand,type:`switch`,on:e,onSelect:s})}if(S(`fullscreen`)&&w(`fullscreen`)){let e=r===`fullscreen`;k.push({id:`fullscreen`,icon:h(e?mr:pr,{}),label:e?_.exitFullscreen:_.fullscreen,type:`switch`,on:e,onSelect:c})}y&&S(`sound`)&&k.push({id:`sound`,icon:h(b?vr:_r,{}),label:b?_.soundOff:_.soundOn,type:`switch`,on:!b,onSelect:l}),S(`theme`)&&k.push({id:`theme`,icon:Xi(T),label:`${_.theme}: ${E[T]}`,onSelect:()=>p(Ji(T)),keepOpen:!0}),S(`textSize`)&&k.push({id:`textSize`,icon:h(yr,{}),label:`${_.textSize}: ${O[D]}`,onSelect:()=>m(Yi[D]),keepOpen:!0}),S(`language`)&&n.availableLocales.length>1&&k.push({id:`language`,icon:h(Cr,{}),label:_.language,segments:n.availableLocales.map(e=>({value:e,label:Zi(e),lang:e})),value:n.locale,onSelectValue:d});let A=!!a&&mi(v,r,n.actions),ee=y&&S(`history`);return g(`div`,{class:`${qi}-header-actions`,children:[ee?h(`button`,{type:`button`,class:`${qi}-icon-btn`,onClick:u,"aria-label":_.history,title:_.history,"data-testid":G.actionHistory,children:h(Sr,{})}):null,k.length>0?h(Ki,{items:k,triggerLabel:_.moreActions}):null,A?h(`button`,{type:`button`,class:`${qi}-icon-btn`,onClick:a,"aria-label":_.close,title:_.close,"data-testid":G.actionClose,children:h(nr,{})}):null]})}const $i=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ea=/^https?:\/\/[^\s.]+\.[^\s]+$/i,ta=/^[+]?[\d\s().-]{6,}$/;function na(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}function ra(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function ia(e,t,n){let r=e.required??!0,i=e.validation;if(e.type===`multiselect`){let e=ra(t);return r&&e===0?n.formRequired:e===0?void 0:i?.minSelections!=null&&e<i.minSelections?na(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&e>i.maxSelections?na(n.formChooseAtMost,{max:i.maxSelections}):void 0}let a=typeof t==`string`?t.trim():``;if(!a)return r?n.formRequired:void 0;switch(e.type){case`email`:if(!$i.test(a))return n.formInvalidEmail;break;case`url`:if(!ea.test(a))return n.formInvalidUrl;break;case`tel`:if(!ta.test(a))return n.formInvalidTel;break;case`number`:{let e=Number(a);if(!Number.isFinite(e))return n.formInvalidNumber;if(i?.min!=null&&e<i.min)return na(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&e>i.max)return na(n.formNumberTooLarge,{max:i.max});break}default:break}if(i?.minLength!=null&&a.length<i.minLength)return na(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return na(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function aa(e,t,n){let r={};for(let i of e){let e=ia(i,t[i.name],n);e&&(r[i.name]=e)}return r}function oa(e){let t={};for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r.join(`, `):r;e&&e.trim()&&(t[n]=e.trim())}return t}const q=y.cssPrefix,sa=`__other__`;function ca({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:l,initialValues:u,hideActions:d,fieldTypeLabels:f,rootTestId:p,submitTestId:m,skipTestId:_}){let[v,y]=c(()=>({...fa(e),...u})),[b,x]=c({}),[S,C]=c({}),w=e=>{S[e]&&C(t=>({...t,[e]:``}))},T=(e,t)=>{y(n=>({...n,[e]:t})),w(e)},E=(e,t)=>{x(n=>({...n,[e]:t})),w(e)},D=n=>{if(n.preventDefault(),l)return;let i=pa(e,v,b),a=aa(e,i,t);if(Object.keys(a).length>0){C(a);return}r(oa(i))};return g(`form`,{class:`${q}-form`,onSubmit:D,onKeyDown:e=>{!s||e.key!==`Enter`||e.shiftKey||e.isComposing||e.target?.tagName===`TEXTAREA`&&D(e)},"data-testid":p,noValidate:!0,children:[e.map(e=>h(la,{field:e,value:v[e.name],otherText:b[e.name]??``,error:S[e.name],disabled:l,typeLabel:f?.[e.name],strings:t,onChange:t=>T(e.name,t),onOtherChange:t=>E(e.name,t)},e.name)),d?null:g(`div`,{class:`${q}-form-actions`,children:[o?h(`span`,{class:`${q}-form-hint`,children:o}):null,i&&a?h(`button`,{type:`button`,class:`${q}-form-skip`,onClick:a,disabled:l,"data-testid":_,children:i}):null,h(`button`,{type:`submit`,class:`${q}-form-submit`,disabled:l,"data-testid":m,children:n})]})]})}function la({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=ua({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:ti(G.formField,e.name)});return g(`label`,{class:`${q}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[g(`span`,{class:`${q}-field-head`,children:[g(`span`,{class:`${q}-field-label`,children:[e.label,e.required??!0?h(`span`,{class:`${q}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?h(`span`,{class:`${q}-field-type`,children:a}):null]}),l,e.validationHint&&!r?h(`span`,{class:`${q}-field-hint`,children:e.validationHint}):null,r?h(`span`,{class:`${q}-field-error`,role:`alert`,children:r}):null]})}function ua(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c}=e,l=typeof n==`string`?n:``;switch(t.type){case`textarea`:return h(`textarea`,{class:`${q}-field-input`,rows:3,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.target.value),"data-testid":c});case`select`:return g(`select`,{class:`${q}-field-input`,value:l,disabled:i,onChange:e=>o(e.target.value),"data-testid":c,children:[h(`option`,{value:``,children:t.placeholder??`—`}),(t.options??[]).map(e=>h(`option`,{value:e.value,children:e.label??e.value},e.value))]});case`radio`:{let e=t.allowOther&&l===sa;return g(`div`,{class:`${q}-field-choices`,role:`radiogroup`,"data-testid":c,children:[(t.options??[]).map(e=>g(`label`,{class:`${q}-choice`,children:[h(`input`,{type:`radio`,name:`${q}-${t.name}`,checked:l===e.value,disabled:i,onChange:()=>o(e.value)}),h(`span`,{children:e.label??e.value})]},e.value)),t.allowOther?g(`label`,{class:`${q}-choice`,children:[h(`input`,{type:`radio`,name:`${q}-${t.name}`,checked:l===sa,disabled:i,onChange:()=>o(sa)}),h(`span`,{children:a.formOther})]}):null,e?h(`input`,{class:`${q}-field-input`,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.target.value)}):null]})}case`checkbox`:return g(`label`,{class:`${q}-choice`,children:[h(`input`,{type:`checkbox`,checked:l===`true`,disabled:i,onChange:e=>o(e.target.checked?`true`:``),"data-testid":c}),h(`span`,{children:t.placeholder??t.label})]});case`multiselect`:{let e=Array.isArray(n)?n:[],l=(t,n)=>o(n?[...e,t]:e.filter(e=>e!==t));return g(`div`,{class:`${q}-field-choices`,"data-testid":c,children:[(t.options??[]).map(t=>g(`label`,{class:`${q}-choice`,children:[h(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>l(t.value,e.target.checked)}),h(`span`,{children:t.label??t.value})]},t.value)),t.allowOther||(t.options??[]).length===0?h(`textarea`,{class:`${q}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.target.value)}):null]})}default:return h(`input`,{class:`${q}-field-input`,type:da(t.type),value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.target.value),"data-testid":c})}}function da(e){switch(e){case`number`:case`email`:case`tel`:case`url`:case`date`:case`time`:return e;default:return`text`}}function fa(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type===`multiselect`?n.defaultValue.split(`,`).map(e=>e.trim()).filter(Boolean):n.defaultValue);return t}function pa(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if(i.type===`radio`&&i.allowOther&&t[i.name]===sa)r[i.name]=e??``;else if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=Array.isArray(t[i.name])?t[i.name]:[];r[i.name]=[...a,...n]}}return r}const ma=y.cssPrefix;function ha({form:e,strings:t,onSubmit:n,onSkip:r}){return g(`div`,{class:`${ma}-form-gate`,"data-testid":G.formGate,children:[e.title?h(`h3`,{class:`${ma}-form-gate-title`,children:e.title}):null,e.description?h(`p`,{class:`${ma}-form-gate-desc`,children:e.description}):null,h(ca,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?r:void 0,submitTestId:G.formSubmit,skipTestId:G.formSkip})]})}function ga({marker:e,strings:t,onFill:n}){let r=e.outcome===`skipped`,i=r?t.formSkipped:t.formSubmitted,a=e.title?g(m,{children:[h(`span`,{children:e.title}),h(`span`,{class:`${ma}-sr-only`,children:i})]}):h(`span`,{children:i}),o=e.form?.reviewable??!1,s=!r&&o&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){let t=t=>e.form?.fields.find(e=>e.name===t)?.label??t;return g(`details`,{class:`${ma}-form-done`,"data-outcome":e.outcome,"data-testid":G.formDone,children:[g(`summary`,{class:`${ma}-form-done-summary`,"data-testid":G.formDoneToggle,children:[h(xr,{}),a,h(sr,{})]}),h(`dl`,{class:`${ma}-form-answers`,"data-testid":G.formAnswers,children:Object.entries(s).map(([e,n])=>g(`div`,{class:`${ma}-form-answer`,children:[h(`dt`,{children:t(e)}),h(`dd`,{children:n})]},e))})]})}return g(`div`,{class:`${ma}-form-done`,"data-outcome":e.outcome,"data-testid":G.formDone,role:`status`,children:[h(r?br:xr,{}),a,r&&e.form?.reopenable&&n?h(`button`,{type:`button`,class:`${ma}-form-done-fill`,"data-testid":G.formFill,onClick:n,children:t.formFillOut}):null]})}function _a(e){if(!e)return!1;let t=e.startsWith(`tool:`)?e.slice(5):e;return t===`ask-user-questions`||t===`ask_user_questions`}function va({textSig:e,doneSig:t}){let n=s(null);return a(()=>{let r=n.current;if(!r)return;r.classList.add(`${y.cssPrefix}-md`);let i=v.default_renderer(r),a=v.parser(i),o=0,s=u(()=>{let n=e.value,s=t.value;n.length<o&&(r.replaceChildren(),i=v.default_renderer(r),a=v.parser(i),o=0);let c=n.slice(o);c&&v.parser_write(a,c),o=n.length,s&&v.parser_end(a)}),c=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes){if(!(e instanceof HTMLElement))continue;let t=e.matches?.(`a`)?[e]:[...e.querySelectorAll?.(`a`)??[]];for(let e of t)ba(e)}});c.observe(r,{childList:!0,subtree:!0});for(let e of r.querySelectorAll(`a`))ba(e);let l=e=>{let t=e.target?.closest?.(`a`);if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;!n||n.startsWith(`#`)||(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))};return r.addEventListener(`click`,l),()=>{s(),c.disconnect(),r.removeEventListener(`click`,l)}},[e,t]),h(`div`,{ref:n})}function ya({text:e}){return h(va,{textSig:o(()=>d(e),[e]),doneSig:o(()=>d(!0),[])})}function ba(e){let t=e.getAttribute(`href`)??``;if(!t||t.startsWith(`#`))return;e.target!==`_blank`&&(e.target=`_blank`);let n=new Set((e.rel||``).split(/\s+/).filter(Boolean));n.add(`noopener`),n.add(`noreferrer`),e.rel=[...n].join(` `)}const xa=y.cssPrefix;function Sa({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=c(t),o=t=>{let n=i===t?null:t;a(n),r(e,n)};return g(`div`,{class:`${xa}-feedback`,role:`group`,"data-testid":G.messageFeedback,children:[h(`button`,{type:`button`,class:`${xa}-msg-action`,"data-active":i===`up`?`true`:void 0,"aria-pressed":i===`up`,"aria-label":n.feedbackUp,title:n.feedbackUp,onClick:()=>o(`up`),"data-testid":G.feedbackUp,children:h(Jr,{})}),h(`button`,{type:`button`,class:`${xa}-msg-action`,"data-active":i===`down`?`true`:void 0,"aria-pressed":i===`down`,"aria-label":n.feedbackDown,title:n.feedbackDown,onClick:()=>o(`down`),"data-testid":G.feedbackDown,children:h(Yr,{})}),h(`span`,{class:`${xa}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}const Ca=y.cssPrefix;function wa({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?g(`a`,{class:`${Ca}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":G.source,children:[h(`span`,{class:`${Ca}-source-icon`,"aria-hidden":`true`,children:`🔗`}),h(`span`,{class:`${Ca}-source-label`,children:n})]}):g(`span`,{class:`${Ca}-source`,"data-testid":G.source,children:[h(`span`,{class:`${Ca}-source-icon`,"aria-hidden":`true`,children:`📄`}),h(`span`,{class:`${Ca}-source-label`,children:n})]})}const Ta=y.cssPrefix;function Ea(e){return e.startsWith(`tool:`)||e.startsWith(`tool-`)?e.slice(5):e}function Da(e,t){let n=e===`output-available`||e===`output-error`||e===`output-denied`,r=e===`approval-responded`||t?.approved!==void 0;return{terminal:n,responded:r,decided:n||r}}function Oa({status:e,icon:t,label:n}){return g(`span`,{class:`${Ta}-toolui-badge ${Ta}-toolui-status`,"data-status":e,children:[h(`span`,{class:`${Ta}-toolui-status-icon`,children:t}),n]})}function ka(e,t){return e===`output-error`?`error`:e===`output-denied`||t?.approved===!1?`denied`:e===`output-available`?`completed`:e===`approval-responded`||t?.approved===!0?`responded`:e===`approval-requested`?`awaiting`:`running`}function Aa({status:e}){return h(e===`denied`||e===`error`||e===`superseded`?$r:e===`completed`||e===`responded`?Qr:Zr,{})}function ja(e,t){switch(e){case`awaiting`:return t.statusAwaiting;case`responded`:return t.statusResponded;case`completed`:return t.statusCompleted;case`denied`:return t.statusDenied;case`error`:return t.statusError;case`superseded`:return t.statusSuperseded;default:return t.statusRunning}}function Ma(e,t,n){return t&&(e===`awaiting`||e===`running`)?`superseded`:!n&&e===`running`?`error`:e}function Na({state:e,approval:t,strings:n,superseded:r,live:i=!0}){let a=Ma(ka(e,t),r,i);return h(Oa,{status:a,icon:h(Aa,{status:a}),label:ja(a,n)})}function Pa({name:e,state:t,approval:n,strings:r,superseded:i,live:a}){return g(m,{children:[g(`span`,{class:`${Ta}-toolui-name-pill`,children:[h(Xr,{}),h(`span`,{class:`${Ta}-toolui-name-text`,children:e})]}),h(Na,{state:t,approval:n,strings:r,superseded:i,live:a}),h(`span`,{class:`${Ta}-toolui-chevron`,children:h(Er,{})})]})}function Fa({part:e,strings:t,testid:n,superseded:r,live:i}){let a=f(()=>e.inputSig.value),o=f(()=>e.outputSig.value),s=f(()=>e.errorSig.value),c=f(()=>e.stateSig.value),l=f(()=>e.approvalSig.value);return g(`details`,{class:`${Ta}-toolui ${Ta}-toolui-collapsible`,"data-testid":n,children:[h(`summary`,{class:`${Ta}-toolui-head`,children:h(Pa,{name:Ea(e.toolName),state:c.value,approval:l.value,strings:t,superseded:r,live:i})}),h(Ia,{label:t.toolParameters,value:a.value}),o.value===void 0?null:h(Ia,{label:t.toolResult,value:o.value}),s.value?h(Ia,{label:t.statusError,value:s.value,error:!0}):null]})}function Ia({label:e,value:t,error:n}){let r=n?String(t??``):Ra(La(t));return r?g(`div`,{class:`${Ta}-toolui-section`,children:[h(`span`,{class:`${Ta}-toolui-label`,children:e}),h(`pre`,{class:`${Ta}-toolui-code`,"data-error":n?`true`:void 0,children:r})]}):null}function La(e){if(e&&typeof e==`object`){let t=e;if(t.storage===`tool-result-ref`&&`summary`in t)return t.summary}return e}function Ra(e){if(e==null)return``;try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return!t||t===`{}`||t===`[]`||t===`""`?``:t.length>800?`${t.slice(0,800)}…`:t}catch{return``}}const J=y.cssPrefix;function za({part:e,strings:t,active:n,superseded:r=!1,onDecision:i,onEdit:a}){let o=f(()=>e.approvalSig.value),s=f(()=>e.stateSig.value),c=Ea(e.toolName),l=o.value?.approved,{terminal:u,responded:d,decided:p}=Da(s.value,o.value),_=d&&n&&!u,v=r&&!p,y=e.toolCallId;return g(`div`,{class:`${J}-toolui-group`,"data-testid":p?G.toolDecision:G.toolApproval,children:[h(Fa,{part:e,strings:t,superseded:v}),v||u?null:g(`div`,{class:`${J}-toolui ${J}-toolui-body`,children:[d?g(m,{children:[g(`p`,{class:`${J}-toolui-prompt`,children:[t.approvalYourResponse.replace(`{decision}`,l?t.approve:t.reject),o.value?.reason?` — ${o.value.reason}`:``]}),_?h(`p`,{class:`${J}-toolui-subtle`,children:t.approvalEditHint}):null,!_&&!u?h(`p`,{class:`${J}-toolui-subtle`,children:t.approvalSubmitting}):null]}):g(m,{children:[h(`p`,{class:`${J}-toolui-prompt`,children:t.approvalPrompt.replace(`{tool}`,c)}),h(`p`,{class:`${J}-toolui-subtle`,children:t.approvalBody})]}),!p&&!r?g(`div`,{class:`${J}-toolui-actions`,children:[h(`button`,{type:`button`,class:`${J}-form-skip`,onClick:()=>i(y,!1),"data-testid":G.toolReject,children:t.reject}),h(`button`,{type:`button`,class:`${J}-form-submit`,onClick:()=>i(y,!0),"data-testid":G.toolApprove,children:t.approve})]}):null,_?h(`div`,{class:`${J}-toolui-actions`,children:h(`button`,{type:`button`,class:`${J}-form-skip`,onClick:()=>a(y),"data-testid":G.toolEdit,children:t.edit})}):null]})]})}const Ba=new Set([`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`]);function Va(e){let t=e&&typeof e==`object`?e:{},n=(Array.isArray(t.questions)?t.questions:[]).map(Ha).filter(e=>e!==null);return{intro:Ga(t.intro),questions:n}}function Ha(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=Ba.has(n.type)?n.type:`text`;return{key:Ga(n.key)??`q${t+1}`,question:Ga(n.question)??`Please provide the missing information.`,type:r,options:Array.isArray(n.options)?n.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof n.required==`boolean`?n.required:void 0,helpText:Ga(n.helpText)}}function Ua(e){switch(e){case`text`:return`textarea`;case`phone`:return`tel`;case`single-select`:case`boolean`:return`radio`;case`multi-select`:return`multiselect`;default:return e}}function Wa(e,t,n){return e.questions.map(e=>{let r=Ua(e.type),i=e.type===`boolean`?[{value:`yes`,label:t},{value:`no`,label:n}]:(e.options??[]).map(e=>({value:e,label:e}));return{name:e.key,label:e.question,type:r,required:e.required??!1,options:i.length>0?i:void 0,validationHint:e.helpText}})}function Ga(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const Y=y.cssPrefix,Ka={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function qa(e,t){let n={};for(let r of e)n[r.key]=t[Ka[r.type]];return n}function Ja({part:e,strings:t,active:n,superseded:r=!1,onDecision:i,onEdit:a}){let o=f(()=>e.stateSig.value).value,s=f(()=>e.approvalSig.value).value,l=f(()=>Va(e.inputSig.value)).value,{terminal:u,decided:d}=Da(o,s),p=d&&s?.approved===!0,m=!d&&!r,_=!m&&!p,v=p&&n&&!u,y=l.questions,[b,x]=c(null),S=b??(m||p),[C,w]=c(!1),T=y.length>1?tr:Ar,E=m?t.inputRequired:t.inputBadge,D=m?h(Ya,{req:l,strings:t,active:n,resolve:(t,n)=>i(e.toolCallId,n,t)}):C?h(ca,{fields:Wa(l,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:qa(y,t),initialValues:p?to(y,s?.reason):void 0}):h(Xa,{questions:y,answers:p?eo(s?.reason):{},strings:t});return g(`details`,{class:`${Y}-toolui ${Y}-toolui-collapsible${r?` ${Y}-toolui-stale`:``}`,open:S,onToggle:e=>{let t=e.currentTarget.open;t!==S&&x(t)},"data-testid":m?G.toolAskQuestions:G.toolDecision,children:[g(`summary`,{class:`${Y}-toolui-head`,children:[g(`span`,{class:`${Y}-toolui-q-pill`,children:[h(T,{}),E]}),g(`span`,{class:`${Y}-toolui-head-end`,children:[m?null:h(Oa,{status:_?`superseded`:`completed`,icon:h(_?$r:Qr,{}),label:_?t.inputSkipped:t.inputAnswered}),h(`span`,{class:`${Y}-toolui-chevron`,children:h(Er,{})})]})]}),g(`div`,{class:`${Y}-toolui-collapse-body`,children:[l.intro?h(`div`,{class:`${Y}-toolui-desc`,children:l.intro}):null,D,m?null:g(`div`,{class:`${Y}-toolui-footer`,children:[g(`button`,{type:`button`,class:`${Y}-toolui-options-toggle`,onClick:()=>w(e=>!e),"data-testid":G.toolAskOptions,children:[h(`span`,{class:`${Y}-toolui-options-chevron${C?` ${Y}-open`:``}`,children:h(Er,{})}),C?t.hideOptions:t.showOptions]}),v?h(`button`,{type:`button`,class:`${Y}-form-skip`,onClick:()=>a(e.toolCallId),"data-testid":G.toolEdit,children:t.edit}):null]})]})]})}function Ya({req:e,strings:t,active:n,resolve:r}){let i=Wa(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return h(ca,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(Qa(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:qa(e.questions,t),submitTestId:G.toolInputSubmit,skipTestId:G.toolInputSkip})}function Xa({questions:e,answers:t,strings:n}){return h(`div`,{class:`${Y}-toolui-summary`,"data-testid":G.toolAskSummary,children:e.map(e=>g(`div`,{class:`${Y}-field`,children:[h(`span`,{class:`${Y}-field-head`,children:g(`span`,{class:`${Y}-field-label`,children:[e.question,e.required?h(`span`,{class:`${Y}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),h(`p`,{class:`${Y}-toolui-answer`,children:Za(e,t[e.key],n)||`—`})]},e.key))})}function Za(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function Qa(e,t){let n=e.flatMap(e=>{let n=t[e.key];if(n==null||n.trim()===``)return[];let r=e.type===`multi-select`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;return[{key:e.key,value:r}]});return JSON.stringify({answers:n})}function $a(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})()?.answers;if(!Array.isArray(t))return{};let n={};for(let e of t)if(e&&typeof e==`object`&&`key`in e){let{key:t,value:r}=e;if(typeof t!=`string`)continue;typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.filter(e=>typeof e==`string`))}return n}function eo(e){let t=$a(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function to(e,t){let n=$a(t),r={};for(let t of e){let e=n[t.key];e!==void 0&&(t.type===`multi-select`?r[t.key]=Array.isArray(e)?e:[e]:r[t.key]=Array.isArray(e)?e[0]??``:e)}return r}function no({part:e,strings:t,live:n}){let r=f(()=>e.inputSig.value),i=f(()=>e.outputSig.value),a=f(()=>e.errorSig.value);return f(()=>!!Ra(r.value)||!!a.value||!!Ra(La(i.value))).value?h(Fa,{part:e,strings:t,testid:G.toolCall,live:n}):null}const X=y.cssPrefix,ro=_(io);function io({message:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:o=!1,superseded:s=!1,tool:c,onRetry:l,enableMessageFeedback:u=!1,onFeedback:d}){let p=f(()=>e.partsSig.value).value,m=f(()=>Ln(e)),_=f(()=>Rn(e)),v=f(()=>e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)),y=f(()=>r&&e.partsSig.value.some(e=>e.kind===`reasoning`)),b=f(()=>{let t=e.partsSig.value,n=-1;for(let e=0;e<t.length;e++){let r=t[e]?.kind;(r===`text`||r===`file`||r===`source`)&&(n=e)}return n}),x=e.role===`assistant`&&e.status===`streaming`,S=n===`buffered`&&x,C=x&&!v.value,w=x&&!S&&!(y.value&&C);if(_.value)return null;let T=oo(e.createdAt),E=e.role===`assistant`||e.role===`operator`,D=u&&!!d&&!!e.serverMessageId&&E&&!x&&e.status!==`error`&&!m.value,O=p.filter(e=>e.kind===`text`).map(e=>e.textSig.value).join(`
|
|
11
11
|
|
|
12
|
-
`).trim(),k=!x&&e.status!==`error`&&!m.value&&O.length>0,A=D||k;return h(`div`,{class:`${X}-bubble-row`,"data-role":e.role,"data-testid":Zr(G.messageBubble,e.serverMessageId??e.id),children:g(`div`,{class:`${X}-bubble-col`,children:[g(`div`,{class:`${X}-bubble`,children:[e.role===`operator`&&e.operatorInitials?h(`span`,{class:`${X}-bubble-author`,children:e.operatorInitials}):null,g(`div`,{class:`${X}-bubble-body`,children:[S?h(co,{label:t.loading}):p.map((e,n)=>h(ro,{part:e,active:C,live:x,strings:t,showReasoning:r,showToolCalls:i,showSources:a,interactive:o&&(e.kind!==`tool`||n>b.value),superseded:s,tool:c},`${oo(e)}#${n}`)),w&&h(so,{}),e.status===`error`&&e.errorText||m.value?g(`div`,{class:`${X}-error`,role:`alert`,children:[h(`span`,{children:e.errorText??t.errorGeneric}),l?h(`button`,{type:`button`,class:`${X}-error-retry`,onClick:l,"data-testid":G.messageRetry,children:t.errorRetry}):null]}):null]})]}),T||A?g(`div`,{class:`${X}-bubble-meta`,children:[T?h(`time`,{class:`${X}-bubble-time`,dateTime:T.iso,title:T.full,children:T.short}):null,A?g(`div`,{class:`${X}-bubble-actions`,children:[D&&e.serverMessageId?h(va,{messageId:e.serverMessageId,initial:e.feedback??null,strings:t,onFeedback:d}):null,k?h(to,{text:O,strings:t}):null]}):null]}):null]})})}function to({text:e,strings:t}){let[n,r]=c(!1),i=()=>{navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})},a=n?t.copied:t.copy;return h(`button`,{type:`button`,class:`${X}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":G.messageCopy,children:h(n?_r:Ur,{})})}function no(e){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let t=new Date(e);return{short:t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}),full:t.toLocaleString(void 0,{dateStyle:`full`,timeStyle:`short`}),iso:t.toISOString()}}catch{return null}}function ro({part:e,active:t,live:n,strings:r,showReasoning:i,showToolCalls:a,showSources:o,interactive:s,superseded:c,tool:l}){switch(e.kind){case`step-start`:return null;case`text`:return h(ma,{textSig:e.textSig,doneSig:e.doneSig});case`reasoning`:return i?h(ao,{part:e,active:t,strings:r}):null;case`tool`:return h(io,{part:e,strings:r,showToolCalls:a,interactive:s,superseded:c,live:n,tool:l});case`file`:return e.mediaType.startsWith(`image/`)?h(`img`,{src:e.url,alt:``,loading:`lazy`}):h(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,children:e.url});case`source`:return o?h(ba,{part:e,strings:r}):null}}function io({part:e,strings:t,showToolCalls:n,interactive:r,superseded:i,live:a,tool:o}){let s=f(()=>e.approvalSig.value!==void 0);if(o?.humanInLoop){if(pa(e.toolName))return h(Wa,{part:e,strings:t,active:r,superseded:i,onDecision:o.onDecision,onEdit:o.onEdit});if(s.value)return h(Fa,{part:e,strings:t,active:r,superseded:i,onDecision:o.onDecision,onEdit:o.onEdit})}return n?h(Qa,{part:e,strings:t,live:a}):null}function ao({part:e,active:t,strings:n}){return g(`details`,{class:`${X}-reasoning`,open:t,"data-active":t?`true`:void 0,children:[h(`summary`,{class:`${X}-reasoning-summary`,children:h(`span`,{class:`${X}-reasoning-label`,children:t?n.thinking:n.thoughts})}),h(`div`,{class:`${X}-reasoning-body`,children:h(ma,{textSig:e.textSig,doneSig:e.doneSig})})]})}function oo(e){switch(e.kind){case`text`:case`reasoning`:case`step-start`:return`${e.kind}:${e.id}`;case`tool`:return`tool:${e.toolCallId}`;case`file`:return`file:${e.url}`;case`source`:return`source:${e.sourceId}`}}function so(){return g(`span`,{class:`${X}-typing`,"aria-hidden":`true`,children:[h(`span`,{}),h(`span`,{}),h(`span`,{})]})}function co({label:e}){return g(`span`,{class:`${X}-loading`,role:`status`,children:[h(`span`,{class:`${X}-loading-spinner`,"aria-hidden":`true`}),h(`span`,{class:`${X}-loading-label`,children:e})]})}const lo=y.cssPrefix;function uo({messagesSig:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:o,showSources:l,enableMessageFeedback:u,onFeedback:d,loading:p,idle:m,tool:_,onRetry:v,form:y,formMarkers:b,onFillForm:x}){let S=s(null),C=f(()=>e.value),[w,T]=c(!1),E=s(!1),D=s(!1),O=s(!1),k=s(0),A=()=>O.current||performance.now()-k.current<350,ee=s(0),te=e=>{let t=e.scrollHeight-e.clientHeight>1;e.dataset.fadeTop=t&&e.scrollTop>1?`true`:`false`,e.dataset.fadeBottom=t&&e.scrollHeight-e.scrollTop-e.clientHeight>1?`true`:`false`},ne=e=>T(e.scrollHeight-e.scrollTop-e.clientHeight>240),j=e=>{ee.current=performance.now(),e.scrollTop=e.scrollHeight,te(e)},re=(e,t)=>{j(e);let n=t,r=0,i=()=>{j(e),--n>0&&(r=requestAnimationFrame(i))};return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)},ie=(e,t)=>{let n,r,i,a=-1,o=()=>{n.disconnect(),r.disconnect(),clearTimeout(i)},s=()=>{if(D.current||A()||a>=0&&e.scrollTop<a-4)return o();j(e),a=e.scrollTop};return n=new ResizeObserver(s),r=new MutationObserver(s),s(),n.observe(e),r.observe(e,{childList:!0,subtree:!0,characterData:!0}),i=setTimeout(o,t),o},ae=C.value[0]?.id;a(()=>{let e=S.current;if(e&&C.value.length!==0&&(E.current=!0,C.value.some(e=>e.role===`user`)))return ie(e,300)},[ae]);let oe=s(0);i(()=>{let e=S.current,t=C.value,n=oe.current;if(oe.current=t.length,e&&E.current){if(t.slice(n).some(e=>e.role===`user`))return D.current=!1,re(e,3);t.some(e=>e.role===`user`)&&(D.current||A()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&j(e))}},[C.value.length]);let se=s(null);i(()=>{let e=S.current,t=C.value.at(-1),n=se.current;if(se.current=t?.id??null,e&&E.current&&!(!t||t.id!==n||t.status!==`streaming`))return D.current=!1,re(e,3)},[C.value]),i(()=>{let e=S.current;if(!e)return;let t=C.value.at(-1);if(!t||t.status!==`streaming`&&!C.value.some(e=>e.role===`user`))return;let n=()=>{D.current||A()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&j(e)};if(t.status!==`streaming`)return ie(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[C.value]);let ce=y?.form.id,M=!!y&&(b??[]).some(e=>e.formId===y.form.id);a(()=>{let e=S.current;!e||!ce||D.current||C.value.some(e=>e.role===`user`)&&(M?e.querySelector(`[data-testid="${G.formGate}"]`)?.scrollIntoView({block:`nearest`}):j(e))},[ce,M]),i(()=>{let e=S.current;if(!e)return;let t=()=>{ne(e),te(e),performance.now()-ee.current>150&&(D.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)},n=()=>{D.current=!0},r=e=>{e.deltaY<0&&n()},i=0,a=e=>{i=e.touches[0]?.clientY??0,O.current=!0},o=e=>{(e.touches[0]?.clientY??0)>i+4&&n()},s=()=>{O.current=!1,k.current=performance.now()},c=()=>{O.current=!0};return e.addEventListener(`scroll`,t,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),e.addEventListener(`pointerdown`,c,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),ne(e),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s),e.removeEventListener(`pointerdown`,c),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[]);let N=()=>{let e=S.current;e&&(D.current=!1,j(e))},le=[],ue=``,de=C.value.at(-1)?.id,P=[...b??[]].toSorted((e,t)=>(e.createdAt??1/0)-(t.createdAt??1/0)),fe=e=>y&&e.formId===y.form.id?h(da,{form:y.form,strings:t,onSubmit:y.onSubmit,onSkip:y.onSkip},`gate:${e.formId}`):h(fa,{marker:e,strings:t,onFill:!y&&x?()=>x(e.formId):void 0},e.key),pe=e=>{for(let t=P[0];t?.createdAt!==void 0&&!(e!==void 0&&t.createdAt>e);t=P[0])P.shift(),le.push(fe(t))};for(let e of C.value){if(e.role===`assistant`&&e.id!==de&&Nn(e))continue;pe(e.createdAt);let i=fo(e.createdAt);i&&i!==ue&&(le.push(h(`div`,{class:`${lo}-date-divider`,children:h(`span`,{class:`${lo}-date-pill`,title:po(e.createdAt),children:mo(e.createdAt,t)})},`day:${i}`)),ue=i),le.push(h($a,{message:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:o,showSources:l,interactive:!!m&&e.id===de,superseded:e.id!==de,tool:_,onRetry:m&&e.id===de?v:void 0,enableMessageFeedback:u,onFeedback:d},e.id))}for(let e of P)le.push(fe(e));return g(`div`,{class:`${lo}-list-wrap`,children:[g(`div`,{ref:S,class:`${lo}-list ${lo}-list--fade`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[p&&C.value.length===0?h(`div`,{class:`${lo}-list-loading`,role:`status`,children:t.conversationLoading}):null,le,y&&!M?h(da,{form:y.form,strings:t,onSubmit:y.onSubmit,onSkip:y.onSkip}):null]}),w?h(`button`,{type:`button`,class:`${lo}-jump`,onClick:N,"aria-label":t.scrollToBottom,title:t.scrollToBottom,"data-testid":G.scrollToBottom,children:h(Sr,{})}):null]})}function fo(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function po(e){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(void 0,{dateStyle:`full`})}catch{return``}}function mo(e,t){let n=new Date(e),r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),i=Math.round((r(new Date)-r(n))/864e5);return i<=0?t.dateToday:i===1?t.dateYesterday:i<7?n.toLocaleDateString(void 0,{weekday:`long`}):n.toLocaleDateString(void 0,{month:`long`,day:`numeric`,year:`numeric`})}const ho=[`today`,`yesterday`,`lastWeek`,`older`];function go(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.floor((vo(e)-vo(n))/(1440*60*1e3));return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function _o(e,t){let n=new Map;for(let r of t){let t=go(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return ho.filter(e=>n.has(e)).map(e=>({bucket:e,conversations:n.get(e)}))}function vo(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}const yo=M.scope(`history`),bo={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function xo(e,t,n){let r=Date.parse(e);return Number.isFinite(r)?new Date(r).toDateString()===new Date(t).toDateString()?new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(r):t-r<10080*60*1e3?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function So({transport:e,strings:t,locale:n,persistence:r,visitorId:a,onSelect:o,onNewConversation:s}){let l=y.cssPrefix,u=e.peekConversations({visitorId:a}),[d,f]=c(u?`loaded`:`loading`),[p,_]=c(u?.conversations??[]);i(()=>{let t=!1;return e.listConversations({visitorId:a}).then(e=>{if(t)return;let n=e.conversations??[];_(n),f(`loaded`),r.saveHistoryCount(n.length)}).catch(e=>{t||(yo.warn(`listConversations failed`,{err:e}),f(`error`))}),()=>{t=!0}},[e,a,r]);let v=s?h(`div`,{class:`${l}-history-footer`,children:g(`button`,{type:`button`,class:`${l}-history-new`,onClick:s,"data-testid":G.sidebarNewConversation,children:[h($n,{}),t.newConversation]})}):null;if(d===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return g(m,{children:[h(`div`,{class:`${l}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:g(`div`,{class:`${l}-history-group`,"aria-hidden":`true`,children:[h(`div`,{class:`${l}-history-heading`,children:h(`span`,{class:`${l}-skeleton ${l}-skeleton-heading`})}),h(`div`,{class:`${l}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>g(`div`,{class:`${l}-history-item ${l}-history-item-skeleton`,children:[h(`span`,{class:`${l}-history-avatar ${l}-skeleton`}),g(`span`,{class:`${l}-history-body`,children:[g(`span`,{class:`${l}-history-row`,children:[h(`span`,{class:`${l}-history-title`,children:h(`span`,{class:`${l}-skeleton ${l}-skeleton-title`})}),h(`span`,{class:`${l}-history-time`,children:h(`span`,{class:`${l}-skeleton ${l}-skeleton-time`})})]}),h(`span`,{class:`${l}-history-row`,children:h(`span`,{class:`${l}-history-preview`,children:h(`span`,{class:`${l}-skeleton ${l}-skeleton-preview`})})})]})]},t))})]})}),v]})}if(d===`error`||p.length===0)return g(m,{children:[h(`div`,{class:`${l}-history-empty`,children:t.historyEmpty}),v]});let b=Date.now(),x=_o(b,p);return g(m,{children:[h(`div`,{class:`${l}-history`,role:`list`,children:x.map(e=>g(`div`,{class:`${l}-history-group`,children:[h(`div`,{class:`${l}-history-heading`,children:t[bo[e.bucket]]}),h(`div`,{class:`${l}-history-card`,children:e.conversations.map(e=>g(`button`,{type:`button`,role:`listitem`,class:`${l}-history-item`,onClick:()=>o(e),"data-closed":e.canContinue?void 0:`true`,"data-unread":e.hasUnread?`true`:void 0,"data-testid":Zr(G.historyItem,e.conversationId),children:[h(`span`,{class:`${l}-history-avatar`,"aria-hidden":`true`,children:h(Tr,{})}),g(`span`,{class:`${l}-history-body`,children:[g(`span`,{class:`${l}-history-row`,children:[h(`span`,{class:`${l}-history-title`,children:e.title}),h(`span`,{class:`${l}-history-time`,children:xo(e.lastMessageAt,b,n)})]}),g(`span`,{class:`${l}-history-row`,children:[h(`span`,{class:`${l}-history-preview`,children:e.preview??(e.canContinue?t.historyContinue:t.conversationClosed)}),e.hasUnread?h(`span`,{class:`${l}-history-dot`}):null]})]})]},e.conversationId))})]},e.bucket))}),v]})}const Co=y.cssPrefix;function wo({suggestions:e,onPick:t}){return e.length===0?null:h(`div`,{class:`${Co}-suggestions`,role:`group`,"aria-label":`Suggested replies`,children:e.map((e,n)=>h(`button`,{type:`button`,class:`${Co}-suggestion`,onClick:()=>t(e),"data-testid":Zr(G.suggestion,n),children:e.label},e.id))})}const Z=y.cssPrefix;function To(e){let{options:t,onClose:n}=e,a=t.strings,o=s(null);i(()=>{let e=o.current;if(!e)return;let t=fi(e),r=e=>{e.key===`Escape`&&n?.()};return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let c=e.composerApiRef,{visible:l}=Bi({containerRef:o,onDrop:r(e=>{c.current?.attachFromDrop(e)},[c])});return ci(o.current,t.mode===`modal`),g(`div`,{ref:o,class:`${Z}-panel`,role:`dialog`,"aria-modal":`false`,"aria-label":a.panelTitle,style:{position:`relative`},"data-testid":G.panel,children:[h(Eo,{...e,containerEl:o.current,dragOver:l,composerAttachApiRef:c}),h(Mo,{poweredBy:e.options.poweredBy})]})}function Eo(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,panelSize:o,view:s,canSend:c,isStreaming:l,controlMode:u,assignedOperatorInitials:d,operatorAvailable:f,operatorRequestEnabled:p,onRequestOperator:_,onCancelRequest:v,loadingMessages:y,messagesSig:b,agent:x,suggestions:S,initialWidgetSize:C,visitorId:w,onClose:T,onBack:E,onClear:D,onToggleHistory:O,onSelectHistoryConversation:k,onNewConversation:A,onWidgetSizeChange:ee,onSend:te,onStop:ne,onSuggestion:j,activeForm:re,formMarkers:ie,onFormSubmit:ae,onFormSkip:oe,onFormFill:se,tool:ce,onRetry:M,onMessageFeedback:N,containerEl:le,dragOver:ue,composerAttachApiRef:de}=e,P=t.strings,fe;return fe=re?null:c?g(m,{children:[u&&u!==`ai-agent`?h(ko,{controlMode:u,operatorInitials:d,operatorAvailable:f,onCancelRequest:v,strings:P}):null,!l&&u===`ai-agent`&&h(wo,{suggestions:S,onPick:j}),h(Li,{options:t,transport:n,feedback:r,bus:i,isStreaming:l,operatorRequestEnabled:p,controlMode:u,onRequestOperator:_,onSend:te,onStop:ne,attachApiRef:de})]}):h(Oo,{label:P.conversationClosed,ctaLabel:P.startNewConversation,onNewConversation:D}),g(m,{children:[s===`history`?h(Do,{strings:P,onBack:O,onClose:T,showClose:ui(t.mode,o,t.actions)}):g(`header`,{class:`${Z}-header`,"data-testid":G.panelHeader,children:[E?h(`button`,{type:`button`,class:`${Z}-icon-btn`,onClick:E,"aria-label":P.moduleBack,title:P.moduleBack,children:h(br,{})}):null,x?h(hi,{agent:x,strings:P}):h(`h1`,{children:P.panelTitle}),h(Ji,{panelProps:e,variant:`chat`})]}),s===`history`?h(So,{transport:n,strings:P,locale:t.locale,persistence:a,visitorId:w,onSelect:e=>k(e.conversationId),onNewConversation:A}):g(m,{children:[h(zi,{visible:ue,strings:P}),h(uo,{messagesSig:b,strings:P,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:N,loading:y,idle:!l,tool:ce,onRetry:M,form:re?{form:re,onSubmit:ae,onSkip:oe}:null,formMarkers:ie,onFillForm:se}),fe,h(jo,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?h(ai,{panelEl:le,resize:t.size.resize,position:t.position,initialSize:C,onSizeChange:ee,strings:P}):null]})}function Do({strings:e,onBack:t,onClose:n,showClose:r}){return g(`header`,{class:`${Z}-header`,children:[h(`button`,{type:`button`,class:`${Z}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:h(br,{})}),h(`h1`,{children:e.historyTitle}),r?h(`button`,{type:`button`,class:`${Z}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:h(Qn,{})}):null]})}function Oo({label:e,ctaLabel:t,onNewConversation:n}){return g(`div`,{class:`${Z}-readonly-banner`,role:`note`,children:[h(`span`,{class:`${Z}-readonly-label`,children:e}),h(`button`,{type:`button`,class:`${Z}-readonly-cta`,onClick:n,children:t})]})}function ko({controlMode:e,operatorInitials:t,operatorAvailable:n,onCancelRequest:r,strings:i}){let a=Ao(e,t,n,i);return g(`div`,{class:`${Z}-operator-banner`,role:`status`,"data-mode":e,"data-testid":G.operatorBanner,children:[h(`span`,{class:`${Z}-operator-pulse`,"aria-hidden":`true`}),h(`span`,{class:`${Z}-operator-label`,children:a}),e===`awaiting_operator`&&r?h(`button`,{type:`button`,class:`${Z}-operator-cancel`,"data-testid":G.operatorCancelRequest,onClick:r,children:i.cancelOperatorRequest}):null]})}function Ao(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function jo({disclaimer:e}){return e?h(`div`,{class:`${Z}-composer-footer`,children:h(`div`,{class:`${Z}-disclaimer`,children:e})}):null}function Mo({poweredBy:e}){return e?h(`div`,{class:`${Z}-poweredby-bar`,children:h(No,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function No({logoUrl:e,text:t,href:n}){let r=g(m,{children:[e?h(`img`,{class:`${Z}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?h(`span`,{children:t}):null]});return n?h(`a`,{class:`${Z}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):h(`span`,{class:`${Z}-poweredby`,children:r})}function Po(e){let t=s(e);t.current=e;let n=s(null);return n.current??(n.current=Fo(t)),n.current}function Fo(e){let t=d(null),n=new Set,r=t=>`${e.current.conversationId()??``}:${t}`,i=t=>t.frequency===`always`?!1:t.frequency===`conversation`?n.has(r(t.id)):t.id in e.current.persistence.loadFormsDone(),a=(n,r)=>{if(t.value)return;let a=e.current;if(n===`manual`){let e=a.forms.list.find(e=>e.id===r);e&&(t.value={form:e,trigger:`manual`});return}for(let e of a.forms.byTrigger[n]??[]){let r=e.triggers.find(e=>e.kind===n);if(!(!r||!Io(r,a)||i(e)||!Lo(e,a))){t.value={form:e,trigger:n};return}}},o=(i,a)=>{let o=t.value;if(!o)return;t.value=null;let{form:s,trigger:c}=o;s.frequency===`conversation`?n.add(r(s.id)):s.frequency!==`always`&&e.current.persistence.saveFormDone(s.id),e.current.onComplete(s,c,i,a)};return{activeForm:t,fire:a,refresh:()=>{let n=t.value;if(!n)return;let r=e.current.forms.list.find(e=>e.id===n.form.id);r&&r!==n.form&&(t.value={form:r,trigger:n.trigger})},complete:e=>o(e,!1),skip:()=>o({},!0)}}function Io(e,t){return e.kind===`after-messages`?t.messageCount()>=Number(e.param??0):e.kind!==`page-area`||t.pageArea()===e.param}function Lo(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let e=t.userContext()??{};if(n.missingContext.some(t=>e[t]!==void 0&&e[t]!==``))return!1}if(n.pageArea&&!(Array.isArray(n.pageArea)?n.pageArea:[n.pageArea]).includes(t.pageArea()??``))return!1;let r=t.messageCount();return!(n.minMessages!=null&&r<n.minMessages||n.maxMessages!=null&&r>n.maxMessages)}function Ro(e){let t=y.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return g(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":G.sidebar,children:[g(`div`,{class:`${t}-sidebar-header`,children:[h(zo,{site:n}),h(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":G.sidebarToggle,children:h(Bo,{collapsed:a})})]}),a?null:g(m,{children:[o.length>0?h(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:h(Vo,{items:o})}):null,s.length>0?h(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:h(Ho,{items:s})}):null,e.showConversations?h(`div`,{class:`${t}-sidebar-conversations`,children:h(So,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,visitorId:e.visitorId,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function zo({site:e}){let t=y.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return g(`picture`,{children:[e.logoDark?.url?h(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,h(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return h(`div`,{class:`${t}-sidebar-title`,children:e?.title??y.name})}function Bo({collapsed:e}){return h(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?h(`polyline`,{points:`9 6 15 12 9 18`}):h(`polyline`,{points:`15 6 9 12 15 18`})})}function Vo({items:e}){let t=y.cssPrefix;return h(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>h(`li`,{children:g(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?h(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,h(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function Ho({items:e}){let t=y.cssPrefix;return h(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>g(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[h(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?h(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const Uo=y.cssPrefix;function Wo(e){return g(`main`,{class:`${Uo}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[h(Ro,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,visitorId:e.visitorId,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),h(`section`,{class:`${Uo}-page-chat`,"aria-label":`Chat`,children:e.children})]})}const Go=e=>Object.fromEntries(e.map(e=>[e,[]]));function Ko(e,t,n){let r=d({activeTab:e,stacks:Go(t)});return{sig:r,switchTab(e){r.value.activeTab!==e&&(r.value={...r.value,activeTab:e},n?.(e))},push(e){let t=r.value,n=t.stacks[t.activeTab]??[];r.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=r.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(r.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){r.value={activeTab:e,stacks:Go(t)}}}}const qo=e=>e.stacks[e.activeTab]??[],Jo=e=>qo(e).at(-1),Yo=e=>qo(e).length===0,Xo={Icon:Fr},Zo=y.cssPrefix;function Qo({title:e,actions:t}){return g(`header`,{class:`${Zo}-back-header`,"data-variant":`title`,children:[h(`span`,{class:`${Zo}-back-spacer`,"aria-hidden":`true`}),h(`h1`,{class:`${Zo}-back-title`,children:e}),t??h(`span`,{class:`${Zo}-back-spacer`,"aria-hidden":`true`})]})}function $o({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return g(`header`,{class:`${Zo}-back-header`,"data-testid":i,children:[h(`button`,{type:`button`,class:`${Zo}-icon-btn`,onClick:n,"aria-label":t,title:t,children:h(br,{})}),h(`h1`,{class:`${Zo}-back-title`,children:e}),r??h(`span`,{class:`${Zo}-back-spacer`,"aria-hidden":`true`})]})}function es(e,t){return e instanceof Ut&&e.status===429?t.errorRateLimited:t.errorGeneric}const ts=y.cssPrefix;function ns({placeholder:e,onActivate:t}){return g(`button`,{type:`button`,class:`${ts}-home-search`,onClick:t,"data-testid":G.homeSearch,children:[h(`span`,{class:`${ts}-home-search-text`,children:e}),h(`span`,{class:`${ts}-home-search-icon`,"aria-hidden":`true`,children:h(jr,{})})]})}function rs({placeholder:e,value:t,onInput:n}){return g(`div`,{class:`${ts}-home-search`,"data-input":`true`,children:[h(`input`,{type:`search`,class:`${ts}-home-search-input`,placeholder:e,value:t,onInput:e=>n(e.currentTarget.value),"data-testid":G.helpSearch}),h(`span`,{class:`${ts}-home-search-icon`,"aria-hidden":`true`,children:h(jr,{})})]})}const is=y.cssPrefix;function as({title:e,subtitle:t,onClick:n,testid:r}){return g(`button`,{type:`button`,class:`${is}-list-row`,onClick:n,"data-testid":r,children:[g(`span`,{class:`${is}-list-row-body`,children:[h(`span`,{class:`${is}-list-row-title`,children:e}),t?h(`span`,{class:`${is}-list-row-sub`,children:t}):null]}),h(`span`,{class:`${is}-list-row-chevron`,"aria-hidden":`true`,children:h(rr,{})})]})}const os=y.cssPrefix;function ss({tone:e=`info`,message:t,onRetry:n,strings:r}){return g(`div`,{class:`${os}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[h(`span`,{children:t}),n?h(`button`,{type:`button`,class:`${os}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const cs=y.cssPrefix,ls=M.scope(`help`),us=(e,t)=>t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title});function ds(e){let t=new Map;for(let n of e){let e=n.categories?.[0]??``;(t.get(e)??t.set(e,[]).get(e)).push(n)}return[...t.entries()]}function fs(e,t){let n=t.toLowerCase(),r=n.indexOf(e);if(r!==-1)return 100-Math.min(r,99);let i=0;for(let t of e){if(i=n.indexOf(t,i),i===-1)return 0;i+=1}return 1}function ps(e,t){let n=t.toLowerCase().trim();return n?e.map(e=>({item:e,score:Math.max(fs(n,e.title)*2,fs(n,e.description??``))})).filter(e=>e.score>0).toSorted((e,t)=>t.score-e.score).map(e=>e.item):[]}function ms({article:e,nav:t}){return h(as,{title:e.title,subtitle:e.description,onClick:()=>us(t,e),testid:Zr(G.helpArticle,e.id)})}function hs({transport:e,strings:t,config:n,nav:r,bus:a,panelProps:s}){let l=n.contentTags,[u,d]=c(`loading`),[f,p]=c(t.errorGeneric),[m,_]=c([]),[v,y]=c(``),[b,x]=c(0);i(()=>{let n=!1;return d(`loading`),e.listContent({tags:l,sortBy:`order`,limit:100}).then(e=>{if(n)return;let t=e.items??[];_(t),d(`loaded`),a.emit(`contentView`,{section:`help`,tags:l?.join(`,`),count:t.length})}).catch(e=>{n||(ls.warn(`listContent (help) failed`,{err:e}),p(es(e,t)),d(`error`))}),()=>{n=!0}},[e,l,b,a]);let S=o(()=>ps(m,v),[m,v]);i(()=>{let e=v.trim();if(!e)return;let t=setTimeout(()=>a.emit(`contentSearch`,{queryLength:e.length,hitCount:S.length}),600);return()=>clearTimeout(t)},[v,S,a]);function C(){return v.trim().length>0?S.length===0?h(ss,{message:t.helpSearchEmpty,strings:t}):h(`div`,{class:`${cs}-help-card`,children:S.map(e=>h(ms,{article:e,nav:r},e.id))}):u===`loading`?h(ss,{message:t.helpLoading,strings:t}):u===`error`?h(ss,{tone:`error`,message:f,onRetry:()=>x(e=>e+1),strings:t}):m.length===0?h(ss,{message:t.helpEmpty,strings:t}):ds(m).map(([e,t])=>g(`section`,{class:`${cs}-help-group`,children:[e?h(`h2`,{class:`${cs}-help-section-title`,children:e}):null,h(`div`,{class:`${cs}-help-card`,children:t.map(e=>h(ms,{article:e,nav:r},e.id))})]},e))}return g(`div`,{class:`${cs}-module`,children:[h(Qo,{title:t.helpTitle,actions:h(Ji,{panelProps:s,variant:`plain`})}),h(`div`,{class:`${cs}-module-pad`,children:h(rs,{placeholder:t.helpSearchPlaceholder,value:v,onInput:y})}),h(`div`,{class:`${cs}-help-list`,children:C()})]})}const gs={Icon:Er,Root:e=>h(hs,{...e})},_s=y.cssPrefix;function vs({onClick:e,children:t,testid:n}){return e?h(`button`,{type:`button`,class:`${_s}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):h(`div`,{class:`${_s}-home-card`,"data-testid":n,children:t})}const Q=y.cssPrefix,ys=M.scope(`home`);function bs(e){let t=e.options.userContext?.name,n=e.config.greetingText?E(e.strings,e.config.greetingText):void 0;return n?{title:t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),subtitle:e.strings.homeGreetingLead}:t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}const xs=(e,t)=>t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title});function Ss(e){let{transport:t,strings:n,config:r,nav:a,bus:o,panelProps:s}=e,[l,u]=c(null),[d,f]=c([]),p=r.contentTags?.join(`,`);i(()=>{if(r.showRecentConversations===!1)return;let e=!1;return t.listConversations({limit:1}).then(t=>!e&&u(t.conversations?.[0]??null)).catch(t=>!e&&ys.warn(`listConversations (home) failed`,{err:t})),()=>{e=!0}},[t,r.showRecentConversations]),i(()=>{if(!r.contentTags?.length)return;let e=!1;return t.listContent({tags:r.contentTags,limit:6}).then(t=>{if(e)return;let n=t.items??[];f(n),o.emit(`contentView`,{section:`home`,tags:p,count:n.length})}).catch(t=>!e&&ys.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,p,o]);let _=bs(e),v=r.userAvatars??[],y=r.status,b=y?.text?E(n,y.text):n.homeStatus,x=r.contentBlockTitle?E(n,r.contentBlockTitle):n.homeContentTitle;return h(`div`,{class:`${Q}-module ${Q}-home`,"data-testid":G.homeView,children:g(`div`,{class:`${Q}-home-scroll`,children:[g(`div`,{class:`${Q}-home-hero`,children:[g(`div`,{class:`${Q}-home-hero-top`,children:[r.brandName?h(`span`,{class:`${Q}-home-brand`,"data-testid":G.homeBrand,children:r.brandName}):h(`span`,{class:`${Q}-home-brand-spacer`,"aria-hidden":`true`}),g(`div`,{class:`${Q}-home-hero-actions`,children:[v.length>0?h(`div`,{class:`${Q}-home-avatars`,children:v.map(e=>h(`span`,{class:`${Q}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?h(`img`,{src:e.avatar,alt:``,loading:`lazy`}):h(`span`,{children:pi(e.name)})},e.name))}):null,h(Ji,{panelProps:s,variant:`plain`})]})]}),r.showGreeting===!1?null:g(m,{children:[h(`h1`,{class:`${Q}-home-greeting`,"data-testid":G.homeGreeting,children:_.title}),_.subtitle?h(`p`,{class:`${Q}-home-lead`,children:_.subtitle}):null]})]}),g(`div`,{class:`${Q}-home-cards`,children:[r.showSearchBar===!1?null:h(ns,{placeholder:n.homeSearchPlaceholder,onActivate:()=>a.switchToLayout(`help`)}),l?h(vs,{onClick:()=>a.selectConversation(l.conversationId),testid:G.homeRecent,children:g(`div`,{class:`${Q}-home-recent-row`,"data-unread":l.hasUnread?`true`:void 0,children:[h(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:h(Fr,{})}),g(`span`,{class:`${Q}-home-recent-body`,children:[h(`span`,{class:`${Q}-home-recent-title`,children:l.title}),l.preview?h(`span`,{class:`${Q}-home-recent-preview`,children:l.preview}):null]}),l.hasUnread?h(`span`,{class:`${Q}-home-recent-dot`,"aria-label":`Unread`}):null]})}):null,y?h(vs,{onClick:y.url?()=>a.push({kind:`iframe`,url:y.url,title:b}):void 0,children:g(`div`,{class:`${Q}-home-status`,"data-level":y.level??`operational`,children:[h(`span`,{class:`${Q}-home-status-icon`,"aria-hidden":`true`,children:h(Mr,{})}),h(`span`,{class:`${Q}-home-status-text`,children:b})]})}):null,d.length>0?g(`section`,{class:`${Q}-home-content`,children:[h(`div`,{class:`${Q}-home-content-title`,children:x}),h(`div`,{class:`${Q}-home-content-list`,children:d.map(e=>h(as,{title:e.title,subtitle:e.description,onClick:()=>xs(a,e),testid:Zr(G.homeContentRow,e.id)},e.id))})]}):null]})]})})}const Cs={Icon:Nr,Root:e=>h(Ss,{...e})},ws=y.cssPrefix,Ts=M.scope(`news`);function Es({transport:e,strings:t,config:n,nav:r,bus:a,panelProps:o}){let s=n.contentTags,[l,u]=c(`loading`),[d,f]=c(t.errorGeneric),[p,m]=c([]),[_,v]=c(0);i(()=>{let n=!1;return u(`loading`),e.listContent({tags:s,sortBy:`publishedAt`,sortOrder:`desc`}).then(e=>{if(n)return;let t=e.items??[];m(t),u(`loaded`),a.emit(`contentView`,{section:`news`,tags:s?.join(`,`),count:t.length})}).catch(e=>{n||(Ts.warn(`listContent (news) failed`,{err:e}),f(es(e,t)),u(`error`))}),()=>{n=!0}},[e,s,_,a]);function y(){return l===`loading`?h(ss,{message:t.newsLoading,strings:t}):l===`error`?h(ss,{tone:`error`,message:d,onRetry:()=>v(e=>e+1),strings:t}):p.length===0?h(ss,{message:t.newsEmpty,strings:t}):h(`div`,{class:`${ws}-news-list`,children:p.map(e=>g(`button`,{type:`button`,class:`${ws}-news-card`,onClick:()=>r.push({kind:`content`,id:e.id,title:e.title}),"data-testid":Zr(G.newsItem,e.id),children:[e.image?h(`img`,{class:`${ws}-news-hero`,src:e.image,alt:``,loading:`lazy`}):null,g(`span`,{class:`${ws}-news-body`,children:[h(`span`,{class:`${ws}-news-title`,children:e.title}),e.description?h(`span`,{class:`${ws}-news-summary`,children:e.description}):null]})]},e.id))})}return g(`div`,{class:`${ws}-module`,children:[h(Qo,{title:t.newsTitle,actions:h(Ji,{panelProps:o,variant:`plain`})}),h(`div`,{class:`${ws}-module-scroll`,children:y()})]})}const Ds={chat:Xo,home:Cs,help:gs,news:{Icon:Pr,Root:e=>h(Es,{...e})}},Os=y.cssPrefix;function ks({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return h(`nav`,{class:`${Os}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=Ds[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return g(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${Os}-tab`,onClick:()=>i(e.id),"data-testid":Zr(G.tab,e.id),children:[g(`span`,{class:`${Os}-tab-icon`,"aria-hidden":`true`,children:[h(a,{}),s?h(`span`,{class:`${Os}-tab-badge`,"data-testid":G.tabBadge,"aria-label":`Unread`}):null]}),h(`span`,{class:`${Os}-tab-label`,children:E(n,e.label)})]},e.id)})})}const As=y.cssPrefix;function js({url:e,title:t,strings:n,onBack:r,actions:i}){return g(`div`,{class:`${As}-module`,children:[h($o,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),h(`iframe`,{class:`${As}-content-frame`,src:e,title:t||`content`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads`,referrerpolicy:`no-referrer`,loading:`lazy`,allow:`fullscreen`})]})}const Ms=y.cssPrefix,Ns=M.scope(`content`);function Ps({id:e,title:t,transport:n,strings:a,bus:o,onBack:s,actions:l}){let[u,d]=c(null),[f,p]=c(!1),[m,_]=c(0),v=r(()=>{p(!1),d(null),_(e=>e+1)},[]);i(()=>{let t=!1;return n.listContent({ids:[e],limit:1}).then(n=>{if(t)return;let r=n.items[0];r?(d(r),o.emit(`contentOpen`,{contentId:e,tags:r.tags?.length?r.tags.join(`,`):void 0})):p(!0)}).catch(e=>{t||(Ns.warn(`listContent (reader) failed`,{err:e}),p(!0))}),()=>{t=!0}},[n,e,m,o]),i(()=>{if(!u)return;let t=setTimeout(()=>o.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[u,e,o]);let y=r(t=>{let n=(t.target?.closest?.(`a`))?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&o.emit(`contentLinkClick`,{contentId:e})},[o,e]);function b(){return f?h(ss,{tone:`error`,message:a.errorGeneric,onRetry:v,strings:a}):u===null?h(ss,{message:a.contentLoading,strings:a}):g(`article`,{class:`${Ms}-content`,"data-testid":G.contentView,onClick:y,children:[u.image?h(`img`,{class:`${Ms}-content-hero`,src:u.image,alt:``,loading:`lazy`}):null,u.description?h(`p`,{class:`${Ms}-content-subtitle`,children:u.description}):null,h(ha,{text:u.content??``})]})}return g(`div`,{class:`${Ms}-module`,children:[h($o,{title:u?.title||t||a.moduleBack,backLabel:a.moduleBack,onBack:s,actions:l,testid:G.backHeader}),h(`div`,{class:`${Ms}-module-scroll`,"data-testid":G.contentScroll,children:b()})]})}const Fs=y.cssPrefix;function Is({panelProps:e,enabledModules:t,nav:n,bus:a,hasUnread:o,onSelectConversation:c,onStartNewConversation:l,onSetPanelSize:u}){let d=e.options,p=d.strings,m=s(null),_=s(new Set);i(()=>{let t=m.current;if(!t)return;let n=fi(t),r=t=>{t.key===`Escape`&&e.onClose?.()};return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let v=e.composerApiRef,{visible:y}=Bi({containerRef:m,onDrop:r(e=>{v.current?.attachFromDrop(e)},[v])});ci(m.current,d.mode===`modal`);let b=f(()=>n.sig.value).value,x=Jo(b),S=d.modules.byId[b.activeTab],C=x?.kind===`iframe`||x?.kind===`content`,w=t.length>1&&(Yo(b)||!C),T=s(null);i(()=>{if(C&&T.current===null)T.current=e.panelSize,e.panelSize===`normal`&&u(`expanded`);else if(!C&&T.current!==null){let e=T.current;T.current=null,u(e)}},[C]);let E={push:n.push,pop:n.pop,switchTab:n.switchTab,switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:c,startNewConversation:l},D=t=>({options:d,transport:e.transport,strings:p,config:t,visitorId:e.visitorId,nav:E,bus:a,panelProps:e}),O=h(Ji,{panelProps:e,variant:`plain`});S&&_.current.add(S.id);let k=t.filter(e=>_.current.has(e.id)),A=t=>{if(t.layout===`chat`)return h(Eo,{...e,containerEl:m.current,dragOver:y,composerAttachApiRef:v});let n=Ds[t.layout].Root;return n?h(n,{...D(t)}):null};return g(`div`,{ref:m,class:`${Fs}-panel ${Fs}-messenger`,role:`dialog`,"aria-modal":`false`,"aria-label":p.panelTitle,style:{position:`relative`},"data-testid":G.messengerHome,children:[g(`div`,{class:`${Fs}-messenger-body`,children:[k.map(e=>h(`div`,{class:`${Fs}-messenger-pane`,hidden:C||e.id!==S?.id,children:A(e)},e.id)),x?.kind===`iframe`?h(js,{url:x.url,title:x.title,strings:p,onBack:n.pop,actions:O}):x?.kind===`content`?h(Ps,{id:x.id,title:x.title,transport:e.transport,strings:p,bus:a,onBack:n.pop,actions:O}):null]}),w?h(ks,{modules:t,activeTab:b.activeTab,strings:p,hasUnread:o,onSelect:n.switchTab}):null,h(Mo,{poweredBy:d.poweredBy}),d.size.resize?.enabled&&!(S?.layout===`chat`&&!x)?h(ai,{panelEl:m.current,resize:d.size.resize,position:d.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:p}):null]})}const Ls=y.cssPrefix;function Rs({strings:e,onClose:t}){return g(`div`,{class:`${Ls}-panel ${Ls}-modules-empty`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":G.modulesEmpty,children:[t?h(`button`,{type:`button`,class:`${Ls}-icon-btn ${Ls}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:h(Qn,{})}):null,h(`p`,{class:`${Ls}-modules-empty-text`,children:e.modulesEmpty})]})}function zs(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}const Bs=M.scope(`hitl`);function Vs(e){let t=e.partsSig.value.filter(e=>e.kind===`tool`);return t.length>0&&t.every(e=>{let t=e.stateSig.value;return t===`output-available`||t===`output-error`||t===`output-denied`||t===`approval-responded`})}function Hs(e){let{streaming:t,messagesSig:n,sendAiTurn:i,bus:a,humanInLoop:s}=e,c=r((e,r)=>{if(t)return;let a=n.value.at(-1),o=a?.partsSig.value.find(t=>t.kind===`tool`&&t.toolCallId===e);if(!a||!o){Bs.warn(`decideTool: tool part not found`,{toolCallId:e});return}r(o),a.partsSig.value=[...a.partsSig.value],Vs(a)&&(a.status=`streaming`,a.awaitingContinuation=!0,n.value=[...n.value],i({continueExisting:!0}))},[t,n,i]),l=r((e,t)=>{Bs.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e}),c(e,e=>{e.outputSig.value=t,e.stateSig.value=`output-available`})},[a,c]),u=r((e,t,n)=>{Bs.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}),c(e,r=>{let i=r.approvalSig.value?.id??e;r.approvalSig.value={id:i,approved:t,reason:n},r.stateSig.value=`approval-responded`})},[a,c]),d=r(e=>{if(t)return;let r=n.value.at(-1),i=r?.partsSig.value.find(t=>t.kind===`tool`&&t.toolCallId===e);if(!r||!i)return;let a=i.approvalSig.value?.id??e;i.approvalSig.value={id:a},i.stateSig.value=`approval-requested`,r.partsSig.value=[...r.partsSig.value]},[t,n]);return{toolInteraction:o(()=>({humanInLoop:s,onResult:l,onDecision:u,onEdit:d}),[s,l,u,d])}}function Us({callout:e,persistence:t}){let n=e?.text??``,a=e?.persistent??!0,[o,s]=c(()=>!a&&t.loadCalloutDismissed(n));return i(()=>{s(!a&&t.loadCalloutDismissed(n))},[n,a,t]),{dismissed:o,dismissCallout:r(()=>{s(!0),a||t.saveCalloutDismissed(n)},[t,n,a])}}function Ws(e){let{transport:t}=e,n=p(`ai-agent`),i=p(void 0),a=p(void 0),o=r(e=>{n.value=e.controlMode,i.value=e.assignedOperatorInitials,e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable)},[n,i,a]);return{controlModeSig:n,assignedOperatorInitialsSig:i,operatorAvailableSig:a,applyControlState:o,adoptControlStateChunk:r(e=>{e.type===`data-control-state`&&o(en(e.data))},[o]),requestOperator:r(async()=>{if(n.value!==`ai-agent`)return;let e=await t.requestOperator();e&&o(en(e))},[t,n,o]),cancelRequestOperator:r(async()=>{if(n.value!==`awaiting_operator`)return;let e=await t.cancelRequestOperator();e&&o(en(e))},[t,n,o])}}function Gs(e){let{hostElement:t,mode:n,panelSize:r,isOpen:o,setIsOpen:s}=e;a(()=>{Dt(t,Pt(n,r,o))},[t,o,r,n]),i(()=>{if(n!==`modal`||!o)return;let e=e=>{e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${y.cssPrefix}-panel`))||s(!1)};return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,o,n,s]),i(()=>{if(n!==`drawer`||!o)return;let e=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,n,s])}const Ks=M.scope(`reducer`);var qs=class{constructor(e){this.messagesSig=e,z(this,`active`,null),z(this,`openTextParts`,new Map),z(this,`partSeq`,0),z(this,`resumeIgnore`,!1)}attach(e){this.active=e,this.openTextParts.clear()}resetForReplay(e){e.partsSig.value=[],e.status=`streaming`,e.finishReason=void 0,e.errorText=void 0,e.suggestions=void 0,this.openTextParts.clear(),this.messagesSig.value=[...this.messagesSig.value]}detach(){this.active=null,this.openTextParts.clear()}applyResume(e){if(e.type===`data-control-state`||e.type===`data-conversation-rebind`)return null;if(e.type===`start`){let t=e.messageId,n=t===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===t||e.id===t),r=n!==void 0&&(n.awaitingContinuation===!0||An(n));if(n!==void 0&&!r&&On(n))return this.resumeIgnore=!0,this.detach(),null;if(this.resumeIgnore=!1,n!==void 0)return r?(n.awaitingContinuation=!1,n.status=`streaming`,this.messagesSig.value=[...this.messagesSig.value]):this.resetForReplay(n),this.attach(n),this.apply(e),null;let i=e.messageMetadata?.senderRole,a=this.messagesSig.value.at(-1);if(i===void 0&&a?.role===`assistant`&&a.status===`streaming`&&a.serverMessageId===void 0&&!En(a))return this.attach(a),this.apply(e),null;let o=mn();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.resumeIgnore||!this.active)return null;if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let e=this.active;return this.detach(),e}return null}ensureTextPart(e,t,n){let r=`${t}:${n}`,i=this.openTextParts.get(r);if(i)return i;let a={kind:t,id:`${n}#${this.partSeq++}`,textSig:d(``),doneSig:d(!1)};return this.openTextParts.set(r,a),Ys(e,a),a}apply(e){let t=this.active;if(t)switch(e.type){case`start`:{e.messageId&&(t.serverMessageId=e.messageId);let n=e.messageMetadata;n?.senderRole===`operator`?(t.role=`operator`,n.operatorInitials&&(t.operatorInitials=n.operatorInitials)):n?.senderRole===`visitor`&&(t.role=`user`);return}case`finish-step`:this.openTextParts.clear();return;case`start-step`:Ys(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`finish`:Ks.debug(`finish`,{reason:e.finishReason,canContinue:e.canContinue}),t.status=`complete`,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:Ks.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=e.errorText,this.bumpDone(t);return;case`abort`:Ks.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,this.bumpDone(t);return;case`text-start`:this.ensureTextPart(t,`text`,e.id);return;case`text-delta`:{let n=this.ensureTextPart(t,`text`,e.id);n.textSig.value+=e.delta;return}case`text-end`:this.ensureTextPart(t,`text`,e.id).doneSig.value=!0;return;case`reasoning-start`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!1;return;case`reasoning-delta`:{let n=this.ensureTextPart(t,`reasoning`,e.id);n.textSig.value+=e.delta;return}case`reasoning-end`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!0;return;case`tool-input-start`:case`tool-input-delta`:case`tool-input-available`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:Zs(t,e);return;case`file`:Ys(t,{kind:`file`,url:e.url,mediaType:e.mediaType});return;case`source-url`:Xs(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:Xs(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-notification`:return;case`data-conversation-rebind`:return;case`data-suggestions`:t.suggestions=tn(e.data);return;case`data-control-state`:t.operatorRoutedTurn=!0;return;default:}}bumpDone(e){e.partsSig.value=[...e.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function Js(e,t,n){let r=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(r)return r;let i={kind:`tool`,toolCallId:t,toolName:n??`tool`,inputPartialSig:d(``),inputSig:d(void 0),outputSig:d(void 0),errorSig:d(void 0),stateSig:d(`input-streaming`),approvalSig:d(void 0)};return Ys(e,i),i}function Ys(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Xs(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||Ys(e,t)}function Zs(e,t){switch(t.type){case`tool-input-start`:Js(e,t.toolCallId,t.toolName);return;case`tool-input-delta`:{let n=Js(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=Js(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-approval-request`:{let n=Js(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-output-available`:{let n=Js(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=Js(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=Js(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const Qs=1e3;async function $s(e){let t=Qs;for(;!e.signal.aborted;){let n,r=`held`;try{r=await e.connect(()=>{n=e.now(),e.backfill()})}catch{}if(e.signal.aborted||r===`unavailable`)return;n!==void 0&&e.now()-n>=1e3&&(t=Qs),await e.sleep(t),t=Math.min(t*2,15e3)}}const ec=M.scope(`resume-stream`);function tc(e){let{activated:t,conversationReady:n,conversationIdSig:r,messagesSig:a,streamingRef:o,optionsRef:s,isChatActiveRef:c,transport:l,visitorId:u,adoptControlStateChunk:d,settleSuggestions:f,markActiveConversationRead:p,onReplyLanded:m,setStreaming:h,setActiveCancel:g,setCanSend:_,feedback:v,bus:y,homeNav:b}=e;i(()=>{if(!t||!n||!r.value)return;let e=r.value,i=new AbortController,x=new qs(a);l.primeIdentity(u,e),ec.debug(`resume stream opened`,{conversationId:e});let S=()=>{h(!1),g(null),p(),m()},C=e=>{let t=o.current,n=s.current;if(e.canceled){t&&S(),a.value=[...a.value];return}let r=e.status===`error`;switch(Fn(e,r)){case`drop`:a.value=a.value.filter(t=>t!==e);break;case`complete-operator-routed`:e.status=`complete`,t&&(v.play(`messageReceived`),zs(y,n,`assistant`,Tn(e)));break;case`error`:if(e.status=`error`,e.errorText=n.strings.errorGeneric,t){v.play(`error`);let e=Error(r?`stream error chunk`:`empty reply`);y.emit(`error`,e),n.onError?.(e)}break;case`complete`:e.status=`complete`,t&&(v.play(`messageReceived`),zs(y,n,`assistant`,Tn(e))),f(e);break}t&&S(),a.value=[...a.value]},w=t=>{d(t);let n=a.value.length,r=x.applyResume(t);if(t.type===`finish`&&t.canContinue===!1&&_(!1),a.value.length>n){let e=s.current.modules.list.find(e=>e.layout===`chat`)?.id;e&&b?.switchTab(e)}if(r){if(r.role===`operator`){v.play(`messageReceived`),zs(y,s.current,`operator`,Tn(r)),!document.hidden&&c.current()&&l.markRead(e).catch(()=>void 0);return}C(r)}},T=async()=>{let t=await l.loadConversation(e).catch(()=>null);if(i.signal.aborted||!t?.messages?.length)return!1;let{messages:n,changed:r}=Mn(a.value,Sn(t.messages));return r&&(a.value=n),r},E=0;$s({signal:i.signal,now:()=>performance.now(),sleep:e=>zt(e,i.signal),connect:e=>l.connectResumeStream({signal:i.signal,onChunk:w,onConnected:e}),backfill:()=>{let e=performance.now();e-E<2e3||(E=e,T())}});let D=e=>e.partsSig.value.reduce((e,t)=>e+(t.kind===`text`||t.kind===`reasoning`?t.textSig.value.length:1),0),O=0,k=-1,A=setInterval(()=>{let e=a.value.at(-1);if(o.current&&e&&e.role!==`user`&&e.status!==`streaming`&&(h(!1),g(null)),!(!o.current&&e!==void 0&&e.role!==`user`&&!e.ephemeral&&(e.status===`streaming`||En(e)&&Tn(e).trim()===``))){O=0,k=-1;return}let t=D(e);if(t!==k){k=t,O=0;return}O++>=30||T().then(e=>{e&&(O=0)})},2500);return()=>{i.abort(),clearInterval(A),x.detach(),ec.debug(`resume stream closed`,{conversationId:e})}},[t,n,r,r.value,u,l,d,f,p,m,h,g,_,a,y,v,b])}const nc=M.scope(`send`);function rc(e){let{transport:t,messagesSig:n,conversationIdSig:i,options:a,bus:o,feedback:s,persistence:c,visitorId:l,adoptConversationId:u,setStreaming:d,setActiveCancel:f}=e,p=r(()=>{let e=i.value??ut();return i.value||(i.value=e,c.saveConversationId(e)),e},[i,c]);return{sendAiTurn:r(async({continueExisting:e})=>{let r=p(),m=nn({messages:Cn(n.value,e).map(wn),conversationId:r,tools:a.features.tools,visitorId:l,userPrefs:c.loadUserPrefs()});d(!0),f(()=>()=>t.cancelTurn(i.value));try{let e=await t.sendTurn(m);u(e.conversationId)}catch(t){let r=es(t,a.strings),i=n.value.at(-1);if(e&&i?.role===`assistant`)i.status=`error`,i.errorText=r,n.value=[...n.value];else{let e=mn();e.status=`error`,e.errorText=r,n.value=[...n.value,e]}d(!1),f(null),s.play(`error`),o.emit(`error`,t),a.onError?.(t)}},[t,n,i,a,o,s,c,l,u,p,d,f]),sendRoutedTurn:r(async e=>{let n=p(),r=nn({messages:[wn(e)],conversationId:n,tools:a.features.tools,visitorId:l,userPrefs:c.loadUserPrefs()});try{let e=await t.sendTurn(r);u(e.conversationId)}catch(e){nc.debug(`operator-routed send failed (non-fatal)`,{error:e});let t=e instanceof Error?e:Error(String(e));o.emit(`error`,t),a.onError?.(t)}},[t,a,o,c,l,u,p])}}const ic=M.scope(`unread`);function ac(e){let{transport:t,options:n,conversationIdSig:a,isChatActiveRef:o,activated:c,conversationReady:l}=e,u=p(!1),d=s(new Set),f=s();i(()=>()=>clearTimeout(f.current),[]);let m=r(()=>{let e=o.current()?a.value:void 0;u.value=[...d.current].some(t=>t!==e)},[u,a,o]),h=r(()=>{n.modules.list.some(e=>e.layout===`chat`)&&t.listConversations({limit:50}).then(e=>{d.current=new Set(e.conversations.filter(e=>e.hasUnread).map(e=>e.conversationId)),m()}).catch(e=>ic.debug(`refreshUnread failed (non-fatal)`,{err:e}))},[t,n.modules,m]),g=r(e=>{d.current.delete(e),m()},[m]),_=r(()=>{if(!o.current())return;let e=a.value;e&&(clearTimeout(f.current),f.current=setTimeout(()=>{g(e),t.markRead(e)},300))},[t,a,g,o]),v=s(!1);return i(()=>{!c||!l||v.current||(v.current=!0,h())},[c,l,h]),i(()=>{if(!c)return;let e=()=>{document.visibilityState===`visible`&&h()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[c,h]),{hasUnreadSig:u,refreshUnread:h,clearUnread:g,markActiveConversationRead:_}}const oc=M.scope(`settings`);function sc(e){let{options:t,persistence:n,transport:a,feedback:o,hostElement:s,bus:l}=e,u=n.loadUserPrefs(),[d,f]=c(()=>u.locale??t.locale),[p,m]=c(()=>u.themeMode??t.themeMode),[h,g]=c(()=>u.textSize??t.textSize),_=r(e=>{n.patchUserPrefs(e),a.saveUserPrefs(n.loadUserPrefs()).catch(e=>oc.warn(`saveUserPrefs failed`,{err:e}))},[n,a]);i(()=>{u.soundMuted!==void 0&&o.setMuted(u.soundMuted)},[]),i(()=>{s.dataset.theme=p},[s,p,t]),i(()=>{s.dataset.textSize=h},[s,h,t]),i(()=>{let e=!0;return o.mutedSig.subscribe(t=>{if(e){e=!1;return}_({soundMuted:t})})},[o,_]);let v=De(d,t.availableLocales,t.defaultLocale);return i(()=>{a.setLocale(v)},[a,v]),i(()=>{s.dir=T(v)?`rtl`:`ltr`},[s,v]),i(()=>{v!==d&&f(v)},[v,d]),{activeLocale:d,activeThemeMode:p,activeTextSize:h,effectiveLocale:v,setActiveLocale:f,setActiveThemeMode:m,setActiveTextSize:g,patchAndSync:_,handleLocaleChange:r(e=>{oc.info(`localeChange`,{locale:e}),f(e),_({locale:e}),l.emit(`localeChange`,e)},[_,l]),handleThemeChange:r(e=>{oc.info(`themeChange`,{mode:e}),m(e),s.dataset.theme=e,_({themeMode:e}),l.emit(`themeChange`,e)},[s,_,l]),handleTextSizeChange:r(e=>{oc.info(`textSizeChange`,{size:e}),g(e),s.dataset.textSize=e,_({textSize:e}),l.emit(`textSizeChange`,e)},[s,_,l]),handleSoundToggle:r(()=>{o.toggleMuted();let e=o.mutedSig.value;oc.info(`soundToggle`,{muted:e}),l.emit(`soundToggle`,{muted:e})},[o,l])}}const $=M.scope(`app`),cc=y.cssPrefix;function lc(e,t){return hn({...e,text:E(t,e.text)})}function uc({options:e,hostElement:t,bus:n}){let[a]=c(()=>pt(e.widgetId,e.storage,e.aiAgentDeploymentId)),[u,d]=c(()=>a.getVisitorId()),m=a.loadUserPrefs(),_=p(a.loadConversationId()),v=p([]),[y,b]=c(!1),[x,S]=c([]);function C(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=a.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function w(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function T(){let t=w();return t?e.modules.list.length===1||k.sig.value.activeTab===t:!1}let D=s(T);D.current=T;let O=s();if(!O.current){let t=e.modules.list.map(e=>e.id);O.current=Ko(C(),t,e=>a.saveActiveModule(e))}let k=O.current,[A,ee]=c(!1),[te,ne]=c(null),[j,re]=c(!1),ie=e.mode===`standalone`||e.mode===`inline`,ae=s(It(e,Lt(),a.loadPanelOpen(),a.loadPanelSize())),[oe,se]=c(ae.current.panelOpen),[ce,M]=c(ae.current.panelOpen),N=s(!1),le=s(void 0);i(()=>{oe&&M(!0)},[oe]);let ue=s(!1),[de,P]=c(!1),{dismissed:fe,dismissCallout:pe}=Us({callout:e.launcher.callout,persistence:a}),me=e.launcher.callout?.persistent??!0,he=r(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),pe()},[n,pe]),[ge,_e]=c(ae.current.panelSize),ve=s(!1),[ye,be]=c(`chat`),[xe,Se]=c(!0),[F,Ce]=c(!1),we=s(F);we.current=F;let[Te,Ee]=c(null),[De,Oe]=c([]),[ke,Ae]=c(null),je=s(e.strings),Me=s(e);Me.current=e;let[Ne,Pe]=c(void 0),[Ie,Le]=c(void 0),[ze,Be]=c(()=>a.loadSidebarCollapsed()??!1),[Ve,He]=c({}),[I]=c(()=>new un({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Rt({publicKey:e.publicKey,aiAgentDeploymentId:e.aiAgentDeploymentId,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints})),[L]=c(()=>new Yn(e.sound,e.haptics)),{activeLocale:Ue,activeThemeMode:We,activeTextSize:Ge,effectiveLocale:Ke,setActiveLocale:qe,setActiveThemeMode:Je,setActiveTextSize:Ye,patchAndSync:Xe,handleLocaleChange:Ze,handleThemeChange:Qe,handleTextSizeChange:$e,handleSoundToggle:et}=sc({options:e,persistence:a,transport:I,feedback:L,hostElement:t,bus:n}),{controlModeSig:tt,assignedOperatorInitialsSig:nt,operatorAvailableSig:rt,applyControlState:it,adoptControlStateChunk:at,requestOperator:ot,cancelRequestOperator:st}=Ws({transport:I}),{hasUnreadSig:ct,refreshUnread:lt,clearUnread:dt,markActiveConversationRead:ft}=ac({transport:I,options:e,conversationIdSig:_,isChatActiveRef:D,activated:ce,conversationReady:A});i(()=>{L.update(e.sound,e.haptics)},[L,e.sound,e.haptics]),i(()=>()=>L.destroy(),[L]),i(()=>{ve.current||!e.size.initialSize||(ve.current=!0,!a.loadPanelSize()&&_e(Ft(e.mode,e.size,Lt())))},[e.mode,e.size,a]),i(()=>{if(!A||ue.current)return;ue.current=!0;let t=It(e,Lt(),a.loadPanelOpen(),a.loadPanelSize());se(t.panelOpen),_e(t.panelSize)},[A,e,a]);let mt=s(!1),ht=s(null);i(()=>{!A||mt.current||(mt.current=!0,k.reset(C()))},[A]);let gt=r(e=>{!e||e.length===0||(v.value=e.map(e=>lc(e,je.current)))},[v]),_t=s(null),vt=r(async e=>{try{let{formSubmissions:t}=await(e?I.bootstrap(e):_t.current??I.bootstrap()),n=new Map;return t.forEach((e,t)=>n.set(e.formId,t)),t.filter((e,t)=>!e.skipped||n.get(e.formId)===t).map((e,t)=>({key:`wire:${e.formId}:${e.createdAt??t}`,formId:e.formId,outcome:e.skipped?`skipped`:`submitted`,createdAt:Zt(e.createdAt),values:e.values}))}catch(e){return $.debug(`bootstrap failed — no form markers (non-fatal)`,{err:e}),[]}},[I]),yt=s(0),bt=r((e,t)=>{let n=[...e.map(e=>e.createdAt),...t.map(e=>e.createdAt)].filter(e=>e!==void 0),r=(n.length?Math.min(...n):Date.now())-1;return[...(le.current?.messages??[]).map(e=>{let t=lc(e,je.current);return t.createdAt=r,t}),...e]},[]),xt=r(async e=>{let t=yt.current,n=()=>t!==yt.current;b(!0);try{let[t,r]=await Promise.all([I.loadConversation(e),vt()]);if(n())return;let i=Sn(t.messages??[]);if(S(r),v.value=bt(jn(i,v.value),r),i.length){Se(t.canContinue??!0),it(en(t.controlState));let e=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);Oe(e?.suggestions??t.suggestions??[])}}catch(t){if(n())return;$.warn(`loadThread failed; resetting conversationId`,{err:t,conversationId:e}),_.value=void 0,a.saveConversationId(void 0)}finally{n()||b(!1)}},[I,vt,v,_,a,bt]),St=r(async({newConversation:t})=>{let r=++yt.current,i=()=>r!==yt.current,o=_.value,s=t||!o?ut():o;s!==o&&(_.value=s,a.saveConversationId(s));let c;try{c=await I.handshake({visitorId:u,conversationId:s,userPrefs:a.loadUserPrefs(),locale:Ue})}catch(r){if(i())return;n.emit(`error`,r),e.onError?.(r),t||ee(!0);return}if(!i()){if(c.visitorId&&c.visitorId!==u&&($.info(`visitor rebound`,{previous:u,current:c.visitorId,reason:c.rebind?.visitorId}),a.setVisitorId(c.visitorId),d(c.visitorId),n.emit(`visitorRebound`,{previous:u,current:c.visitorId,reason:c.rebind?.visitorId})),c.conversationId&&c.conversationId!==s&&($.info(`conversation rebound`,{previous:s,current:c.conversationId,reason:c.rebind?.conversationId}),n.emit(`conversationRebound`,{previous:s,current:c.conversationId,reason:c.rebind?.conversationId})),c.agent&&Ee(c.agent),it(en(c.controlState)),e.mode===`page`&&(c.site&&At(c.site)?Pe(c.site):c.site&&$.warn(`invalid site config, using fallback`,{site:c.site}),c.blocks&&jt(c.blocks)?Le(c.blocks):c.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:c.blocks})),c.userPrefs&&!t&&(a.saveUserPrefs(c.userPrefs),c.userPrefs.locale&&qe(c.userPrefs.locale),c.userPrefs.soundMuted!==void 0&&L.setMuted(c.userPrefs.soundMuted),c.userPrefs.themeMode&&Je(c.userPrefs.themeMode),c.userPrefs.textSize&&Ye(c.userPrefs.textSize)),le.current=c.welcome,t||n.emit(`handshake`,c),c.welcome?.suggestions){let e=je.current;Oe(c.welcome.suggestions.map(t=>({...t,label:E(e,t.label),...t.text===void 0?{}:{text:E(e,t.text)}})))}!t&&o&&c.conversationId===o?N.current=!0:(_.value=c.conversationId,a.saveConversationId(c.conversationId),gt(c.welcome?.messages)),t||ee(!0)}},[I,u,a,e,n,_,L,gt,xt,Ue]),Ct=JSON.stringify(e.userContext??null);i(()=>{let t=Object.keys(Ve).length?{...Ve,...e.userContext}:e.userContext;I.setContext(t,dc(e.pageContext))},[I,Ct,JSON.stringify(e.pageContext??null),JSON.stringify(Ve)]);let wt=r((e,t=[])=>Oe(e.suggestions??t),[]),Tt=r(e=>{if(!e||e===_.value)return;let t=_.value;_.value=e,a.saveConversationId(e),I.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e,reason:e})},[_,a,I,n]);i(()=>(I.primeIdentity(u,_.value),St({newConversation:!1}),()=>{yt.current++}),[]);let Et=s(!1);i(()=>{if(!(!ce||!A||Et.current)&&(Et.current=!0,_t.current=I.bootstrap(),(async()=>{try{let e=await _t.current;ne(Fe((e??{forms:[]}).forms,Ke))}catch(e){$.debug(`bootstrap failed — treating as no forms`,{err:e})}finally{re(!0)}})(),N.current)){N.current=!1;let e=_.value;e&&xt(e)}},[ce,A]);let Dt=s(null);i(()=>{if(!ce||!A)return;if(Dt.current===null){Dt.current=Ke;return}if(Dt.current===Ke)return;Dt.current=Ke;let e=!1;return I.bootstrap().then(t=>{e||ne(Fe((t??{forms:[]}).forms,Ke))}).catch(e=>$.debug(`forms re-localize failed — keeping current copy`,{err:e})),()=>{e=!0}},[ce,A,Ke,I]);let Ot=s(Ct);i(()=>{!A||Ot.current===Ct||(Ot.current=Ct,St({newConversation:!1}))},[Ct,A,St]);let kt=s(()=>{});tc({activated:ce,conversationReady:A,conversationIdSig:_,messagesSig:v,streamingRef:we,optionsRef:Me,isChatActiveRef:D,transport:I,visitorId:u,adoptControlStateChunk:at,settleSuggestions:wt,markActiveConversationRead:ft,onReplyLanded:r(()=>kt.current(),[]),setStreaming:Ce,setActiveCancel:Ae,setCanSend:Se,feedback:L,bus:n,homeNav:k}),Gs({hostElement:t,mode:e.mode,panelSize:ge,isOpen:oe,setIsOpen:se});let{sendAiTurn:Mt,sendRoutedTurn:Pt}=rc({transport:I,messagesSig:v,conversationIdSig:_,options:e,bus:n,feedback:L,persistence:a,visitorId:u,adoptConversationId:Tt,setStreaming:Ce,setActiveCancel:Ae}),{toolInteraction:zt}=Hs({streaming:F,messagesSig:v,sendAiTurn:Mt,bus:n,humanInLoop:e.features.humanInLoop}),Bt=r((e,t)=>{$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),I.submitFeedback({messageId:e,value:t})},[n,I]),Vt=()=>v.value.reduce((e,t)=>e+ +(t.role===`user`),0),Ht=e.forms.list.length>0?e.forms:te??e.forms,R=Po({forms:Ht,persistence:a,userContext:()=>e.userContext,messageCount:Vt,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>_.value,onComplete:(e,t,r,i)=>{$.info(`formSubmit`,{formId:e.id,trigger:t,skipped:i}),n.emit(`formSubmit`,{formId:e.id,values:r,skipped:i}),S(t=>{let n=t.find(t=>t.formId===e.id&&t.outcome===`skipped`)?.createdAt??Date.now();return[...t.filter(t=>!(t.formId===e.id&&t.outcome===`skipped`)),{key:`local:${e.id}:${n}`,formId:e.id,outcome:i?`skipped`:`submitted`,createdAt:n,...i?{}:{values:r}}]});let o=_.value??ut();_.value||(_.value=o,a.saveConversationId(o),I.primeIdentity(void 0,o)),!i&&e.mirrorToContext&&He(e=>({...e,...r})),I.submitForm({formId:e.id,conversationId:o,trigger:t,values:r,skipped:i})}}),z=f(()=>R.activeForm.value);kt.current=()=>R.fire(`after-messages`),i(()=>{R.refresh()},[Ht,R]);let Ut=e.pageContext?.area?String(e.pageContext.area):void 0,Wt=f(()=>v.value.length);i(()=>{A&&j&&R.fire(`pre-chat`)},[A,j,R]),i(()=>{j&&!xe&&R.fire(`conversation-closed`)},[j,xe,R]),i(()=>{A&&j&&Ut&&R.fire(`page-area`)},[A,j,Ut,R]);let Gt=o(()=>{let e=Ht.list.flatMap(e=>e.triggers).filter(e=>e.kind===`idle`).map(e=>Number(e.param));return e.length?Math.min(...e)*1e3:0},[Ht]);i(()=>{if(!Gt||!oe)return;let e=setTimeout(()=>R.fire(`idle`),Gt);return()=>clearTimeout(e)},[Gt,oe,R,Wt.value]);let Kt=r(async(t,r)=>{let i=tt.value!==`ai-agent`;if($.info(`send`,{textLen:t.length,attachments:r.length,streaming:F,routedToOperator:i}),F&&!i)return;n.emit(`send`,{text:t,attachmentCount:r.length}),De.length>0&&Oe([]);let a=await pc(I,r,t=>{$.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t)});L.unlock(),L.play(`messageSent`);let o=pn(t,a);if(zs(n,e,`user`,t),i){v.value=[...v.value,o],Pt(o);return}v.value=[...v.value,o,mn()],Mt({continueExisting:!1})},[F,I,n,e,De.length,v,Mt,Pt,tt]),qt=r(()=>{$.info(`stop`),n.emit(`stop`,void 0);let e=v.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,v.value=[...v.value]),ke?.()},[ke,n,v]),Jt=r(()=>{if(F)return;let e=v.value,t=e.at(-1);!t||t.role!==`assistant`||t.status!==`error`&&!Nn(t)||(v.value=[...e.slice(0,-1),mn()],$.info(`retry`),Mt({continueExisting:!1}))},[F,v,Mt]),Yt=r(()=>{if(di(e.mode,ge)===`exit-fullscreen`){$.info(`close → exit-fullscreen`,{mode:e.mode}),_e(`normal`),n.emit(`fullscreen`,!1);return}$.info(`close → panel closed`,{mode:e.mode}),R.fire(`panel-close`),se(!1),a.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.()},[n,e,a,ge,R]),Xt=r(()=>{$.info(`open`,{mode:e.mode}),L.unlock(),P(!0),se(!0),a.savePanelOpen(!0),!fe&&!me&&he(),setTimeout(()=>P(!1),fc),lt(),n.emit(`open`,void 0),e.onOpen?.()},[n,e,L,a,fe,me,he,lt]),Qt=r(()=>{if(!v.value.some(e=>e.role===`user`)&&xe&&_.value){$.info(`clear → reusing empty conversation`,{conversationId:_.value}),v.value.length===0&>(le.current?.messages);return}$.info(`clear → new conversation`,{wasStreaming:F}),n.emit(`clear`,void 0),F&&Ce(!1),l(()=>{v.value=[],_.value=void 0}),a.clearConversation(),Se(!0),S([]),St({newConversation:!0})},[F,v,_,a,St,n,xe,gt]),$t=r(()=>{Qt(),be(`chat`);let t=e.modules.list.find(e=>e.layout===`chat`)?.id;t&&k.switchTab(t)},[Qt,k,e]),B=r(()=>{let e=ge===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:ge,expanded:e===`expanded`}),_e(e),a.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,ge,a]),tn=r(()=>{let e=ge===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:ge,fullscreen:e===`fullscreen`}),_e(e),a.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,ge,a]),nn=r(()=>{be(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),rn=r(()=>{Be(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),a.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[a,n]),an=r(e=>{$.info(`resize`,e),Xe({widgetSize:e}),n.emit(`resize`,e)},[Xe,n]),on=r(async t=>{$.info(`selectConversation`,{conversationId:t,wasStreaming:F}),n.emit(`selectConversation`,{conversationId:t}),F&&Ce(!1);try{let[e,n]=await Promise.all([I.loadConversation(t),vt(t)]),r=Sn(e.messages);l(()=>{v.value=bt(r,n),_.value=e.conversationId}),S(n),a.saveConversationId(e.conversationId),I.primeIdentity(u,e.conversationId),e.agent&&Ee(e.agent),Se(e.canContinue),it(en(e.controlState));let i=r.findLast(e=>e.role===`assistant`&&!e.ephemeral);Oe(i?.suggestions??e.suggestions??[]),be(`chat`),await I.markRead(t),dt(t)}catch(t){n.emit(`error`,t),e.onError?.(t)}},[I,v,_,n,e,a,dt,vt,bt,F,u]),V=s(null),sn=r(e=>{typeof e==`string`&&(j?R.fire(`manual`,e):V.current=e)},[j,R]);i(()=>{!j||!V.current||(R.fire(`manual`,V.current),V.current=null)},[j,R]),i(()=>Nt(t,{open:Xt,close:Yt,expand:B,fullscreen:tn,openForm:sn}),[t,Xt,Yt,B,tn,sn]);let H=o(()=>Re(e,Ue,We,Ge),[e,Ue,We,Ge]);je.current=H.strings;let cn=o(()=>x.map(e=>{let t=Ht.list.find(t=>t.id===e.formId);return{...e,title:t?.title,form:t}}),[x,Ht]),ln={options:H,transport:I,feedback:L,bus:n,persistence:a,composerApiRef:ht,view:ye,canSend:xe,isStreaming:F,controlMode:tt.value,assignedOperatorInitials:nt.value,operatorAvailable:rt.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:ot,onCancelRequest:st,loadingMessages:y,messagesSig:v,agent:Te,suggestions:De,initialWidgetSize:m.widgetSize??null,visitorId:u,onClose:Yt,onClear:Qt,onExpand:B,onFullscreen:tn,onSoundToggle:et,onToggleHistory:nn,onSelectHistoryConversation:on,onNewConversation:$t,onLocaleChange:Ze,onThemeChange:Qe,onTextSizeChange:$e,onWidgetSizeChange:an,onSend:Kt,onStop:qt,onSuggestion:t=>{let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?Kt(r,[]):ht.current?.fill(r)},activeForm:z.value?.form??null,formMarkers:cn,onFormSubmit:R.complete,onFormSkip:R.skip,onFormFill:e=>R.fire(`manual`,e),tool:zt,onRetry:Jt,onMessageFeedback:Bt},dn=e=>{on(e);let t=w();t&&k.switchTab(t)};if(!A)return null;let fn=H.modules.list,hn=e=>{let t=li(`close`,H.mode,e);return fn.length===0?h(Rs,{strings:H.strings,onClose:t?Yt:void 0}):fn.length===1&&fn[0]?.layout===`chat`?h(To,{...ln,panelSize:e}):h(Is,{panelProps:{...ln,panelSize:e,onClose:t?Yt:void 0},enabledModules:fn,nav:k,bus:n,hasUnread:ct.value,onSelectConversation:dn,onStartNewConversation:$t,onSetPanelSize:_e})};if(e.mode===`page`){let e=e=>{on(e.conversationId)},t=fn.some(e=>e.layout===`chat`);return h(`div`,{class:`${cc}-anchor`,children:h(Wo,{site:Ne,blocks:Ie,transport:I,strings:H.strings,locale:H.locale,persistence:a,visitorId:u,showConversations:t,onSelectConversation:e,onNewConversation:$t,sidebarCollapsed:ze,onToggleSidebarCollapsed:rn,children:hn(`fullscreen`)})})}if(ie){let t=e.mode===`standalone`?`fullscreen`:ge;return h(`div`,{class:`${cc}-anchor`,children:hn(t)})}let gn=e.mode===`drawer`,_n=e.mode!==`modal`&&!e.launcher.hidden&&(!oe||de),vn=_n&&!de&&!fe&&!gn?H.launcher.callout:null;return g(`div`,{class:`${cc}-anchor`,"data-launcher-size":H.launcher.size,children:[oe||ce?h(`div`,{class:`${cc}-surface`,hidden:!oe,children:hn(ge)}):null,_n?h($r,{onToggle:Xt,launcher:H.launcher,strings:H.strings,leaving:de,edgeTab:gn}):null,vn?h(ri,{callout:vn,launcherPosition:H.position,strings:H.strings,closeLabel:H.strings.close,onDismiss:he}):null]})}function dc(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(!(!e&&!t))return{...e,...t?{url:t}:{}}}const fc=120;async function pc(e,t,n){let r=[];for(let i of t)try{let{id:t,url:n}=await e.uploadFile(i.file);r.push({id:t,name:i.name,mediaType:i.mediaType,size:i.size,url:n})}catch(e){n(e)}return r}const mc=M.scope(`error-boundary`);var hc=class extends e{constructor(...e){super(...e),z(this,`state`,{crashed:!1})}componentDidCatch(e,t){mc.error(`widget render crashed`,{error:e,componentStack:t?.componentStack}),this.setState({crashed:!0}),this.props.onError(e,t?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};const gc={open:()=>void 0,close:()=>void 0,expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>void 0,clear:()=>void 0,suggestion:()=>void 0,toggleHistory:e=>({view:e.view}),handshake:()=>void 0,formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,tags:e.tags,count:e.count}),contentOpen:e=>({contentId:e.contentId,tags:e.tags}),contentSearch:e=>({qlen:e.queryLength,hits:e.hitCount}),contentRead:e=>({contentId:e.contentId}),contentLinkClick:e=>({contentId:e.contentId}),attach:e=>({count:e.count,bytes:e.totalBytes}),voiceStart:()=>void 0,voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>void 0,localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>void 0,error:()=>void 0};function _c(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function vc(){return location.origin+location.pathname}function yc(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function bc(e,t){let n=Math.random(),r=0,i=0,a=new Set,o=(e,o)=>{let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||_c()||n>=s.sampleRate)return;let f=performance.now();if(f-r>6e4&&(r=f,i=0),++i>60)return;let p=new URLSearchParams;p.set(`v`,`1`),p.set(`_ev`,Bt),p.set(`e`,e),s.token&&p.set(`tk`,s.token),c&&p.set(`pk`,c),l&&p.set(`dep`,l),p.set(`vid`,t.getVisitorId());let m=t.getConversationId();m&&p.set(`cid`,m),p.set(`url`,vc());let h=yc();h&&p.set(`ref`,h),p.set(`sw`,String(screen.width)),p.set(`sh`,String(screen.height)),p.set(`vw`,String(innerWidth)),p.set(`vh`,String(innerHeight)),p.set(`dpr`,String(devicePixelRatio)),p.set(`lang`,navigator.language);try{p.set(`tz`,Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(p.set(`m`,u),p.set(`th`,d),o)for(let[e,t]of Object.entries(o))t!==void 0&&p.set(e,String(t));p.set(`ts`,String(Date.now()));let g=`${s.endpoint}?${p}`;if(g.length>2e3)return;let _=new Image(1,1);a.add(_);let v=()=>a.delete(_);_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g},s=Object.keys(gc).map(t=>e.on(t,e=>o(t,gc[t]?.(e))));return()=>{for(let e of s)e();a.clear()}}function xc(e){let{bus:r,host:i,appRoot:a,persistence:o,reportError:s}=e,c=e.initialRaw,l,u=we(c),d=!0,f=()=>{u=we(l?Be(c,l):c)},p=()=>{yt(i,bt(u.mode));let e=o.loadUserPrefs().themeMode;Ot(i,e?{...u,themeMode:e}:u),d&&(Dt(i,Sc(u)),d=!1)},m=()=>{p(),n(t(hc,{onError:s},t(uc,{bus:r,hostElement:i,options:u})),a)};r.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&o.rememberStorageVersion(e.config.storageVersion),l=e.config,f(),m())});let h=bc(r,{getOptions:()=>u,getVisitorId:()=>o.getVisitorId(),getConversationId:()=>o.loadConversationId()});return{getOptions:()=>u,getUserOptions:()=>c,render:m,setUserOptions:e=>{c=e,f(),m()},patchUserOptions:e=>{c={...c,...e},f(),m()},destroy:()=>h()}}function Sc(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=pt(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=It(e,Lt(),t.loadPanelOpen(),t.loadPanelSize());return Pt(e.mode,r,n)}var Cc=class{constructor(){z(this,`handlers`,new Map)}on(e,t){let n=this.handlers.get(e);return n||(n=new Set,this.handlers.set(e,n)),n.add(t),()=>this.handlers.get(e)?.delete(t)}emit(e,t){let n=this.handlers.get(e);if(n)for(let e of n)try{e(t)}catch{}}clear(){this.handlers.clear()}},wc=class extends HTMLElement{constructor(...e){super(...e),z(this,`bus`,new Cc),z(this,`mountResult`,null),z(this,`runtime`,null)}static get observedAttributes(){return at}connectedCallback(){this.boot()}disconnectedCallback(){this.mountResult&&(this.runtime?.destroy(),this.runtime=null,n(null,this.mountResult.appRoot),this.bus.clear())}attributeChangedCallback(){this.isConnected&&this.boot()}boot(){let e=ot(e=>this.getAttribute(e));if(this.runtime){this.runtime.setUserOptions(e);return}let t=we(e);this.mountResult||(this.mountResult=xt({existingHost:this,position:bt(t.mode)}));let n=pt(t.widgetId,t.storage,t.aiAgentDeploymentId);this.runtime=xc({bus:this.bus,host:this.mountResult.hostElement,appRoot:this.mountResult.appRoot,persistence:n,initialRaw:e,reportError:e=>this.bus.emit(`error`,e)}),this.runtime.render()}};let Tc=!1;function Ec(){if(Tc||typeof customElements>`u`)return;let e=y.tagName;customElements.get(e)||customElements.define(e,wc),Tc=!0}typeof customElements<`u`&&Ec();export{Ec as registerWebComponent};
|
|
12
|
+
`).trim(),k=!x&&e.status!==`error`&&!m.value&&O.length>0,A=D||k;return h(`div`,{class:`${X}-bubble-row`,"data-role":e.role,"data-testid":ti(G.messageBubble,e.serverMessageId??e.id),children:g(`div`,{class:`${X}-bubble-col`,children:[g(`div`,{class:`${X}-bubble`,children:[e.role===`operator`&&e.operatorInitials?h(`span`,{class:`${X}-bubble-author`,children:e.operatorInitials}):null,g(`div`,{class:`${X}-bubble-body`,children:[S?h(po,{label:t.loading}):p.map((e,n)=>h(so,{part:e,active:C,live:x,strings:t,showReasoning:r,showToolCalls:i,showSources:a,interactive:o&&(e.kind!==`tool`||n>b.value),superseded:s,tool:c},`${uo(e)}#${n}`)),w&&h(fo,{}),e.status===`error`&&e.errorText||m.value?g(`div`,{class:`${X}-error`,role:`alert`,children:[h(`span`,{children:e.errorText??t.errorGeneric}),l?h(`button`,{type:`button`,class:`${X}-error-retry`,onClick:l,"data-testid":G.messageRetry,children:t.errorRetry}):null]}):null]})]}),T||A?g(`div`,{class:`${X}-bubble-meta`,children:[T?h(`time`,{class:`${X}-bubble-time`,dateTime:T.iso,title:T.full,children:T.short}):null,A?g(`div`,{class:`${X}-bubble-actions`,children:[D&&e.serverMessageId?h(Sa,{messageId:e.serverMessageId,initial:e.feedback??null,strings:t,onFeedback:d}):null,k?h(ao,{text:O,strings:t}):null]}):null]}):null]})})}function ao({text:e,strings:t}){let[n,r]=c(!1),i=()=>{navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})},a=n?t.copied:t.copy;return h(`button`,{type:`button`,class:`${X}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":G.messageCopy,children:h(n?xr:qr,{})})}function oo(e){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let t=new Date(e);return{short:t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}),full:t.toLocaleString(void 0,{dateStyle:`full`,timeStyle:`short`}),iso:t.toISOString()}}catch{return null}}function so({part:e,active:t,live:n,strings:r,showReasoning:i,showToolCalls:a,showSources:o,interactive:s,superseded:c,tool:l}){switch(e.kind){case`step-start`:return null;case`text`:return h(va,{textSig:e.textSig,doneSig:e.doneSig});case`reasoning`:return i?h(lo,{part:e,active:t,strings:r}):null;case`tool`:return h(co,{part:e,strings:r,showToolCalls:a,interactive:s,superseded:c,live:n,tool:l});case`file`:return e.mediaType.startsWith(`image/`)?h(`img`,{src:e.url,alt:``,loading:`lazy`}):h(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,children:e.url});case`source`:return o?h(wa,{part:e,strings:r}):null}}function co({part:e,strings:t,showToolCalls:n,interactive:r,superseded:i,live:a,tool:o}){let s=f(()=>e.approvalSig.value!==void 0);if(o?.humanInLoop){if(_a(e.toolName))return h(Ja,{part:e,strings:t,active:r,superseded:i,onDecision:o.onDecision,onEdit:o.onEdit});if(s.value)return h(za,{part:e,strings:t,active:r,superseded:i,onDecision:o.onDecision,onEdit:o.onEdit})}return n?h(no,{part:e,strings:t,live:a}):null}function lo({part:e,active:t,strings:n}){return g(`details`,{class:`${X}-reasoning`,open:t,"data-active":t?`true`:void 0,children:[h(`summary`,{class:`${X}-reasoning-summary`,children:h(`span`,{class:`${X}-reasoning-label`,children:t?n.thinking:n.thoughts})}),h(`div`,{class:`${X}-reasoning-body`,children:h(va,{textSig:e.textSig,doneSig:e.doneSig})})]})}function uo(e){switch(e.kind){case`text`:case`reasoning`:case`step-start`:return`${e.kind}:${e.id}`;case`tool`:return`tool:${e.toolCallId}`;case`file`:return`file:${e.url}`;case`source`:return`source:${e.sourceId}`}}function fo(){return g(`span`,{class:`${X}-typing`,"aria-hidden":`true`,children:[h(`span`,{}),h(`span`,{}),h(`span`,{})]})}function po({label:e}){return g(`span`,{class:`${X}-loading`,role:`status`,children:[h(`span`,{class:`${X}-loading-spinner`,"aria-hidden":`true`}),h(`span`,{class:`${X}-loading-label`,children:e})]})}const mo=y.cssPrefix;function ho({messagesSig:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:o,showSources:l,enableMessageFeedback:u,onFeedback:d,loading:p,idle:m,tool:_,onRetry:v,form:y,formMarkers:b,onFillForm:x}){let S=s(null),C=f(()=>e.value),[w,T]=c(!1),E=s(!1),D=s(!1),O=s(!1),k=s(0),A=()=>O.current||performance.now()-k.current<350,ee=s(0),te=e=>{let t=e.scrollHeight-e.clientHeight>1;e.dataset.fadeTop=t&&e.scrollTop>1?`true`:`false`,e.dataset.fadeBottom=t&&e.scrollHeight-e.scrollTop-e.clientHeight>1?`true`:`false`},ne=e=>T(e.scrollHeight-e.scrollTop-e.clientHeight>240),j=e=>{ee.current=performance.now(),e.scrollTop=e.scrollHeight,te(e)},re=(e,t)=>{j(e);let n=t,r=0,i=()=>{j(e),--n>0&&(r=requestAnimationFrame(i))};return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)},ie=(e,t)=>{let n,r,i,a=-1,o=()=>{n.disconnect(),r.disconnect(),clearTimeout(i)},s=()=>{if(D.current||A()||a>=0&&e.scrollTop<a-4)return o();j(e),a=e.scrollTop};return n=new ResizeObserver(s),r=new MutationObserver(s),s(),n.observe(e),r.observe(e,{childList:!0,subtree:!0,characterData:!0}),i=setTimeout(o,t),o},ae=C.value[0]?.id;a(()=>{let e=S.current;if(e&&C.value.length!==0&&(E.current=!0,C.value.some(e=>e.role===`user`)))return ie(e,300)},[ae]);let oe=s(0);i(()=>{let e=S.current,t=C.value,n=oe.current;if(oe.current=t.length,e&&E.current){if(t.slice(n).some(e=>e.role===`user`))return D.current=!1,re(e,3);t.some(e=>e.role===`user`)&&(D.current||A()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&j(e))}},[C.value.length]);let se=s(null);i(()=>{let e=S.current,t=C.value.at(-1),n=se.current;if(se.current=t?.id??null,e&&E.current&&!(!t||t.id!==n||t.status!==`streaming`))return D.current=!1,re(e,3)},[C.value]),i(()=>{let e=S.current;if(!e)return;let t=C.value.at(-1);if(!t||t.status!==`streaming`&&!C.value.some(e=>e.role===`user`))return;let n=()=>{D.current||A()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&j(e)};if(t.status!==`streaming`)return ie(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[C.value]);let M=y?.form.id,N=!!y&&(b??[]).some(e=>e.formId===y.form.id);a(()=>{let e=S.current;!e||!M||D.current||C.value.some(e=>e.role===`user`)&&(N?e.querySelector(`[data-testid="${G.formGate}"]`)?.scrollIntoView({block:`nearest`}):j(e))},[M,N]),i(()=>{let e=S.current;if(!e)return;let t=()=>{ne(e),te(e),performance.now()-ee.current>150&&(D.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)},n=()=>{D.current=!0},r=e=>{e.deltaY<0&&n()},i=0,a=e=>{i=e.touches[0]?.clientY??0,O.current=!0},o=e=>{(e.touches[0]?.clientY??0)>i+4&&n()},s=()=>{O.current=!1,k.current=performance.now()},c=()=>{O.current=!0};return e.addEventListener(`scroll`,t,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),e.addEventListener(`pointerdown`,c,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),ne(e),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s),e.removeEventListener(`pointerdown`,c),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[]);let ce=()=>{let e=S.current;e&&(D.current=!1,j(e))},le=[],ue=``,de=C.value.at(-1)?.id,P=[...b??[]].toSorted((e,t)=>(e.createdAt??1/0)-(t.createdAt??1/0)),fe=e=>y&&e.formId===y.form.id?h(ha,{form:y.form,strings:t,onSubmit:y.onSubmit,onSkip:y.onSkip},`gate:${e.formId}`):h(ga,{marker:e,strings:t,onFill:!y&&x?()=>x(e.formId):void 0},e.key),pe=e=>{for(let t=P[0];t?.createdAt!==void 0&&!(e!==void 0&&t.createdAt>e);t=P[0])P.shift(),le.push(fe(t))};for(let e of C.value){if(e.role===`assistant`&&e.id!==de&&Ln(e))continue;pe(e.createdAt);let i=go(e.createdAt);i&&i!==ue&&(le.push(h(`div`,{class:`${mo}-date-divider`,children:h(`span`,{class:`${mo}-date-pill`,title:_o(e.createdAt),children:vo(e.createdAt,t)})},`day:${i}`)),ue=i),le.push(h(ro,{message:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:o,showSources:l,interactive:!!m&&e.id===de,superseded:e.id!==de,tool:_,onRetry:m&&e.id===de?v:void 0,enableMessageFeedback:u,onFeedback:d},e.id))}for(let e of P)le.push(fe(e));return g(`div`,{class:`${mo}-list-wrap`,children:[g(`div`,{ref:S,class:`${mo}-list ${mo}-list--fade`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[p&&C.value.length===0?h(`div`,{class:`${mo}-list-loading`,role:`status`,children:t.conversationLoading}):null,le,y&&!N?h(ha,{form:y.form,strings:t,onSubmit:y.onSubmit,onSkip:y.onSkip}):null]}),w?h(`button`,{type:`button`,class:`${mo}-jump`,onClick:ce,"aria-label":t.scrollToBottom,title:t.scrollToBottom,"data-testid":G.scrollToBottom,children:h(Er,{})}):null]})}function go(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function _o(e){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(void 0,{dateStyle:`full`})}catch{return``}}function vo(e,t){let n=new Date(e),r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),i=Math.round((r(new Date)-r(n))/864e5);return i<=0?t.dateToday:i===1?t.dateYesterday:i<7?n.toLocaleDateString(void 0,{weekday:`long`}):n.toLocaleDateString(void 0,{month:`long`,day:`numeric`,year:`numeric`})}const yo=[`today`,`yesterday`,`lastWeek`,`older`];function bo(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.floor((So(e)-So(n))/(1440*60*1e3));return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function xo(e,t){let n=new Map;for(let r of t){let t=bo(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return yo.filter(e=>n.has(e)).map(e=>({bucket:e,conversations:n.get(e)}))}function So(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}const Co=N.scope(`history`),wo={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function To(e,t,n){let r=Date.parse(e);return Number.isFinite(r)?new Date(r).toDateString()===new Date(t).toDateString()?new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(r):t-r<10080*60*1e3?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function Eo({transport:e,strings:t,locale:n,persistence:r,visitorId:a,onSelect:o,onNewConversation:s}){let l=y.cssPrefix,u=e.peekConversations({visitorId:a}),[d,f]=c(u?`loaded`:`loading`),[p,_]=c(u?.conversations??[]);i(()=>{let t=!1;return e.listConversations({visitorId:a}).then(e=>{if(t)return;let n=e.conversations??[];_(n),f(`loaded`),r.saveHistoryCount(n.length)}).catch(e=>{t||(Co.warn(`listConversations failed`,{err:e}),f(`error`))}),()=>{t=!0}},[e,a,r]);let v=s?h(`div`,{class:`${l}-history-footer`,children:g(`button`,{type:`button`,class:`${l}-history-new`,onClick:s,"data-testid":G.sidebarNewConversation,children:[h(rr,{}),t.newConversation]})}):null;if(d===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return g(m,{children:[h(`div`,{class:`${l}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:g(`div`,{class:`${l}-history-group`,"aria-hidden":`true`,children:[h(`div`,{class:`${l}-history-heading`,children:h(`span`,{class:`${l}-skeleton ${l}-skeleton-heading`})}),h(`div`,{class:`${l}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>g(`div`,{class:`${l}-history-item ${l}-history-item-skeleton`,children:[h(`span`,{class:`${l}-history-avatar ${l}-skeleton`}),g(`span`,{class:`${l}-history-body`,children:[g(`span`,{class:`${l}-history-row`,children:[h(`span`,{class:`${l}-history-title`,children:h(`span`,{class:`${l}-skeleton ${l}-skeleton-title`})}),h(`span`,{class:`${l}-history-time`,children:h(`span`,{class:`${l}-skeleton ${l}-skeleton-time`})})]}),h(`span`,{class:`${l}-history-row`,children:h(`span`,{class:`${l}-history-preview`,children:h(`span`,{class:`${l}-skeleton ${l}-skeleton-preview`})})})]})]},t))})]})}),v]})}if(d===`error`||p.length===0)return g(m,{children:[h(`div`,{class:`${l}-history-empty`,children:t.historyEmpty}),v]});let b=Date.now(),x=xo(b,p);return g(m,{children:[h(`div`,{class:`${l}-history`,role:`list`,children:x.map(e=>g(`div`,{class:`${l}-history-group`,children:[h(`div`,{class:`${l}-history-heading`,children:t[wo[e.bucket]]}),h(`div`,{class:`${l}-history-card`,children:e.conversations.map(e=>g(`button`,{type:`button`,role:`listitem`,class:`${l}-history-item`,onClick:()=>o(e),"data-closed":e.canContinue?void 0:`true`,"data-unread":e.hasUnread?`true`:void 0,"data-testid":ti(G.historyItem,e.conversationId),children:[h(`span`,{class:`${l}-history-avatar`,"aria-hidden":`true`,children:h(kr,{})}),g(`span`,{class:`${l}-history-body`,children:[g(`span`,{class:`${l}-history-row`,children:[h(`span`,{class:`${l}-history-title`,children:e.title}),h(`span`,{class:`${l}-history-time`,children:To(e.lastMessageAt,b,n)})]}),g(`span`,{class:`${l}-history-row`,children:[h(`span`,{class:`${l}-history-preview`,children:e.preview??(e.canContinue?t.historyContinue:t.conversationClosed)}),e.hasUnread?h(`span`,{class:`${l}-history-dot`}):null]})]})]},e.conversationId))})]},e.bucket))}),v]})}const Do=y.cssPrefix;function Oo({suggestions:e,onPick:t}){return e.length===0?null:h(`div`,{class:`${Do}-suggestions`,role:`group`,"aria-label":`Suggested replies`,children:e.map((e,n)=>h(`button`,{type:`button`,class:`${Do}-suggestion`,onClick:()=>t(e),"data-testid":ti(G.suggestion,n),children:e.label},e.id))})}const Z=y.cssPrefix;function ko(e){let{options:t,onClose:n}=e,a=t.strings,o=s(null);i(()=>{let e=o.current;if(!e)return;let t=gi(e),r=e=>{e.key===`Escape`&&n?.()};return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let c=e.composerApiRef,{visible:l}=Wi({containerRef:o,onDrop:r(e=>{c.current?.attachFromDrop(e)},[c])});return fi(o.current,t.mode===`modal`),g(`div`,{ref:o,class:`${Z}-panel`,role:`dialog`,"aria-modal":`false`,"aria-label":a.panelTitle,style:{position:`relative`},"data-testid":G.panel,children:[h(Ao,{...e,containerEl:o.current,dragOver:l,composerAttachApiRef:c}),h(Io,{poweredBy:e.options.poweredBy})]})}function Ao(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,panelSize:o,view:s,canSend:c,isStreaming:l,controlMode:u,assignedOperatorInitials:d,operatorAvailable:f,operatorRequestEnabled:p,onRequestOperator:_,onCancelRequest:v,loadingMessages:y,messagesSig:b,agent:x,suggestions:S,initialWidgetSize:C,visitorId:w,onClose:T,onBack:E,onClear:D,onToggleHistory:O,onSelectHistoryConversation:k,onNewConversation:A,onWidgetSizeChange:ee,onSend:te,onStop:ne,onSuggestion:j,activeForm:re,formMarkers:ie,onFormSubmit:ae,onFormSkip:oe,onFormFill:se,tool:M,onRetry:N,onMessageFeedback:ce,containerEl:le,dragOver:ue,composerAttachApiRef:de}=e,P=t.strings,fe;return fe=re?null:c?g(m,{children:[u&&u!==`ai-agent`?h(No,{controlMode:u,operatorInitials:d,operatorAvailable:f,onCancelRequest:v,strings:P}):null,!l&&u===`ai-agent`&&h(Oo,{suggestions:S,onPick:j}),h(Vi,{options:t,transport:n,feedback:r,bus:i,isStreaming:l,operatorRequestEnabled:p,controlMode:u,onRequestOperator:_,onSend:te,onStop:ne,attachApiRef:de})]}):h(Mo,{label:P.conversationClosed,ctaLabel:P.startNewConversation,onNewConversation:D}),g(m,{children:[s===`history`?h(jo,{strings:P,onBack:O,onClose:T,showClose:mi(t.mode,o,t.actions)}):g(`header`,{class:`${Z}-header`,"data-testid":G.panelHeader,children:[E?h(`button`,{type:`button`,class:`${Z}-icon-btn`,onClick:E,"aria-label":P.moduleBack,title:P.moduleBack,children:h(wr,{})}):null,x?h(yi,{agent:x,strings:P}):h(`h1`,{children:P.panelTitle}),h(Qi,{panelProps:e,variant:`chat`})]}),s===`history`?h(Eo,{transport:n,strings:P,locale:t.locale,persistence:a,visitorId:w,onSelect:e=>k(e.conversationId),onNewConversation:A}):g(m,{children:[h(Ui,{visible:ue,strings:P}),h(ho,{messagesSig:b,strings:P,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:ce,loading:y,idle:!l,tool:M,onRetry:N,form:re?{form:re,onSubmit:ae,onSkip:oe}:null,formMarkers:ie,onFillForm:se}),fe,h(Fo,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?h(li,{panelEl:le,resize:t.size.resize,position:t.position,initialSize:C,onSizeChange:ee,strings:P}):null]})}function jo({strings:e,onBack:t,onClose:n,showClose:r}){return g(`header`,{class:`${Z}-header`,children:[h(`button`,{type:`button`,class:`${Z}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:h(wr,{})}),h(`h1`,{children:e.historyTitle}),r?h(`button`,{type:`button`,class:`${Z}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:h(nr,{})}):null]})}function Mo({label:e,ctaLabel:t,onNewConversation:n}){return g(`div`,{class:`${Z}-readonly-banner`,role:`note`,children:[h(`span`,{class:`${Z}-readonly-label`,children:e}),h(`button`,{type:`button`,class:`${Z}-readonly-cta`,onClick:n,children:t})]})}function No({controlMode:e,operatorInitials:t,operatorAvailable:n,onCancelRequest:r,strings:i}){let a=Po(e,t,n,i);return g(`div`,{class:`${Z}-operator-banner`,role:`status`,"data-mode":e,"data-testid":G.operatorBanner,children:[h(`span`,{class:`${Z}-operator-pulse`,"aria-hidden":`true`}),h(`span`,{class:`${Z}-operator-label`,children:a}),e===`awaiting_operator`&&r?h(`button`,{type:`button`,class:`${Z}-operator-cancel`,"data-testid":G.operatorCancelRequest,onClick:r,children:i.cancelOperatorRequest}):null]})}function Po(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Fo({disclaimer:e}){return e?h(`div`,{class:`${Z}-composer-footer`,children:h(`div`,{class:`${Z}-disclaimer`,children:e})}):null}function Io({poweredBy:e}){return e?h(`div`,{class:`${Z}-poweredby-bar`,children:h(Lo,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function Lo({logoUrl:e,text:t,href:n}){let r=g(m,{children:[e?h(`img`,{class:`${Z}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?h(`span`,{children:t}):null]});return n?h(`a`,{class:`${Z}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):h(`span`,{class:`${Z}-poweredby`,children:r})}function Ro(e){let t=s(e);t.current=e;let n=s(null);return n.current??(n.current=zo(t)),n.current}function zo(e){let t=d(null),n=new Set,r=t=>`${e.current.conversationId()??``}:${t}`,i=t=>t.frequency===`always`?!1:t.frequency===`conversation`?n.has(r(t.id)):t.id in e.current.persistence.loadFormsDone(),a=(n,r)=>{if(t.value)return;let a=e.current;if(n===`manual`){let e=a.forms.list.find(e=>e.id===r);e&&(t.value={form:e,trigger:`manual`});return}for(let e of a.forms.byTrigger[n]??[]){let r=e.triggers.find(e=>e.kind===n);if(!(!r||!Bo(r,a)||i(e)||!Vo(e,a))){t.value={form:e,trigger:n};return}}},o=(i,a)=>{let o=t.value;if(!o)return;t.value=null;let{form:s,trigger:c}=o;s.frequency===`conversation`?n.add(r(s.id)):s.frequency!==`always`&&e.current.persistence.saveFormDone(s.id),e.current.onComplete(s,c,i,a)};return{activeForm:t,fire:a,refresh:()=>{let n=t.value;if(!n)return;let r=e.current.forms.list.find(e=>e.id===n.form.id);r&&r!==n.form&&(t.value={form:r,trigger:n.trigger})},complete:e=>o(e,!1),skip:()=>o({},!0)}}function Bo(e,t){return e.kind===`after-messages`?t.messageCount()>=Number(e.param??0):e.kind!==`page-area`||t.pageArea()===e.param}function Vo(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let e=t.userContext()??{};if(n.missingContext.some(t=>e[t]!==void 0&&e[t]!==``))return!1}if(n.pageArea&&!(Array.isArray(n.pageArea)?n.pageArea:[n.pageArea]).includes(t.pageArea()??``))return!1;let r=t.messageCount();return!(n.minMessages!=null&&r<n.minMessages||n.maxMessages!=null&&r>n.maxMessages)}function Ho(e){let t=y.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return g(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":G.sidebar,children:[g(`div`,{class:`${t}-sidebar-header`,children:[h(Uo,{site:n}),h(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":G.sidebarToggle,children:h(Wo,{collapsed:a})})]}),a?null:g(m,{children:[o.length>0?h(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:h(Go,{items:o})}):null,s.length>0?h(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:h(Ko,{items:s})}):null,e.showConversations?h(`div`,{class:`${t}-sidebar-conversations`,children:h(Eo,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,visitorId:e.visitorId,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function Uo({site:e}){let t=y.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return g(`picture`,{children:[e.logoDark?.url?h(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,h(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return h(`div`,{class:`${t}-sidebar-title`,children:e?.title??y.name})}function Wo({collapsed:e}){return h(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?h(`polyline`,{points:`9 6 15 12 9 18`}):h(`polyline`,{points:`15 6 9 12 15 18`})})}function Go({items:e}){let t=y.cssPrefix;return h(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>h(`li`,{children:g(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?h(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,h(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function Ko({items:e}){let t=y.cssPrefix;return h(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>g(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[h(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?h(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const qo=y.cssPrefix;function Jo(e){return g(`main`,{class:`${qo}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[h(Ho,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,visitorId:e.visitorId,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),h(`section`,{class:`${qo}-page-chat`,"aria-label":`Chat`,children:e.children})]})}const Yo=e=>Object.fromEntries(e.map(e=>[e,[]]));function Xo(e,t,n){let r=d({activeTab:e,stacks:Yo(t)});return{sig:r,switchTab(e){r.value.activeTab!==e&&(r.value={...r.value,activeTab:e},n?.(e))},push(e){let t=r.value,n=t.stacks[t.activeTab]??[];r.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=r.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(r.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){r.value={activeTab:e,stacks:Yo(t)}}}}const Zo=e=>e.stacks[e.activeTab]??[],Qo=e=>Zo(e).at(-1),$o=e=>Zo(e).length===0,es={Icon:zr},ts=y.cssPrefix;function ns({title:e,actions:t}){return g(`header`,{class:`${ts}-back-header`,"data-variant":`title`,children:[h(`span`,{class:`${ts}-back-spacer`,"aria-hidden":`true`}),h(`h1`,{class:`${ts}-back-title`,children:e}),t??h(`span`,{class:`${ts}-back-spacer`,"aria-hidden":`true`})]})}function rs({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return g(`header`,{class:`${ts}-back-header`,"data-testid":i,children:[h(`button`,{type:`button`,class:`${ts}-icon-btn`,onClick:n,"aria-label":t,title:t,children:h(wr,{})}),h(`h1`,{class:`${ts}-back-title`,children:e}),r??h(`span`,{class:`${ts}-back-spacer`,"aria-hidden":`true`})]})}function is(e,t){return e instanceof Ut&&e.status===429?t.errorRateLimited:t.errorGeneric}const as=y.cssPrefix;function os({placeholder:e,onActivate:t}){return g(`button`,{type:`button`,class:`${as}-home-search`,onClick:t,"data-testid":G.homeSearch,children:[h(`span`,{class:`${as}-home-search-text`,children:e}),h(`span`,{class:`${as}-home-search-icon`,"aria-hidden":`true`,children:h(Fr,{})})]})}function ss({placeholder:e,value:t,onInput:n}){return g(`div`,{class:`${as}-home-search`,"data-input":`true`,children:[h(`input`,{type:`search`,class:`${as}-home-search-input`,placeholder:e,value:t,onInput:e=>n(e.currentTarget.value),"data-testid":G.helpSearch}),h(`span`,{class:`${as}-home-search-icon`,"aria-hidden":`true`,children:h(Fr,{})})]})}const cs=y.cssPrefix;function ls({title:e,subtitle:t,onClick:n,testid:r}){return g(`button`,{type:`button`,class:`${cs}-list-row`,onClick:n,"data-testid":r,children:[g(`span`,{class:`${cs}-list-row-body`,children:[h(`span`,{class:`${cs}-list-row-title`,children:e}),t?h(`span`,{class:`${cs}-list-row-sub`,children:t}):null]}),h(`span`,{class:`${cs}-list-row-chevron`,"aria-hidden":`true`,children:h(sr,{})})]})}const us=y.cssPrefix;function ds({tone:e=`info`,message:t,onRetry:n,strings:r}){return g(`div`,{class:`${us}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[h(`span`,{children:t}),n?h(`button`,{type:`button`,class:`${us}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const fs=y.cssPrefix,ps=N.scope(`help`),ms=(e,t)=>t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title});function hs(e){let t=new Map;for(let n of e){let e=n.categories?.[0]??``;(t.get(e)??t.set(e,[]).get(e)).push(n)}return[...t.entries()]}function gs(e,t){let n=t.toLowerCase(),r=n.indexOf(e);if(r!==-1)return 100-Math.min(r,99);let i=0;for(let t of e){if(i=n.indexOf(t,i),i===-1)return 0;i+=1}return 1}function _s(e,t){let n=t.toLowerCase().trim();return n?e.map(e=>({item:e,score:Math.max(gs(n,e.title)*2,gs(n,e.description??``))})).filter(e=>e.score>0).toSorted((e,t)=>t.score-e.score).map(e=>e.item):[]}function vs({article:e,nav:t}){return h(ls,{title:e.title,subtitle:e.description,onClick:()=>ms(t,e),testid:ti(G.helpArticle,e.id)})}function ys({transport:e,strings:t,config:n,nav:r,bus:a,panelProps:s}){let l=n.contentTags,[u,d]=c(`loading`),[f,p]=c(t.errorGeneric),[m,_]=c([]),[v,y]=c(``),[b,x]=c(0);i(()=>{let n=!1;return d(`loading`),e.listContent({tags:l,sortBy:`order`,limit:100}).then(e=>{if(n)return;let t=e.items??[];_(t),d(`loaded`),a.emit(`contentView`,{section:`help`,tags:l?.join(`,`),count:t.length})}).catch(e=>{n||(ps.warn(`listContent (help) failed`,{err:e}),p(is(e,t)),d(`error`))}),()=>{n=!0}},[e,l,b,a]);let S=o(()=>_s(m,v),[m,v]);i(()=>{let e=v.trim();if(!e)return;let t=setTimeout(()=>a.emit(`contentSearch`,{queryLength:e.length,hitCount:S.length}),600);return()=>clearTimeout(t)},[v,S,a]);function C(){return v.trim().length>0?S.length===0?h(ds,{message:t.helpSearchEmpty,strings:t}):h(`div`,{class:`${fs}-help-card`,children:S.map(e=>h(vs,{article:e,nav:r},e.id))}):u===`loading`?h(ds,{message:t.helpLoading,strings:t}):u===`error`?h(ds,{tone:`error`,message:f,onRetry:()=>x(e=>e+1),strings:t}):m.length===0?h(ds,{message:t.helpEmpty,strings:t}):hs(m).map(([e,t])=>g(`section`,{class:`${fs}-help-group`,children:[e?h(`h2`,{class:`${fs}-help-section-title`,children:e}):null,h(`div`,{class:`${fs}-help-card`,children:t.map(e=>h(vs,{article:e,nav:r},e.id))})]},e))}return g(`div`,{class:`${fs}-module`,children:[h(ns,{title:t.helpTitle,actions:h(Qi,{panelProps:s,variant:`plain`})}),h(`div`,{class:`${fs}-module-pad`,children:h(ss,{placeholder:t.helpSearchPlaceholder,value:v,onInput:y})}),h(`div`,{class:`${fs}-help-list`,children:C()})]})}const bs={Icon:Ar,Root:e=>h(ys,{...e})},xs=y.cssPrefix;function Ss({onClick:e,children:t,testid:n}){return e?h(`button`,{type:`button`,class:`${xs}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):h(`div`,{class:`${xs}-home-card`,"data-testid":n,children:t})}const Q=y.cssPrefix,Cs=N.scope(`home`);function ws(e){let t=e.options.userContext?.name,n=e.config.greetingText?E(e.strings,e.config.greetingText):void 0;return n?{title:t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),subtitle:e.strings.homeGreetingLead}:t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}const Ts=(e,t)=>t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title});function Es(e){let{transport:t,strings:n,config:r,nav:a,bus:o,panelProps:s}=e,[l,u]=c(null),[d,f]=c([]),p=r.contentTags?.join(`,`);i(()=>{if(r.showRecentConversations===!1)return;let e=!1;return t.listConversations({limit:1}).then(t=>!e&&u(t.conversations?.[0]??null)).catch(t=>!e&&Cs.warn(`listConversations (home) failed`,{err:t})),()=>{e=!0}},[t,r.showRecentConversations]),i(()=>{if(!r.contentTags?.length)return;let e=!1;return t.listContent({tags:r.contentTags,limit:6}).then(t=>{if(e)return;let n=t.items??[];f(n),o.emit(`contentView`,{section:`home`,tags:p,count:n.length})}).catch(t=>!e&&Cs.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,p,o]);let _=ws(e),v=r.userAvatars??[],y=r.status,b=y?.text?E(n,y.text):n.homeStatus,x=r.contentBlockTitle?E(n,r.contentBlockTitle):n.homeContentTitle;return h(`div`,{class:`${Q}-module ${Q}-home`,"data-testid":G.homeView,children:g(`div`,{class:`${Q}-home-scroll`,children:[g(`div`,{class:`${Q}-home-hero`,children:[g(`div`,{class:`${Q}-home-hero-top`,children:[r.brandName?h(`span`,{class:`${Q}-home-brand`,"data-testid":G.homeBrand,children:r.brandName}):h(`span`,{class:`${Q}-home-brand-spacer`,"aria-hidden":`true`}),g(`div`,{class:`${Q}-home-hero-actions`,children:[v.length>0?h(`div`,{class:`${Q}-home-avatars`,children:v.map(e=>h(`span`,{class:`${Q}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?h(`img`,{src:e.avatar,alt:``,loading:`lazy`}):h(`span`,{children:_i(e.name)})},e.name))}):null,h(Qi,{panelProps:s,variant:`plain`})]})]}),r.showGreeting===!1?null:g(m,{children:[h(`h1`,{class:`${Q}-home-greeting`,"data-testid":G.homeGreeting,children:_.title}),_.subtitle?h(`p`,{class:`${Q}-home-lead`,children:_.subtitle}):null]})]}),g(`div`,{class:`${Q}-home-cards`,children:[r.showSearchBar===!1?null:h(os,{placeholder:n.homeSearchPlaceholder,onActivate:()=>a.switchToLayout(`help`)}),l?h(Ss,{onClick:()=>a.selectConversation(l.conversationId),testid:G.homeRecent,children:g(`div`,{class:`${Q}-home-recent-row`,"data-unread":l.hasUnread?`true`:void 0,children:[h(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:h(zr,{})}),g(`span`,{class:`${Q}-home-recent-body`,children:[h(`span`,{class:`${Q}-home-recent-title`,children:l.title}),l.preview?h(`span`,{class:`${Q}-home-recent-preview`,children:l.preview}):null]}),l.hasUnread?h(`span`,{class:`${Q}-home-recent-dot`,"aria-label":`Unread`}):null]})}):null,y?h(Ss,{onClick:y.url?()=>a.push({kind:`iframe`,url:y.url,title:b}):void 0,children:g(`div`,{class:`${Q}-home-status`,"data-level":y.level??`operational`,children:[h(`span`,{class:`${Q}-home-status-icon`,"aria-hidden":`true`,children:h(Ir,{})}),h(`span`,{class:`${Q}-home-status-text`,children:b})]})}):null,d.length>0?g(`section`,{class:`${Q}-home-content`,children:[h(`div`,{class:`${Q}-home-content-title`,children:x}),h(`div`,{class:`${Q}-home-content-list`,children:d.map(e=>h(ls,{title:e.title,subtitle:e.description,onClick:()=>Ts(a,e),testid:ti(G.homeContentRow,e.id)},e.id))})]}):null]})]})})}const Ds={Icon:Lr,Root:e=>h(Es,{...e})},Os=y.cssPrefix,ks=N.scope(`news`);function As({transport:e,strings:t,config:n,nav:r,bus:a,panelProps:o}){let s=n.contentTags,[l,u]=c(`loading`),[d,f]=c(t.errorGeneric),[p,m]=c([]),[_,v]=c(0);i(()=>{let n=!1;return u(`loading`),e.listContent({tags:s,sortBy:`publishedAt`,sortOrder:`desc`}).then(e=>{if(n)return;let t=e.items??[];m(t),u(`loaded`),a.emit(`contentView`,{section:`news`,tags:s?.join(`,`),count:t.length})}).catch(e=>{n||(ks.warn(`listContent (news) failed`,{err:e}),f(is(e,t)),u(`error`))}),()=>{n=!0}},[e,s,_,a]);function y(){return l===`loading`?h(ds,{message:t.newsLoading,strings:t}):l===`error`?h(ds,{tone:`error`,message:d,onRetry:()=>v(e=>e+1),strings:t}):p.length===0?h(ds,{message:t.newsEmpty,strings:t}):h(`div`,{class:`${Os}-news-list`,children:p.map(e=>g(`button`,{type:`button`,class:`${Os}-news-card`,onClick:()=>r.push({kind:`content`,id:e.id,title:e.title}),"data-testid":ti(G.newsItem,e.id),children:[e.image?h(`img`,{class:`${Os}-news-hero`,src:e.image,alt:``,loading:`lazy`}):null,g(`span`,{class:`${Os}-news-body`,children:[h(`span`,{class:`${Os}-news-title`,children:e.title}),e.description?h(`span`,{class:`${Os}-news-summary`,children:e.description}):null]})]},e.id))})}return g(`div`,{class:`${Os}-module`,children:[h(ns,{title:t.newsTitle,actions:h(Qi,{panelProps:o,variant:`plain`})}),h(`div`,{class:`${Os}-module-scroll`,children:y()})]})}const js={chat:es,home:Ds,help:bs,news:{Icon:Rr,Root:e=>h(As,{...e})}},Ms=y.cssPrefix;function Ns({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return h(`nav`,{class:`${Ms}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=js[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return g(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${Ms}-tab`,onClick:()=>i(e.id),"data-testid":ti(G.tab,e.id),children:[g(`span`,{class:`${Ms}-tab-icon`,"aria-hidden":`true`,children:[h(a,{}),s?h(`span`,{class:`${Ms}-tab-badge`,"data-testid":G.tabBadge,"aria-label":`Unread`}):null]}),h(`span`,{class:`${Ms}-tab-label`,children:E(n,e.label)})]},e.id)})})}const Ps=y.cssPrefix;function Fs({url:e,title:t,strings:n,onBack:r,actions:i}){return g(`div`,{class:`${Ps}-module`,children:[h(rs,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),h(`iframe`,{class:`${Ps}-content-frame`,src:e,title:t||`content`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads`,referrerpolicy:`no-referrer`,loading:`lazy`,allow:`fullscreen`})]})}const Is=y.cssPrefix,Ls=N.scope(`content`);function Rs({id:e,title:t,transport:n,strings:a,bus:o,onBack:s,actions:l}){let[u,d]=c(null),[f,p]=c(!1),[m,_]=c(0),v=r(()=>{p(!1),d(null),_(e=>e+1)},[]);i(()=>{let t=!1;return n.listContent({ids:[e],limit:1}).then(n=>{if(t)return;let r=n.items[0];r?(d(r),o.emit(`contentOpen`,{contentId:e,tags:r.tags?.length?r.tags.join(`,`):void 0})):p(!0)}).catch(e=>{t||(Ls.warn(`listContent (reader) failed`,{err:e}),p(!0))}),()=>{t=!0}},[n,e,m,o]),i(()=>{if(!u)return;let t=setTimeout(()=>o.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[u,e,o]);let y=r(t=>{let n=(t.target?.closest?.(`a`))?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&o.emit(`contentLinkClick`,{contentId:e})},[o,e]);function b(){return f?h(ds,{tone:`error`,message:a.errorGeneric,onRetry:v,strings:a}):u===null?h(ds,{message:a.contentLoading,strings:a}):g(`article`,{class:`${Is}-content`,"data-testid":G.contentView,onClick:y,children:[u.image?h(`img`,{class:`${Is}-content-hero`,src:u.image,alt:``,loading:`lazy`}):null,u.description?h(`p`,{class:`${Is}-content-subtitle`,children:u.description}):null,h(ya,{text:u.content??``})]})}return g(`div`,{class:`${Is}-module`,children:[h(rs,{title:u?.title||t||a.moduleBack,backLabel:a.moduleBack,onBack:s,actions:l,testid:G.backHeader}),h(`div`,{class:`${Is}-module-scroll`,"data-testid":G.contentScroll,children:b()})]})}const zs=y.cssPrefix;function Bs({panelProps:e,enabledModules:t,nav:n,bus:a,hasUnread:o,onSelectConversation:c,onStartNewConversation:l,onSetPanelSize:u}){let d=e.options,p=d.strings,m=s(null),_=s(new Set);i(()=>{let t=m.current;if(!t)return;let n=gi(t),r=t=>{t.key===`Escape`&&e.onClose?.()};return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let v=e.composerApiRef,{visible:y}=Wi({containerRef:m,onDrop:r(e=>{v.current?.attachFromDrop(e)},[v])});fi(m.current,d.mode===`modal`);let b=f(()=>n.sig.value).value,x=Qo(b),S=d.modules.byId[b.activeTab],C=x?.kind===`iframe`||x?.kind===`content`,w=t.length>1&&($o(b)||!C),T=s(null);i(()=>{if(C&&T.current===null)T.current=e.panelSize,e.panelSize===`normal`&&u(`expanded`);else if(!C&&T.current!==null){let e=T.current;T.current=null,u(e)}},[C]);let E={push:n.push,pop:n.pop,switchTab:n.switchTab,switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:c,startNewConversation:l},D=t=>({options:d,transport:e.transport,strings:p,config:t,visitorId:e.visitorId,nav:E,bus:a,panelProps:e}),O=h(Qi,{panelProps:e,variant:`plain`});S&&_.current.add(S.id);let k=t.filter(e=>_.current.has(e.id)),A=t=>{if(t.layout===`chat`)return h(Ao,{...e,containerEl:m.current,dragOver:y,composerAttachApiRef:v});let n=js[t.layout].Root;return n?h(n,{...D(t)}):null};return g(`div`,{ref:m,class:`${zs}-panel ${zs}-messenger`,role:`dialog`,"aria-modal":`false`,"aria-label":p.panelTitle,style:{position:`relative`},"data-testid":G.messengerHome,children:[g(`div`,{class:`${zs}-messenger-body`,children:[k.map(e=>h(`div`,{class:`${zs}-messenger-pane`,hidden:C||e.id!==S?.id,children:A(e)},e.id)),x?.kind===`iframe`?h(Fs,{url:x.url,title:x.title,strings:p,onBack:n.pop,actions:O}):x?.kind===`content`?h(Rs,{id:x.id,title:x.title,transport:e.transport,strings:p,bus:a,onBack:n.pop,actions:O}):null]}),w?h(Ns,{modules:t,activeTab:b.activeTab,strings:p,hasUnread:o,onSelect:n.switchTab}):null,h(Io,{poweredBy:d.poweredBy}),d.size.resize?.enabled&&!(S?.layout===`chat`&&!x)?h(li,{panelEl:m.current,resize:d.size.resize,position:d.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:p}):null]})}const Vs=y.cssPrefix;function Hs({strings:e,onClose:t}){return g(`div`,{class:`${Vs}-panel ${Vs}-modules-empty`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":G.modulesEmpty,children:[t?h(`button`,{type:`button`,class:`${Vs}-icon-btn ${Vs}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:h(nr,{})}):null,h(`p`,{class:`${Vs}-modules-empty-text`,children:e.modulesEmpty})]})}function Us(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}const Ws=N.scope(`hitl`);function Gs(e){let t=e.partsSig.value.filter(e=>e.kind===`tool`);return t.length>0&&t.every(e=>{let t=e.stateSig.value;return t===`output-available`||t===`output-error`||t===`output-denied`||t===`approval-responded`})}function Ks(e){let{streaming:t,messagesSig:n,sendAiTurn:i,bus:a,humanInLoop:s}=e,c=r((e,r)=>{if(t)return;let a=n.value.at(-1),o=a?.partsSig.value.find(t=>t.kind===`tool`&&t.toolCallId===e);if(!a||!o){Ws.warn(`decideTool: tool part not found`,{toolCallId:e});return}r(o),a.partsSig.value=[...a.partsSig.value],Gs(a)&&(a.status=`streaming`,a.awaitingContinuation=!0,n.value=[...n.value],i({continueExisting:!0}))},[t,n,i]),l=r((e,t)=>{Ws.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e}),c(e,e=>{e.outputSig.value=t,e.stateSig.value=`output-available`})},[a,c]),u=r((e,t,n)=>{Ws.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}),c(e,r=>{let i=r.approvalSig.value?.id??e;r.approvalSig.value={id:i,approved:t,reason:n},r.stateSig.value=`approval-responded`})},[a,c]),d=r(e=>{if(t)return;let r=n.value.at(-1),i=r?.partsSig.value.find(t=>t.kind===`tool`&&t.toolCallId===e);if(!r||!i)return;let a=i.approvalSig.value?.id??e;i.approvalSig.value={id:a},i.stateSig.value=`approval-requested`,r.partsSig.value=[...r.partsSig.value]},[t,n]);return{toolInteraction:o(()=>({humanInLoop:s,onResult:l,onDecision:u,onEdit:d}),[s,l,u,d])}}function qs({callout:e,persistence:t}){let n=e?.text??``,a=e?.persistent??!0,[o,s]=c(()=>!a&&t.loadCalloutDismissed(n));return i(()=>{s(!a&&t.loadCalloutDismissed(n))},[n,a,t]),{dismissed:o,dismissCallout:r(()=>{s(!0),a||t.saveCalloutDismissed(n)},[t,n,a])}}function Js(e){let{transport:t}=e,n=p(`ai-agent`),i=p(void 0),a=p(void 0),o=r(e=>{n.value=e.controlMode,i.value=e.assignedOperatorInitials,e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable)},[n,i,a]);return{controlModeSig:n,assignedOperatorInitialsSig:i,operatorAvailableSig:a,applyControlState:o,adoptControlStateChunk:r(e=>{e.type===`data-control-state`&&o(en(e.data))},[o]),requestOperator:r(async()=>{if(n.value!==`ai-agent`)return;let e=await t.requestOperator();e&&o(en(e))},[t,n,o]),cancelRequestOperator:r(async()=>{if(n.value!==`awaiting_operator`)return;let e=await t.cancelRequestOperator();e&&o(en(e))},[t,n,o])}}function Ys(e){let{hostElement:t,mode:n,panelSize:r,isOpen:o,setIsOpen:s}=e;a(()=>{Dt(t,Pt(n,r,o))},[t,o,r,n]),i(()=>{if(n!==`modal`||!o)return;let e=e=>{e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${y.cssPrefix}-panel`))||s(!1)};return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,o,n,s]),i(()=>{if(n!==`drawer`||!o)return;let e=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,n,s])}const Xs=N.scope(`reducer`);var Zs=class{constructor(e){this.messagesSig=e,z(this,`active`,null),z(this,`openTextParts`,new Map),z(this,`partSeq`,0),z(this,`resumeIgnore`,!1)}attach(e){this.active=e,this.openTextParts.clear()}resetForReplay(e){e.partsSig.value=[],e.status=`streaming`,e.finishReason=void 0,e.errorText=void 0,e.suggestions=void 0,this.openTextParts.clear(),this.messagesSig.value=[...this.messagesSig.value]}truncateAfterLastTool(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);e.partsSig.value=t.slice(0,n+1),e.status=`streaming`,e.finishReason=void 0,e.errorText=void 0,e.suggestions=void 0,this.openTextParts.clear(),this.messagesSig.value=[...this.messagesSig.value]}detach(){this.active=null,this.openTextParts.clear()}applyResume(e){if(e.type===`data-control-state`||e.type===`data-conversation-rebind`)return null;if(e.type===`start`){let t=e.messageId,n=t===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===t||e.id===t),r=n!==void 0&&(n.awaitingContinuation===!0||Pn(n));if(n!==void 0&&!r&&On(n))return this.resumeIgnore=!0,this.detach(),null;if(this.resumeIgnore=!1,n!==void 0)return r?(n.awaitingContinuation=!1,n.status=`streaming`,this.messagesSig.value=[...this.messagesSig.value]):n.status===`streaming`&&Mn(n)?this.truncateAfterLastTool(n):this.resetForReplay(n),this.attach(n),this.apply(e),null;let i=e.messageMetadata?.senderRole,a=this.messagesSig.value.at(-1);if(i===void 0&&a?.role===`assistant`&&a.status===`streaming`&&a.serverMessageId===void 0&&!En(a))return this.attach(a),this.apply(e),null;let o=mn();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.resumeIgnore||!this.active)return null;if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let e=this.active;return this.detach(),e}return null}ensureTextPart(e,t,n){let r=`${t}:${n}`,i=this.openTextParts.get(r);if(i)return i;let a={kind:t,id:`${n}#${this.partSeq++}`,textSig:d(``),doneSig:d(!1)};return this.openTextParts.set(r,a),$s(e,a),a}apply(e){let t=this.active;if(t)switch(e.type){case`start`:{e.messageId&&(t.serverMessageId=e.messageId);let n=e.messageMetadata;n?.senderRole===`operator`?(t.role=`operator`,n.operatorInitials&&(t.operatorInitials=n.operatorInitials)):n?.senderRole===`visitor`&&(t.role=`user`);return}case`finish-step`:this.openTextParts.clear();return;case`start-step`:$s(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`finish`:Xs.debug(`finish`,{reason:e.finishReason,canContinue:e.canContinue}),t.status=`complete`,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:Xs.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=e.errorText,this.bumpDone(t);return;case`abort`:Xs.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,this.bumpDone(t);return;case`text-start`:this.ensureTextPart(t,`text`,e.id);return;case`text-delta`:{let n=this.ensureTextPart(t,`text`,e.id);n.textSig.value+=e.delta;return}case`text-end`:this.ensureTextPart(t,`text`,e.id).doneSig.value=!0;return;case`reasoning-start`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!1;return;case`reasoning-delta`:{let n=this.ensureTextPart(t,`reasoning`,e.id);n.textSig.value+=e.delta;return}case`reasoning-end`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!0;return;case`tool-input-start`:case`tool-input-delta`:case`tool-input-available`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:tc(t,e);return;case`file`:$s(t,{kind:`file`,url:e.url,mediaType:e.mediaType});return;case`source-url`:ec(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:ec(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-notification`:return;case`data-conversation-rebind`:return;case`data-suggestions`:t.suggestions=tn(e.data);return;case`data-control-state`:t.operatorRoutedTurn=!0;return;default:}}bumpDone(e){e.partsSig.value=[...e.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function Qs(e,t,n){let r=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(r)return r;let i={kind:`tool`,toolCallId:t,toolName:n??`tool`,inputPartialSig:d(``),inputSig:d(void 0),outputSig:d(void 0),errorSig:d(void 0),stateSig:d(`input-streaming`),approvalSig:d(void 0)};return $s(e,i),i}function $s(e,t){e.partsSig.value=[...e.partsSig.value,t]}function ec(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||$s(e,t)}function tc(e,t){switch(t.type){case`tool-input-start`:Qs(e,t.toolCallId,t.toolName);return;case`tool-input-delta`:{let n=Qs(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=Qs(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-approval-request`:{let n=Qs(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-output-available`:{let n=Qs(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=Qs(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=Qs(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const nc=1e3;async function rc(e){let t=nc;for(;!e.signal.aborted;){let n,r=`held`;try{r=await e.connect(()=>{n=e.now(),e.backfill()})}catch{}if(e.signal.aborted||r===`unavailable`)return;n!==void 0&&e.now()-n>=1e3&&(t=nc),await e.sleep(t),t=Math.min(t*2,15e3)}}const ic=N.scope(`resume-stream`);function ac(e){let{activated:t,conversationReady:n,conversationIdSig:r,messagesSig:a,streamingRef:o,optionsRef:s,isChatActiveRef:c,transport:l,visitorId:u,adoptControlStateChunk:d,settleSuggestions:f,markActiveConversationRead:p,onReplyLanded:m,setStreaming:h,setActiveCancel:g,setCanSend:_,feedback:v,bus:y,homeNav:b}=e;i(()=>{if(!t||!n||!r.value)return;let e=r.value,i=new AbortController,x=new Zs(a);l.primeIdentity(u,e),ic.debug(`resume stream opened`,{conversationId:e});let S=()=>{h(!1),g(null),p(),m()},C=e=>{let t=o.current,n=s.current;if(e.canceled){t&&S(),a.value=[...a.value];return}let r=e.status===`error`;switch(zn(e,r)){case`drop`:a.value=a.value.filter(t=>t!==e);break;case`complete-operator-routed`:e.status=`complete`,t&&(v.play(`messageReceived`),Us(y,n,`assistant`,Tn(e)));break;case`error`:if(e.status=`error`,e.errorText=n.strings.errorGeneric,t){v.play(`error`);let e=Error(r?`stream error chunk`:`empty reply`);y.emit(`error`,e),n.onError?.(e)}break;case`complete`:e.status=`complete`,t&&(v.play(`messageReceived`),Us(y,n,`assistant`,Tn(e))),f(e);break}t&&S(),a.value=[...a.value]},w=t=>{d(t);let n=a.value.length,r=x.applyResume(t);if(t.type===`finish`&&t.canContinue===!1&&_(!1),a.value.length>n){let e=s.current.modules.list.find(e=>e.layout===`chat`)?.id;e&&b?.switchTab(e)}if(r){if(r.role===`operator`){v.play(`messageReceived`),Us(y,s.current,`operator`,Tn(r)),!document.hidden&&c.current()&&l.markRead(e).catch(()=>void 0);return}C(r)}},T=async()=>{let t=await l.loadConversation(e).catch(()=>null);if(i.signal.aborted||!t?.messages?.length)return!1;let{messages:n,changed:r}=In(a.value,Sn(t.messages));return r&&(a.value=n),r},E=0;rc({signal:i.signal,now:()=>performance.now(),sleep:e=>zt(e,i.signal),connect:e=>l.connectResumeStream({signal:i.signal,onChunk:w,onConnected:e}),backfill:()=>{let e=performance.now();e-E<2e3||(E=e,T())}});let D=e=>e.partsSig.value.reduce((e,t)=>e+(t.kind===`text`||t.kind===`reasoning`?t.textSig.value.length:1),0),O=0,k=-1,A=setInterval(()=>{let e=a.value.at(-1);if(o.current&&e&&e.role!==`user`&&e.status!==`streaming`&&(h(!1),g(null)),!(!o.current&&e!==void 0&&e.role!==`user`&&!e.ephemeral&&(e.status===`streaming`||En(e)&&Tn(e).trim()===``||Nn(e)))){O=0,k=-1;return}let t=D(e);if(t!==k){k=t,O=0;return}O++>=30||T().then(e=>{e&&(O=0)})},2500);return()=>{i.abort(),clearInterval(A),x.detach(),ic.debug(`resume stream closed`,{conversationId:e})}},[t,n,r,r.value,u,l,d,f,p,m,h,g,_,a,y,v,b])}const oc=N.scope(`send`);function sc(e){let{transport:t,messagesSig:n,conversationIdSig:i,options:a,bus:o,feedback:s,persistence:c,visitorId:l,adoptConversationId:u,setStreaming:d,setActiveCancel:f}=e,p=r(()=>{let e=i.value??ut();return i.value||(i.value=e,c.saveConversationId(e)),e},[i,c]);return{sendAiTurn:r(async({continueExisting:e})=>{let r=p(),m=nn({messages:Cn(n.value,e).map(wn),conversationId:r,tools:a.features.tools,visitorId:l,userPrefs:c.loadUserPrefs()});d(!0),f(()=>()=>t.cancelTurn(i.value));try{let e=await t.sendTurn(m);u(e.conversationId)}catch(t){let r=is(t,a.strings),i=n.value.at(-1);if(e&&i?.role===`assistant`)i.status=`error`,i.errorText=r,n.value=[...n.value];else{let e=mn();e.status=`error`,e.errorText=r,n.value=[...n.value,e]}d(!1),f(null),s.play(`error`),o.emit(`error`,t),a.onError?.(t)}},[t,n,i,a,o,s,c,l,u,p,d,f]),sendRoutedTurn:r(async e=>{let n=p(),r=nn({messages:[wn(e)],conversationId:n,tools:a.features.tools,visitorId:l,userPrefs:c.loadUserPrefs()});try{let e=await t.sendTurn(r);u(e.conversationId)}catch(e){oc.debug(`operator-routed send failed (non-fatal)`,{error:e});let t=e instanceof Error?e:Error(String(e));o.emit(`error`,t),a.onError?.(t)}},[t,a,o,c,l,u,p])}}const cc=N.scope(`unread`);function lc(e){let{transport:t,options:n,conversationIdSig:a,isChatActiveRef:o,activated:c,conversationReady:l}=e,u=p(!1),d=s(new Set),f=s();i(()=>()=>clearTimeout(f.current),[]);let m=r(()=>{let e=o.current()?a.value:void 0;u.value=[...d.current].some(t=>t!==e)},[u,a,o]),h=r(()=>{n.modules.list.some(e=>e.layout===`chat`)&&t.listConversations({limit:50}).then(e=>{d.current=new Set(e.conversations.filter(e=>e.hasUnread).map(e=>e.conversationId)),m()}).catch(e=>cc.debug(`refreshUnread failed (non-fatal)`,{err:e}))},[t,n.modules,m]),g=r(e=>{d.current.delete(e),m()},[m]),_=r(()=>{if(!o.current())return;let e=a.value;e&&(clearTimeout(f.current),f.current=setTimeout(()=>{g(e),t.markRead(e)},300))},[t,a,g,o]),v=s(!1);return i(()=>{!c||!l||v.current||(v.current=!0,h())},[c,l,h]),i(()=>{if(!c)return;let e=()=>{document.visibilityState===`visible`&&h()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[c,h]),{hasUnreadSig:u,refreshUnread:h,clearUnread:g,markActiveConversationRead:_}}const uc=N.scope(`settings`);function dc(e){let{options:t,persistence:n,transport:a,feedback:o,hostElement:s,bus:l}=e,u=n.loadUserPrefs(),[d,f]=c(()=>u.locale??t.locale),[p,m]=c(()=>u.themeMode??t.themeMode),[h,g]=c(()=>u.textSize??t.textSize),_=r(e=>{n.patchUserPrefs(e),a.saveUserPrefs(n.loadUserPrefs()).catch(e=>uc.warn(`saveUserPrefs failed`,{err:e}))},[n,a]);i(()=>{u.soundMuted!==void 0&&o.setMuted(u.soundMuted)},[]),i(()=>{s.dataset.theme=p},[s,p,t]),i(()=>{s.dataset.textSize=h},[s,h,t]),i(()=>{let e=!0;return o.mutedSig.subscribe(t=>{if(e){e=!1;return}_({soundMuted:t})})},[o,_]);let v=De(d,t.availableLocales,t.defaultLocale);return i(()=>{a.setLocale(v)},[a,v]),i(()=>{s.dir=T(v)?`rtl`:`ltr`},[s,v]),i(()=>{v!==d&&f(v)},[v,d]),{activeLocale:d,activeThemeMode:p,activeTextSize:h,effectiveLocale:v,setActiveLocale:f,setActiveThemeMode:m,setActiveTextSize:g,patchAndSync:_,handleLocaleChange:r(e=>{uc.info(`localeChange`,{locale:e}),f(e),_({locale:e}),l.emit(`localeChange`,e)},[_,l]),handleThemeChange:r(e=>{uc.info(`themeChange`,{mode:e}),m(e),s.dataset.theme=e,_({themeMode:e}),l.emit(`themeChange`,e)},[s,_,l]),handleTextSizeChange:r(e=>{uc.info(`textSizeChange`,{size:e}),g(e),s.dataset.textSize=e,_({textSize:e}),l.emit(`textSizeChange`,e)},[s,_,l]),handleSoundToggle:r(()=>{o.toggleMuted();let e=o.mutedSig.value;uc.info(`soundToggle`,{muted:e}),l.emit(`soundToggle`,{muted:e})},[o,l])}}const $=N.scope(`app`),fc=y.cssPrefix;function pc(e,t){return hn({...e,text:E(t,e.text)})}function mc({options:e,hostElement:t,bus:n}){let[a]=c(()=>pt(e.widgetId,e.storage,e.aiAgentDeploymentId)),[u,d]=c(()=>a.getVisitorId()),m=a.loadUserPrefs(),_=p(a.loadConversationId()),v=p([]),[y,b]=c(!1),[x,S]=c([]);function C(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=a.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function w(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function T(){let t=w();return t?e.modules.list.length===1||k.sig.value.activeTab===t:!1}let D=s(T);D.current=T;let O=s();if(!O.current){let t=e.modules.list.map(e=>e.id);O.current=Xo(C(),t,e=>a.saveActiveModule(e))}let k=O.current,[A,ee]=c(!1),[te,ne]=c(null),[j,re]=c(!1),ie=e.mode===`standalone`||e.mode===`inline`,ae=s(It(e,Lt(),a.loadPanelOpen(),a.loadPanelSize())),[oe,se]=c(ae.current.panelOpen),[M,N]=c(ae.current.panelOpen),ce=s(!1),le=s(void 0);i(()=>{oe&&N(!0)},[oe]);let ue=s(!1),[de,P]=c(!1),{dismissed:fe,dismissCallout:pe}=qs({callout:e.launcher.callout,persistence:a}),me=e.launcher.callout?.persistent??!0,he=r(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),pe()},[n,pe]),[ge,_e]=c(ae.current.panelSize),ve=s(!1),[ye,be]=c(`chat`),[xe,Se]=c(!0),[F,Ce]=c(!1),we=s(F);we.current=F;let[Te,Ee]=c(null),[De,Oe]=c([]),[ke,Ae]=c(null),je=s(e.strings),Me=s(e);Me.current=e;let[Ne,Pe]=c(void 0),[Ie,Le]=c(void 0),[ze,Be]=c(()=>a.loadSidebarCollapsed()??!1),[Ve,He]=c({}),[I]=c(()=>new un({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Rt({publicKey:e.publicKey,aiAgentDeploymentId:e.aiAgentDeploymentId,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints})),[L]=c(()=>new $n(e.sound,e.haptics)),{activeLocale:Ue,activeThemeMode:We,activeTextSize:Ge,effectiveLocale:Ke,setActiveLocale:qe,setActiveThemeMode:Je,setActiveTextSize:Ye,patchAndSync:Xe,handleLocaleChange:Ze,handleThemeChange:Qe,handleTextSizeChange:$e,handleSoundToggle:et}=dc({options:e,persistence:a,transport:I,feedback:L,hostElement:t,bus:n}),{controlModeSig:tt,assignedOperatorInitialsSig:nt,operatorAvailableSig:rt,applyControlState:it,adoptControlStateChunk:at,requestOperator:ot,cancelRequestOperator:st}=Js({transport:I}),{hasUnreadSig:ct,refreshUnread:lt,clearUnread:dt,markActiveConversationRead:ft}=lc({transport:I,options:e,conversationIdSig:_,isChatActiveRef:D,activated:M,conversationReady:A});i(()=>{L.update(e.sound,e.haptics)},[L,e.sound,e.haptics]),i(()=>()=>L.destroy(),[L]),i(()=>{ve.current||!e.size.initialSize||(ve.current=!0,!a.loadPanelSize()&&_e(Ft(e.mode,e.size,Lt())))},[e.mode,e.size,a]),i(()=>{if(!A||ue.current)return;ue.current=!0;let t=It(e,Lt(),a.loadPanelOpen(),a.loadPanelSize());se(t.panelOpen),_e(t.panelSize)},[A,e,a]);let mt=s(!1),ht=s(null);i(()=>{!A||mt.current||(mt.current=!0,k.reset(C()))},[A]);let gt=r(e=>{!e||e.length===0||(v.value=e.map(e=>pc(e,je.current)))},[v]),_t=s(null),vt=r(async e=>{try{let{formSubmissions:t}=await(e?I.bootstrap(e):_t.current??I.bootstrap()),n=new Map;return t.forEach((e,t)=>n.set(e.formId,t)),t.filter((e,t)=>!e.skipped||n.get(e.formId)===t).map((e,t)=>({key:`wire:${e.formId}:${e.createdAt??t}`,formId:e.formId,outcome:e.skipped?`skipped`:`submitted`,createdAt:Zt(e.createdAt),values:e.values}))}catch(e){return $.debug(`bootstrap failed — no form markers (non-fatal)`,{err:e}),[]}},[I]),yt=s(0),bt=r((e,t)=>{let n=[...e.map(e=>e.createdAt),...t.map(e=>e.createdAt)].filter(e=>e!==void 0),r=(n.length?Math.min(...n):Date.now())-1;return[...(le.current?.messages??[]).map(e=>{let t=pc(e,je.current);return t.createdAt=r,t}),...e]},[]),xt=r(async e=>{let t=yt.current,n=()=>t!==yt.current;b(!0);try{let[t,r]=await Promise.all([I.loadConversation(e),vt()]);if(n())return;let i=Sn(t.messages??[]);if(S(r),v.value=bt(Fn(i,v.value),r),i.length){Se(t.canContinue??!0),it(en(t.controlState));let e=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);Oe(e?.suggestions??t.suggestions??[])}}catch(t){if(n())return;$.warn(`loadThread failed; resetting conversationId`,{err:t,conversationId:e}),_.value=void 0,a.saveConversationId(void 0)}finally{n()||b(!1)}},[I,vt,v,_,a,bt]),St=r(async({newConversation:t})=>{let r=++yt.current,i=()=>r!==yt.current,o=_.value,s=t||!o?ut():o;s!==o&&(_.value=s,a.saveConversationId(s));let c;try{c=await I.handshake({visitorId:u,conversationId:s,userPrefs:a.loadUserPrefs(),locale:Ue})}catch(r){if(i())return;n.emit(`error`,r),e.onError?.(r),t||ee(!0);return}if(!i()){if(c.visitorId&&c.visitorId!==u&&($.info(`visitor rebound`,{previous:u,current:c.visitorId,reason:c.rebind?.visitorId}),a.setVisitorId(c.visitorId),d(c.visitorId),n.emit(`visitorRebound`,{previous:u,current:c.visitorId,reason:c.rebind?.visitorId})),c.conversationId&&c.conversationId!==s&&($.info(`conversation rebound`,{previous:s,current:c.conversationId,reason:c.rebind?.conversationId}),n.emit(`conversationRebound`,{previous:s,current:c.conversationId,reason:c.rebind?.conversationId})),c.agent&&Ee(c.agent),it(en(c.controlState)),e.mode===`page`&&(c.site&&At(c.site)?Pe(c.site):c.site&&$.warn(`invalid site config, using fallback`,{site:c.site}),c.blocks&&jt(c.blocks)?Le(c.blocks):c.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:c.blocks})),c.userPrefs&&!t&&(a.saveUserPrefs(c.userPrefs),c.userPrefs.locale&&qe(c.userPrefs.locale),c.userPrefs.soundMuted!==void 0&&L.setMuted(c.userPrefs.soundMuted),c.userPrefs.themeMode&&Je(c.userPrefs.themeMode),c.userPrefs.textSize&&Ye(c.userPrefs.textSize)),le.current=c.welcome,t||n.emit(`handshake`,c),c.welcome?.suggestions){let e=je.current;Oe(c.welcome.suggestions.map(t=>({...t,label:E(e,t.label),...t.text===void 0?{}:{text:E(e,t.text)}})))}!t&&o&&c.conversationId===o?ce.current=!0:(_.value=c.conversationId,a.saveConversationId(c.conversationId),gt(c.welcome?.messages)),t||ee(!0)}},[I,u,a,e,n,_,L,gt,xt,Ue]),Ct=JSON.stringify(e.userContext??null);i(()=>{let t=Object.keys(Ve).length?{...Ve,...e.userContext}:e.userContext;I.setContext(t,hc(e.pageContext))},[I,Ct,JSON.stringify(e.pageContext??null),JSON.stringify(Ve)]);let wt=r((e,t=[])=>Oe(e.suggestions??t),[]),Tt=r(e=>{if(!e||e===_.value)return;let t=_.value;_.value=e,a.saveConversationId(e),I.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e,reason:e})},[_,a,I,n]);i(()=>(I.primeIdentity(u,_.value),St({newConversation:!1}),()=>{yt.current++}),[]);let Et=s(!1);i(()=>{if(!(!M||!A||Et.current)&&(Et.current=!0,_t.current=I.bootstrap(),(async()=>{try{let e=await _t.current;ne(Fe((e??{forms:[]}).forms,Ke))}catch(e){$.debug(`bootstrap failed — treating as no forms`,{err:e})}finally{re(!0)}})(),ce.current)){ce.current=!1;let e=_.value;e&&xt(e)}},[M,A]);let Dt=s(null);i(()=>{if(!M||!A)return;if(Dt.current===null){Dt.current=Ke;return}if(Dt.current===Ke)return;Dt.current=Ke;let e=!1;return I.bootstrap().then(t=>{e||ne(Fe((t??{forms:[]}).forms,Ke))}).catch(e=>$.debug(`forms re-localize failed — keeping current copy`,{err:e})),()=>{e=!0}},[M,A,Ke,I]);let Ot=s(Ct);i(()=>{!A||Ot.current===Ct||(Ot.current=Ct,St({newConversation:!1}))},[Ct,A,St]);let kt=s(()=>{});ac({activated:M,conversationReady:A,conversationIdSig:_,messagesSig:v,streamingRef:we,optionsRef:Me,isChatActiveRef:D,transport:I,visitorId:u,adoptControlStateChunk:at,settleSuggestions:wt,markActiveConversationRead:ft,onReplyLanded:r(()=>kt.current(),[]),setStreaming:Ce,setActiveCancel:Ae,setCanSend:Se,feedback:L,bus:n,homeNav:k}),Ys({hostElement:t,mode:e.mode,panelSize:ge,isOpen:oe,setIsOpen:se});let{sendAiTurn:Mt,sendRoutedTurn:Pt}=sc({transport:I,messagesSig:v,conversationIdSig:_,options:e,bus:n,feedback:L,persistence:a,visitorId:u,adoptConversationId:Tt,setStreaming:Ce,setActiveCancel:Ae}),{toolInteraction:zt}=Ks({streaming:F,messagesSig:v,sendAiTurn:Mt,bus:n,humanInLoop:e.features.humanInLoop}),Bt=r((e,t)=>{$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),I.submitFeedback({messageId:e,value:t})},[n,I]),Vt=()=>v.value.reduce((e,t)=>e+ +(t.role===`user`),0),Ht=e.forms.list.length>0?e.forms:te??e.forms,R=Ro({forms:Ht,persistence:a,userContext:()=>e.userContext,messageCount:Vt,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>_.value,onComplete:(e,t,r,i)=>{$.info(`formSubmit`,{formId:e.id,trigger:t,skipped:i}),n.emit(`formSubmit`,{formId:e.id,values:r,skipped:i}),S(t=>{let n=t.find(t=>t.formId===e.id&&t.outcome===`skipped`)?.createdAt??Date.now();return[...t.filter(t=>!(t.formId===e.id&&t.outcome===`skipped`)),{key:`local:${e.id}:${n}`,formId:e.id,outcome:i?`skipped`:`submitted`,createdAt:n,...i?{}:{values:r}}]});let o=_.value??ut();_.value||(_.value=o,a.saveConversationId(o),I.primeIdentity(void 0,o)),!i&&e.mirrorToContext&&He(e=>({...e,...r})),I.submitForm({formId:e.id,conversationId:o,trigger:t,values:r,skipped:i})}}),z=f(()=>R.activeForm.value);kt.current=()=>R.fire(`after-messages`),i(()=>{R.refresh()},[Ht,R]);let Ut=e.pageContext?.area?String(e.pageContext.area):void 0,Wt=f(()=>v.value.length);i(()=>{A&&j&&R.fire(`pre-chat`)},[A,j,R]),i(()=>{j&&!xe&&R.fire(`conversation-closed`)},[j,xe,R]),i(()=>{A&&j&&Ut&&R.fire(`page-area`)},[A,j,Ut,R]);let Gt=o(()=>{let e=Ht.list.flatMap(e=>e.triggers).filter(e=>e.kind===`idle`).map(e=>Number(e.param));return e.length?Math.min(...e)*1e3:0},[Ht]);i(()=>{if(!Gt||!oe)return;let e=setTimeout(()=>R.fire(`idle`),Gt);return()=>clearTimeout(e)},[Gt,oe,R,Wt.value]);let Kt=r(async(t,r)=>{let i=tt.value!==`ai-agent`;if($.info(`send`,{textLen:t.length,attachments:r.length,streaming:F,routedToOperator:i}),F&&!i)return;n.emit(`send`,{text:t,attachmentCount:r.length}),De.length>0&&Oe([]);let a=await _c(I,r,t=>{$.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t)});L.unlock(),L.play(`messageSent`);let o=pn(t,a);if(Us(n,e,`user`,t),i){v.value=[...v.value,o],Pt(o);return}v.value=[...v.value,o,mn()],Mt({continueExisting:!1})},[F,I,n,e,De.length,v,Mt,Pt,tt]),qt=r(()=>{$.info(`stop`),n.emit(`stop`,void 0);let e=v.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,v.value=[...v.value]),ke?.()},[ke,n,v]),Jt=r(()=>{if(F)return;let e=v.value,t=e.at(-1);!t||t.role!==`assistant`||t.status!==`error`&&!Ln(t)||(v.value=[...e.slice(0,-1),mn()],$.info(`retry`),Mt({continueExisting:!1}))},[F,v,Mt]),Yt=r(()=>{if(hi(e.mode,ge)===`exit-fullscreen`){$.info(`close → exit-fullscreen`,{mode:e.mode}),_e(`normal`),n.emit(`fullscreen`,!1);return}$.info(`close → panel closed`,{mode:e.mode}),R.fire(`panel-close`),se(!1),a.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.()},[n,e,a,ge,R]),Xt=r(()=>{$.info(`open`,{mode:e.mode}),L.unlock(),P(!0),se(!0),a.savePanelOpen(!0),!fe&&!me&&he(),setTimeout(()=>P(!1),gc),lt(),n.emit(`open`,void 0),e.onOpen?.()},[n,e,L,a,fe,me,he,lt]),Qt=r(()=>{if(!v.value.some(e=>e.role===`user`)&&xe&&_.value){$.info(`clear → reusing empty conversation`,{conversationId:_.value}),v.value.length===0&>(le.current?.messages);return}$.info(`clear → new conversation`,{wasStreaming:F}),n.emit(`clear`,void 0),F&&Ce(!1),l(()=>{v.value=[],_.value=void 0}),a.clearConversation(),Se(!0),S([]),St({newConversation:!0})},[F,v,_,a,St,n,xe,gt]),$t=r(()=>{Qt(),be(`chat`);let t=e.modules.list.find(e=>e.layout===`chat`)?.id;t&&k.switchTab(t)},[Qt,k,e]),B=r(()=>{let e=ge===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:ge,expanded:e===`expanded`}),_e(e),a.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,ge,a]),tn=r(()=>{let e=ge===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:ge,fullscreen:e===`fullscreen`}),_e(e),a.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,ge,a]),nn=r(()=>{be(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),rn=r(()=>{Be(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),a.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[a,n]),an=r(e=>{$.info(`resize`,e),Xe({widgetSize:e}),n.emit(`resize`,e)},[Xe,n]),on=r(async t=>{$.info(`selectConversation`,{conversationId:t,wasStreaming:F}),n.emit(`selectConversation`,{conversationId:t}),F&&Ce(!1);try{let[e,n]=await Promise.all([I.loadConversation(t),vt(t)]),r=Sn(e.messages);l(()=>{v.value=bt(r,n),_.value=e.conversationId}),S(n),a.saveConversationId(e.conversationId),I.primeIdentity(u,e.conversationId),e.agent&&Ee(e.agent),Se(e.canContinue),it(en(e.controlState));let i=r.findLast(e=>e.role===`assistant`&&!e.ephemeral);Oe(i?.suggestions??e.suggestions??[]),be(`chat`),await I.markRead(t),dt(t)}catch(t){n.emit(`error`,t),e.onError?.(t)}},[I,v,_,n,e,a,dt,vt,bt,F,u]),V=s(null),sn=r(e=>{typeof e==`string`&&(j?R.fire(`manual`,e):V.current=e)},[j,R]);i(()=>{!j||!V.current||(R.fire(`manual`,V.current),V.current=null)},[j,R]),i(()=>Nt(t,{open:Xt,close:Yt,expand:B,fullscreen:tn,openForm:sn}),[t,Xt,Yt,B,tn,sn]);let H=o(()=>Re(e,Ue,We,Ge),[e,Ue,We,Ge]);je.current=H.strings;let cn=o(()=>x.map(e=>{let t=Ht.list.find(t=>t.id===e.formId);return{...e,title:t?.title,form:t}}),[x,Ht]),ln={options:H,transport:I,feedback:L,bus:n,persistence:a,composerApiRef:ht,view:ye,canSend:xe,isStreaming:F,controlMode:tt.value,assignedOperatorInitials:nt.value,operatorAvailable:rt.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:ot,onCancelRequest:st,loadingMessages:y,messagesSig:v,agent:Te,suggestions:De,initialWidgetSize:m.widgetSize??null,visitorId:u,onClose:Yt,onClear:Qt,onExpand:B,onFullscreen:tn,onSoundToggle:et,onToggleHistory:nn,onSelectHistoryConversation:on,onNewConversation:$t,onLocaleChange:Ze,onThemeChange:Qe,onTextSizeChange:$e,onWidgetSizeChange:an,onSend:Kt,onStop:qt,onSuggestion:t=>{let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?Kt(r,[]):ht.current?.fill(r)},activeForm:z.value?.form??null,formMarkers:cn,onFormSubmit:R.complete,onFormSkip:R.skip,onFormFill:e=>R.fire(`manual`,e),tool:zt,onRetry:Jt,onMessageFeedback:Bt},dn=e=>{on(e);let t=w();t&&k.switchTab(t)};if(!A)return null;let fn=H.modules.list,hn=e=>{let t=pi(`close`,H.mode,e);return fn.length===0?h(Hs,{strings:H.strings,onClose:t?Yt:void 0}):fn.length===1&&fn[0]?.layout===`chat`?h(ko,{...ln,panelSize:e}):h(Bs,{panelProps:{...ln,panelSize:e,onClose:t?Yt:void 0},enabledModules:fn,nav:k,bus:n,hasUnread:ct.value,onSelectConversation:dn,onStartNewConversation:$t,onSetPanelSize:_e})};if(e.mode===`page`){let e=e=>{on(e.conversationId)},t=fn.some(e=>e.layout===`chat`);return h(`div`,{class:`${fc}-anchor`,children:h(Jo,{site:Ne,blocks:Ie,transport:I,strings:H.strings,locale:H.locale,persistence:a,visitorId:u,showConversations:t,onSelectConversation:e,onNewConversation:$t,sidebarCollapsed:ze,onToggleSidebarCollapsed:rn,children:hn(`fullscreen`)})})}if(ie){let t=e.mode===`standalone`?`fullscreen`:ge;return h(`div`,{class:`${fc}-anchor`,children:hn(t)})}let gn=e.mode===`drawer`,_n=e.mode!==`modal`&&!e.launcher.hidden&&(!oe||de),vn=_n&&!de&&!fe&&!gn?H.launcher.callout:null;return g(`div`,{class:`${fc}-anchor`,"data-launcher-size":H.launcher.size,children:[oe||M?h(`div`,{class:`${fc}-surface`,hidden:!oe,children:hn(ge)}):null,_n?h(ri,{onToggle:Xt,launcher:H.launcher,strings:H.strings,leaving:de,edgeTab:gn}):null,vn?h(si,{callout:vn,launcherPosition:H.position,strings:H.strings,closeLabel:H.strings.close,onDismiss:he}):null]})}function hc(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(!(!e&&!t))return{...e,...t?{url:t}:{}}}const gc=120;async function _c(e,t,n){let r=[];for(let i of t)try{let{id:t,url:n}=await e.uploadFile(i.file);r.push({id:t,name:i.name,mediaType:i.mediaType,size:i.size,url:n})}catch(e){n(e)}return r}const vc=N.scope(`error-boundary`);var yc=class extends e{constructor(...e){super(...e),z(this,`state`,{crashed:!1})}componentDidCatch(e,t){vc.error(`widget render crashed`,{error:e,componentStack:t?.componentStack}),this.setState({crashed:!0}),this.props.onError(e,t?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};const bc={open:()=>void 0,close:()=>void 0,expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>void 0,clear:()=>void 0,suggestion:()=>void 0,toggleHistory:e=>({view:e.view}),handshake:()=>void 0,formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,tags:e.tags,count:e.count}),contentOpen:e=>({contentId:e.contentId,tags:e.tags}),contentSearch:e=>({qlen:e.queryLength,hits:e.hitCount}),contentRead:e=>({contentId:e.contentId}),contentLinkClick:e=>({contentId:e.contentId}),attach:e=>({count:e.count,bytes:e.totalBytes}),voiceStart:()=>void 0,voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>void 0,localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>void 0,error:()=>void 0};function xc(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Sc(){return location.origin+location.pathname}function Cc(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function wc(e,t){let n=Math.random(),r=0,i=0,a=new Set,o=(e,o)=>{let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||xc()||n>=s.sampleRate)return;let f=performance.now();if(f-r>6e4&&(r=f,i=0),++i>60)return;let p=new URLSearchParams;p.set(`v`,`1`),p.set(`_ev`,Bt),p.set(`e`,e),s.token&&p.set(`tk`,s.token),c&&p.set(`pk`,c),l&&p.set(`dep`,l),p.set(`vid`,t.getVisitorId());let m=t.getConversationId();m&&p.set(`cid`,m),p.set(`url`,Sc());let h=Cc();h&&p.set(`ref`,h),p.set(`sw`,String(screen.width)),p.set(`sh`,String(screen.height)),p.set(`vw`,String(innerWidth)),p.set(`vh`,String(innerHeight)),p.set(`dpr`,String(devicePixelRatio)),p.set(`lang`,navigator.language);try{p.set(`tz`,Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(p.set(`m`,u),p.set(`th`,d),o)for(let[e,t]of Object.entries(o))t!==void 0&&p.set(e,String(t));p.set(`ts`,String(Date.now()));let g=`${s.endpoint}?${p}`;if(g.length>2e3)return;let _=new Image(1,1);a.add(_);let v=()=>a.delete(_);_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g},s=Object.keys(bc).map(t=>e.on(t,e=>o(t,bc[t]?.(e))));return()=>{for(let e of s)e();a.clear()}}function Tc(e){let{bus:r,host:i,appRoot:a,persistence:o,reportError:s}=e,c=e.initialRaw,l,u=we(c),d=!0,f=()=>{u=we(l?Be(c,l):c)},p=()=>{yt(i,bt(u.mode));let e=o.loadUserPrefs().themeMode;Ot(i,e?{...u,themeMode:e}:u),d&&(Dt(i,Ec(u)),d=!1)},m=()=>{p(),n(t(yc,{onError:s},t(mc,{bus:r,hostElement:i,options:u})),a)};r.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&o.rememberStorageVersion(e.config.storageVersion),l=e.config,f(),m())});let h=wc(r,{getOptions:()=>u,getVisitorId:()=>o.getVisitorId(),getConversationId:()=>o.loadConversationId()});return{getOptions:()=>u,getUserOptions:()=>c,render:m,setUserOptions:e=>{c=e,f(),m()},patchUserOptions:e=>{c={...c,...e},f(),m()},destroy:()=>h()}}function Ec(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=pt(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=It(e,Lt(),t.loadPanelOpen(),t.loadPanelSize());return Pt(e.mode,r,n)}var Dc=class{constructor(){z(this,`handlers`,new Map)}on(e,t){let n=this.handlers.get(e);return n||(n=new Set,this.handlers.set(e,n)),n.add(t),()=>this.handlers.get(e)?.delete(t)}emit(e,t){let n=this.handlers.get(e);if(n)for(let e of n)try{e(t)}catch{}}clear(){this.handlers.clear()}},Oc=class extends HTMLElement{constructor(...e){super(...e),z(this,`bus`,new Dc),z(this,`mountResult`,null),z(this,`runtime`,null)}static get observedAttributes(){return at}connectedCallback(){this.boot()}disconnectedCallback(){this.mountResult&&(this.runtime?.destroy(),this.runtime=null,n(null,this.mountResult.appRoot),this.bus.clear())}attributeChangedCallback(){this.isConnected&&this.boot()}boot(){let e=ot(e=>this.getAttribute(e));if(this.runtime){this.runtime.setUserOptions(e);return}let t=we(e);this.mountResult||(this.mountResult=xt({existingHost:this,position:bt(t.mode)}));let n=pt(t.widgetId,t.storage,t.aiAgentDeploymentId);this.runtime=Tc({bus:this.bus,host:this.mountResult.hostElement,appRoot:this.mountResult.appRoot,persistence:n,initialRaw:e,reportError:e=>this.bus.emit(`error`,e)}),this.runtime.render()}};let kc=!1;function Ac(){if(kc||typeof customElements>`u`)return;let e=y.tagName;customElements.get(e)||customElements.define(e,Oc),kc=!0}typeof customElements<`u`&&Ac();export{Ac as registerWebComponent};
|
|
13
13
|
//# sourceMappingURL=web-component.mjs.map
|