@helpai/elements 6.14.0 → 6.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web-component.mjs CHANGED
@@ -1,44 +1,44 @@
1
1
  import{Component as e,h as t,render as n}from"preact";import{batch as r,computed as i,effect as a,signal as o,useComputed as s,useSignal as c}from"@preact/signals";import{useCallback as l,useEffect as u,useId as d,useLayoutEffect as f,useMemo as p,useRef as m,useState as h}from"preact/hooks";import{Fragment as g,jsx as _,jsxs as v}from"preact/jsx-runtime";import*as y from"streaming-markdown";import{memo as b}from"preact/compat";const x=[`en`,`fr`,`es`,`ar`,`he`,`zh`];function S(e){let t=e?.split(`-`)[0]?.toLowerCase();return x.find(e=>e===t)??`en`}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function w(e){return C(e)?e.id??e.key:void 0}function T(e,t){return C(e)&&C(t)?Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t)])].map(n=>[n,T(e[n],t[n])])):Array.isArray(e)&&Array.isArray(t)&&t.length>0&&t.every(e=>w(e)!==void 0)?e.map(e=>T(e,t.find(t=>w(t)===w(e)))):t==null||typeof t==`string`&&!t.trim()?e:t}function E(e,t){let n=t?.toLowerCase(),r=n?.split(`-`)[0],i=e.translations??[],a=i.find(e=>e.locale.toLowerCase()===n)??i.find(e=>e.locale.toLowerCase().split(`-`)[0]===r);if(!a)return e;let{locale:o,...s}=a;return T(e,s)}const D={attach:`Attach files`,file:`File`,attachmentMimeRejected:`{name} isn't a file type this chat accepts.`,attachmentTooLarge:`{name} is too large. Files can be up to {max} together.`,poweredBy:`Powered by {name}`,attachmentTooMany:`The attachment limit is {count}.`,attachmentUploadFailed:`{name} couldn't be uploaded.`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,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`,dropZoneRejected:`These files can't be attached here`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRateLimitedIn:`Too many requests — please try again in {seconds} s.`,errorOffline:`Can't reach the server. Check your connection and try again.`,errorServer:`Something went wrong on our side. Please try again.`,errorOriginNotAllowed:`This chat isn't set up for this website yet.`,errorMessageTooLong:`That message is too long. Shorten it and send it again.`,errorReconnecting:`Connection lost. Reconnecting…`,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`,loadMoreConversations:`Load more conversations`,language:`Language`,launcherOpen:`Open chat`,launcherAsk:`Ask {name}`,micBlocked:`The microphone is blocked for this site, so voice input can't start.`,micStart:`Start voice input`,micStop:`Stop voice input`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,removeAttachment:`Remove {name}`,suggestedReplies:`Suggested replies`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,operatorBadgeTitle:`Live chat`,chatNotice:`You're chatting with an AI assistant.`,cancelOperatorRequest:`Keep chatting with the AI`,loginPrompt:`Log in for faster, more personalized support`,loginAction:`Log in`,loginRequired:`Log in to chat with us`,loginExpired:`Your login expired. Log in to continue this chat.`,loginExpiredGuest:`Your login expired. Log in to continue this chat, or start a new conversation as a guest.`,startAsGuest:`Start new conversation`,loggedInAs:`Logged in as {name}`,loggedIn:`Logged in`,dismissLoginPrompt:`Hide`,emailTranscript:`Email transcript`,emailTranscriptPrompt:`Get a copy of this conversation by email.`,emailTranscriptEmailLabel:`Email address`,emailTranscriptSend:`Send transcript`,emailTranscriptSending:`Sending…`,emailTranscriptSent:`Sent to {email}.`,emailTranscriptAlreadySent:`This conversation was already emailed. Send a new message to email it again.`,emailTranscriptLimited:`You've reached the limit for now. Try again later.`,emailTranscriptFailed:`Couldn't send it. Try again.`,emailTranscriptNotDelivered:`Couldn't send to this address. Check it and try again.`,emailTranscriptCancel:`Cancel`,emailTranscriptDone:`Done`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,visualSoldOut:`Sold out`,visualCartEmpty:`Your cart is empty.`,visualQuantity:`Qty`,visualChoose:`Choose`,visualDirect:`Direct`,visualVia:`via`,visualNight:`1 night`,visualNights:`{count} nights`,visualPerNight:`per night`,visualTravellers:`Travellers`,thinking:`Thinking…`,thought:`Thought`,thoughtFor:`Thought for {time}`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,copyTicketReference:`Ticket {reference}, copy`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,chatUnavailable:`This chat isn't available right now`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsShowMore:`Show more`,newsUnseen:`New post`,unread:`Unread`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidNumber:`Enter a valid number`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,askFallbackQuestion:`Please provide the missing information.`,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`,decline:`Decline`,changeAnswer:`Change answer`,approvalPrompt:`{action}?`,approvalEditHint:`You can change your answer until this step continues.`,stepInput:`Input`,stepWorking:`Working`,stepWorkingOnIt:`Working on it…`,stepNeedsYourApproval:`Needs your approval`,stepWaitingForVisitor:`Waiting for the visitor`,stepApproved:`Approved`,stepDeclined:`Declined`,stepReplaced:`Replaced`,stepFailed:`Failed`,stepDidNotWork:`Didn't work`,decidedYouApproved:`You approved`,decidedYouDeclined:`You declined`,decidedVisitorApproved:`Visitor approved`,decidedVisitorDeclined:`Visitor declined`,decidedTeamApproved:`Approved by a team member`,decidedTeamDeclined:`Declined by a team member`,decidedMemberApproved:`Approved by {name}`,decidedMemberDeclined:`Declined by {name}`,stepRawData:`Raw data`,decidedRulesApproved:`Auto-approved`,decidedRulesDeclined:`Auto-declined`,edit:`Edit`,toolStepsFailed:`{count} failed`,statusStopped:`Stopped`,toolStepsStopped:`Stopped after {count} steps`,toolStepsStoppedOne:`Stopped after 1 step`},O={en:D,fr:{attach:`Joindre des fichiers`,file:`Fichier`,attachmentMimeRejected:`{name} n'est pas un type de fichier accepté ici.`,attachmentTooLarge:`{name} est trop volumineux. Les fichiers peuvent faire jusqu'à {max} au total.`,poweredBy:`Propulsé par {name}`,attachmentTooMany:`Limite de pièces jointes : {count}.`,attachmentUploadFailed:`{name} n'a pas pu être envoyé.`,conversationLoading:`Chargement du chat…`,loadPreviousMessages:`Charger les messages précédents`,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`,dropZoneRejected:`Ces fichiers ne peuvent pas être joints ici`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRateLimitedIn:`Trop de requêtes — veuillez réessayer dans {seconds} s.`,errorOffline:`Impossible de joindre le serveur. Vérifiez votre connexion et réessayez.`,errorServer:`Un problème est survenu de notre côté. Veuillez réessayer.`,errorOriginNotAllowed:`Ce chat n'est pas encore configuré pour ce site.`,errorMessageTooLong:`Ce message est trop long. Raccourcissez-le et renvoyez-le.`,errorReconnecting:`Connexion perdue. Reconnexion…`,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`,loadMoreConversations:`Charger plus de conversations`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherAsk:`Demander à {name}`,micBlocked:`Le micro est bloqué pour ce site : la saisie vocale ne peut pas démarrer.`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,popOut:`Ouvrir dans un nouvel onglet`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,queueMessage:`Mettre le message en attente`,removeQueuedMessage:`Retirer le message en attente`,removeAttachment:`Retirer {name}`,suggestedReplies:`Réponses suggérées`,compactingContext:`Optimisation du contexte de la conversation…`,soundOff:`Son désactivé`,soundOn:`Son activé`,talkToOperator:`Parler à une personne`,connectingOperator:`Mise en relation avec une personne…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,operatorBadgeTitle:`Chat en direct`,chatNotice:`Vous discutez avec un assistant IA.`,cancelOperatorRequest:`Continuer avec l'IA`,loginPrompt:`Connectez-vous pour une aide plus rapide et personnalisée`,loginAction:`Se connecter`,loginRequired:`Connectez-vous pour discuter avec nous`,loginExpired:`Votre connexion a expiré. Connectez-vous pour poursuivre cette conversation.`,loginExpiredGuest:`Votre connexion a expiré. Connectez-vous pour poursuivre cette conversation, ou démarrez-en une nouvelle en tant qu'invité.`,startAsGuest:`Démarrer une nouvelle conversation`,loggedInAs:`Connecté en tant que {name}`,loggedIn:`Connecté`,dismissLoginPrompt:`Masquer`,emailTranscript:`Envoyer la transcription`,emailTranscriptPrompt:`Recevez une copie de cette conversation par e-mail.`,emailTranscriptEmailLabel:`Adresse e-mail`,emailTranscriptSend:`Envoyer la transcription`,emailTranscriptSending:`Envoi…`,emailTranscriptSent:`Envoyé à {email}.`,emailTranscriptAlreadySent:`Cette conversation a déjà été envoyée. Envoyez un nouveau message pour l'envoyer à nouveau.`,emailTranscriptLimited:`Vous avez atteint la limite pour le moment. Réessayez plus tard.`,emailTranscriptFailed:`Envoi impossible. Réessayez.`,emailTranscriptNotDelivered:`Envoi impossible à cette adresse. Vérifiez-la et réessayez.`,emailTranscriptCancel:`Annuler`,emailTranscriptDone:`Terminé`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,visualPreparing:`Préparation du visuel…`,visualError:`Ce visuel n’a pas pu être affiché.`,visualPartial:`Certaines parties de ce visuel n’ont pas pu être affichées.`,visualSoldOut:`Épuisé`,visualCartEmpty:`Votre panier est vide.`,visualQuantity:`Qté`,visualChoose:`Choisissez`,visualDirect:`Direct`,visualVia:`via`,visualNight:`1 nuit`,visualNights:`{count} nuits`,visualPerNight:`par nuit`,visualTravellers:`Voyageurs`,thinking:`Réflexion…`,thought:`Réflexion`,thoughtFor:`Réflexion : {time}`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,copyTicketReference:`Ticket {reference}, copier`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,chatUnavailable:`Ce chat n'est pas disponible pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,contentHelpful:`Cela vous a-t-il aidé ?`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeAskPlaceholder:`Posez une question…`,homeWhatsNew:`Nouveautés`,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 pour «\xA0{query}\xA0»`,helpShowMore:`Afficher plus`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsShowMore:`Afficher plus`,newsUnseen:`Nouvelle publication`,unread:`Non lu`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidNumber:`Saisissez un nombre valide`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,askFallbackQuestion:`Veuillez fournir les informations manquantes.`,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`,decline:`Refuser`,changeAnswer:`Modifier la réponse`,approvalPrompt:`{action} ?`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,stepInput:`Entrée`,stepWorking:`En cours`,stepWorkingOnIt:`En cours…`,stepNeedsYourApproval:`Votre accord est requis`,stepWaitingForVisitor:`En attente du visiteur`,stepApproved:`Approuvé`,stepDeclined:`Refusé`,stepReplaced:`Remplacé`,stepFailed:`Échec`,stepDidNotWork:`N'a pas fonctionné`,decidedYouApproved:`Vous avez approuvé`,decidedYouDeclined:`Vous avez refusé`,decidedVisitorApproved:`Approuvé par le visiteur`,decidedVisitorDeclined:`Refusé par le visiteur`,decidedTeamApproved:`Approuvé par un membre de l'équipe`,decidedTeamDeclined:`Refusé par un membre de l'équipe`,decidedMemberApproved:`Approuvé par {name}`,decidedMemberDeclined:`Refusé par {name}`,stepRawData:`Données brutes`,decidedRulesApproved:`Approuvé automatiquement`,decidedRulesDeclined:`Refusé automatiquement`,edit:`Modifier`,toolStepsFailed:`{count} en échec`,statusStopped:`Arrêté`,toolStepsStopped:`Arrêté après {count} étapes`,toolStepsStoppedOne:`Arrêté après 1 étape`},es:{attach:`Adjuntar archivos`,file:`Archivo`,attachmentMimeRejected:`{name} no es un tipo de archivo que acepte este chat.`,attachmentTooLarge:`{name} es demasiado grande. Los archivos pueden ocupar hasta {max} en total.`,poweredBy:`Con la tecnología de {name}`,attachmentTooMany:`Límite de adjuntos: {count}.`,attachmentUploadFailed:`No se pudo subir {name}.`,conversationLoading:`Cargando chat…`,loadPreviousMessages:`Cargar mensajes anteriores`,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`,dropZoneRejected:`Estos archivos no se pueden adjuntar aquí`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRateLimitedIn:`Demasiadas solicitudes: inténtalo de nuevo en {seconds} s.`,errorOffline:`No se puede conectar con el servidor. Revisa tu conexión e inténtalo de nuevo.`,errorServer:`Algo salió mal por nuestra parte. Inténtalo de nuevo.`,errorOriginNotAllowed:`Este chat aún no está configurado para este sitio web.`,errorMessageTooLong:`Ese mensaje es demasiado largo. Acórtalo y envíalo de nuevo.`,errorReconnecting:`Se perdió la conexión. Reconectando…`,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`,loadMoreConversations:`Cargar más conversaciones`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherAsk:`Pregúntale a {name}`,micBlocked:`El micrófono está bloqueado para este sitio, así que la entrada de voz no puede iniciarse.`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,popOut:`Abrir en una pestaña nueva`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,queueMessage:`Poner mensaje en cola`,removeQueuedMessage:`Quitar mensaje de la cola`,removeAttachment:`Quitar {name}`,suggestedReplies:`Respuestas sugeridas`,compactingContext:`Optimizando el contexto de la conversación…`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,talkToOperator:`Hablar con una persona`,connectingOperator:`Conectándote con una persona…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,operatorBadgeTitle:`Chat en vivo`,chatNotice:`Estás chateando con un asistente de IA.`,cancelOperatorRequest:`Seguir con la IA`,loginPrompt:`Inicia sesión para recibir una ayuda más rápida y personalizada`,loginAction:`Iniciar sesión`,loginRequired:`Inicia sesión para chatear con nosotros`,loginExpired:`Tu sesión ha caducado. Inicia sesión para continuar esta conversación.`,loginExpiredGuest:`Tu sesión ha caducado. Inicia sesión para continuar esta conversación o empieza una nueva como invitado.`,startAsGuest:`Empezar una nueva conversación`,loggedInAs:`Sesión iniciada como {name}`,loggedIn:`Sesión iniciada`,dismissLoginPrompt:`Ocultar`,emailTranscript:`Enviar transcripción`,emailTranscriptPrompt:`Recibe una copia de esta conversación por correo.`,emailTranscriptEmailLabel:`Correo electrónico`,emailTranscriptSend:`Enviar transcripción`,emailTranscriptSending:`Enviando…`,emailTranscriptSent:`Enviado a {email}.`,emailTranscriptAlreadySent:`Esta conversación ya se envió. Envía un mensaje nuevo para enviarla otra vez.`,emailTranscriptLimited:`Has alcanzado el límite por ahora. Inténtalo más tarde.`,emailTranscriptFailed:`No se pudo enviar. Inténtalo de nuevo.`,emailTranscriptNotDelivered:`No se pudo enviar a esta dirección. Revísala e inténtalo de nuevo.`,emailTranscriptCancel:`Cancelar`,emailTranscriptDone:`Listo`,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…`,visualPreparing:`Preparando visualización…`,visualError:`No se pudo mostrar esta visualización.`,visualPartial:`No se pudieron mostrar algunas partes de esta visualización.`,visualSoldOut:`Agotado`,visualCartEmpty:`Tu carrito está vacío.`,visualQuantity:`Cant.`,visualChoose:`Elige`,visualDirect:`Directo`,visualVia:`vía`,visualNight:`1 noche`,visualNights:`{count} noches`,visualPerNight:`por noche`,visualTravellers:`Viajeros`,thinking:`Pensando…`,thought:`Razonamiento`,thoughtFor:`Razonó durante {time}`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,copyTicketReference:`Ticket {reference}, copiar`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,chatUnavailable:`Este chat no está disponible en este momento`,moduleBack:`Atrás`,contentLoading:`Cargando…`,contentHelpful:`¿Te resultó útil?`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeAskPlaceholder:`Haz una pregunta…`,homeWhatsNew:`Lo nuevo`,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:`Sin resultados para «{query}»`,helpShowMore:`Mostrar más`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsShowMore:`Mostrar más`,newsUnseen:`Publicación nueva`,unread:`No leído`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidNumber:`Introduce un número válido`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,askFallbackQuestion:`Indica la información que falta.`,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`,decline:`Rechazar`,changeAnswer:`Cambiar respuesta`,approvalPrompt:`¿{action}?`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,stepInput:`Entrada`,stepWorking:`En curso`,stepWorkingOnIt:`En curso…`,stepNeedsYourApproval:`Necesita tu aprobación`,stepWaitingForVisitor:`Esperando al visitante`,stepApproved:`Aprobado`,stepDeclined:`Rechazado`,stepReplaced:`Reemplazado`,stepFailed:`Falló`,stepDidNotWork:`No funcionó`,decidedYouApproved:`Lo aprobaste`,decidedYouDeclined:`Lo rechazaste`,decidedVisitorApproved:`El visitante aprobó`,decidedVisitorDeclined:`El visitante rechazó`,decidedTeamApproved:`Aprobado por un miembro del equipo`,decidedTeamDeclined:`Rechazado por un miembro del equipo`,decidedMemberApproved:`Aprobado por {name}`,decidedMemberDeclined:`Rechazado por {name}`,stepRawData:`Datos sin procesar`,decidedRulesApproved:`Aprobado automáticamente`,decidedRulesDeclined:`Rechazado automáticamente`,edit:`Editar`,toolStepsFailed:`{count} con error`,statusStopped:`Detenido`,toolStepsStopped:`Detenido tras {count} pasos`,toolStepsStoppedOne:`Detenido tras 1 paso`},ar:{attach:`إرفاق ملفات`,file:`ملف`,attachmentMimeRejected:`نوع الملف {name} غير مقبول في هذه المحادثة.`,attachmentTooLarge:`الملف {name} كبير جدًا. يمكن أن يصل حجم الملفات معًا إلى {max}.`,poweredBy:`مدعوم من {name}`,attachmentTooMany:`الحد الأقصى للمرفقات: {count}.`,attachmentUploadFailed:`تعذّر رفع {name}.`,conversationLoading:`جارٍ تحميل الدردشة…`,loadPreviousMessages:`تحميل الرسائل السابقة`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,dropZoneRejected:`لا يمكن إرفاق هذه الملفات هنا`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRateLimitedIn:`طلبات كثيرة جدًا — يرجى المحاولة بعد {seconds} ث.`,errorOffline:`تعذّر الوصول إلى الخادم. تحقّق من اتصالك وحاول مرة أخرى.`,errorServer:`حدث خطأ من جهتنا. يرجى المحاولة مرة أخرى.`,errorOriginNotAllowed:`هذه المحادثة غير مُعدّة لهذا الموقع بعد.`,errorMessageTooLong:`هذه الرسالة طويلة جدًا. اختصرها وأرسلها مرة أخرى.`,errorReconnecting:`انقطع الاتصال. جارٍ إعادة الاتصال…`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,loadMoreConversations:`تحميل المزيد من المحادثات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherAsk:`اسأل {name}`,micBlocked:`الميكروفون محظور لهذا الموقع، لذا لا يمكن بدء الإدخال الصوتي.`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,popOut:`فتح في علامة تبويب جديدة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,queueMessage:`إضافة الرسالة إلى قائمة الانتظار`,removeQueuedMessage:`إزالة الرسالة من قائمة الانتظار`,removeAttachment:`إزالة {name}`,suggestedReplies:`ردود مقترحة`,compactingContext:`جارٍ تحسين سياق المحادثة…`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,talkToOperator:`التحدث إلى شخص`,connectingOperator:`جارٍ توصيلك بشخص…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,operatorBadgeTitle:`محادثة مباشرة`,chatNotice:`أنت تتحدث مع مساعد ذكاء اصطناعي.`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,loginPrompt:`سجّل الدخول للحصول على دعم أسرع ومخصّص لك`,loginAction:`تسجيل الدخول`,loginRequired:`سجّل الدخول للدردشة معنا`,loginExpired:`انتهت صلاحية تسجيل دخولك. سجّل الدخول لمتابعة هذه المحادثة.`,loginExpiredGuest:`انتهت صلاحية تسجيل دخولك. سجّل الدخول لمتابعة هذه المحادثة، أو ابدأ محادثة جديدة كضيف.`,startAsGuest:`بدء محادثة جديدة`,loggedInAs:`تم تسجيل الدخول باسم {name}`,loggedIn:`تم تسجيل الدخول`,dismissLoginPrompt:`إخفاء`,emailTranscript:`إرسال نص المحادثة`,emailTranscriptPrompt:`احصل على نسخة من هذه المحادثة عبر البريد الإلكتروني.`,emailTranscriptEmailLabel:`عنوان البريد الإلكتروني`,emailTranscriptSend:`إرسال نص المحادثة`,emailTranscriptSending:`جارٍ الإرسال…`,emailTranscriptSent:`تم الإرسال إلى {email}.`,emailTranscriptAlreadySent:`تم إرسال هذه المحادثة بالفعل. أرسل رسالة جديدة لإرسالها مرة أخرى.`,emailTranscriptLimited:`لقد بلغت الحد المسموح به حاليًا. حاول مرة أخرى لاحقًا.`,emailTranscriptFailed:`تعذّر الإرسال. حاول مرة أخرى.`,emailTranscriptNotDelivered:`تعذّر الإرسال إلى هذا العنوان. تحقّق منه وحاول مرة أخرى.`,emailTranscriptCancel:`إلغاء`,emailTranscriptDone:`تم`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,visualPreparing:`جارٍ إعداد المحتوى المرئي…`,visualError:`تعذر عرض هذا المحتوى المرئي.`,visualPartial:`تعذر عرض بعض أجزاء هذا المحتوى المرئي.`,visualSoldOut:`نفدت الكمية`,visualCartEmpty:`سلتك فارغة.`,visualQuantity:`الكمية`,visualChoose:`اختر`,visualDirect:`مباشر`,visualVia:`عبر`,visualNight:`ليلة واحدة`,visualNights:`الليالي: {count}`,visualPerNight:`لليلة`,visualTravellers:`المسافرون`,thinking:`يفكّر…`,thought:`تفكير`,thoughtFor:`فكّر لمدة {time}`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,copyTicketReference:`التذكرة {reference}، نسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,chatUnavailable:`هذه المحادثة غير متاحة حالياً`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,contentHelpful:`هل كان هذا مفيدًا؟`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeAskPlaceholder:`اطرح سؤالاً…`,homeWhatsNew:`ما الجديد`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا نتائج لـ «{query}»`,helpShowMore:`عرض المزيد`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsShowMore:`عرض المزيد`,newsUnseen:`منشور جديد`,unread:`غير مقروء`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,askFallbackQuestion:`يرجى تقديم المعلومات الناقصة.`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,decline:`رفض`,changeAnswer:`تغيير الإجابة`,approvalPrompt:`{action}؟`,approvalEditHint:`يمكنك تغيير إجابتك حتى تستأنف هذه الخطوة.`,stepInput:`المدخلات`,stepWorking:`قيد التنفيذ`,stepWorkingOnIt:`جارٍ التنفيذ…`,stepNeedsYourApproval:`بحاجة إلى موافقتك`,stepWaitingForVisitor:`بانتظار الزائر`,stepApproved:`تمت الموافقة`,stepDeclined:`مرفوض`,stepReplaced:`تم الاستبدال`,stepFailed:`فشل`,stepDidNotWork:`لم ينجح`,decidedYouApproved:`وافقت`,decidedYouDeclined:`رفضت`,decidedVisitorApproved:`وافق الزائر`,decidedVisitorDeclined:`رفض الزائر`,decidedTeamApproved:`وافق عضو في الفريق`,decidedTeamDeclined:`رفض عضو في الفريق`,decidedMemberApproved:`وافق {name}`,decidedMemberDeclined:`رفض {name}`,stepRawData:`البيانات الأولية`,decidedRulesApproved:`تمت الموافقة تلقائيًا`,decidedRulesDeclined:`رُفض تلقائيًا`,edit:`تعديل`,toolStepsFailed:`فشل {count}`,statusStopped:`أُوقف`,toolStepsStopped:`أُوقف بعد {count} خطوات`,toolStepsStoppedOne:`أُوقف بعد خطوة واحدة`},he:{attach:`צירוף קבצים`,file:`קובץ`,attachmentMimeRejected:`הקובץ {name} אינו מסוג שהצ׳אט הזה מקבל.`,attachmentTooLarge:`הקובץ {name} גדול מדי. הקבצים יכולים להגיע יחד עד {max}.`,poweredBy:`מופעל על ידי {name}`,attachmentTooMany:`מספר הקבצים המרבי לצירוף: {count}.`,attachmentUploadFailed:`לא ניתן היה להעלות את {name}.`,conversationLoading:`טוען צ׳אט…`,loadPreviousMessages:`טעינת הודעות קודמות`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,dropZoneRejected:`לא ניתן לצרף כאן את הקבצים האלה`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRateLimitedIn:`יותר מדי בקשות — נסה שוב בעוד {seconds} שנ׳.`,errorOffline:`אין חיבור לשרת. בדוק את החיבור ונסה שוב.`,errorServer:`משהו השתבש אצלנו. נסה שוב.`,errorOriginNotAllowed:`הצ'אט הזה עדיין לא מוגדר לאתר הזה.`,errorMessageTooLong:`ההודעה הזו ארוכה מדי. קצרו אותה ושלחו שוב.`,errorReconnecting:`החיבור אבד. מתחבר מחדש…`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,loadMoreConversations:`טעינת שיחות נוספות`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherAsk:`לשאול את {name}`,micBlocked:`המיקרופון חסום באתר הזה, ולכן אי אפשר להתחיל קלט קולי.`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,popOut:`פתיחה בכרטיסייה חדשה`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,queueMessage:`הוספת ההודעה לתור`,removeQueuedMessage:`הסרת ההודעה מהתור`,removeAttachment:`הסרת {name}`,suggestedReplies:`תשובות מוצעות`,compactingContext:`מבצע אופטימיזציה להקשר השיחה…`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,talkToOperator:`דברו עם אדם`,connectingOperator:`מחברים אותך לאדם…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,operatorBadgeTitle:`צ׳אט חי`,chatNotice:`אתה מצ׳וטט עם עוזר בינה מלאכותית.`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,loginPrompt:`התחברו לקבלת תמיכה מהירה ומותאמת אישית`,loginAction:`התחברות`,loginRequired:`התחברו כדי לשוחח איתנו`,loginExpired:`פג תוקף ההתחברות שלך. התחברו כדי להמשיך בשיחה הזו.`,loginExpiredGuest:`פג תוקף ההתחברות שלך. התחברו כדי להמשיך בשיחה הזו, או התחילו שיחה חדשה כאורחים.`,startAsGuest:`התחלת שיחה חדשה`,loggedInAs:`מחובר/ת בתור {name}`,loggedIn:`מחובר/ת`,dismissLoginPrompt:`הסתרה`,emailTranscript:`שליחת תמליל בדוא״ל`,emailTranscriptPrompt:`קבלו עותק של השיחה הזו בדוא״ל.`,emailTranscriptEmailLabel:`כתובת דוא״ל`,emailTranscriptSend:`שליחת התמליל`,emailTranscriptSending:`שולחים…`,emailTranscriptSent:`נשלח אל {email}.`,emailTranscriptAlreadySent:`השיחה הזו כבר נשלחה. שלחו הודעה חדשה כדי לשלוח אותה שוב.`,emailTranscriptLimited:`הגעתם למגבלה כרגע. נסו שוב מאוחר יותר.`,emailTranscriptFailed:`השליחה נכשלה. נסו שוב.`,emailTranscriptNotDelivered:`לא ניתן לשלוח לכתובת הזו. בדקו אותה ונסו שוב.`,emailTranscriptCancel:`ביטול`,emailTranscriptDone:`סיום`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,visualPreparing:`מכין תצוגה…`,visualError:`לא ניתן היה להציג תצוגה זו.`,visualPartial:`לא ניתן היה להציג חלקים מתצוגה זו.`,visualSoldOut:`אזל מהמלאי`,visualCartEmpty:`העגלה שלך ריקה.`,visualQuantity:`כמות`,visualChoose:`בחרו`,visualDirect:`ישיר`,visualVia:`דרך`,visualNight:`לילה אחד`,visualNights:`{count} לילות`,visualPerNight:`ללילה`,visualTravellers:`נוסעים`,thinking:`חושב…`,thought:`מחשבה`,thoughtFor:`חשב במשך {time}`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,copyTicketReference:`פנייה {reference}, העתקה`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,chatUnavailable:`הצ׳אט הזה אינו זמין כרגע`,moduleBack:`חזרה`,contentLoading:`טוען…`,contentHelpful:`האם זה עזר?`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeAskPlaceholder:`שאלו שאלה…`,homeWhatsNew:`מה חדש`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`אין תוצאות עבור „{query}”`,helpShowMore:`הצגת עוד`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsShowMore:`הצגת עוד`,newsUnseen:`פוסט חדש`,unread:`לא נקרא`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidNumber:`הזן מספר תקין`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,askFallbackQuestion:`אנא ספקו את המידע החסר.`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,decline:`דחייה`,changeAnswer:`שינוי התשובה`,approvalPrompt:`{action}?`,approvalEditHint:`אפשר לשנות את התשובה עד שהשלב הזה ימשיך.`,stepInput:`קלט`,stepWorking:`בביצוע`,stepWorkingOnIt:`מטפלים בזה…`,stepNeedsYourApproval:`נדרש האישור שלך`,stepWaitingForVisitor:`ממתין למבקר`,stepApproved:`אושר`,stepDeclined:`נדחה`,stepReplaced:`הוחלף`,stepFailed:`נכשל`,stepDidNotWork:`לא הצליח`,decidedYouApproved:`אישרת`,decidedYouDeclined:`דחית`,decidedVisitorApproved:`אושר על ידי המבקר`,decidedVisitorDeclined:`נדחה על ידי המבקר`,decidedTeamApproved:`אושר על ידי חבר צוות`,decidedTeamDeclined:`נדחה על ידי חבר צוות`,decidedMemberApproved:`אושר על ידי {name}`,decidedMemberDeclined:`נדחה על ידי {name}`,stepRawData:`נתונים גולמיים`,decidedRulesApproved:`אושר אוטומטית`,decidedRulesDeclined:`נדחה אוטומטית`,edit:`עריכה`,toolStepsFailed:`{count} נכשלו`,statusStopped:`נעצר`,toolStepsStopped:`נעצר אחרי {count} שלבים`,toolStepsStoppedOne:`נעצר אחרי שלב אחד`},zh:{attach:`添加附件`,file:`文件`,attachmentMimeRejected:`此聊天不接受 {name} 的文件类型。`,attachmentTooLarge:`{name} 太大了。文件总大小不能超过 {max}。`,poweredBy:`由 {name} 提供支持`,attachmentTooMany:`最多可添加 {count} 个附件。`,attachmentUploadFailed:`{name} 上传失败。`,conversationLoading:`正在加载聊天…`,loadPreviousMessages:`加载更早的消息`,close:`关闭`,collapse:`收起`,collapseSidebar:`收起侧边栏`,composerPlaceholder:`输入消息…`,dateLastWeek:`最近 7 天`,dateOlder:`更早`,dateToday:`今天`,dateYesterday:`昨天`,dropZone:`拖放文件以添加附件`,dropZoneRejected:`这些文件无法在此添加`,errorGeneric:`出了点问题`,errorRateLimited:`请求过多,请稍后再试。`,errorRateLimitedIn:`请求过多,请在 {seconds} 秒后重试。`,errorOffline:`无法连接服务器。请检查网络后重试。`,errorServer:`我们这边出了点问题。请重试。`,errorOriginNotAllowed:`此聊天尚未为本网站设置。`,errorMessageTooLong:`消息太长了。请缩短后重新发送。`,errorReconnecting:`连接已断开,正在重新连接…`,errorRetry:`重试`,expand:`展开`,expandSidebar:`展开侧边栏`,exitFullscreen:`退出全屏`,fullscreen:`全屏`,history:`历史记录`,historyBack:`返回聊天`,historyEmpty:`还没有以前的聊天`,historyLoading:`正在加载你的聊天…`,historyContinue:`继续聊天`,historyTitle:`聊天记录`,loadMoreConversations:`加载更多对话`,language:`语言`,launcherOpen:`打开聊天`,launcherAsk:`询问 {name}`,micBlocked:`此网站的麦克风已被阻止,无法开始语音输入。`,micStart:`开始语音输入`,micStop:`停止语音输入`,moreActions:`更多操作`,newConversation:`新聊天`,panelTitle:`聊天`,popOut:`在新标签页中打开`,resizeHandle:`拖动以调整大小`,scrollToBottom:`滚动到最新`,send:`发送`,queueMessage:`排队发送`,removeQueuedMessage:`移除排队的消息`,removeAttachment:`移除 {name}`,suggestedReplies:`推荐回复`,compactingContext:`正在优化对话上下文…`,soundOff:`关闭声音`,soundOn:`打开声音`,talkToOperator:`与真人交谈`,connectingOperator:`正在为你联系真人…`,noOperatorAvailable:`目前没有人有空,请留下你的联系方式,我们会跟进。`,chattingWithOperator:`你正在与 {operator} 聊天`,operatorBadgeTitle:`在线聊天`,chatNotice:`你正在与 AI 助手聊天。`,cancelOperatorRequest:`继续与 AI 聊天`,loginPrompt:`登录以获得更快、更个性化的支持`,loginAction:`登录`,loginRequired:`登录后与我们聊天`,loginExpired:`你的登录已过期。请登录以继续此聊天。`,loginExpiredGuest:`你的登录已过期。请登录以继续此聊天,或以访客身份开始新对话。`,startAsGuest:`开始新对话`,loggedInAs:`已登录为 {name}`,loggedIn:`已登录`,dismissLoginPrompt:`隐藏`,emailTranscript:`通过邮件发送聊天记录`,emailTranscriptPrompt:`通过邮件获取此对话的副本。`,emailTranscriptEmailLabel:`邮箱地址`,emailTranscriptSend:`发送聊天记录`,emailTranscriptSending:`正在发送…`,emailTranscriptSent:`已发送至 {email}。`,emailTranscriptAlreadySent:`此对话已通过邮件发送。发送一条新消息后可再次发送。`,emailTranscriptLimited:`你已达到当前上限。请稍后再试。`,emailTranscriptFailed:`发送失败。请重试。`,emailTranscriptNotDelivered:`无法发送到此地址。请检查后重试。`,emailTranscriptCancel:`取消`,emailTranscriptDone:`完成`,stop:`停止`,theme:`主题`,themeAuto:`自动`,themeDark:`深色`,themeLight:`浅色`,textSize:`文字大小`,textSizeSmall:`小`,textSizeNormal:`标准`,textSizeLarge:`大`,loading:`正在加载…`,visualPreparing:`正在准备图表…`,visualError:`无法显示此图表。`,visualPartial:`此图表的部分内容无法显示。`,visualSoldOut:`已售罄`,visualCartEmpty:`你的购物车是空的。`,visualQuantity:`数量`,visualChoose:`选择`,visualDirect:`直飞`,visualVia:`经停`,visualNight:`1 晚`,visualNights:`{count} 晚`,visualPerNight:`每晚`,visualTravellers:`旅客`,thinking:`正在思考…`,thought:`思考过程`,thoughtFor:`思考了 {time}`,toolResult:`结果`,sources:`来源`,feedbackUp:`回答很好`,feedbackDown:`回答不好`,feedbackThanks:`感谢你的反馈`,copy:`复制`,copied:`已复制`,copyTicketReference:`工单 {reference},复制`,tabHome:`首页`,tabConversations:`聊天`,tabHelp:`帮助`,tabNews:`动态`,modulesEmpty:`这里还没有内容`,chatUnavailable:`此聊天目前不可用`,moduleBack:`返回`,contentLoading:`正在加载…`,contentHelpful:`这对你有帮助吗?`,homeGreeting:`有什么可以帮你?`,homeGreetingNamed:`你好,{name} 👋`,homeGreetingLead:`有什么可以帮你?`,homeSearchPlaceholder:`搜索帮助`,homeAskPlaceholder:`提出问题…`,homeWhatsNew:`最新动态`,homeContentTitle:`热门文章`,homeStatus:`状态`,helpTitle:`帮助`,helpSearchPlaceholder:`搜索帮助`,helpEmpty:`还没有帮助文章`,helpLoading:`正在加载帮助…`,helpSearchEmpty:`没有找到“{query}”的结果`,helpShowMore:`显示更多`,newsTitle:`动态`,newsEmpty:`还没有动态`,newsLoading:`正在加载动态…`,newsShowMore:`显示更多`,newsUnseen:`新文章`,unread:`未读`,formRequired:`此项为必填`,formInvalidEmail:`请输入有效的邮箱地址`,formInvalidTel:`请输入有效的电话号码`,formInvalidNumber:`请输入有效的数字`,formOtherPlaceholder:`输入你的回答…`,inputRequired:`需要你回答的问题`,askFallbackQuestion:`请提供缺少的信息。`,inputBadge:`问题`,inputAnswered:`已回答`,inputSkipped:`已跳过`,showOptions:`显示选项`,hideOptions:`隐藏选项`,qtypeText:`你的回答`,qtypeEmail:`邮箱地址`,qtypePhone:`电话号码`,qtypeNumber:`数字`,qtypeDate:`日期`,qtypeChooseOne:`选择一项`,qtypeChooseAny:`可多选`,qtypeBoolean:`是 / 否`,inputSubmit:`提交回答`,inputSubmitHint:`Enter 发送 · Shift+Enter 换行`,inputSkip:`跳过`,confirmYes:`是`,confirmNo:`否`,approve:`批准`,decline:`拒绝`,changeAnswer:`修改回答`,approvalPrompt:`{action}?`,approvalEditHint:`在此步骤继续之前,你可以修改回答。`,stepInput:`输入`,stepWorking:`进行中`,stepWorkingOnIt:`正在处理…`,stepNeedsYourApproval:`需要你的批准`,stepWaitingForVisitor:`等待访客`,stepApproved:`已批准`,stepDeclined:`已拒绝`,stepReplaced:`已替换`,stepFailed:`失败`,stepDidNotWork:`未成功`,decidedYouApproved:`你已批准`,decidedYouDeclined:`你已拒绝`,decidedVisitorApproved:`访客已批准`,decidedVisitorDeclined:`访客已拒绝`,decidedTeamApproved:`团队成员已批准`,decidedTeamDeclined:`团队成员已拒绝`,decidedMemberApproved:`{name} 已批准`,decidedMemberDeclined:`{name} 已拒绝`,stepRawData:`原始数据`,decidedRulesApproved:`已自动批准`,decidedRulesDeclined:`已自动拒绝`,edit:`编辑`,toolStepsFailed:`{count} 个失败`,statusStopped:`已停止`,toolStepsStopped:`在 {count} 步后停止`,toolStepsStoppedOne:`在 1 步后停止`}};function k(e,t){let n=A(e),r=N(t),i=O[S(n)],a=r?{...t[n],...t[e]}:t??{},o=r?t.en??{}:{};return{...D,...i,...o,...a}}function A(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const j=/* @__PURE__ */ new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function ee(e){return j.has(A(e))}function M(e,t){return e[t]??t}function N(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}const P={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`},te=[`decided`,`auto-decided`,`unasked`,`failed`],ne=[`platform`,`mcp`,`api`,`webmcp`],re=[`none`,`values`,`table`,`json`,`table-and-json`];function F(e,t){return typeof t==`string`&&e.some(e=>e===t)}const ie={visitor:{stepsFrom:ne,stepsShown:[],stepDetails:`values`,showStepSystem:!1,showDecidedBy:!1,foldApprovals:!0},member:{stepsFrom:ne,stepsShown:te,stepDetails:`table-and-json`,showStepSystem:!0,showDecidedBy:!0,foldApprovals:!0}},ae=[`showStepSystem`,`showDecidedBy`,`foldApprovals`];function I(e){let t={};if(typeof e!=`object`||!e)return t;for(let n of ae){let r=Reflect.get(e,n);typeof r==`boolean`&&(t[n]=r)}let n=Reflect.get(e,`stepsFrom`);Array.isArray(n)&&(t.stepsFrom=ne.filter(e=>n.includes(e)));let r=Reflect.get(e,`stepsShown`);Array.isArray(r)&&(t.stepsShown=te.filter(e=>r.includes(e)));let i=Reflect.get(e,`stepDetails`);return F(re,i)&&(t.stepDetails=i),t}function oe(e,t){return{...ie[t],...e}}const se=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ce(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function le(e){if(e.title)return e.title;let t=e.toolName.replace(/^tool[:-]/,``),n=t.indexOf(`__`);return ce(n>0?t.slice(n+2):t)}function ue(e,t,n){let r=e.approval;return r?.replacedByMessageId?`replaced`:e.state===`output-available`?n.error===void 0?`done`:`failed`:e.state===`output-error`?t.interrupted?`stopped`:`failed`:e.state===`output-denied`||r?.approved===!1?`declined`:e.state===`approval-responded`||r?.approved===!0?t.cutOff?`stopped`:`approved`:e.state===`approval-requested`?t.submitted?`submitted`:t.cutOff?`stopped`:t.superseded?`replaced`:`waiting`:t.live?`running`:`stopped`}function L(e,t){if(e.isAutomatic)return`rules`;let n=e.respondedBy;return n?.visitorId?`visitor`:n?.userId?n.userId===t.userId?`you`:`teamMember`:t.decides?`you`:`visitor`}function de(e,t,n,r,i){let a=r[t?`inputAnswered`:`inputSkipped`];if(i)return{label:a,title:a};let o=r[t?`stepApproved`:`stepDeclined`];if(e===`teamMember`&&n)return{label:o,title:r[t?`decidedMemberApproved`:`decidedMemberDeclined`].replace(`{name}`,n)};let s=r[R[e][+!t]];return e===`you`?{label:o,title:s}:{label:s,title:s}}const R={you:[`decidedYouApproved`,`decidedYouDeclined`],visitor:[`decidedVisitorApproved`,`decidedVisitorDeclined`],teamMember:[`decidedTeamApproved`,`decidedTeamDeclined`],rules:[`decidedRulesApproved`,`decidedRulesDeclined`]};function fe(e,t){switch(e){case`running`:return t.strings.stepWorking;case`waiting`:return t.reader.decides?t.strings.stepNeedsYourApproval:t.strings.stepWaitingForVisitor;case`submitted`:return t.strings.stepWorkingOnIt;case`approved`:return t.strings.stepApproved;case`declined`:return t.card?t.strings.inputSkipped:t.strings.stepDeclined;case`replaced`:return t.card?t.strings.inputSkipped:t.strings.stepReplaced;case`stopped`:return t.strings.statusStopped;case`failed`:return t.plain?t.strings.stepDidNotWork:t.strings.stepFailed;case`done`:return``;default:return e}}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pe(e){return typeof e==`string`?e.trim():typeof e==`number`||typeof e==`boolean`?String(e):``}function me(e){return pe(e)||(typeof e==`object`&&e?JSON.stringify(e):``)}function he(e){if(!z(e))return me(e);let[t,...n]=Object.values(e).map(me).filter(Boolean);return t===void 0?``:n.length>0?`${t} (${n.join(`, `)})`:t}function B(e,t){if(!z(e))return[];let n=[];function r(e,i){if(Array.isArray(e)){let t=e.map(he).filter(Boolean).join(`, `);t&&n.push({path:i,value:t});return}if(z(e)){for(let[t,n]of Object.entries(e))r(n,[...i,t]);return}let a=pe(e);a&&(t.withIds||!se.test(a))&&n.push({path:i,value:a})}r(e,[]);let i=n.map(({path:e})=>ce(e.at(-1)??``));return n.map(({path:e,value:t},n)=>{let r=i[n]??``;return{label:i.filter(e=>e===r).length>1&&e.length>1?`${ce(e.at(-2)??``)} · ${r.toLowerCase()}`:r,value:t}})}function ge(e,t){if(z(e))return Object.entries(e).find(e=>e[0]!==t&&typeof e[1]==`string`&&e[1].trim().length>0&&!se.test(e[1].trim()))?.[1].trim()}function _e(e){if(typeof e.toolMetadata?.system==`string`)return e.toolMetadata.system;let t=e.toolMetadata?.systemField,n=typeof t==`string`&&z(e.input)?e.input[t]:void 0;return typeof n==`string`&&n.trim()?n.trim():void 0}function ve(e,t=1/0){if(e==null)return;let n=typeof e==`string`?e:JSON.stringify(e,null,2);if(n&&n!==`{}`&&n!==`[]`&&n!==`""`)return n.length>t?`${n.slice(0,t)}…`:n}function ye(e){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function be(e){if(z(e)&&e.storage===`tool-result-ref`&&`summary`in e)return be(e.summary);if(z(e)&&Array.isArray(e.content)){let t=e.content.flatMap(e=>z(e)&&typeof e.text==`string`?[e.text]:[]).join(`
2
- `),n=z(e.structuredContent)?e.structuredContent:ye(t);return e.isError===!0?{value:n,error:z(n)&&typeof n.error==`string`?n.error:t}:{value:n}}return z(e)&&typeof e.error==`string`&&typeof e.instruction==`string`?{value:e,error:e.error}:{value:e}}function xe(e){return ve(e.input)!==void 0||ve(e.output)!==void 0||!!e.errorText}function Se(e,t){let n=e.approval?`decided`:`unasked`,r=e.approval?.isAutomatic?`auto-decided`:n;return t===`failed`?[r,`failed`]:[r]}function Ce(e){let t=e.toolMetadata?.origin;return F(ne,t)?t:void 0}function we(e,t,n){let{display:r}=n,i=e.approval,a=i!==void 0&&!i.isAutomatic;if(a&&Te(e,n.turn))return`card`;let o=n.by===`you`||a&&n.by===void 0&&n.reader.decides,s=Ce(e),c=(s===void 0||r.stepsFrom.includes(s))&&Se(e,t.status).some(e=>r.stepsShown.includes(e));return!(o||c)||!i&&!xe(e)?`hidden`:a&&!r.foldApprovals?`card`:`step`}function Te(e,t){return e.approval?.replacedByMessageId||(t.superseded||t.cutOff)&&e.approval?.approved===void 0?!1:e.state===`approval-requested`||e.state===`approval-responded`}function Ee(e,t){let{turn:n,reader:r,display:i,strings:a}=t,o=be(e.output),s=ue(e,n,o),c=e.approval,l=c!==void 0&&!c.isAutomatic,u=typeof e.toolMetadata?.card==`string`?e.toolMetadata.card:void 0,d=i.stepDetails,f=d===`table`||d===`table-and-json`,p=d===`none`||d===`values`,m=c?.replacedByMessageId?void 0:c?.approved,h=c&&m!==void 0?L(c,r):void 0,g=h===`teamMember`?c?.respondedBy?.userId:void 0,_=h&&m!==void 0&&(h===`you`||h===`rules`||i.showDecidedBy)?{approved:m,by:h,...de(h,m,g&&t.names?.get(g),a,u!==void 0),...g?{userId:g}:{}}:void 0,v=le(e),y=i.showStepSystem||e.toolMetadata?.nameShared===!0?_e(e):void 0,b=ge(e.input,typeof e.toolMetadata?.systemField==`string`?e.toolMetadata.systemField:void 0),x=e.errorText??o.error,S=f&&o.error===void 0?B(o.value,{withIds:!0}):[],C=d===`json`||d===`table-and-json`?{input:ve(e.input),output:ve(o.value,4e3)}:void 0,w=l&&Te(e,n),T=d===`none`&&!w?[]:B(e.input,{withIds:f||w}),E=x!==void 0&&x!==``&&!p,D=z(c?.descriptor)&&z(c.descriptor.decision)?c.descriptor.decision:void 0,O=d!==`none`||w?D:void 0,k=_!==void 0&&(s===`approved`||s===`declined`),A={toolCallId:e.toolCallId,placement:`hidden`,...u&&c?{card:u}:{},name:v,...y?{system:y}:{},status:s,statusLabel:k?``:fe(s,{reader:r,strings:a,card:u!==void 0,plain:p}),..._?{decision:_}:{},...O?{why:O}:{},...b?{summary:b}:{},fields:T,tables:f,...S.length>0?{resultFields:S}:{},...E?{error:x}:{},...C?{raw:C}:{},opens:T.length>0||S.length>0||C!==void 0||E||O!==void 0,...l&&!u?{approval:De(e,s,{turn:n,reader:r,strings:a,name:v})}:{}};return{...A,placement:we(e,A,{turn:n,reader:r,display:i,by:h})}}function De(e,t,n){let r=n.strings.approvalPrompt.replace(`{action}`,n.name);return t===`waiting`?{ask:r,buttons:n.reader.decides?`decide`:`none`}:t===`submitted`||!Te(e,n.turn)?{ask:r,buttons:`none`}:n.turn.canAct&&n.reader.decides?{ask:r,buttons:`change`,note:n.strings.approvalEditHint}:t===`approved`?{ask:r,buttons:`none`,note:n.strings.stepWorkingOnIt}:{ask:r,buttons:`none`}}function Oe(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);let n=/* @__PURE__ */ new Map;for(let{decision:t}of e){if(!t)continue;let e=n.get(t.title)??{approved:t.approved,label:t.label,title:t.title,...t.userId?{userId:t.userId}:{},count:0};n.set(t.title,{...e,count:e.count+1})}let[r]=e,i=e.some(e=>e.status===`stopped`);return{tools:[...t].map(([e,t])=>({name:e,count:t})),...e.length===1&&r?{single:{name:r.name,...r.system?{system:r.system}:{},...r.summary?{summary:r.summary}:{},...ke(r)}}:{},marks:[...n.values()].map(({count:e,...t})=>Object.assign(t,{label:e>1?`${t.label} ×${e}`:t.label})),failed:e.filter(e=>e.status===`failed`).length,...i?{stopped:{finished:e.filter(e=>e.status!==`stopped`).length}}:{}}}function ke(e){return!e.decision&&(e.status===`replaced`||e.status===`declined`)?{outcome:e.statusLabel}:{}}function Ae(e,t){return e===0?t.statusStopped:e===1?t.toolStepsStoppedOne:t.toolStepsStopped.replace(`{count}`,String(e))}const je=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{}}},Me={get(e){try{return sessionStorage.getItem(e)}catch{return null}},set(e,t){try{sessionStorage.setItem(e,t)}catch{}},remove(e){try{sessionStorage.removeItem(e)}catch{}}},Ne={maxBytes:10485760,maxCount:10,accept:`*/*`},Pe={voice:`local`},Fe={enabled:!0,sampleRate:1},Ie={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`},Le={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},Re={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`]},ze={enabled:!0,volume:.3,events:void 0},Be={enabled:!0,events:void 0},Ve=[{label:`tabConversations`,layout:`chat`}],He=[`off`,`error`,`warn`,`info`,`debug`,`trace`],Ue=P.cssPrefix,We=`${Ue}.debug`,Ge=`__${P.global}_DEBUG__`,Ke=`${Ue}-debug`;let qe=2;function Je(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(Ke);if(e!==null){let t=Ye(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(We);if(e){let t=Ye(e);if(t>=0)return t}}catch{}return Reflect.get(window,Ge)?4:2}function Ye(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=He.findIndex(t=>t===e);if(t>=0)return t}return-1}qe=Je();function Xe(e){let t=`[${Ue}:${e}]`;function n(e,n,r){return(r,i)=>{qe<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=>Xe(`${e}:${t}`)}}const V=Xe(`core`),Ze=V.scope(`context`),Qe=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),$e=1024,et=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function tt(e){return H(e,`userContext`,!0)}function nt(e){return H(e,`pageContext`,!1)}function rt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e,t,n){if(e==null)return;if(!rt(e)){Ze.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(Qe.has(n)){Ze.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){Ze.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=it(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!et.test(r.email)&&(Ze.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function it(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){Ze.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>$e?(Ze.warn(`truncated ${e}.${t} to ${$e} chars`),r.slice(0,$e)):r}Ze.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function at(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??{},c={enabled:t.history?.enabled??!0},{themeMode:l,themeOverrides:u}=ot(t.theme),d=n.mode??`floating`,f=st(i.defaultLocale),p=i.availableLocales??[i.locale??f],m=ct(i.locale??f,p,f),h=(t.baseUrl??P.defaultBaseUrl).replace(/\/$/,``),g=(t.agentApiBaseUrl??`${h}/api/agent`).replace(/\/$/,``),_=(t.dataApiBaseUrl??`${h}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:h,agentApiBaseUrl:g,dataApiBaseUrl:_,userContext:tt(t.userContext),pageContext:nt(t.pageContext),position:n.position??(ee(m)?`bottom-left`:`bottom-right`),themeMode:l,textSize:`normal`,themeOverrides:u,mode:d,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,stepDisplay:oe(r.stepDisplay,`visitor`),showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,cardAnswerWaitSeconds:r.cardAnswerWaitSeconds??60,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??Pe.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),emailTranscript:!(t.features?.disableEmailTranscript??!1),operatorRequest:t.features?.enableOperatorRequest===!0&&!(t.features.hideRequestOperatorButton??!1)},endpoints:{upload:t.endpoints?.upload??Ie.upload,transcribe:t.endpoints?.transcribe??Ie.transcribe},attachments:{accept:t.composer?.attachments?.accept??Ne.accept,maxBytes:t.composer?.attachments?.maxBytes??Ne.maxBytes,maxCount:t.composer?.attachments?.maxCount??Ne.maxCount},locale:m,defaultLocale:f,availableLocales:p,startMinimized:r.startMinimized??!0,actions:lt(d,s.actions,c.enabled),size:{...n.size,resize:{...n.size?.resize,enabled:n.size?.resize?.enabled??!0}},launcher:gt(t.launcher,t.agent?.name),sound:ut(a.sound),haptics:dt(a.haptics),strings:k(m,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,header:{variant:s.variant??`plain`,notice:s.notice,showNotice:!(s.hideNotice??!1)},poweredBy:pt(o.poweredBy),composer:mt(t.composer),modules:ht(t.modules,c.enabled),tracking:ft(t.tracking,_),history:c,storage:t.storage??je,userToken:t.userToken,continueLink:t.continueLink,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function ot(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`host`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`host`,themeOverrides:n}}function st(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function ct(e,t,n){if(t.length<=1||t.includes(e))return e;let r=e.split(`-`)[0];return r&&t.includes(r)?r:t.includes(n)?n:t[0]??e}function lt(e,t,n){let r=t??Re[e];return n?r:r.filter(e=>e!==`history`)}function ut(e){return{enabled:e?.enabled??ze.enabled,volume:e?.volume??ze.volume,events:e?.events}}function dt(e){return{enabled:e?.enabled??Be.enabled,events:e?.events}}function ft(e,t){let n=e?.sampleRate??Fe.sampleRate;return{enabled:e?.enabled??Fe.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 pt(e){return e?.text===``&&!e.logoUrl?null:{href:P.siteUrl,...e}}function mt(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function ht(e,t){let n=(e??Ve).slice(0,4),r=n.some(e=>e?.label&&e.layout===`help`),i=/* @__PURE__ */ new Set,a=[];for(let e of n){if(!e?.label||!e?.layout)continue;let n=e.contentCollectionIds?.filter(Boolean),o=e.id??n?.[0]??e.layout;for(;i.has(o);)o=`${o}-${a.length}`;i.add(o);let s={id:o,label:e.label,layout:e.layout};n?.length&&(s.contentCollectionIds=n),e.layout===`home`&&(s.brandName=e.brandName,s.greetingText=e.greetingText,s.showGreeting=!(e.hideGreeting??!1),s.showSearchBar=r&&!(e.hideSearchBar??!1),s.showRecentConversations=t&&!(e.hideRecentConversations??!1),e.userAvatars?.length&&(s.userAvatars=e.userAvatars),e.status&&(s.status=e.status),s.contentBlockTitle=e.contentBlockTitle),a.push(s)}return{list:a,byId:Object.fromEntries(a.map(e=>[e.id,e]))}}function gt(e,t){let n=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??Le.variant,size:e?.size??Le.size,label:e?.label??Le.label,icon:e?.icon??Le.icon,hidden:e?.hidden??Le.hidden,...t&&{personaName:t},callout:n}}function _t(e,t){return e===`host`?`host`:t??e}function vt(e,t,n,r){let i=ct(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=k(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}function yt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const bt=[`agent`,`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`,`history`];function xt(e,t){if(!t)return e;let n={...e};for(let r of bt){let i=t[r];if(i===void 0)continue;let a=e[r];r===`theme`?a===void 0?n[r]=i:typeof a==`string`&&typeof i==`object`&&i&&(n[r]={...i,mode:a}):r!==`i18n`&&(n[r]=St(yt(i)?i:{},yt(a)?a:void 0))}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=St(yt(i)?i:{},yt(r)?r:void 0);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=Ct(a,t)),n.i18n=e}return n}function St(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 Ct(e,t){if(!e)return t;if(!t)return e;let n=N(e),r=N(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 wt=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function Tt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Et(e){return e!==`false`}function Dt(e){try{return I(JSON.parse(e))}catch{return}}function Ot(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=0?t:void 0}function kt(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}const At=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`continue-link`,`continueLink`],[`theme`,`theme`,e=>e]],jt=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e]],Mt=[[`width`,`width`],[`height`,`height`]],Nt=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,Et],[`show-reasoning`,`showReasoning`,Et],[`step-display`,`stepDisplay`,Dt],[`show-sources`,`showSources`,Et],[`disable-message-feedback`,`disableMessageFeedback`,Et],[`auto-send-suggestions`,`autoSendSuggestions`,Et],[`card-answer-wait-seconds`,`cardAnswerWaitSeconds`,Ot],[`pop-out-url`,`popOutUrl`]],Pt=[[`locale`,`locale`]],Ft=new Set(wt);function It(e){return kt(e).filter(e=>Ft.has(e))}const Lt=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,Et]],Rt=[[`features-disable-file-upload`,`disableFileUpload`,Et],[`features-disable-email-transcript`,`disableEmailTranscript`,Et],[`features-voice`,`voice`,e=>e]],zt=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],Bt=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],Vt=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],Ht=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],Ut=[At,jt,Mt,Nt,Pt,Lt,Rt,zt,Bt,Vt],Wt=/* @__PURE__ */ new Set([`start-minimized`]),Gt=[...Ut.flatMap(e=>e.map(([e])=>e).filter(e=>!Wt.has(e))),...Ht];function Kt(e){let t={};function n(t){let n=e(t);return n===null||n===``?void 0:n}for(let[e,r,i]of At){let a=n(e);a!==void 0&&Reflect.set(t,r,i?i(a):a)}let r=qt(n,jt),i=qt(n,Mt);(r||i)&&(t.presentation={...r,...i?{size:i}:{}});let a=qt(n,Nt);a&&(t.behavior=a);let o=qt(n,Pt);o&&(t.i18n=o);let s=Yt(e,n);s&&(t.launcher=s);let c=qt(n,Rt);c&&(t.features=c);let l=qt(n,zt);l&&(t.endpoints=l);let u=Jt(n,Bt,`user-context`);u&&(t.userContext=u);let d=Jt(n,Vt,`page-context`);d&&(t.pageContext=d);let f=n(`actions`);return f!==void 0&&(t.header={actions:It(f)}),t}function qt(e,t){let n={};for(let[r,i,a]of t){let t=e(r);t!==void 0&&Reflect.set(n,i,a?a(t):t)}return Object.keys(n).length>0?n:null}function Jt(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);if(Tt(e))for(let[t,n]of Object.entries(e))(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)&&(i[t]=n)}catch{}let o={...i,...r};return Object.keys(o).length>0?o:null}function Yt(e,t){let n=qt(t,Lt)??{},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}const Xt=V.scope(`track`);function Zt(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){Xt.warn(`track: ignored an event without a name of 1–64 characters`,{name:e});return}let r=Object.fromEntries(Object.entries(typeof t==`object`&&t?t:{}).filter(e=>typeof e[1]==`string`||typeof e[1]==`boolean`||Number.isFinite(e[1])));return JSON.stringify(r).length>256?(Xt.warn(`track: sent the event without its data, which is over 256 characters`,{name:n}),{name:n}):Object.keys(r).length>0?{name:n,data:r}:{name:n}}function Qt(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function $t(){let e=Date.now(),t=/* @__PURE__ */ 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,en(t.subarray(6)),t[6]=(t[6]??0)&15|112,t[8]=(t[8]??0)&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 en(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const tn=V.scope(`persistence`);function nn(e,t=je,n){let r=n?`${e}.${n}`:e,i=`${P.cssPrefix}.${r}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${P.cssPrefix}.${r}${o}`,c=`${P.cssPrefix}${o}.visitorId`,l=`${P.cssPrefix}${o}.lastUserSub`,u=`${s}.conversationId`,d=`${s}.userPrefs`,f=`${s}.panelOpen`,p=`${s}.panelSize`,m=`${s}.calloutDismissed`,h=`${s}.sidebarCollapsed`,g=`${s}.activeModule`,_=`${s}.seenNewsId`,v=`${s}.historyCount`,y=`${s}.loginReturn`,b=`${s}.loginPromptDismissedIn`,x={getVisitorId(){let e=t.get(c);if(e)return e;let n=$t();return t.set(c,n),n},loadLastUserSub(){return t.get(l)??void 0},saveLastUserSub(e){t.set(l,e)},loadConversationId(){return t.get(u)??void 0},saveConversationId(e){tn.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(u,e):t.remove(u)},loadDraft(e){return t.get(`${s}.draft.${e}`)??``},saveDraft(e,n){let r=`${s}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${s}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(an)?[]:e}catch(e){return tn.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${s}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){tn.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(d);if(!e)return{};try{return on(JSON.parse(e))}catch(e){return tn.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(d,JSON.stringify(e))}catch(e){tn.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=x.loadUserPrefs();x.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(f);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(f,e?`1`:`0`)},loadPanelSize(){let e=t.get(p);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(p,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(m);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(m,e):t.remove(m)},loadSidebarCollapsed(){let e=t.get(h);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(h,e?`1`:`0`)},loadActiveModule(){return t.get(g)||null},saveActiveModule(e){t.set(g,e)},loadSeenNewsId(){return t.get(_)||null},saveSeenNewsId(e){t.set(_,e)},loadHistoryCount(){let e=t.get(v);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(v,String(e))},rememberStorageVersion(e){e&&e!==t.get(i)&&(tn.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},saveLoginReturn(e){Me.set(y,JSON.stringify(e))},takeLoginReturn(){let e=Me.get(y);if(e){Me.remove(y);try{let t=JSON.parse(e);return rn(t)&&typeof t.conversationId==`string`&&t.conversationId&&typeof t.draft==`string`?{conversationId:t.conversationId,draft:t.draft}:void 0}catch(e){tn.warn(`takeLoginReturn parse failed`,{error:e});return}}},loadLoginPromptDismissedIn(){return Me.get(b)??void 0},dismissLoginPromptIn(e){Me.set(b,e)},clearConversation(){t.remove(u)},reset(){let e=t.get(u);e&&(t.remove(`${s}.draft.${e}`),t.remove(`${s}.messageQueue.${e}`));for(let e of[y,b])Me.remove(e);for(let e of[c,l,u,d,p,m,h,g,_,v])t.remove(e);tn.info(`reset: forgot the visitor`,{scope:r})}};return x}function rn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function an(e){return rn(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function on(e){if(!rn(e))return{};let t={};return typeof e.locale==`string`&&(t.locale=e.locale),typeof e.soundMuted==`boolean`&&(t.soundMuted=e.soundMuted),(e.themeMode===`auto`||e.themeMode===`light`||e.themeMode===`dark`)&&(t.themeMode=e.themeMode),(e.textSize===`small`||e.textSize===`normal`||e.textSize===`large`)&&(t.textSize=e.textSize),rn(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const sn=`6.14.0`,cn={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,toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),hostEvent:e=>({name:e.name,data:e.data&&JSON.stringify(e.data)}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,count:e.count}),contentOpen:e=>({contentId:e.contentId,contentCollectionId:e.contentCollectionId}),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 ln(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function un(){return location.origin+location.pathname}function dn(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function fn(e,t){let n=Math.random(),r=0,i=0,a=/* @__PURE__ */ new Set;function o(e,o){let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||ln()||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`,sn),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`,un());let h=dn();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(_);function v(){return a.delete(_)}_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g}let s=[];function c(e,t){if(s&&e!==`handshake`){s.length<60&&s.push([e,t]);return}let n=s??[];s=void 0;for(let[e,t]of n)o(e,t);o(e,t)}function l(e,t){return cn[e]?.(t)}let u=Object.keys(cn).filter(e=>Object.hasOwn(cn,e)).map(t=>e.on(t,e=>c(t,l(t,e))));return()=>{for(let e of u)e();a.clear()}}const pn=`: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, .55) 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
+ `),n=z(e.structuredContent)?e.structuredContent:ye(t);return e.isError===!0?{value:n,error:z(n)&&typeof n.error==`string`?n.error:t}:{value:n}}return z(e)&&typeof e.error==`string`&&typeof e.instruction==`string`?{value:e,error:e.error}:{value:e}}function xe(e){return ve(e.input)!==void 0||ve(e.output)!==void 0||!!e.errorText}function Se(e,t){let n=e.approval?`decided`:`unasked`,r=e.approval?.isAutomatic?`auto-decided`:n;return t===`failed`?[r,`failed`]:[r]}function Ce(e){let t=e.toolMetadata?.origin;return F(ne,t)?t:void 0}function we(e,t,n){let{display:r}=n,i=e.approval,a=i!==void 0&&!i.isAutomatic;if(a&&Te(e,n.turn))return`card`;let o=n.by===`you`||a&&n.by===void 0&&n.reader.decides,s=Ce(e),c=(s===void 0||r.stepsFrom.includes(s))&&Se(e,t.status).some(e=>r.stepsShown.includes(e));return!(o||c)||!i&&!xe(e)?`hidden`:a&&!r.foldApprovals?`card`:`step`}function Te(e,t){return e.approval?.replacedByMessageId||(t.superseded||t.cutOff)&&e.approval?.approved===void 0?!1:e.state===`approval-requested`||e.state===`approval-responded`}function Ee(e,t){let{turn:n,reader:r,display:i,strings:a}=t,o=be(e.output),s=ue(e,n,o),c=e.approval,l=c!==void 0&&!c.isAutomatic,u=typeof e.toolMetadata?.card==`string`?e.toolMetadata.card:void 0,d=i.stepDetails,f=d===`table`||d===`table-and-json`,p=d===`none`||d===`values`,m=c?.replacedByMessageId?void 0:c?.approved,h=c&&m!==void 0?L(c,r):void 0,g=h===`teamMember`?c?.respondedBy?.userId:void 0,_=h&&m!==void 0&&(h===`you`||h===`rules`||i.showDecidedBy)?{approved:m,by:h,...de(h,m,g&&t.names?.get(g),a,u!==void 0),...g?{userId:g}:{}}:void 0,v=le(e),y=i.showStepSystem||e.toolMetadata?.nameShared===!0?_e(e):void 0,b=ge(e.input,typeof e.toolMetadata?.systemField==`string`?e.toolMetadata.systemField:void 0),x=e.errorText??o.error,S=f&&o.error===void 0?B(o.value,{withIds:!0}):[],C=d===`json`||d===`table-and-json`?{input:ve(e.input),output:ve(o.value,4e3)}:void 0,w=l&&Te(e,n),T=d===`none`&&!w?[]:B(e.input,{withIds:f||w}),E=x!==void 0&&x!==``&&!p,D=z(c?.descriptor)&&z(c.descriptor.decision)?c.descriptor.decision:void 0,O=d!==`none`||w?D:void 0,k=_!==void 0&&(s===`approved`||s===`declined`),A={toolCallId:e.toolCallId,placement:`hidden`,...u&&c?{card:u}:{},name:v,...y?{system:y}:{},status:s,statusLabel:k?``:fe(s,{reader:r,strings:a,card:u!==void 0,plain:p}),..._?{decision:_}:{},...O?{why:O}:{},...b?{summary:b}:{},fields:T,tables:f,...S.length>0?{resultFields:S}:{},...E?{error:x}:{},...C?{raw:C}:{},opens:T.length>0||S.length>0||C!==void 0||E||O!==void 0,...l&&!u?{approval:De(e,s,{turn:n,reader:r,strings:a,name:v})}:{}};return{...A,placement:we(e,A,{turn:n,reader:r,display:i,by:h})}}function De(e,t,n){let r=n.strings.approvalPrompt.replace(`{action}`,n.name);return t===`waiting`?{ask:r,buttons:n.reader.decides?`decide`:`none`}:t===`submitted`||!Te(e,n.turn)?{ask:r,buttons:`none`}:n.turn.canAct&&n.reader.decides?{ask:r,buttons:`change`,note:n.strings.approvalEditHint}:t===`approved`?{ask:r,buttons:`none`,note:n.strings.stepWorkingOnIt}:{ask:r,buttons:`none`}}function Oe(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);let n=/* @__PURE__ */ new Map;for(let{decision:t}of e){if(!t)continue;let e=n.get(t.title)??{approved:t.approved,label:t.label,title:t.title,...t.userId?{userId:t.userId}:{},count:0};n.set(t.title,{...e,count:e.count+1})}let[r]=e,i=e.some(e=>e.status===`stopped`);return{tools:[...t].map(([e,t])=>({name:e,count:t})),...e.length===1&&r?{single:{name:r.name,...r.system?{system:r.system}:{},...r.summary?{summary:r.summary}:{},...ke(r)}}:{},marks:[...n.values()].map(({count:e,...t})=>Object.assign(t,{label:e>1?`${t.label} ×${e}`:t.label})),failed:e.filter(e=>e.status===`failed`).length,...i?{stopped:{finished:e.filter(e=>e.status!==`stopped`).length}}:{}}}function ke(e){return!e.decision&&(e.status===`replaced`||e.status===`declined`)?{outcome:e.statusLabel}:{}}function Ae(e,t){return e===0?t.statusStopped:e===1?t.toolStepsStoppedOne:t.toolStepsStopped.replace(`{count}`,String(e))}const je=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{}}},Me={get(e){try{return sessionStorage.getItem(e)}catch{return null}},set(e,t){try{sessionStorage.setItem(e,t)}catch{}},remove(e){try{sessionStorage.removeItem(e)}catch{}}},Ne={maxBytes:10485760,maxCount:10,accept:`*/*`},Pe={voice:`local`},Fe={enabled:!0,sampleRate:1},Ie={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`},Le={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},Re={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`]},ze={enabled:!0,volume:.3,events:void 0},Be={enabled:!0,events:void 0},Ve=[{label:`tabConversations`,layout:`chat`}],He=[`off`,`error`,`warn`,`info`,`debug`,`trace`],Ue=P.cssPrefix,We=`${Ue}.debug`,Ge=`__${P.global}_DEBUG__`,Ke=`${Ue}-debug`;let qe=2;function Je(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(Ke);if(e!==null){let t=Ye(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(We);if(e){let t=Ye(e);if(t>=0)return t}}catch{}return Reflect.get(window,Ge)?4:2}function Ye(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=He.findIndex(t=>t===e);if(t>=0)return t}return-1}qe=Je();function Xe(e){let t=`[${Ue}:${e}]`;function n(e,n,r){return(r,i)=>{qe<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=>Xe(`${e}:${t}`)}}const V=Xe(`core`),Ze=V.scope(`context`),Qe=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),$e=1024,et=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function tt(e){return H(e,`userContext`,!0)}function nt(e){return H(e,`pageContext`,!1)}function rt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e,t,n){if(e==null)return;if(!rt(e)){Ze.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(Qe.has(n)){Ze.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){Ze.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=it(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!et.test(r.email)&&(Ze.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function it(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){Ze.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>$e?(Ze.warn(`truncated ${e}.${t} to ${$e} chars`),r.slice(0,$e)):r}Ze.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function at(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??{},c={enabled:t.history?.enabled??!0},{themeMode:l,themeOverrides:u}=ot(t.theme),d=n.mode??`floating`,f=st(i.defaultLocale),p=i.availableLocales??[i.locale??f],m=ct(i.locale??f,p,f),h=(t.baseUrl??P.defaultBaseUrl).replace(/\/$/,``),g=(t.agentApiBaseUrl??`${h}/api/agent`).replace(/\/$/,``),_=(t.dataApiBaseUrl??`${h}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:h,agentApiBaseUrl:g,dataApiBaseUrl:_,userContext:tt(t.userContext),pageContext:nt(t.pageContext),position:n.position??(ee(m)?`bottom-left`:`bottom-right`),themeMode:l,textSize:`normal`,themeOverrides:u,mode:d,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,stepDisplay:oe(r.stepDisplay,`visitor`),showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,cardAnswerWaitSeconds:r.cardAnswerWaitSeconds??60,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??Pe.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),emailTranscript:!(t.features?.disableEmailTranscript??!1),operatorRequest:t.features?.enableOperatorRequest===!0&&!(t.features.hideRequestOperatorButton??!1)},endpoints:{upload:t.endpoints?.upload??Ie.upload,transcribe:t.endpoints?.transcribe??Ie.transcribe},attachments:{accept:t.composer?.attachments?.accept??Ne.accept,maxBytes:t.composer?.attachments?.maxBytes??Ne.maxBytes,maxCount:t.composer?.attachments?.maxCount??Ne.maxCount},locale:m,defaultLocale:f,availableLocales:p,startMinimized:r.startMinimized??!0,actions:lt(d,s.actions,c.enabled),size:{...n.size,resize:{...n.size?.resize,enabled:n.size?.resize?.enabled??!0}},launcher:gt(t.launcher,t.agent?.name),sound:ut(a.sound),haptics:dt(a.haptics),strings:k(m,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,header:{variant:s.variant??`plain`,notice:s.notice,showNotice:!(s.hideNotice??!1)},poweredBy:pt(o.poweredBy),composer:mt(t.composer),modules:ht(t.modules,c.enabled),tracking:ft(t.tracking,_),history:c,storage:t.storage??je,userToken:t.userToken,continueLink:t.continueLink,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function ot(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`host`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`host`,themeOverrides:n}}function st(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function ct(e,t,n){if(t.length<=1||t.includes(e))return e;let r=e.split(`-`)[0];return r&&t.includes(r)?r:t.includes(n)?n:t[0]??e}function lt(e,t,n){let r=t??Re[e];return n?r:r.filter(e=>e!==`history`)}function ut(e){return{enabled:e?.enabled??ze.enabled,volume:e?.volume??ze.volume,events:e?.events}}function dt(e){return{enabled:e?.enabled??Be.enabled,events:e?.events}}function ft(e,t){let n=e?.sampleRate??Fe.sampleRate;return{enabled:e?.enabled??Fe.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 pt(e){return e?.text===``&&!e.logoUrl?null:{href:P.siteUrl,...e}}function mt(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function ht(e,t){let n=(e??Ve).slice(0,4),r=n.some(e=>e?.label&&e.layout===`help`),i=/* @__PURE__ */ new Set,a=[];for(let e of n){if(!e?.label||!e?.layout)continue;let n=e.contentCollectionIds?.filter(Boolean),o=e.id??n?.[0]??e.layout;for(;i.has(o);)o=`${o}-${a.length}`;i.add(o);let s={id:o,label:e.label,layout:e.layout};n?.length&&(s.contentCollectionIds=n),e.layout===`home`&&(s.brandName=e.brandName,s.greetingText=e.greetingText,s.showGreeting=!(e.hideGreeting??!1),s.showSearchBar=r&&!(e.hideSearchBar??!1),s.showRecentConversations=t&&!(e.hideRecentConversations??!1),e.userAvatars?.length&&(s.userAvatars=e.userAvatars),e.status&&(s.status=e.status),s.contentBlockTitle=e.contentBlockTitle),a.push(s)}return{list:a,byId:Object.fromEntries(a.map(e=>[e.id,e]))}}function gt(e,t){let n=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??Le.variant,size:e?.size??Le.size,label:e?.label??Le.label,icon:e?.icon??Le.icon,hidden:e?.hidden??Le.hidden,...t&&{personaName:t},callout:n}}function _t(e,t){return e===`host`?`host`:t??e}function vt(e,t,n,r){let i=ct(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=k(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}function yt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const bt=[`agent`,`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`,`history`];function xt(e,t){if(!t)return e;let n={...e};for(let r of bt){let i=t[r];if(i===void 0)continue;let a=e[r];r===`theme`?a===void 0?n[r]=i:typeof a==`string`&&typeof i==`object`&&i&&(n[r]={...i,mode:a}):r!==`i18n`&&(n[r]=St(yt(i)?i:{},yt(a)?a:void 0))}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=St(yt(i)?i:{},yt(r)?r:void 0);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=Ct(a,t)),n.i18n=e}return n}function St(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 Ct(e,t){if(!e)return t;if(!t)return e;let n=N(e),r=N(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 wt=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function Tt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Et(e){return e!==`false`}function Dt(e){try{return I(JSON.parse(e))}catch{return}}function Ot(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=0?t:void 0}function kt(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}const At=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`continue-link`,`continueLink`],[`theme`,`theme`,e=>e]],jt=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e]],Mt=[[`width`,`width`],[`height`,`height`]],Nt=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,Et],[`show-reasoning`,`showReasoning`,Et],[`step-display`,`stepDisplay`,Dt],[`show-sources`,`showSources`,Et],[`disable-message-feedback`,`disableMessageFeedback`,Et],[`auto-send-suggestions`,`autoSendSuggestions`,Et],[`card-answer-wait-seconds`,`cardAnswerWaitSeconds`,Ot],[`pop-out-url`,`popOutUrl`]],Pt=[[`locale`,`locale`]],Ft=new Set(wt);function It(e){return kt(e).filter(e=>Ft.has(e))}const Lt=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,Et]],Rt=[[`features-disable-file-upload`,`disableFileUpload`,Et],[`features-disable-email-transcript`,`disableEmailTranscript`,Et],[`features-voice`,`voice`,e=>e]],zt=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],Bt=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],Vt=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],Ht=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],Ut=[At,jt,Mt,Nt,Pt,Lt,Rt,zt,Bt,Vt],Wt=/* @__PURE__ */ new Set([`start-minimized`]),Gt=[...Ut.flatMap(e=>e.map(([e])=>e).filter(e=>!Wt.has(e))),...Ht];function Kt(e){let t={};function n(t){let n=e(t);return n===null||n===``?void 0:n}for(let[e,r,i]of At){let a=n(e);a!==void 0&&Reflect.set(t,r,i?i(a):a)}let r=qt(n,jt),i=qt(n,Mt);(r||i)&&(t.presentation={...r,...i?{size:i}:{}});let a=qt(n,Nt);a&&(t.behavior=a);let o=qt(n,Pt);o&&(t.i18n=o);let s=Yt(e,n);s&&(t.launcher=s);let c=qt(n,Rt);c&&(t.features=c);let l=qt(n,zt);l&&(t.endpoints=l);let u=Jt(n,Bt,`user-context`);u&&(t.userContext=u);let d=Jt(n,Vt,`page-context`);d&&(t.pageContext=d);let f=n(`actions`);return f!==void 0&&(t.header={actions:It(f)}),t}function qt(e,t){let n={};for(let[r,i,a]of t){let t=e(r);t!==void 0&&Reflect.set(n,i,a?a(t):t)}return Object.keys(n).length>0?n:null}function Jt(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);if(Tt(e))for(let[t,n]of Object.entries(e))(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)&&(i[t]=n)}catch{}let o={...i,...r};return Object.keys(o).length>0?o:null}function Yt(e,t){let n=qt(t,Lt)??{},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}const Xt=V.scope(`track`);function Zt(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){Xt.warn(`track: ignored an event without a name of 1–64 characters`,{name:e});return}let r=Object.fromEntries(Object.entries(typeof t==`object`&&t?t:{}).filter(e=>typeof e[1]==`string`||typeof e[1]==`boolean`||Number.isFinite(e[1])));return JSON.stringify(r).length>256?(Xt.warn(`track: sent the event without its data, which is over 256 characters`,{name:n}),{name:n}):Object.keys(r).length>0?{name:n,data:r}:{name:n}}function Qt(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function $t(){let e=Date.now(),t=/* @__PURE__ */ 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,en(t.subarray(6)),t[6]=(t[6]??0)&15|112,t[8]=(t[8]??0)&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 en(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const tn=V.scope(`persistence`);function nn(e,t=je,n){let r=n?`${e}.${n}`:e,i=`${P.cssPrefix}.${r}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${P.cssPrefix}.${r}${o}`,c=`${P.cssPrefix}${o}.visitorId`,l=`${P.cssPrefix}${o}.lastUserSub`,u=`${s}.conversationId`,d=`${s}.userPrefs`,f=`${s}.panelOpen`,p=`${s}.panelSize`,m=`${s}.calloutDismissed`,h=`${s}.sidebarCollapsed`,g=`${s}.activeModule`,_=`${s}.seenNewsId`,v=`${s}.historyCount`,y=`${s}.loginReturn`,b=`${s}.loginPromptDismissedIn`,x={getVisitorId(){let e=t.get(c);if(e)return e;let n=$t();return t.set(c,n),n},loadLastUserSub(){return t.get(l)??void 0},saveLastUserSub(e){t.set(l,e)},loadConversationId(){return t.get(u)??void 0},saveConversationId(e){tn.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(u,e):t.remove(u)},loadDraft(e){return t.get(`${s}.draft.${e}`)??``},saveDraft(e,n){let r=`${s}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${s}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(an)?[]:e}catch(e){return tn.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${s}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){tn.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(d);if(!e)return{};try{return on(JSON.parse(e))}catch(e){return tn.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(d,JSON.stringify(e))}catch(e){tn.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=x.loadUserPrefs();x.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(f);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(f,e?`1`:`0`)},loadPanelSize(){let e=t.get(p);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(p,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(m);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(m,e):t.remove(m)},loadSidebarCollapsed(){let e=t.get(h);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(h,e?`1`:`0`)},loadActiveModule(){return t.get(g)||null},saveActiveModule(e){t.set(g,e)},loadSeenNewsId(){return t.get(_)||null},saveSeenNewsId(e){t.set(_,e)},loadHistoryCount(){let e=t.get(v);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(v,String(e))},rememberStorageVersion(e){e&&e!==t.get(i)&&(tn.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},saveLoginReturn(e){Me.set(y,JSON.stringify(e))},takeLoginReturn(){let e=Me.get(y);if(e){Me.remove(y);try{let t=JSON.parse(e);return rn(t)&&typeof t.conversationId==`string`&&t.conversationId&&typeof t.draft==`string`?{conversationId:t.conversationId,draft:t.draft}:void 0}catch(e){tn.warn(`takeLoginReturn parse failed`,{error:e});return}}},loadLoginPromptDismissedIn(){return Me.get(b)??void 0},dismissLoginPromptIn(e){Me.set(b,e)},clearConversation(){t.remove(u)},reset(){let e=t.get(u);e&&(t.remove(`${s}.draft.${e}`),t.remove(`${s}.messageQueue.${e}`));for(let e of[y,b])Me.remove(e);for(let e of[c,l,u,d,p,m,h,g,_,v])t.remove(e);tn.info(`reset: forgot the visitor`,{scope:r})}};return x}function rn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function an(e){return rn(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function on(e){if(!rn(e))return{};let t={};return typeof e.locale==`string`&&(t.locale=e.locale),typeof e.soundMuted==`boolean`&&(t.soundMuted=e.soundMuted),(e.themeMode===`auto`||e.themeMode===`light`||e.themeMode===`dark`)&&(t.themeMode=e.themeMode),(e.textSize===`small`||e.textSize===`normal`||e.textSize===`large`)&&(t.textSize=e.textSize),rn(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const sn=`6.15.0`,cn={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,toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),hostEvent:e=>({name:e.name,data:e.data&&JSON.stringify(e.data)}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,count:e.count}),contentOpen:e=>({contentId:e.contentId,contentCollectionId:e.contentCollectionId}),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 ln(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function un(){return location.origin+location.pathname}function dn(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function fn(e,t){let n=Math.random(),r=0,i=0,a=/* @__PURE__ */ new Set;function o(e,o){let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||ln()||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`,sn),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`,un());let h=dn();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(_);function v(){return a.delete(_)}_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g}let s=[];function c(e,t){if(s&&e!==`handshake`){s.length<60&&s.push([e,t]);return}let n=s??[];s=void 0;for(let[e,t]of n)o(e,t);o(e,t)}function l(e,t){return cn[e]?.(t)}let u=Object.keys(cn).filter(e=>Object.hasOwn(cn,e)).map(t=>e.on(t,e=>c(t,l(t,e))));return()=>{for(let e of u)e();a.clear()}}const pn=`: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, .55) 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}}
3
3
 
4
4
  *,*: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}
5
5
 
6
6
  .__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:18px;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;width:max-content;max-width:min(260px,calc(100vw - 100% - var(--__P__-callout-gap) - 32px));white-space:normal;overflow-wrap:anywhere}.__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)}.__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{flex-shrink:0;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;overflow:clip;overscroll-behavior:none;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:var(--__P__-visual-viewport-top, 0px) 0 auto;height:var(--__P__-visual-viewport-height, 100dvh);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:100%;max-width:none;max-height:none;border-radius:0;border:0}:host([data-mode="fullscreen"]) .__P__-fab{display:none}: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: clamp(440px, 32vw, 640px);--__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;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:min(var(--__P__-widget-w, var(--__P__-panel-w)),calc(100vw - var(--__P__-inset-x) * 2));height:100%;min-width:min(var(--__P__-resize-min-w, 0px),calc(100vw - var(--__P__-inset-x) * 2));max-width:var(--__P__-resize-max-w, none);max-height:none;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}}@media(max-width:640px){:host([data-mode="open"][data-position]) .__P__-anchor,:host([data-mode="expanded"][data-position]) .__P__-anchor,:host([data-mode="drawer"][data-position]) .__P__-anchor,:host([data-mode="modal"][data-position]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;align-items:stretch;width:auto;height:var(--__P__-visual-viewport-height, 100dvh);padding:0}:host([data-mode="open"][data-position]) .__P__-panel,:host([data-mode="expanded"][data-position]) .__P__-panel,:host([data-mode="drawer"][data-position]) .__P__-panel,:host([data-mode="modal"][data-position]) .__P__-panel{width:100vw;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;border-radius:0;border:0;box-shadow:none;translate:none}:host([data-mode="modal"]){background:none;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__-header[data-variant=accent]{background:var(--__P__-accent);color:var(--__P__-on-accent);border-bottom-color:transparent}.__P__-header[data-variant=accent]>h1,.__P__-header[data-variant=accent] .__P__-agent-meta strong,.__P__-header[data-variant=accent] .__P__-agent-sub span,.__P__-header[data-variant=accent] .__P__-agent-ticket,.__P__-header[data-variant=accent] .__P__-agent-ticket:hover,.__P__-header[data-variant=accent]>.__P__-icon-btn,.__P__-header[data-variant=accent] .__P__-header-actions>.__P__-icon-btn,.__P__-header[data-variant=accent] .__P__-menu-wrap>.__P__-icon-btn{color:var(--__P__-on-accent);--__P__-focus: var(--__P__-on-accent)}.__P__-header[data-variant=accent]>.__P__-icon-btn:hover,.__P__-header[data-variant=accent] .__P__-header-actions>.__P__-icon-btn:hover,.__P__-header[data-variant=accent] .__P__-menu-wrap>.__P__-icon-btn:hover{background:color-mix(in oklch,var(--__P__-on-accent) 16%,transparent);color:var(--__P__-on-accent)}.__P__-header[data-variant=accent]>.__P__-icon-btn:active,.__P__-header[data-variant=accent] .__P__-header-actions>.__P__-icon-btn:active,.__P__-header[data-variant=accent] .__P__-menu-wrap>.__P__-icon-btn:active{background:color-mix(in oklch,var(--__P__-on-accent) 24%,transparent)}.__P__-header[data-variant=accent] .__P__-agent-avatar{background:color-mix(in oklch,var(--__P__-on-accent) 18%,transparent);color:var(--__P__-on-accent)}.__P__-header[data-variant=accent] .__P__-agent-avatar:after{border-color:var(--__P__-accent)}.__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:var(--__P__-radius-md);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);flex-shrink:0}.__P__-agent-avatar img{width:100%;height:100%;border-radius:inherit;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__-agent-sub{display:flex;gap:4px;min-width:0}.__P__-agent-sub button+span:before{content:"\\b7\\a0"}.__P__-agent-ticket{flex:none;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);cursor:copy}.__P__-agent-ticket:hover{color:var(--__P__-fg)}.__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[data-cut-end=true]{mask-image:linear-gradient(to right,#000 calc(100% - 32px),transparent)}.__P__-suggestions[data-cut-start=true]{mask-image:linear-gradient(to right,transparent,#000 32px)}.__P__-suggestions[data-cut-start=true][data-cut-end=true]{mask-image:linear-gradient(to right,transparent,#000 32px,#000 calc(100% - 32px),transparent)}:host([dir="rtl"]) .__P__-suggestions[data-cut-end=true]{mask-image:linear-gradient(to left,#000 calc(100% - 32px),transparent)}:host([dir="rtl"]) .__P__-suggestions[data-cut-start=true]{mask-image:linear-gradient(to left,transparent,#000 32px)}:host([dir="rtl"]) .__P__-suggestions[data-cut-start=true][data-cut-end=true]{mask-image:linear-gradient(to left,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__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;position:relative;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 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:0;bottom:14px;z-index:2;margin-inline:auto;display: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;overflow-anchor:none}.__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__-load-previous,.__P__-history-more{display:flex;justify-content:center}.__P__-load-previous button,.__P__-history-more button{border:0;padding:4px 8px;background:transparent;color:var(--__P__-accent);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;cursor:pointer}.__P__-load-previous button:hover,.__P__-history-more button:hover{text-decoration:underline}.__P__-load-previous button:focus-visible,.__P__-history-more button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-load-previous button:disabled,.__P__-history-more button:disabled{cursor:wait;opacity:.6}.__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-body{display:flex;flex-wrap:wrap;align-items:flex-start;gap:var(--__P__-space-3) 6px;min-width:0}.__P__-bubble-body>*{flex:1 0 100%;min-width:0}.__P__-bubble-body>.__P__-source,.__P__-bubble-body>.__P__-typing{flex:0 1 auto}.__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,.__P__-steps){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui,.__P__-steps) .__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 :not(pre)>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__-file-image,.__P__-file-chip{border-radius:var(--__P__-radius-sm);color:inherit;text-decoration:none}.__P__-file-image{display:block;width:fit-content;max-width:min(100%,240px);overflow:hidden}.__P__-file-image img{max-height:240px;object-fit:cover}.__P__-file-chip{display:flex;align-items:center;gap:var(--__P__-space-2);max-width:min(100%,280px);padding:var(--__P__-space-2);border:1px solid color-mix(in srgb,currentColor 18%,transparent);background:color-mix(in srgb,currentColor 5%,transparent);transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-file-chip:hover{background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-image:focus-visible,.__P__-file-chip:focus-visible{outline:2px solid currentColor;outline-offset:2px}.__P__-file-chip-icon{flex:none;display:grid;place-items:center;width:32px;height:32px;border-radius:var(--__P__-radius-sm);background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-chip-text{display:grid;min-width:0;line-height:1.35}.__P__-file-chip-name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-file-chip-meta{font-size:var(--__P__-text-xs);opacity:.75}.__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__-chat-notice{padding:0 var(--__P__-space-3);text-align:center;font-size:var(--__P__-text-xs);line-height:1.5;color:var(--__P__-fg-muted)}.__P__-chat-notice .__P__-md p{margin:0}.__P__-chat-notice .__P__-md a{color:var(--__P__-accent-fg)}.__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__-steps{min-width:0;font-size:var(--__P__-text-sm)}.__P__-steps-head,.__P__-steps-row-head{display:inline-flex;align-items:center;gap:var(--__P__-space-2);max-width:100%;min-width:0;min-height:28px;padding:0;border:0;background:none;color:var(--__P__-fg-muted);font:inherit;text-align:start;cursor:pointer;-webkit-tap-highlight-color:transparent}.__P__-steps-head:hover,.__P__-steps-row-head:hover{color:var(--__P__-fg)}.__P__-steps-head:focus-visible,.__P__-steps-row-head:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-steps-icon,.__P__-steps-row-icon{display:inline-flex;flex:none;align-items:center;justify-content:center;width:16px;height:16px}.__P__-steps-icon svg,.__P__-steps-row-icon svg{width:14px;height:14px}.__P__-steps-label,.__P__-steps-row-label{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-steps-sep{margin-inline:var(--__P__-space-1)}.__P__-steps-name .__P__-steps-count{margin-inline-start:var(--__P__-space-1)}.__P__-steps-count,.__P__-steps-failed,.__P__-steps-denied,.__P__-steps-time{flex:none;font-variant-numeric:tabular-nums}.__P__-steps-failed{color:var(--__P__-danger-text)}.__P__-steps-denied{color:var(--__P__-fg-muted)}.__P__-steps-decision{display:inline-flex;flex:none;align-items:center;gap:var(--__P__-space-1);font-variant-numeric:tabular-nums;color:var(--__P__-success)}.__P__-steps-decision[data-approved=false]{color:var(--__P__-warning)}.__P__-steps-decision svg{width:14px;height:14px}.__P__-steps-row-error{margin:0;color:var(--__P__-danger-text)}.__P__-steps-chevron{display:inline-flex;flex:none;width:16px;height:16px;transition:transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-steps-chevron svg{width:16px;height:16px}.__P__-steps-chevron[data-open=true]{transform:rotate(180deg)}.__P__-steps-list{position:relative;display:flex;flex-direction:column;gap:var(--__P__-space-1);margin:var(--__P__-space-1) 0 0;padding:0;list-style:none}.__P__-steps-list:before{content:"";position:absolute;inset-block:0;inset-inline-start:7px;width:2px;border-radius:1px;background:var(--__P__-border)}.__P__-steps-row{position:relative;display:grid;grid-template-columns:16px minmax(0,1fr);column-gap:var(--__P__-space-2);align-items:start}.__P__-steps-row .__P__-steps-row-icon{margin-block:6px;border-radius:999px;background:var(--__P__-bubble-assistant);color:var(--__P__-fg-muted)}.__P__-steps-row[data-status=error] .__P__-steps-row-icon{color:var(--__P__-danger-text)}.__P__-steps-row-main{display:flex;flex-direction:column;align-items:flex-start;min-width:0}.__P__-steps-row-name{color:var(--__P__-fg);font-weight:500}.__P__-steps-row-system,.__P__-steps-row-summary{margin-inline-start:var(--__P__-space-2);color:var(--__P__-fg-muted)}.__P__-steps-row-body{grid-column:2;display:flex;flex-direction:column;gap:var(--__P__-space-2);width:100%;margin:var(--__P__-space-1) 0 var(--__P__-space-2)}.__P__-steps-row[data-standalone=true]>:is(.__P__-steps-row-body,.__P__-steps-thought-text){grid-column:1 / -1}.__P__-steps-body{display:grid;grid-template-rows:0fr;transition:grid-template-rows .2s ease-out}.__P__-steps-body[data-open=true]{grid-template-rows:1fr}.__P__-steps-body-inner{min-height:0;overflow:hidden}.__P__-steps-live{min-width:0;overflow:hidden;text-overflow:ellipsis;background:linear-gradient(90deg,var(--__P__-fg-muted) 0%,var(--__P__-fg) 50%,var(--__P__-fg-muted) 100%) 0 0 / 200% 100%;background-clip:text;-webkit-background-clip:text;color:transparent;animation:__P__-steps-shimmer 2s linear infinite}@keyframes __P__-steps-shimmer{to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-steps-body,.__P__-steps-chevron{transition:none}.__P__-steps-live{background:none;color:var(--__P__-fg-muted);animation:none}}.__P__-steps-thought,.__P__-steps-stopped-label{color:var(--__P__-fg-muted)}.__P__-steps-thought-label,.__P__-steps-stopped-label{display:inline-flex;align-items:center;min-height:28px}.__P__-steps-thought-text{grid-column:2;width:100%;margin:var(--__P__-space-1) 0 var(--__P__-space-2)}.__P__-reasoning-body{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%;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__-compaction-status{width:100%;padding:10px 14px;justify-content:center;font-size:var(--__P__-text-xs)}.__P__-message-queue{display:flex;max-height:112px;flex-direction:column;gap:var(--__P__-space-1);overflow-y:auto}.__P__-attachment-chip.__P__-queued-message{width:100%;max-width:none}.__P__-queued-text{min-width:0;flex:1}.__P__-composer-row{--__P__-composer-line-height: 40px;display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;--__P__-textarea-base-height: 40px;height:var(--__P__-textarea-base-height);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)}.__P__-textarea:focus-visible{outline:none;border-color:var(--__P__-focus)}.__P__-textarea:placeholder-shown{white-space:nowrap;overflow:hidden}.__P__-textarea::placeholder{text-overflow:ellipsis}@media(pointer:coarse){.__P__-textarea{--__P__-textarea-base-height: 44px}.__P__-composer-row{--__P__-composer-line-height: 44px}.__P__-composer-row>.__P__-send{margin-block-end:2px}}.__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;margin-block-end:calc((var(--__P__-composer-line-height) - 32px) / 2)}.__P__-attachments{display:flex;flex-wrap:wrap;gap:6px}.__P__-attachment-chip{position:relative;display:inline-flex;align-items:center;gap:8px;padding:5px;border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);font-size:var(--__P__-text-xs);max-width:220px;overflow:hidden}.__P__-attachment-chip[data-upload=error]{border-color:color-mix(in oklab,var(--__P__-danger) 45%,transparent);background:color-mix(in oklab,var(--__P__-danger) 6%,var(--__P__-bg-elevated))}.__P__-attachment-thumb{flex-shrink:0;width:32px;height:32px;border-radius:var(--__P__-radius-sm);object-fit:cover;background:var(--__P__-border);display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-text{display:flex;flex-direction:column;min-width:0;line-height:1.3}.__P__-attachment-name{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--__P__-fg);font-weight:500}.__P__-attachment-meta{display:inline-flex;align-items:center;gap:4px;color:var(--__P__-fg-muted);font-variant-numeric:tabular-nums;white-space:nowrap}.__P__-attachment-meta svg{flex:none;width:12px;height:12px}.__P__-attachment-chip[data-upload=error] .__P__-attachment-meta{color:var(--__P__-danger)}.__P__-attachment-chip[data-upload=done] .__P__-attachment-meta svg{color:var(--__P__-success)}.__P__-attachment-progress{position:absolute;inset-inline:0;bottom:0;height:2px;background:color-mix(in oklab,var(--__P__-accent) 15%,transparent)}.__P__-attachment-progress>span{display:block;height:100%;background:var(--__P__-accent);transition:width var(--__P__-dur-quick) var(--__P__-ease)}.__P__-attachment-remove{flex-shrink:0;width:24px;height:24px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-remove svg{width:14px;height:14px}.__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%,color-mix(in srgb,var(--__P__-bg) 92%,transparent));display:flex;flex-direction:column;gap:10px;align-items:center;justify-content:center;text-align:center;padding:16px;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)}.__P__-dropzone-icon{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:999px;background:color-mix(in srgb,var(--__P__-accent) 14%,transparent)}.__P__-dropzone-icon svg{width:22px;height:22px}.__P__-dropzone[data-state=reject]{border-color:var(--__P__-danger);background:color-mix(in srgb,var(--__P__-danger) 8%,color-mix(in srgb,var(--__P__-bg) 92%,transparent));color:var(--__P__-danger)}.__P__-dropzone[data-state=reject] .__P__-dropzone-icon{background:color-mix(in srgb,var(--__P__-danger) 14%,transparent)}@keyframes __P__-fade-in{0%{opacity:0}to{opacity:1}}.__P__-error{display:flex;align-items:center;gap:var(--__P__-space-2);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)}.__P__-error-icon{display:inline-flex;flex:none;width:16px;height:16px;color:var(--__P__-danger-text)}.__P__-error-icon svg{width:16px;height:16px}.__P__-error-text{min-width:0}.__P__-error-retry{flex:none;margin-inline-start:auto;min-height:28px;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__-error-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__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-card>[role=listitem]{display:flex;flex-direction:column}.__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-card>*+*{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:var(--__P__-radius-md);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-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:var(--__P__-radius-md)}.__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__-transcript-layer{position:absolute;inset:0;z-index:20;display:flex;align-items:center;justify-content:center;padding:var(--__P__-space-4);border-radius:inherit;overflow:hidden}.__P__-transcript-backdrop{position:absolute;inset:0;background:var(--__P__-backdrop);animation:__P__-transcript-fade var(--__P__-dur-base) var(--__P__-ease-out)}.__P__-transcript-sheet{position:relative;display:flex;flex-direction:column;gap:var(--__P__-space-3);box-sizing:border-box;width:100%;max-width:360px;padding:var(--__P__-space-4);border-radius:var(--__P__-radius-lg);background:var(--__P__-bg);color:var(--__P__-fg);box-shadow:var(--__P__-shadow-panel),inset 0 0 0 1px var(--__P__-border);animation:__P__-transcript-in var(--__P__-dur-base) var(--__P__-ease-out)}.__P__-transcript-sheet-head{display:flex;align-items:center;gap:var(--__P__-space-2);margin-block:-4px;margin-inline-end:-6px}.__P__-transcript-sheet-icon{display:inline-flex;align-items:center;justify-content:center;inline-size:28px;block-size:28px;flex-shrink:0;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-accent) 12%,transparent);color:var(--__P__-accent-fg)}.__P__-transcript-sheet-icon svg{inline-size:16px;block-size:16px}.__P__-transcript-sheet-title{flex:1;min-width:0;margin:0;font-size:var(--__P__-text-base);font-weight:600;text-wrap:balance}.__P__-transcript-sheet-form{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-transcript-sheet-text{margin:0;font-size:var(--__P__-text-sm);line-height:1.45;color:var(--__P__-fg-muted);overflow-wrap:anywhere;text-wrap:pretty}.__P__-transcript-sheet-sent{display:flex;align-items:flex-start;gap:var(--__P__-space-2);color:var(--__P__-fg)}.__P__-transcript-sheet-sent svg{flex-shrink:0;inline-size:18px;block-size:18px;color:var(--__P__-success)}.__P__-transcript-sheet-action{width:100%;min-height:44px;text-align:center;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),scale var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-transcript-sheet-action:active:not(:disabled){scale:.96}@keyframes __P__-transcript-fade{0%{opacity:0}}@keyframes __P__-transcript-in{0%{opacity:0;translate:0 8px}}@media(max-width:640px){.__P__-transcript-layer{align-items:flex-end;padding:0}.__P__-transcript-sheet{max-width:none;padding-bottom:calc(var(--__P__-space-4) + env(safe-area-inset-bottom,0px));border-end-start-radius:0;border-end-end-radius:0;animation-name:__P__-transcript-up}}@keyframes __P__-transcript-up{0%{translate:0 100%}}@media(prefers-reduced-motion:reduce){.__P__-transcript-backdrop,.__P__-transcript-sheet{animation:none}}.__P__-operator-banner{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:start;column-gap:10px;box-sizing:border-box;width:calc(100% - 2 * var(--__P__-space-3));max-width:var(--__P__-conversation-max, 768px);margin:0 auto var(--__P__-space-2);padding:10px 12px;border-radius:var(--__P__-radius-lg);background:var(--__P__-bg-elevated);box-shadow:inset 0 0 0 1px var(--__P__-border);color:var(--__P__-fg);font-size:var(--__P__-text-sm);line-height:1.45;text-align:start}.__P__-operator-label{text-wrap:pretty}.__P__-operator-pulse{width:8px;height:8px;margin-block-start:calc((1.45em - 8px)/2);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-banner[data-available=false] .__P__-operator-pulse{background:var(--__P__-warning);animation:none}.__P__-operator-banner[data-mode=operator] .__P__-operator-pulse{background:var(--__P__-success)}.__P__-operator-dismiss{width:28px;height:28px;margin-block:-4px;margin-inline-end:-6px}.__P__-operator-dismiss:before{inset:-8px}.__P__-operator-dismiss svg{width:16px;height:16px}@media(prefers-reduced-motion:reduce){.__P__-operator-banner[data-mode=awaiting-operator] .__P__-operator-pulse{animation:none}}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__P__-login-bar{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;align-items:center;column-gap:10px;padding:6px 8px;padding-inline-start:14px;border-bottom:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font-size:var(--__P__-text-sm);line-height:1.4}.__P__-login-bar-icon,.__P__-login-gate-icon{display:inline-flex;color:var(--__P__-fg-muted)}.__P__-login-bar-icon svg{width:16px;height:16px}.__P__-login-bar-text{text-wrap:pretty}.__P__-login-bar[data-kind=user]{grid-template-columns:auto minmax(0,1fr);padding-inline-end:14px;color:var(--__P__-fg-muted)}.__P__-login-bar[data-kind=user] .__P__-login-bar-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-login-bar-action{appearance:none;border:0;cursor:pointer;padding:6px 12px;border-radius:999px;background:transparent;color:var(--__P__-accent-fg);font:inherit;font-weight:600;white-space:nowrap;transition:background var(--__P__-dur-quick) var(--__P__-ease)}.__P__-login-bar-action:hover{background:var(--__P__-hover)}.__P__-login-bar-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:1px}.__P__-login-bar-hide{width:28px;height:28px}.__P__-login-bar-hide:before{inset:-8px}.__P__-login-bar-hide svg{width:16px;height:16px}.__P__-login-gate{display:flex;flex-direction:column;align-items:center;gap:10px;box-sizing:border-box;width:calc(100% - 2 * var(--__P__-space-3));max-width:var(--__P__-conversation-max, 768px);margin:0 auto var(--__P__-space-3);padding:18px 16px;border-radius:var(--__P__-radius-lg);background:var(--__P__-bg-elevated);box-shadow:inset 0 0 0 1px var(--__P__-border);text-align:center}.__P__-login-gate[data-alone]{flex:1;justify-content:center;margin-block-start:var(--__P__-space-3);background:transparent;box-shadow:none}.__P__-login-gate-icon{align-items:center;justify-content:center;width:40px;height:40px;border-radius:50%;background:var(--__P__-bg);box-shadow:inset 0 0 0 1px var(--__P__-border)}.__P__-login-gate[data-alone] .__P__-login-gate-icon{width:48px;height:48px;background:var(--__P__-bg-elevated)}.__P__-login-gate-icon svg{width:20px;height:20px}.__P__-form-actions.__P__-login-gate-actions{justify-content:center;width:100%;max-width:320px;margin-top:var(--__P__-space-1)}.__P__-login-gate-title{margin:0;color:var(--__P__-fg);font-size:var(--__P__-text-md);font-weight:600;line-height:1.35;text-wrap:balance}.__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);color:var(--__P__-fg);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,.__P__-panel[data-resizing] .__P__-resize-grip{opacity:1}.__P__-resize-grip:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px;border-radius:4px}.__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)}.__P__-resize-grip--edge{top:0;bottom:0;left:0;width:8px;height:auto;opacity:1;cursor:ew-resize}.__P__-resize-grip--edge:focus-visible{outline:none}.__P__-resize-grip--edge:after{content:"";position:absolute;top:var(--__P__-radius, 12px);bottom:var(--__P__-radius, 12px);left:0;width:2px;border-radius:1px;background:var(--__P__-focus);opacity:0;transition:opacity var(--__P__-dur-base) var(--__P__-ease)}:host([data-position$="-left"]) .__P__-resize-grip--edge,:host([data-position$="-left"]) .__P__-resize-grip--edge:after{left:auto;right:0}.__P__-resize-grip--edge:hover:after{opacity:1;transition-delay:.15s}.__P__-resize-grip--edge:focus-visible:after,.__P__-panel[data-resizing] .__P__-resize-grip--edge:after{opacity:1}@media(pointer:coarse){.__P__-resize-grip{width:24px;height:24px}.__P__-resize-grip--edge{width:14px;height:auto}}:host(:not([data-mode="open"]):not([data-mode="expanded"]):not([data-mode="drawer"])) .__P__-resize-grip{display:none}@media(max-width:640px){.__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__-help-more{justify-content:center;color:var(--__P__-accent-fg);font-weight:600}.__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)}@media(hover:hover){.__P__-tab:hover{background:var(--__P__-hover)}}.__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:var(--__P__-radius-md);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:var(--__P__-radius-md);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;line-height:1.45}.__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{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search[data-input=true]:focus-within{outline:none;border-color:var(--__P__-focus)}.__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-input:focus-visible{outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent-fg)}.__P__-home-ask{padding-block:6px;padding-inline-end:6px}.__P__-home-ask .__P__-send{width:32px;height:32px;flex-shrink:0}.__P__-home-ask .__P__-send[data-shape=pill]{width:auto;padding:0 14px}.__P__-home-ask .__P__-send svg{width:16px;height:16px}.__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-vote{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2);padding-top:var(--__P__-space-3);border-top:1px solid var(--__P__-border)}.__P__-news-list{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-news-card{display:block;width:100%;text-align:start;line-height:1.45;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface);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-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-news-tag{padding:1px 8px;border-radius:6px;background:var(--__P__-hover);color:var(--__P__-fg);font-size:calc(12px * var(--__P__-text-scale));white-space:nowrap}.__P__-news-more{display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);width:100%;min-height:44px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);background:var(--__P__-surface);color:var(--__P__-accent-fg);font-weight:600}.__P__-news-more:hover{background:var(--__P__-bg-elevated)}.__P__-news-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__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__-panel-notice{display:flex;align-items:center;justify-content:center;position:relative;padding:var(--__P__-space-6);text-align:center}.__P__-panel-notice-close{position:absolute;top:12px;inset-inline-end:12px}.__P__-panel-notice-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__-textarea,.__P__-home-search-input,.__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__-toolui{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)}.__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=done]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=approved],.__P__-toolui-status[data-status=submitted]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=waiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=declined]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=failed]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=replaced],.__P__-toolui-status[data-status=running],.__P__-toolui-status[data-status=stopped]{--__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-3)}.__P__-toolui-collapse-body>.__P__-form{gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form>.__P__-field,.__P__-toolui-summary>.__P__-field{padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg) 80%,transparent);line-height:1.5}.__P__-toolui-collapse-body>.__P__-form>.__P__-field{gap:var(--__P__-space-2)}.__P__-toolui-summary>.__P__-field{gap:var(--__P__-space-1)}.__P__-toolui-summary .__P__-field-label{color:var(--__P__-fg-muted)}.__P__-toolui-answer{margin:0;font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted);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-system{min-width:0;overflow:hidden;color:var(--__P__-fg-muted);text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-preview{min-width:0}.__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-fields{max-height:240px;overflow:auto;overscroll-behavior:contain;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm)}.__P__-toolui-fields table{width:100%;border-collapse:collapse;font-size:var(--__P__-text-sm);line-height:1.5}.__P__-toolui-fields tr:nth-child(2n){background:color-mix(in oklab,var(--__P__-fg) 4%,transparent)}.__P__-toolui-fields tr+tr{border-top:1px solid var(--__P__-border)}.__P__-toolui-fields th,.__P__-toolui-fields td{padding:6px var(--__P__-space-2);text-align:start;vertical-align:top}.__P__-toolui-fields th{width:1%;color:var(--__P__-fg-muted);font-weight:400;white-space:nowrap}.__P__-toolui-fields td{color:var(--__P__-fg);white-space:pre-wrap;overflow-wrap:anywhere}.__P__-toolui-fields[data-plain=true]{border:0;border-radius:0}.__P__-toolui-fields[data-plain=true] tr:nth-child(2n){background:none}.__P__-toolui-fields[data-plain=true] tr+tr{border-top:0}.__P__-toolui-fields[data-plain=true] th,.__P__-toolui-fields[data-plain=true] td{padding:1px var(--__P__-space-2) 1px 0}.__P__-toolui-raw>summary{width:fit-content;color:var(--__P__-fg-muted);cursor:pointer}.__P__-toolui-raw>summary:hover{color:var(--__P__-fg)}.__P__-toolui-raw>summary:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-toolui-raw[open]{display:flex;flex-direction:column;gap:var(--__P__-space-2)}.__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}
7
7
 
8
- .__P__-generative-ui{display:grid;grid-template-columns:minmax(0,1fr);gap:var(--__P__-space-3);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-generative-ui p{margin:0}.__P__-generative-ui-grid-container{container:__P__-generative-ui-grid / inline-size;min-width:0}.__P__-generative-ui-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:16px}.__P__-generative-ui-cell{display:flex;flex-direction:column;align-self:start;min-width:0;gap:16px}.__P__-generative-ui-grid[data-equal-heights]>.__P__-generative-ui-cell{align-self:stretch}.__P__-generative-ui-grid[data-equal-heights]>.__P__-generative-ui-cell>:only-child{flex:1}@container __P__-generative-ui-grid (min-width: 496px){.__P__-generative-ui-grid:is([data-columns="2"],[data-columns="3"],[data-columns="4"]){grid-template-columns:repeat(2,minmax(0,1fr))}.__P__-generative-ui-grid:is([data-columns="2"],[data-columns="3"],[data-columns="4"])>.__P__-generative-ui-cell:is([data-span="2"],[data-span="3"],[data-span="4"]){grid-column:span 2}}@container __P__-generative-ui-grid (min-width: 752px){.__P__-generative-ui-grid:is([data-columns="3"],[data-columns="4"]){grid-template-columns:repeat(3,minmax(0,1fr))}.__P__-generative-ui-grid:is([data-columns="3"],[data-columns="4"])>.__P__-generative-ui-cell:is([data-span="3"],[data-span="4"]){grid-column:span 3}}@container __P__-generative-ui-grid (min-width: 1008px){.__P__-generative-ui-grid[data-columns="4"]{grid-template-columns:repeat(4,minmax(0,1fr))}.__P__-generative-ui-grid[data-columns="4"]>.__P__-generative-ui-cell[data-span="4"]{grid-column:span 4}}.__P__-generative-ui section{display:flex;flex-direction:column;gap:var(--__P__-space-2);padding:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);min-width:0}.__P__-generative-ui-metric{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);font-size:1.6em;font-weight:700;font-variant-numeric:tabular-nums}.__P__-generative-ui-metric svg{flex:none;width:80px;height:24px;color:var(--__P__-accent)}.__P__-generative-ui-change{align-self:flex-start;padding:2px var(--__P__-space-2);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;font-variant-numeric:tabular-nums}.__P__-generative-ui-change[data-tone=good]{color:var(--__P__-fg);background:color-mix(in oklch,var(--__P__-success) 18%,transparent)}.__P__-generative-ui-change[data-tone=bad]{color:var(--__P__-danger-text);background:var(--__P__-danger-bg)}.__P__-generative-ui-table-card{container:__P__-generative-ui-table / inline-size}.__P__-generative-ui-table{overflow-x:auto}@container __P__-generative-ui-table (max-width: 639.98px){.__P__-generative-ui-table :is(table,tbody,tr,td){display:block}.__P__-generative-ui-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}.__P__-generative-ui-table tr{margin-bottom:var(--__P__-space-2);padding:var(--__P__-space-1) var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm)}.__P__-generative-ui-table td,.__P__-generative-ui-table td[data-numeric=true]{display:flex;justify-content:space-between;gap:var(--__P__-space-3);padding:var(--__P__-space-1) 0;border:0;text-align:end}.__P__-generative-ui-table td:before{content:attr(data-label);color:var(--__P__-fg-muted);text-align:start}}.__P__-generative-ui table{width:100%;border-collapse:collapse;white-space:normal}.__P__-generative-ui caption{text-align:start;font-weight:600;padding-bottom:var(--__P__-space-2)}.__P__-generative-ui th,.__P__-generative-ui td{text-align:start;padding:var(--__P__-space-2);border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui :is(th,td)[data-numeric=true]{text-align:end;font-variant-numeric:tabular-nums}.__P__-generative-ui th button{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:600;text-align:inherit;cursor:pointer}.__P__-generative-ui th button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-generative-ui th[aria-sort=ascending] button:after{content:" \\2191"}.__P__-generative-ui th[aria-sort=descending] button:after{content:" \\2193"}.__P__-generative-ui-chart{display:block;width:100%;max-height:320px;color:var(--__P__-accent)}.__P__-generative-ui-axis line{stroke:var(--__P__-border)}.__P__-generative-ui-axis text{fill:var(--__P__-fg-muted);font-size:9px}.__P__-generative-ui .__P__-generative-ui-legend{display:flex;flex-wrap:wrap;gap:var(--__P__-space-1) var(--__P__-space-3);margin:0;padding:0;list-style:none;color:var(--__P__-accent);font-size:var(--__P__-text-xs)}.__P__-generative-ui-legend li{display:flex;align-items:center;gap:6px;margin:0}.__P__-generative-ui-legend li:before{content:"";width:10px;height:10px;border-radius:3px;background:currentColor}.__P__-generative-ui-legend span{color:var(--__P__-fg)}.__P__-generative-ui-carousel{display:flex;gap:var(--__P__-space-3);margin:0 calc(var(--__P__-space-1) * -1);padding:0 var(--__P__-space-1) var(--__P__-space-2);overflow-x:auto;scroll-snap-type:x mandatory;scroll-padding-inline:var(--__P__-space-1);scrollbar-width:thin;min-width:0}.__P__-generative-ui-card,.__P__-generative-ui-offer{--__P__-card-width: 280px}.__P__-generative-ui-flight{--__P__-card-width: 300px}.__P__-generative-ui-sheet{--__P__-card-width: 480px}.__P__-generative-ui>section,.__P__-generative-ui-carousel>[role=listitem]>section{width:var(--__P__-card-width, 100%);max-width:100%}.__P__-generative-ui-carousel>[role=listitem]{display:flex;flex:none;max-width:100%;scroll-snap-align:start}.__P__-generative-ui-offer{overflow:hidden}.__P__-generative-ui-footer{display:flex;flex-direction:column;gap:var(--__P__-space-2);margin-top:auto}.__P__-generative-ui-hint{min-height:1.4em;line-height:1.4;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-photo{position:relative;display:block;flex:none;width:calc(100% + 2 * var(--__P__-space-3));aspect-ratio:4 / 3;margin:calc(var(--__P__-space-3) * -1) calc(var(--__P__-space-3) * -1) var(--__P__-space-1);overflow:hidden;background:var(--__P__-hover)}.__P__-generative-ui-photo[data-wide=true]{aspect-ratio:16 / 9}.__P__-generative-ui-badges{display:flex;flex-wrap:wrap;gap:var(--__P__-space-1)}.__P__-generative-ui-photo>.__P__-generative-ui-badges{position:absolute;top:var(--__P__-space-2);inset-inline-start:var(--__P__-space-2)}.__P__-generative-ui-photo .__P__-generative-ui-pill{background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:0 0 0 1px var(--__P__-border)}.__P__-generative-ui-thumb{display:block;flex:0 0 auto;width:48px;height:48px;overflow:hidden;border-radius:var(--__P__-radius-sm);background:var(--__P__-hover)}.__P__-generative-ui-photo img,.__P__-generative-ui-thumb img{display:block;width:100%;max-width:none;height:100%;object-fit:cover}.__P__-generative-ui-heading{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-generative-ui-stars{color:var(--__P__-warning);font-size:var(--__P__-text-xs);letter-spacing:1px}.__P__-generative-ui .__P__-generative-ui-details{display:grid;gap:2px;margin:0;padding:0;list-style:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-details li{display:flex;gap:6px;margin:0}.__P__-generative-ui-details li:before{content:"\\2022";flex:none}.__P__-generative-ui-leg{display:grid;grid-template-columns:minmax(0,1fr);gap:2px}.__P__-generative-ui-leg+.__P__-generative-ui-leg{padding-top:var(--__P__-space-2);border-top:1px solid var(--__P__-border)}.__P__-generative-ui-leg-times{display:flex;align-items:center;gap:var(--__P__-space-1)}.__P__-generative-ui-leg-times>span:not(.__P__-generative-ui-leg-path){display:grid;flex:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-leg-times>span:last-child{text-align:end}.__P__-generative-ui-leg-times strong{color:var(--__P__-fg);font-size:1rem;font-variant-numeric:tabular-nums;white-space:nowrap}.__P__-generative-ui-leg-times sup{font-size:.6em;color:var(--__P__-fg-muted)}.__P__-generative-ui-leg-path{flex:1;min-width:0;padding-bottom:4px;border-bottom:1px solid var(--__P__-border-strong);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);line-height:1.3;text-align:center;overflow-wrap:normal}.__P__-generative-ui .__P__-generative-ui-itinerary{display:grid;gap:var(--__P__-space-2);margin:0;padding:0;list-style:none}.__P__-generative-ui-itinerary li{display:grid;margin:0;padding-inline-start:var(--__P__-space-3);border-inline-start:2px solid var(--__P__-border-strong)}.__P__-generative-ui-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;line-height:1.35;min-height:2.7em}.__P__-generative-ui a{color:inherit}.__P__-generative-ui .__P__-generative-ui-title a,.__P__-generative-ui .__P__-generative-ui-lines a,.__P__-generative-ui .__P__-generative-ui-actions>a{text-decoration:none}.__P__-generative-ui .__P__-generative-ui-title a:hover,.__P__-generative-ui .__P__-generative-ui-lines span>a:hover{text-decoration:underline}.__P__-generative-ui-pill{display:inline-flex;align-items:center;padding:2px var(--__P__-space-2);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-muted{color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-star{color:var(--__P__-warning)}.__P__-generative-ui-price{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 var(--__P__-space-2);font-variant-numeric:tabular-nums}.__P__-generative-ui-price strong{font-size:1.1em}.__P__-generative-ui-price s{color:var(--__P__-fg-muted)}.__P__-generative-ui-description{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;color:var(--__P__-fg-muted)}.__P__-generative-ui-option{display:grid;gap:var(--__P__-space-1);min-width:0;margin:0;padding:0;border:0}.__P__-generative-ui-option legend{padding:0 0 var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-option div{display:flex;gap:6px;min-width:0;margin:-4px;padding:4px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.__P__-generative-ui-option div::-webkit-scrollbar{display:none}.__P__-generative-ui-option div[data-cut-end]{mask-image:linear-gradient(to right,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div[data-cut-start]{mask-image:linear-gradient(to right,transparent,#000 32px)}.__P__-generative-ui-option div[data-cut-start][data-cut-end]{mask-image:linear-gradient(to right,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div:dir(rtl)[data-cut-end]{mask-image:linear-gradient(to left,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div:dir(rtl)[data-cut-start]{mask-image:linear-gradient(to left,transparent,#000 32px)}.__P__-generative-ui-option div:dir(rtl)[data-cut-start][data-cut-end]{mask-image:linear-gradient(to left,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option button{flex:0 0 auto;min-height:32px;padding:0 10px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-generative-ui-option button:hover{border-color:var(--__P__-border-strong)}.__P__-generative-ui-option button[aria-pressed=true]{border-color:var(--__P__-accent);box-shadow:inset 0 0 0 1px var(--__P__-accent);font-weight:600}.__P__-generative-ui-option button:disabled{color:var(--__P__-fg-muted);text-decoration:line-through;opacity:.6;cursor:not-allowed}.__P__-generative-ui-actions{display:flex;flex-wrap:wrap;gap:var(--__P__-space-2);margin-top:auto;padding-top:var(--__P__-space-1)}.__P__-generative-ui-actions:not([data-small=true])>*{flex:1 1 auto}.__P__-generative-ui-actions>*{display:inline-flex;align-items:center;justify-content:center;min-height:36px;padding:0 var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:none;white-space:nowrap;min-width:0;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-generative-ui-actions>*>span{overflow:hidden;text-overflow:ellipsis}.__P__-generative-ui-actions[data-small=true]>*{min-height:28px;padding:0 var(--__P__-space-2);font-size:var(--__P__-text-xs)}.__P__-generative-ui-actions>:hover{border-color:var(--__P__-border-strong)}.__P__-generative-ui-actions>[data-primary=true]{border-color:var(--__P__-accent);background:var(--__P__-accent);color:var(--__P__-on-accent)}.__P__-generative-ui-actions>:focus-visible,.__P__-generative-ui-option button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-generative-ui-actions>:disabled{border-color:var(--__P__-border);background:var(--__P__-hover);color:var(--__P__-fg-muted);cursor:not-allowed}.__P__-generative-ui .__P__-generative-ui-lines{display:grid;margin:0;padding:0;list-style:none}.__P__-generative-ui .__P__-generative-ui-lines li{display:flex;margin:0;gap:var(--__P__-space-3);padding:var(--__P__-space-2) 0;border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui .__P__-generative-ui-lines li:first-child{padding-top:0}.__P__-generative-ui-lines li>div{display:grid;flex:1;gap:2px;min-width:0}.__P__-generative-ui-line-head{display:flex;align-items:baseline;gap:var(--__P__-space-3)}.__P__-generative-ui-line-head>span{display:-webkit-box;flex:1;min-width:0;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2}.__P__-generative-ui-line-head>strong{flex:none;font-variant-numeric:tabular-nums}.__P__-generative-ui-totals{display:grid;gap:var(--__P__-space-1);margin:0;font-variant-numeric:tabular-nums}.__P__-generative-ui-totals div{display:flex;justify-content:space-between;gap:var(--__P__-space-3);color:var(--__P__-fg-muted)}.__P__-generative-ui-totals div:last-child{padding-top:var(--__P__-space-1);color:var(--__P__-fg);font-weight:700}.__P__-generative-ui-totals dt{min-width:0}.__P__-generative-ui-totals dd{flex:none;margin:0;white-space:nowrap}.__P__-generative-ui-notice{padding:var(--__P__-space-2) var(--__P__-space-3);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover)}.__P__-generative-ui-notice[data-severity=warning]{color:var(--__P__-fg);background:color-mix(in oklch,var(--__P__-warning) 16%,transparent)}.__P__-generative-ui-notice[data-severity=error]{color:var(--__P__-danger-text);background:var(--__P__-danger-bg)}.__P__-generative-ui .__P__-generative-ui-timeline{display:grid;gap:var(--__P__-space-2);margin:0;padding:0;list-style:none}.__P__-generative-ui .__P__-generative-ui-timeline li{display:flex;margin:0;align-items:baseline;gap:var(--__P__-space-2);color:var(--__P__-fg-muted)}.__P__-generative-ui-timeline li:before{content:"";flex:0 0 auto;width:8px;height:8px;border:2px solid var(--__P__-border-strong);border-radius:50%}.__P__-generative-ui-timeline li[data-done=true]{color:var(--__P__-fg);font-weight:600}.__P__-generative-ui-timeline li[data-done=true]:before{border-color:var(--__P__-accent);background:var(--__P__-accent)}.__P__-generative-ui-timeline li>:first-child{flex:1}@media(pointer:coarse){.__P__-generative-ui-actions>*{min-height:44px}.__P__-generative-ui-actions>*>span{overflow:hidden;text-overflow:ellipsis}.__P__-generative-ui-actions[data-small=true]>*{min-height:32px}.__P__-generative-ui-option button{min-height:40px}}
8
+ .__P__-generative-ui{display:grid;grid-template-columns:minmax(0,1fr);gap:var(--__P__-space-3);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-generative-ui p{margin:0}.__P__-generative-ui-grid-container{container:__P__-generative-ui-grid / inline-size;min-width:0}.__P__-generative-ui-grid{--__P__-cols: 1;display:flex;flex-wrap:wrap;gap:16px}.__P__-generative-ui-cell{display:flex;flex-direction:column;flex:1 1 calc((100% + 16px) * min(var(--__P__-span),var(--__P__-cols)) / var(--__P__-cols) - 16.5px);align-self:flex-start;min-width:0;gap:16px}.__P__-generative-ui-grid[data-equal-heights]>.__P__-generative-ui-cell{align-self:stretch}.__P__-generative-ui-grid[data-equal-heights]>.__P__-generative-ui-cell>:only-child{flex:1}@container __P__-generative-ui-grid (min-width: 496px){.__P__-generative-ui-grid{--__P__-cols: var(--__P__-cols-2)}}@container __P__-generative-ui-grid (min-width: 752px){.__P__-generative-ui-grid{--__P__-cols: var(--__P__-cols-3)}}@container __P__-generative-ui-grid (min-width: 1008px){.__P__-generative-ui-grid{--__P__-cols: var(--__P__-cols-4)}}.__P__-generative-ui section{display:flex;flex-direction:column;gap:var(--__P__-space-2);padding:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);min-width:0}.__P__-generative-ui-metric{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);font-size:1.6em;font-weight:700;font-variant-numeric:tabular-nums}.__P__-generative-ui-metric svg{flex:none;width:80px;height:24px;color:var(--__P__-accent)}.__P__-generative-ui-change{align-self:flex-start;padding:2px var(--__P__-space-2);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;font-variant-numeric:tabular-nums}.__P__-generative-ui-change[data-tone=good]{color:var(--__P__-fg);background:color-mix(in oklch,var(--__P__-success) 18%,transparent)}.__P__-generative-ui-change[data-tone=bad]{color:var(--__P__-danger-text);background:var(--__P__-danger-bg)}.__P__-generative-ui-table-card{container:__P__-generative-ui-table / inline-size}.__P__-generative-ui-table{overflow-x:auto}@container __P__-generative-ui-table (max-width: 639.98px){.__P__-generative-ui-table :is(table,tbody,tr,td){display:block}.__P__-generative-ui-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}.__P__-generative-ui-table tr{margin-bottom:var(--__P__-space-2);padding:var(--__P__-space-1) var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm)}.__P__-generative-ui-table td,.__P__-generative-ui-table td[data-numeric=true]{display:flex;justify-content:space-between;gap:var(--__P__-space-3);padding:var(--__P__-space-1) 0;border:0;text-align:end}.__P__-generative-ui-table td:before{content:attr(data-label);color:var(--__P__-fg-muted);text-align:start}}.__P__-generative-ui table{width:100%;border-collapse:collapse;white-space:normal}.__P__-generative-ui caption{text-align:start;font-weight:600;padding-bottom:var(--__P__-space-2)}.__P__-generative-ui th,.__P__-generative-ui td{text-align:start;padding:var(--__P__-space-2);border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui :is(th,td)[data-numeric=true]{text-align:end;font-variant-numeric:tabular-nums}.__P__-generative-ui th button{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:600;text-align:inherit;cursor:pointer}.__P__-generative-ui th button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-generative-ui th[aria-sort=ascending] button:after{content:" \\2191"}.__P__-generative-ui th[aria-sort=descending] button:after{content:" \\2193"}.__P__-generative-ui-chart{display:block;width:100%;max-height:320px;color:var(--__P__-accent)}.__P__-generative-ui-axis line{stroke:var(--__P__-border)}.__P__-generative-ui-axis text{fill:var(--__P__-fg-muted);font-size:9px}.__P__-generative-ui .__P__-generative-ui-legend{display:flex;flex-wrap:wrap;gap:var(--__P__-space-1) var(--__P__-space-3);margin:0;padding:0;list-style:none;color:var(--__P__-accent);font-size:var(--__P__-text-xs)}.__P__-generative-ui-legend li{display:flex;align-items:center;gap:6px;margin:0}.__P__-generative-ui-legend li:before{content:"";width:10px;height:10px;border-radius:3px;background:currentColor}.__P__-generative-ui-legend span{color:var(--__P__-fg)}.__P__-generative-ui-carousel{display:flex;gap:var(--__P__-space-3);margin:0 calc(var(--__P__-space-1) * -1);padding:0 var(--__P__-space-1) var(--__P__-space-2);overflow-x:auto;scroll-snap-type:x mandatory;scroll-padding-inline:var(--__P__-space-1);scrollbar-width:thin;min-width:0}.__P__-generative-ui-card:has(>.__P__-generative-ui-photo),.__P__-generative-ui-offer{--__P__-card-width: 280px}.__P__-generative-ui-flight{--__P__-card-width: 300px}.__P__-generative-ui-sheet{--__P__-card-width: 480px}.__P__-generative-ui>section,.__P__-generative-ui-carousel>[role=listitem]>section{width:var(--__P__-card-width, 100%);max-width:100%}.__P__-generative-ui-cell>section{max-width:var(--__P__-card-width, 100%)}.__P__-generative-ui-carousel>[role=listitem]{display:flex;flex:none;max-width:100%;scroll-snap-align:start}.__P__-generative-ui-offer{overflow:hidden}.__P__-generative-ui-footer{display:flex;flex-direction:column;gap:var(--__P__-space-2);margin-top:auto}.__P__-generative-ui-hint{min-height:1.4em;line-height:1.4;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-photo{position:relative;display:block;flex:none;width:calc(100% + 2 * var(--__P__-space-3));aspect-ratio:4 / 3;margin:calc(var(--__P__-space-3) * -1) calc(var(--__P__-space-3) * -1) var(--__P__-space-1);overflow:hidden;background:var(--__P__-hover)}.__P__-generative-ui-photo[data-wide=true]{aspect-ratio:16 / 9}.__P__-generative-ui-badges{display:flex;flex-wrap:wrap;gap:var(--__P__-space-1)}.__P__-generative-ui-photo>.__P__-generative-ui-badges{position:absolute;top:var(--__P__-space-2);inset-inline-start:var(--__P__-space-2)}.__P__-generative-ui-photo .__P__-generative-ui-pill{background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:0 0 0 1px var(--__P__-border)}.__P__-generative-ui-thumb{display:block;flex:0 0 auto;width:48px;height:48px;overflow:hidden;border-radius:var(--__P__-radius-sm);background:var(--__P__-hover)}.__P__-generative-ui-photo img,.__P__-generative-ui-thumb img{display:block;width:100%;max-width:none;height:100%;object-fit:cover}.__P__-generative-ui-heading{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-generative-ui-stars{color:var(--__P__-warning);font-size:var(--__P__-text-xs);letter-spacing:1px}.__P__-generative-ui .__P__-generative-ui-details{display:grid;gap:2px;margin:0;padding:0;list-style:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-details li{display:flex;gap:6px;margin:0}.__P__-generative-ui-details li:before{content:"\\2022";flex:none}.__P__-generative-ui-leg{display:grid;grid-template-columns:minmax(0,1fr);gap:2px}.__P__-generative-ui-leg+.__P__-generative-ui-leg{padding-top:var(--__P__-space-2);border-top:1px solid var(--__P__-border)}.__P__-generative-ui-leg-times{display:flex;align-items:center;gap:var(--__P__-space-1)}.__P__-generative-ui-leg-times>span:not(.__P__-generative-ui-leg-path){display:grid;flex:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-leg-times>span:last-child{text-align:end}.__P__-generative-ui-leg-times strong{color:var(--__P__-fg);font-size:1rem;font-variant-numeric:tabular-nums;white-space:nowrap}.__P__-generative-ui-leg-times sup{font-size:.6em;color:var(--__P__-fg-muted)}.__P__-generative-ui-leg-path{flex:1;min-width:0;padding-bottom:4px;border-bottom:1px solid var(--__P__-border-strong);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);line-height:1.3;text-align:center;overflow-wrap:normal}.__P__-generative-ui .__P__-generative-ui-itinerary{display:grid;gap:var(--__P__-space-2);margin:0;padding:0;list-style:none}.__P__-generative-ui-itinerary li{display:grid;margin:0;padding-inline-start:var(--__P__-space-3);border-inline-start:2px solid var(--__P__-border-strong)}.__P__-generative-ui-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;line-height:1.35}:is(.__P__-generative-ui-carousel,.__P__-generative-ui-cell) .__P__-generative-ui-title{min-height:2.7em}.__P__-generative-ui a{color:inherit}.__P__-generative-ui .__P__-generative-ui-title a,.__P__-generative-ui .__P__-generative-ui-lines a,.__P__-generative-ui .__P__-generative-ui-actions>a{text-decoration:none}.__P__-generative-ui .__P__-generative-ui-title a:hover,.__P__-generative-ui .__P__-generative-ui-lines span>a:hover{text-decoration:underline}.__P__-generative-ui-pill{display:inline-flex;align-items:center;padding:2px var(--__P__-space-2);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-muted{color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-star{color:var(--__P__-warning)}.__P__-generative-ui-price{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 var(--__P__-space-2);font-variant-numeric:tabular-nums}.__P__-generative-ui-price strong{font-size:1.1em}.__P__-generative-ui-price s{color:var(--__P__-fg-muted)}.__P__-generative-ui-description{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;color:var(--__P__-fg-muted)}.__P__-generative-ui-option{display:grid;gap:var(--__P__-space-1);min-width:0;margin:0;padding:0;border:0}.__P__-generative-ui-option legend{padding:0 0 var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-option div{display:flex;gap:6px;min-width:0;margin:-4px;padding:4px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.__P__-generative-ui-option div::-webkit-scrollbar{display:none}.__P__-generative-ui-option div[data-cut-end]{mask-image:linear-gradient(to right,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div[data-cut-start]{mask-image:linear-gradient(to right,transparent,#000 32px)}.__P__-generative-ui-option div[data-cut-start][data-cut-end]{mask-image:linear-gradient(to right,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div:dir(rtl)[data-cut-end]{mask-image:linear-gradient(to left,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div:dir(rtl)[data-cut-start]{mask-image:linear-gradient(to left,transparent,#000 32px)}.__P__-generative-ui-option div:dir(rtl)[data-cut-start][data-cut-end]{mask-image:linear-gradient(to left,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option button{flex:0 0 auto;min-height:32px;padding:0 10px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-generative-ui-option button:hover{border-color:var(--__P__-border-strong)}.__P__-generative-ui-option button[aria-pressed=true]{border-color:var(--__P__-accent);box-shadow:inset 0 0 0 1px var(--__P__-accent);font-weight:600}.__P__-generative-ui-option button:disabled{color:var(--__P__-fg-muted);text-decoration:line-through;opacity:.6;cursor:not-allowed}.__P__-generative-ui-actions{display:flex;flex-wrap:wrap;gap:var(--__P__-space-2);margin-top:auto;padding-top:var(--__P__-space-1)}.__P__-generative-ui-actions:not([data-small=true])>*{flex:1 1 auto}.__P__-generative-ui-actions>*{display:inline-flex;align-items:center;justify-content:center;min-height:36px;padding:0 var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:none;white-space:nowrap;min-width:0;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-generative-ui-actions>*>span{overflow:hidden;text-overflow:ellipsis}.__P__-generative-ui-actions[data-small=true]>*{min-height:28px;padding:0 var(--__P__-space-2);font-size:var(--__P__-text-xs)}.__P__-generative-ui-actions>:hover{border-color:var(--__P__-border-strong)}.__P__-generative-ui-actions>[data-primary=true]{border-color:var(--__P__-accent);background:var(--__P__-accent);color:var(--__P__-on-accent)}.__P__-generative-ui-actions>:focus-visible,.__P__-generative-ui-option button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-generative-ui-actions>:disabled{border-color:var(--__P__-border);background:var(--__P__-hover);color:var(--__P__-fg-muted);cursor:not-allowed}.__P__-generative-ui .__P__-generative-ui-lines{display:grid;margin:0;padding:0;list-style:none}.__P__-generative-ui .__P__-generative-ui-lines li{display:flex;margin:0;gap:var(--__P__-space-3);padding:var(--__P__-space-2) 0;border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui .__P__-generative-ui-lines li:first-child{padding-top:0}.__P__-generative-ui-lines li>div{display:grid;flex:1;gap:2px;min-width:0}.__P__-generative-ui-line-head{display:flex;align-items:baseline;gap:var(--__P__-space-3)}.__P__-generative-ui-line-head>span{display:-webkit-box;flex:1;min-width:0;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2}.__P__-generative-ui-line-head>strong{flex:none;font-variant-numeric:tabular-nums}.__P__-generative-ui-totals{display:grid;gap:var(--__P__-space-1);margin:0;font-variant-numeric:tabular-nums}.__P__-generative-ui-totals div{display:flex;justify-content:space-between;gap:var(--__P__-space-3);color:var(--__P__-fg-muted)}.__P__-generative-ui-totals div:last-child{padding-top:var(--__P__-space-1);color:var(--__P__-fg);font-weight:700}.__P__-generative-ui-totals dt{min-width:0}.__P__-generative-ui-totals dd{flex:none;margin:0;white-space:nowrap}.__P__-generative-ui-notice{padding:var(--__P__-space-2) var(--__P__-space-3);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover)}.__P__-generative-ui-notice[data-severity=warning]{color:var(--__P__-fg);background:color-mix(in oklch,var(--__P__-warning) 16%,transparent)}.__P__-generative-ui-notice[data-severity=error]{color:var(--__P__-danger-text);background:var(--__P__-danger-bg)}.__P__-generative-ui .__P__-generative-ui-timeline{display:grid;gap:var(--__P__-space-2);margin:0;padding:0;list-style:none}.__P__-generative-ui .__P__-generative-ui-timeline li{display:flex;margin:0;align-items:baseline;gap:var(--__P__-space-2);color:var(--__P__-fg-muted)}.__P__-generative-ui-timeline li:before{content:"";flex:0 0 auto;width:8px;height:8px;border:2px solid var(--__P__-border-strong);border-radius:50%}.__P__-generative-ui-timeline li[data-done=true]{color:var(--__P__-fg);font-weight:600}.__P__-generative-ui-timeline li[data-done=true]:before{border-color:var(--__P__-accent);background:var(--__P__-accent)}.__P__-generative-ui-timeline li>:first-child{flex:1}@media(pointer:coarse){.__P__-generative-ui-actions>*{min-height:44px}.__P__-generative-ui-actions>*>span{overflow:hidden;text-overflow:ellipsis}.__P__-generative-ui-actions[data-small=true]>*{min-height:32px}.__P__-generative-ui-option button{min-height:40px}}
9
9
 
10
10
  :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;border-radius:var(--__P__-radius-md)}: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}}
11
- `.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`),mn=[`data-theme`,`data-color-scheme`,`data-mode`,`data-bs-theme`];function hn(e){if(e){if(e.classList.contains(`dark`))return`dark`;if(e.classList.contains(`light`))return`light`;for(let t of mn){let n=e.getAttribute(t);if(n===`dark`||n===`light`)return n}}}function gn(e=document){let t=hn(e.documentElement)??hn(e.body);if(t)return t;let n=getComputedStyle(e.documentElement).colorScheme.trim();return n===`dark`||n===`light`?n:typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function _n(e,t=document){let n=gn(t);e(n);function r(){let r=gn(t);r!==n&&(n=r,e(r))}let i=new MutationObserver(r),a={attributes:!0,attributeFilter:[`class`,`style`,...mn]};i.observe(t.documentElement,a),t.body&&i.observe(t.body,a);let o=typeof matchMedia==`function`?matchMedia(`(prefers-color-scheme: dark)`):void 0;return o?.addEventListener(`change`,r),()=>{i.disconnect(),o?.removeEventListener(`change`,r)}}const vn=V.scope(`mount`),yn=/* @__PURE__ */ new WeakMap,bn={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 xn(e,t){let n=t===`flow`?e.style.height:``;e.style.cssText=bn[t],n&&(e.style.height=n)}function Sn(e){return e===`floating`||e===`modal`||e===`drawer`?`floating`:e===`standalone`||e===`page`?`viewport`:`flow`}function Cn(e={}){let t=e.position??`flow`;vn.debug(`createShadowMount`,{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${P.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`,P.id),xn(r,t);let i=r.shadowRoot??r.attachShadow({mode:`open`});for(let e of[`keydown`,`keypress`,`keyup`])i.addEventListener(e,wn);let a=r.ownerDocument;if(!Tn(i,a)){let e=a.createElement(`style`);e.textContent=pn,i.appendChild(e)}let o=document.createElement(`div`);return o.className=`${P.cssPrefix}-app`,i.appendChild(o),{appRoot:o,destroy:()=>r.remove(),hostElement:r,shadowRoot:i}}function wn(e){if(e instanceof KeyboardEvent&&(e.metaKey||e.ctrlKey))return;let t=e.composedPath()[0];t instanceof HTMLElement&&(t.isContentEditable||t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`)&&e.stopPropagation()}function Tn(e,t){if(!(`adoptedStyleSheets`in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!=`function`)return!1;let r=yn.get(t);if(!r)try{r=new n.CSSStyleSheet,r.replaceSync(pn),yn.set(t,r)}catch{return!1}try{return e.adoptedStyleSheets=[r],!0}catch{return!1}}function En(e,t){let n=P.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 Dn(e,t){e.dataset.theme=t===`host`?gn():t}function On(e,t){let n=P.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 kn(e,t){e.dataset.position=t}function An(e,t){e.dataset.mode=t}function jn(e,t){Dn(e,t.themeMode),En(e,t.themeOverrides),kn(e,t.position),On(e,t.size)}function Mn(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);return{headers(){let t={"x-ai-agent-deployment-id":e.aiAgentDeploymentId};return e.publicKey&&(t[e.publicKeyHeader??`x-public-key`]=e.publicKey),t}}}const Nn=/* @__PURE__ */ new Set([`home`,`chats`,`help`,`news`]);function Pn(e){return typeof e!=`object`||!e||!(`to`in e)||typeof e.to!=`string`||!Nn.has(e.to)?!1:!(`id`in e)||e.id===void 0||typeof e.id==`string`}function Fn(e){let[t=``,...n]=e.trim().split(`/`);if(t===``||t===`open`)return;let r=n.join(`/`);return r?{to:t,id:r}:{to:t}}function In(e,t){return{text:e,send:typeof t==`object`&&!!t&&`send`in t&&t.send===!0}}function Ln(e){if(typeof e!=`object`||!e||!(`text`in e)||typeof e.text!=`string`)return;let t=e.text.trim();return t?{text:t,send:`send`in e&&e.send===!0}:void 0}function Rn(e){return`${P.cssPrefix}:${e}`}function zn(e,t,n){e.dispatchEvent(new CustomEvent(Rn(t),{detail:n}))}function Bn(e,t){let n=Object.keys(t).filter(e=>Object.hasOwn(t,e)).map(n=>{let r=t[n],i=Rn(n);function a(e){return r(e instanceof CustomEvent?e.detail:void 0)}return e.addEventListener(i,a),[i,a]});return()=>{for(let[t,r]of n)e.removeEventListener(t,r)}}function Vn(e,t){let n=[],r;for(let i of e){let e=new URLSearchParams(i);e.has(t)?r??(r=e.get(t)??``):n.push(i)}return{value:r,rest:n}}function Hn(e){let t=new URL(e),n=P.cssPrefix,r=`${P.cssPrefix}-ask`,i=t.search.slice(1).split(`&`).filter(Boolean),a=t.hash.slice(1).split(`&`).filter(Boolean),o=Vn(i,n),s=Vn(o.rest,r),c=Vn(a,n),l=Vn(c.rest,r),u=o.value??c.value,d=(s.value??l.value)?.trim()||void 0;if(u!==void 0||d!==void 0)return t.search=s.rest.join(`&`),t.hash=l.rest.join(`&`),{target:u===void 0?void 0:Fn(u),...d?{ask:d}:{},url:t.toString()}}function Un(e){"@babel/helpers - typeof";return Un=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},Un(e)}function Wn(e,t){if(Un(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(Un(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Gn(e){var t=Wn(e,`string`);return Un(t)==`symbol`?t:t+``}function U(e,t,n){return(t=Gn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Kn=V.scope(`events`),qn={open:!1,ready:!1,unread:0};var Jn=class{constructor(){U(this,`handlers`,/* @__PURE__ */ new Map),U(this,`taps`,/* @__PURE__ */ new Set)}on(e,t){let n=this.handlers.get(e);return n||(n=/* @__PURE__ */ new Set,this.handlers.set(e,n)),n.add(t),()=>this.handlers.get(e)?.delete(t)}tap(e){return this.taps.add(e),()=>this.taps.delete(e)}listensTo(e){return(this.handlers.get(e)?.size??0)>0||[...this.taps].some(t=>t.listensTo(e))}emit(e,t){for(let n of this.handlers.get(e)??[])try{n(t)}catch(t){Kn.warn(`listener threw`,{event:e,error:t})}for(let n of this.taps)n.hear(e,t)}clear(){this.handlers.clear(),this.taps.clear()}};const Yn=V.scope(`feedback:audio`);var Xn=class{constructor(){U(this,`ctx`,null),U(this,`master`,null),U(this,`buffers`,/* @__PURE__ */ 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){Yn.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(/* @__PURE__ */ Error(`fetch ${e.status}`))).then(e=>n.decodeAudioData(e)).then(t=>(this.buffers.set(e,t),t)).catch(t=>(Yn.warn(`audio fetch/decode failed`,{url:e,err:t}),this.buffers.delete(e),null));return this.buffers.set(e,r),r}};const Zn={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Qn={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 W=null,$n=0;function er(){return typeof navigator<`u`&&typeof navigator.vibrate==`function`}function tr(){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=`__${P.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;`;e.style.cssText=n,t.style.cssText=n;for(let n of[e,t])n.addEventListener(`click`,e=>e.stopPropagation());return document.body.append(e,t),{input:e,label:t}}function nr(e){if(!(e===0||Array.isArray(e)&&e.every(e=>e===0))){if(er())try{navigator.vibrate(e);return}catch{}if(W??(W=tr()),W)try{W.label.click()}catch{}}}function rr(){$n++;let e=!1;return()=>{e||(e=!0,$n=Math.max(0,$n-1),$n===0&&W&&(W.input.remove(),W.label.remove(),W=null))}}const ir=V.scope(`feedback`);var ar=class{constructor(e,t){U(this,`mutedSig`,o(!1)),U(this,`audio`,new Xn),U(this,`releaseHaptics`,void 0),U(this,`sound`,void 0),U(this,`haptics`,void 0),U(this,`lastPlayed`,/* @__PURE__ */ new Map),U(this,`reducedMotionMq`,null),this.sound=e,this.haptics=t,this.releaseHaptics=rr(),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=>ir.warn(`audio play failed`,{err:e,url:t}));return}let n=Qn[e];n&&this.audio.playTone(n)}playHaptic(e){if(this.reducedMotionMq?.matches)return;let t=this.haptics.events?.[e];t!==!1&&nr(t===!0||t===void 0?Zn[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}};function or(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function sr(e){return or(e)}function cr(e){return!(!or(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function lr(e){if(typeof e!=`object`||!e)return{};let t=Reflect.get(e,`url`);return{url:typeof t==`string`&&/^https?:\/\//i.test(t)&&t.includes(`{returnTo}`)?t:void 0,required:Reflect.get(e,`required`)===!0,hidePrompt:Reflect.get(e,`hidePrompt`)===!0,hideUser:Reflect.get(e,`hideUser`)===!0}}function ur(e,t){let n=encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`);return e.replaceAll(`{returnTo}`,n)}function dr(e){let t=e.split(`.`)[1];if(t)try{let e=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),n=JSON.parse(new TextDecoder().decode(Uint8Array.from(e,e=>e.charCodeAt(0))));return typeof n==`object`&&n&&!Array.isArray(n)?Object.fromEntries(Object.entries(n)):void 0}catch{return}}function fr(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?{[t]:n.trim()}:{}}function pr(e){let t=dr(e);return{...fr(t,`name`),...fr(t,`email`)}}function mr(e){let t=dr(e)?.sub;return typeof t==`string`&&t!==``?t:void 0}function hr(){try{return window.top?.location.href??location.href}catch{return location.href}}function gr(e){try{(window.top??window).location.assign(e)}catch{location.assign(e)}}function _r({amount:e,currency:t},n){let r=new Intl.NumberFormat(`en`,{style:`currency`,currency:t}).resolvedOptions().maximumFractionDigits??2;return new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e/10**r)}function vr(e,t){let n=new Date(e);return!/^\d{4}-\d{2}-\d{2}/.test(e)||Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeZone:e.length===10?`UTC`:void 0}).format(n)}function yr(e,t){let n=br(e);return n?new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`,timeZone:`UTC`}).format(n):e}function br(e){let t=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})/.exec(e);return t?Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]),Number(t[4]),Number(t[5])):void 0}function xr(e,t){let[n,r]=[e,t].map(e=>/^\d{4}-\d{2}-\d{2}/.test(e??``)?Date.parse(`${e?.slice(0,10)}T00:00:00Z`):NaN),i=Math.round(((r??NaN)-(n??NaN))/864e5);return i>0?i:void 0}function Sr(e,t){return!/^\d{4}-\d{2}-\d{2}/.test(e)||Number.isNaN(Date.parse(e.slice(0,10)))?e:new Intl.DateTimeFormat(t,{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}).format(Date.parse(e.slice(0,10)))}function Cr(e,t,n){return[e,t].flatMap(e=>e?[Sr(e,n)]:[]).join(` – `)}function wr(e,t){let n=(e,n)=>new Intl.NumberFormat(t,{style:`unit`,unit:n,unitDisplay:`narrow`}).format(e),r=Math.floor(e/60);return[r>0&&n(r,`hour`),e%60>0&&n(e%60,`minute`)].filter(Boolean).join(` `)}function Tr(e,t,n){let r=e.stops===void 0?void 0:e.stops.length===0?t.visualDirect:`${t.visualVia} ${e.stops.join(`, `)}`;return[e.duration===void 0?void 0:wr(e.duration,n),r].filter(Boolean).join(` · `)}function Er(e,t){return e===1?t.visualNight:t.visualNights.replace(`{count}`,String(e))}function Dr(e,t,n){let r=e.typeName===`Stay`?e.props.stay:void 0,i=e.typeName===`Stay`?{...e.props.stay,title:e.props.stay.name,start:e.props.stay.checkIn,end:e.props.stay.checkOut,nights:void 0,priceNote:void 0}:e.props.package,a=i.nights??xr(i.start,i.end);return{...i,stars:r?.stars,room:r?.room,when:[Cr(i.start,i.end,n),a&&Er(a,t)].filter(Boolean).join(` · `),note:r?.nightly?`${_r(r.nightly,n)} ${t.visualPerNight}`:i.priceNote,available:i.available!==!1}}function Or({value:e,best:t}){return t===void 0||t===5?String(e):`${e}/${t}`}function kr(e){return Array.isArray(e)?e:[e]}function Ar({type:e,data:t}){let n=kr(t[0]?.value??[]).length;if(t.some(e=>kr(e.value).length!==n))return!1;if(e!==`pie`)return!0;let r=t.map(e=>kr(e.value)[0]??0);return n===1&&r.every(e=>e>=0)&&r.some(e=>e>0)}const jr=[`#f59e0b`,`#10b981`,`#ef4444`,`#8b5cf6`,`#0ea5e9`];function Mr({type:e,data:t},n){let r=t.map(e=>kr(e.value)),i=Math.max(1,r[0]?.length??1),a=Math.min(0,...r.flat()),o=Math.max(0,...r.flat()),s=o-a||1,c=272/Math.max(1,t.length),l=c*.7/i,u=Math.ceil(t.length/8),d=new Intl.NumberFormat(n,{notation:`compact`,maximumFractionDigits:1});function f(e){return 148-(e-a)/s*136}return{baseline:f(0),barWidth:l,series:Array.from({length:i},(t,n)=>r.map((t,r)=>({x:24+(r+.5)*c+(e===`bar`?(n-(i-1)/2)*l:0),y:f(t[n]??0)}))),labels:t.flatMap((e,t)=>t%u===0?[{x:24+(t+.5)*c,text:e.label.length*5>c*u?`${e.label.slice(0,Math.max(1,Math.floor(c*u/5)-1))}…`:e.label}]:[]),ticks:[.../* @__PURE__ */ new Set([o,a])].map(e=>({y:f(e),text:d.format(e)})),slices:e===`pie`?Nr(r.map(e=>e[0]??0)):[]}}function Nr(e){let t=e.reduce((e,t)=>e+t,0)||1,n=-Math.PI/2;return e.map(e=>{let r=n+e/t*2*Math.PI,i=Pr(n,Math.min(r,n+2*Math.PI-1e-4));return n=r,{path:i,share:e/t}})}function Pr(e,t){let n=+(t-e>Math.PI),r=(e,t)=>`${(160+e*Math.cos(t)).toFixed(2)} ${(84+e*Math.sin(t)).toFixed(2)}`;return`M${r(64,e)}A64 64 0 ${n} 1 ${r(64,t)}L${r(40,t)}A40 40 0 ${n} 0 ${r(40,e)}Z`}function Fr(e){if(!e||e.length<2)return;let t=Math.min(...e),n=Math.max(...e)-t||1;return e.map((r,i)=>`${(i*80/(e.length-1)).toFixed(1)},${(22-(r-t)/n*20).toFixed(1)}`).join(` `)}function Ir(e){let t=/^[^\d\-−+]{0,4}([-−+]?\d[\d.,\s]*?)\s?[^\d]{0,4}$/u.exec(e.trim());if(!t?.[1])return;let n=t[1].replace(/\s/g,``).replace(`−`,`-`),r=n.match(/[.,]/g)??[],i=r.at(-1),a=new Set(r).size>1||r.length===1&&!/^[-+]?[1-9]\d{0,2}[.,]\d{3}$/.test(n)?i:void 0,o=Number(n.replace(a===`,`?/\./g:a===`.`?/,/g:/[.,]/g,``).replace(`,`,`.`));return Number.isFinite(o)?o:void 0}function Lr(e,t){return e.map((e,n)=>{let r=t.map(e=>e[n]??``).filter(e=>e.trim());return r.length>0&&r.every(e=>Ir(e)!==void 0)})}function Rr(e,t,n){if(!t)return e;let r=new Intl.Collator(n,{numeric:!0}),i=t.descending?-1:1;return[...e].sort((e,n)=>{let[a,o]=[e[t.column]??``,n[t.column]??``];return i*(t.numeric?(Ir(a)??0)-(Ir(o)??0):r.compare(a,o))})}new Map(Object.entries({Card:280,Product:280,Stay:280,Package:280,Flight:300,Cart:480,Order:480,Booking:480}));function zr(e){let t=new Set(e.map(e=>{let t=e.typeName===`Cell`?e.props.children.length===1?e.props.children[0]:void 0:e;return t?.typeName===`Metric`?`Card`:t?.typeName}));return t.size===1&&!t.has(void 0)}function Br({scrollLeft:e,scrollWidth:t,clientWidth:n}){let r=Math.abs(e);return{start:r>1,end:r<t-n-1}}function Vr(e){return/^https:\/\//i.test(e??``)}function Hr(e,t){return(e??[]).flatMap(e=>e.url?Vr(e.url)?[{...e,url:e.url,message:void 0}]:[]:t?[{...e,url:void 0,message:e.label}]:[])}function Ur(e,t,n){return`${e}: ${[t,...Object.entries(n??{}).map(([e,t])=>`${e}: ${t}`)].join(`, `)}`}function Wr(e){return[...e.legs.map(e=>e.number??e.carrier),e.fare].filter(Boolean).join(`, `)}function Gr(e,t){return t!==void 0&&t.currency===e.currency&&t.amount>e.amount}function Kr(e,t){let n=e.variants??[],r=(e.options??[]).filter(e=>e.values.length).map(r=>({...r,value:t[r.name]??r.values.find(t=>t===e.selected?.[r.name])??(r.values.length===1?r.values[0]:void 0),unavailable:n.length?r.values.filter(e=>!n.some(t=>t.available!==!1&&t.options[r.name]===e)):[]})),i=r.filter(e=>e.value===void 0).map(e=>e.name),a=Object.fromEntries(r.flatMap(e=>e.value===void 0?[]:[[e.name,e.value]])),o=i.length?void 0:n.find(e=>r.every(t=>e.options[t.name]===t.value)),s=!i.length&&n.length?o!==void 0&&o.available!==!1:e.available!==!1;return{options:r,missing:i,chosen:a,available:s,price:o?.price??e.price,compareAtPrice:o?.price?o.compareAtPrice:e.compareAtPrice,image:o?.image??e.image,canBuy:!i.length&&s}}const qr={root:`Root`,schema:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{Root:{$ref:`#/$defs/Root`},Grid:{$ref:`#/$defs/Grid`},Cell:{$ref:`#/$defs/Cell`},Carousel:{$ref:`#/$defs/Carousel`},Text:{$ref:`#/$defs/Text`},Card:{$ref:`#/$defs/Card`},Metric:{$ref:`#/$defs/Metric`},Table:{$ref:`#/$defs/Table`},Chart:{$ref:`#/$defs/Chart`},Product:{$ref:`#/$defs/Product`},Cart:{$ref:`#/$defs/Cart`},Order:{$ref:`#/$defs/Order`},Flight:{$ref:`#/$defs/Flight`},Stay:{$ref:`#/$defs/Stay`},Package:{$ref:`#/$defs/Package`},Booking:{$ref:`#/$defs/Booking`}},required:[`Root`,`Grid`,`Cell`,`Carousel`,`Text`,`Card`,`Metric`,`Table`,`Chart`,`Product`,`Cart`,`Order`,`Flight`,`Stay`,`Package`,`Booking`],additionalProperties:!1,$defs:{Root:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Grid`},{$ref:`#/$defs/Carousel`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}}},required:[`children`],additionalProperties:!1},Grid:{type:`object`,properties:{columns:{type:`integer`,enum:[1,2,3,4],default:1},children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Cell`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}}},required:[`columns`,`children`],additionalProperties:!1},Cell:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}},span:{type:`integer`,enum:[1,2,3,4],default:1}},required:[`children`],additionalProperties:!1},Carousel:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Card`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`}]}}},required:[`children`],additionalProperties:!1},Text:{type:`object`,properties:{text:{type:`string`}},required:[`text`],additionalProperties:!1},Card:{type:`object`,properties:{title:{type:`string`},body:{type:`string`},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}},image:{type:`string`}},required:[`title`,`body`],additionalProperties:!1},Metric:{type:`object`,properties:{label:{type:`string`},value:{type:`string`},detail:{type:`string`},change:{type:`object`,properties:{text:{type:`string`},tone:{type:`string`,enum:[`good`,`bad`,`neutral`]}},required:[`text`,`tone`]},trend:{type:`array`,items:{type:`number`}}},required:[`label`,`value`],additionalProperties:!1},Table:{type:`object`,properties:{title:{type:`string`},columns:{type:`array`,items:{type:`string`}},rows:{type:`array`,items:{type:`array`,items:{type:`string`}}}},required:[`title`,`columns`,`rows`],additionalProperties:!1},Chart:{type:`object`,properties:{title:{type:`string`},type:{type:`string`,enum:[`bar`,`line`,`pie`]},data:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},value:{anyOf:[{type:`number`},{type:`array`,items:{type:`number`}}]}},required:[`label`,`value`],additionalProperties:!1}},series:{type:`array`,items:{type:`string`}}},required:[`title`,`type`,`data`],additionalProperties:!1},Product:{type:`object`,properties:{product:{type:`object`,properties:{title:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},description:{type:`string`},badge:{type:`string`},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},available:{type:`boolean`},options:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},values:{type:`array`,items:{type:`string`}}},required:[`name`,`values`]}},variants:{type:`array`,items:{type:`object`,properties:{options:{type:`object`,additionalProperties:{type:`string`}},id:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},available:{type:`boolean`}},required:[`options`]}},selected:{type:`object`,additionalProperties:{type:`string`}},details:{type:`array`,items:{type:`string`}}},required:[`title`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`product`],additionalProperties:!1},Cart:{type:`object`,properties:{cart:{type:`object`,properties:{lines:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},quantity:{type:`integer`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},options:{type:`object`,additionalProperties:{type:`string`}},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`title`,`quantity`,`price`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},messages:{type:`array`,items:{type:`object`,properties:{text:{type:`string`},severity:{type:`string`,enum:[`info`,`warning`,`error`]}},required:[`text`,`severity`]}}},required:[`lines`,`totals`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`cart`],additionalProperties:!1},Order:{type:`object`,properties:{order:{type:`object`,properties:{number:{type:`string`},status:{type:`string`},date:{type:`string`},items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},quantity:{type:`integer`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},options:{type:`object`,additionalProperties:{type:`string`}},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`title`,`quantity`,`price`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},timeline:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},done:{type:`boolean`},date:{type:`string`}},required:[`label`,`done`]}},details:{type:`array`,items:{type:`string`}}},required:[`number`,`status`,`items`,`totals`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`order`],additionalProperties:!1},Flight:{type:`object`,properties:{flight:{type:`object`,properties:{legs:{type:`array`,items:{type:`object`,properties:{from:{type:`string`},to:{type:`string`},departs:{type:`string`},arrives:{type:`string`},carrier:{type:`string`},number:{type:`string`},duration:{type:`integer`},stops:{type:`array`,items:{type:`string`}}},required:[`from`,`to`,`departs`,`arrives`,`carrier`]},minItems:1},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},priceNote:{type:`string`},fare:{type:`string`},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`legs`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`flight`],additionalProperties:!1},Stay:{type:`object`,properties:{stay:{type:`object`,properties:{name:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},image:{type:`string`},url:{type:`string`},location:{type:`string`},stars:{type:`integer`},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},checkIn:{type:`string`},checkOut:{type:`string`},room:{type:`string`},nightly:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`name`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`stay`],additionalProperties:!1},Package:{type:`object`,properties:{package:{type:`object`,properties:{title:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},image:{type:`string`},url:{type:`string`},location:{type:`string`},start:{type:`string`},end:{type:`string`},nights:{type:`integer`},priceNote:{type:`string`},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`title`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`package`],additionalProperties:!1},Booking:{type:`object`,properties:{booking:{type:`object`,properties:{reference:{type:`string`},status:{type:`string`},title:{type:`string`},start:{type:`string`},end:{type:`string`},travellers:{type:`array`,items:{type:`string`}},itinerary:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},date:{type:`string`},time:{type:`string`},detail:{type:`string`}},required:[`title`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},details:{type:`array`,items:{type:`string`}}},required:[`reference`,`status`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`booking`],additionalProperties:!1}}}};function Jr(e){switch(e.k){case`StateRef`:case`RuntimeRef`:case`BinOp`:case`UnaryOp`:case`Ternary`:case`Member`:case`Index`:case`Assign`:return!0;default:return!1}}const Yr=/* @__PURE__ */ new Set([`Comp`,`Ref`,`StateRef`,`RuntimeRef`,`BinOp`,`UnaryOp`,`Ternary`,`Member`,`Index`,`Assign`,`Str`,`Num`,`Bool`,`Null`,`Arr`,`Obj`,`Ph`]);function Xr(e){return!e||typeof e!=`object`||Array.isArray(e)?!1:Yr.has(e.k)}function Zr(e,t){let n=e=>{switch(t(e),e.k){case`Comp`:e.args.forEach(n),Object.values(e.mappedProps??{}).forEach(n);break;case`Arr`:e.els.forEach(n);break;case`Obj`:e.entries.forEach(([,e])=>n(e));break;case`BinOp`:n(e.left),n(e.right);break;case`UnaryOp`:n(e.operand);break;case`Ternary`:n(e.cond),n(e.then),n(e.else);break;case`Member`:n(e.obj);break;case`Index`:n(e.obj),n(e.index);break;case`Assign`:n(e.value)}};n(e)}function Qr(e){return e==null?{k:`Null`}:typeof e==`string`?{k:`Str`,v:e}:typeof e==`number`?{k:`Num`,v:e}:typeof e==`boolean`?{k:`Bool`,v:e}:Array.isArray(e)?{k:`Arr`,els:e.map(Qr)}:typeof e==`object`?{k:`Obj`,entries:Object.entries(e).map(([e,t])=>[e,Qr(t)])}:{k:`Null`}}function $r(e){switch(e.k){case`Str`:case`Num`:case`Bool`:return{v:e.v};case`Null`:return{v:null};case`Arr`:{let t=[];for(let n of e.els){let e=$r(n);if(!e)return;t.push(e.v)}return{v:t}}case`Obj`:{let t={};for(let[n,r]of e.entries){let e=$r(r);if(!e)return;t[n]=e.v}return{v:t}}default:return}}const ei=/* @__PURE__ */ new Map([[`Count`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`First`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`Last`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`Sum`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Avg`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Min`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Max`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Sort`,{kind:`function`,params:[{name:`array`,required:!1},{name:`field`,required:!1},{name:`direction`,required:!1}],builtin:!0}],[`Filter`,{kind:`function`,params:[{name:`array`,required:!1},{name:`field`,required:!1},{name:`operator`,required:!1},{name:`value`,required:!1}],builtin:!0}],[`Round`,{kind:`function`,params:[{name:`number`,required:!1},{name:`decimals`,required:!1}],builtin:!0}],[`Abs`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Floor`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Ceil`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Each`,{kind:`function`,params:[{name:`array`,required:!1},{name:`varName`,required:!1},{name:`template`,required:!1}],builtin:!0,lazy:!0}],[`Run`,{kind:`action`,params:[{name:`ref`,required:!1}],builtin:!0,lazy:!0}],[`ToAssistant`,{kind:`action`,params:[{name:`message`,required:!1},{name:`context`,required:!1}],builtin:!0}],[`OpenUrl`,{kind:`action`,params:[{name:`url`,required:!1}],builtin:!0}],[`Set`,{kind:`action`,params:[{name:`variable`,required:!1},{name:`value`,required:!1}],builtin:!0,lazy:!0}],[`Reset`,{kind:`action`,params:[{name:`variable`,required:!1}],builtin:!0,lazy:!0}],[`Action`,{kind:`action`,params:[{name:`steps`,required:!0}],builtin:!0,lazy:!0}]]),ti={ActionExpression:!0,OpenUrl:!0,ToAssistant:!0},ni={Query:`Query`,Mutation:`Mutation`};function ri(e){return e?.callDefs??ei}function ii(e){return ei.has(e)}function ai(e){return e in ni}var G;(function(e){e[e.Newline=0]=`Newline`,e[e.LParen=1]=`LParen`,e[e.RParen=2]=`RParen`,e[e.LBrack=3]=`LBrack`,e[e.RBrack=4]=`RBrack`,e[e.LBrace=5]=`LBrace`,e[e.RBrace=6]=`RBrace`,e[e.Comma=7]=`Comma`,e[e.Colon=8]=`Colon`,e[e.Equals=9]=`Equals`,e[e.True=10]=`True`,e[e.False=11]=`False`,e[e.Null=12]=`Null`,e[e.EOF=13]=`EOF`,e[e.Str=14]=`Str`,e[e.Num=15]=`Num`,e[e.Ident=16]=`Ident`,e[e.Type=17]=`Type`,e[e.StateVar=18]=`StateVar`,e[e.Dot=19]=`Dot`,e[e.Plus=20]=`Plus`,e[e.Minus=21]=`Minus`,e[e.Star=22]=`Star`,e[e.Slash=23]=`Slash`,e[e.Percent=24]=`Percent`,e[e.EqEq=25]=`EqEq`,e[e.NotEq=26]=`NotEq`,e[e.Greater=27]=`Greater`,e[e.Less=28]=`Less`,e[e.GreaterEq=29]=`GreaterEq`,e[e.LessEq=30]=`LessEq`,e[e.And=31]=`And`,e[e.Or=32]=`Or`,e[e.Not=33]=`Not`,e[e.Question=34]=`Question`,e[e.BuiltinCall=35]=`BuiltinCall`})(G||(G={}));function oi(e){let t=0,n=()=>e[t]??{t:G.EOF},r=()=>{let e=n();return t++,e},i=e=>{n().t===e&&t++};function a(e){switch(e.t){case G.Question:return 1;case G.Or:return 2;case G.And:return 3;case G.EqEq:case G.NotEq:return 4;case G.Greater:case G.Less:case G.GreaterEq:case G.LessEq:return 5;case G.Plus:case G.Minus:return 6;case G.Star:case G.Slash:case G.Percent:return 7;case G.Dot:case G.LBrack:return 9;default:return 0}}function o(e=0){let t=s();for(;a(n())>e;)t=c(t);return t}function s(){let a=n();if(a.t===G.Str)return r(),{k:`Str`,v:a.v};if(a.t===G.Num)return r(),{k:`Num`,v:a.v};if(a.t===G.True)return r(),{k:`Bool`,v:!0};if(a.t===G.False)return r(),{k:`Bool`,v:!1};if(a.t===G.Null)return r(),{k:`Null`};if(a.t===G.LBrack)return u();if(a.t===G.LBrace)return d();if(a.t===G.StateVar){let e=a.v;return r(),n().t===G.Equals?(r(),{k:`Assign`,target:e,value:o(0)}):{k:`StateRef`,n:e}}if(a.t===G.Type){let n=a.v;return e[t+1]?.t===G.LParen&&(!ii(n)||n===`Action`)?l():(r(),{k:`Ref`,n})}if(a.t===G.BuiltinCall){if(e[t+1]?.t===G.LParen){let e=l();return e.k===`Comp`&&!ii(e.name)&&(e.fn=!0),e}return r(),{k:`Ref`,n:a.v}}if(a.t===G.Ident)return r(),{k:`Ref`,n:a.v};if(a.t===G.Not)return r(),{k:`UnaryOp`,op:`!`,operand:o(8)};if(a.t===G.Minus)return r(),{k:`UnaryOp`,op:`-`,operand:o(8)};if(a.t===G.LParen){r();let e=o(0);return i(G.RParen),e}return r(),{k:`Null`}}function c(e){let t=n();if(t.t===G.Plus)return r(),{k:`BinOp`,op:`+`,left:e,right:o(6)};if(t.t===G.Minus)return r(),{k:`BinOp`,op:`-`,left:e,right:o(6)};if(t.t===G.Star)return r(),{k:`BinOp`,op:`*`,left:e,right:o(7)};if(t.t===G.Slash)return r(),{k:`BinOp`,op:`/`,left:e,right:o(7)};if(t.t===G.Percent)return r(),{k:`BinOp`,op:`%`,left:e,right:o(7)};if(t.t===G.EqEq)return r(),{k:`BinOp`,op:`==`,left:e,right:o(4)};if(t.t===G.NotEq)return r(),{k:`BinOp`,op:`!=`,left:e,right:o(4)};if(t.t===G.Greater)return r(),{k:`BinOp`,op:`>`,left:e,right:o(5)};if(t.t===G.Less)return r(),{k:`BinOp`,op:`<`,left:e,right:o(5)};if(t.t===G.GreaterEq)return r(),{k:`BinOp`,op:`>=`,left:e,right:o(5)};if(t.t===G.LessEq)return r(),{k:`BinOp`,op:`<=`,left:e,right:o(5)};if(t.t===G.And)return r(),{k:`BinOp`,op:`&&`,left:e,right:o(3)};if(t.t===G.Or)return r(),{k:`BinOp`,op:`||`,left:e,right:o(2)};if(t.t===G.Question){r();let t=o(0);return i(G.Colon),{k:`Ternary`,cond:e,then:t,else:o(0)}}if(t.t===G.Dot){r();let t=n();return{k:`Member`,obj:e,field:t.t===G.Ident||t.t===G.Type||t.t===G.Str||t.t===G.Num?(r(),String(t.v)):t.t===G.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`)}}if(t.t===G.LBrack){r();let t=o(0);return i(G.RBrack),{k:`Index`,obj:e,index:t}}return e}function l(){let e=n().v;r(),i(G.LParen);let t=[];for(;n().t!==G.RParen&&n().t!==G.EOF;)t.push(o(0)),n().t===G.Comma&&r();return i(G.RParen),{k:`Comp`,name:e,args:t}}function u(){r();let e=[];for(;n().t!==G.RBrack&&n().t!==G.EOF;)e.push(o(0)),n().t===G.Comma&&r();return i(G.RBrack),{k:`Arr`,els:e}}function d(){r();let e=[];for(;n().t!==G.RBrace&&n().t!==G.EOF;){let t=n(),a=t.t===G.Ident||t.t===G.Str||t.t===G.Type||t.t===G.Num?(r(),String(t.v)):t.t===G.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`);i(G.Colon),e.push([a,o(0)]),n().t===G.Comma&&r()}return i(G.RBrace),{k:`Obj`,entries:e}}return o(0)}function si(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&(e.charAt(n)===` `||e.charAt(n)===` `||e.charAt(n)===`\r`);)n++;if(n>=r)break;let i=e.charAt(n);if(i===`
11
+ `.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`),mn=[`data-theme`,`data-color-scheme`,`data-mode`,`data-bs-theme`];function hn(e){if(e){if(e.classList.contains(`dark`))return`dark`;if(e.classList.contains(`light`))return`light`;for(let t of mn){let n=e.getAttribute(t);if(n===`dark`||n===`light`)return n}}}function gn(e=document){let t=hn(e.documentElement)??hn(e.body);if(t)return t;let n=getComputedStyle(e.documentElement).colorScheme.trim();return n===`dark`||n===`light`?n:typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function _n(e,t=document){let n=gn(t);e(n);function r(){let r=gn(t);r!==n&&(n=r,e(r))}let i=new MutationObserver(r),a={attributes:!0,attributeFilter:[`class`,`style`,...mn]};i.observe(t.documentElement,a),t.body&&i.observe(t.body,a);let o=typeof matchMedia==`function`?matchMedia(`(prefers-color-scheme: dark)`):void 0;return o?.addEventListener(`change`,r),()=>{i.disconnect(),o?.removeEventListener(`change`,r)}}const vn=V.scope(`mount`),yn=/* @__PURE__ */ new WeakMap,bn={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 xn(e,t){let n=t===`flow`?e.style.height:``;e.style.cssText=bn[t],n&&(e.style.height=n)}function Sn(e){return e===`floating`||e===`modal`||e===`drawer`?`floating`:e===`standalone`||e===`page`?`viewport`:`flow`}function Cn(e={}){let t=e.position??`flow`;vn.debug(`createShadowMount`,{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${P.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`,P.id),xn(r,t);let i=r.shadowRoot??r.attachShadow({mode:`open`});for(let e of[`keydown`,`keypress`,`keyup`])i.addEventListener(e,wn);let a=r.ownerDocument;if(!Tn(i,a)){let e=a.createElement(`style`);e.textContent=pn,i.appendChild(e)}let o=document.createElement(`div`);return o.className=`${P.cssPrefix}-app`,i.appendChild(o),{appRoot:o,destroy:()=>r.remove(),hostElement:r,shadowRoot:i}}function wn(e){if(e instanceof KeyboardEvent&&(e.metaKey||e.ctrlKey))return;let t=e.composedPath()[0];t instanceof HTMLElement&&(t.isContentEditable||t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`)&&e.stopPropagation()}function Tn(e,t){if(!(`adoptedStyleSheets`in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!=`function`)return!1;let r=yn.get(t);if(!r)try{r=new n.CSSStyleSheet,r.replaceSync(pn),yn.set(t,r)}catch{return!1}try{return e.adoptedStyleSheets=[r],!0}catch{return!1}}function En(e,t){let n=P.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 Dn(e,t){e.dataset.theme=t===`host`?gn():t}function On(e,t){let n=P.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 kn(e,t){e.dataset.position=t}function An(e,t){e.dataset.mode=t}function jn(e,t){Dn(e,t.themeMode),En(e,t.themeOverrides),kn(e,t.position),On(e,t.size)}function Mn(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);return{headers(){let t={"x-ai-agent-deployment-id":e.aiAgentDeploymentId};return e.publicKey&&(t[e.publicKeyHeader??`x-public-key`]=e.publicKey),t}}}const Nn=/* @__PURE__ */ new Set([`home`,`chats`,`help`,`news`]);function Pn(e){return typeof e!=`object`||!e||!(`to`in e)||typeof e.to!=`string`||!Nn.has(e.to)?!1:!(`id`in e)||e.id===void 0||typeof e.id==`string`}function Fn(e){let[t=``,...n]=e.trim().split(`/`);if(t===``||t===`open`)return;let r=n.join(`/`);return r?{to:t,id:r}:{to:t}}function In(e,t){return{text:e,send:typeof t==`object`&&!!t&&`send`in t&&t.send===!0}}function Ln(e){if(typeof e!=`object`||!e||!(`text`in e)||typeof e.text!=`string`)return;let t=e.text.trim();return t?{text:t,send:`send`in e&&e.send===!0}:void 0}function Rn(e){return`${P.cssPrefix}:${e}`}function zn(e,t,n){e.dispatchEvent(new CustomEvent(Rn(t),{detail:n}))}function Bn(e,t){let n=Object.keys(t).filter(e=>Object.hasOwn(t,e)).map(n=>{let r=t[n],i=Rn(n);function a(e){return r(e instanceof CustomEvent?e.detail:void 0)}return e.addEventListener(i,a),[i,a]});return()=>{for(let[t,r]of n)e.removeEventListener(t,r)}}function Vn(e,t){let n=[],r;for(let i of e){let e=new URLSearchParams(i);e.has(t)?r??(r=e.get(t)??``):n.push(i)}return{value:r,rest:n}}function Hn(e){let t=new URL(e),n=P.cssPrefix,r=`${P.cssPrefix}-ask`,i=t.search.slice(1).split(`&`).filter(Boolean),a=t.hash.slice(1).split(`&`).filter(Boolean),o=Vn(i,n),s=Vn(o.rest,r),c=Vn(a,n),l=Vn(c.rest,r),u=o.value??c.value,d=(s.value??l.value)?.trim()||void 0;if(u!==void 0||d!==void 0)return t.search=s.rest.join(`&`),t.hash=l.rest.join(`&`),{target:u===void 0?void 0:Fn(u),...d?{ask:d}:{},url:t.toString()}}function Un(e){"@babel/helpers - typeof";return Un=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},Un(e)}function Wn(e,t){if(Un(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(Un(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Gn(e){var t=Wn(e,`string`);return Un(t)==`symbol`?t:t+``}function U(e,t,n){return(t=Gn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Kn=V.scope(`events`),qn={open:!1,ready:!1,unread:0};var Jn=class{constructor(){U(this,`handlers`,/* @__PURE__ */ new Map),U(this,`taps`,/* @__PURE__ */ new Set)}on(e,t){let n=this.handlers.get(e);return n||(n=/* @__PURE__ */ new Set,this.handlers.set(e,n)),n.add(t),()=>this.handlers.get(e)?.delete(t)}tap(e){return this.taps.add(e),()=>this.taps.delete(e)}listensTo(e){return(this.handlers.get(e)?.size??0)>0||[...this.taps].some(t=>t.listensTo(e))}emit(e,t){for(let n of this.handlers.get(e)??[])try{n(t)}catch(t){Kn.warn(`listener threw`,{event:e,error:t})}for(let n of this.taps)n.hear(e,t)}clear(){this.handlers.clear(),this.taps.clear()}};const Yn=V.scope(`feedback:audio`);var Xn=class{constructor(){U(this,`ctx`,null),U(this,`master`,null),U(this,`buffers`,/* @__PURE__ */ 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){Yn.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(/* @__PURE__ */ Error(`fetch ${e.status}`))).then(e=>n.decodeAudioData(e)).then(t=>(this.buffers.set(e,t),t)).catch(t=>(Yn.warn(`audio fetch/decode failed`,{url:e,err:t}),this.buffers.delete(e),null));return this.buffers.set(e,r),r}};const Zn={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Qn={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 W=null,$n=0;function er(){return typeof navigator<`u`&&typeof navigator.vibrate==`function`}function tr(){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=`__${P.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;`;e.style.cssText=n,t.style.cssText=n;for(let n of[e,t])n.addEventListener(`click`,e=>e.stopPropagation());return document.body.append(e,t),{input:e,label:t}}function nr(e){if(!(e===0||Array.isArray(e)&&e.every(e=>e===0))){if(er())try{navigator.vibrate(e);return}catch{}if(W??(W=tr()),W)try{W.label.click()}catch{}}}function rr(){$n++;let e=!1;return()=>{e||(e=!0,$n=Math.max(0,$n-1),$n===0&&W&&(W.input.remove(),W.label.remove(),W=null))}}const ir=V.scope(`feedback`);var ar=class{constructor(e,t){U(this,`mutedSig`,o(!1)),U(this,`audio`,new Xn),U(this,`releaseHaptics`,void 0),U(this,`sound`,void 0),U(this,`haptics`,void 0),U(this,`lastPlayed`,/* @__PURE__ */ new Map),U(this,`reducedMotionMq`,null),this.sound=e,this.haptics=t,this.releaseHaptics=rr(),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=>ir.warn(`audio play failed`,{err:e,url:t}));return}let n=Qn[e];n&&this.audio.playTone(n)}playHaptic(e){if(this.reducedMotionMq?.matches)return;let t=this.haptics.events?.[e];t!==!1&&nr(t===!0||t===void 0?Zn[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}};function or(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function sr(e){return or(e)}function cr(e){return!(!or(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function lr(e){if(typeof e!=`object`||!e)return{};let t=Reflect.get(e,`url`);return{url:typeof t==`string`&&/^https?:\/\//i.test(t)&&t.includes(`{returnTo}`)?t:void 0,required:Reflect.get(e,`required`)===!0,hidePrompt:Reflect.get(e,`hidePrompt`)===!0,hideUser:Reflect.get(e,`hideUser`)===!0}}function ur(e,t){let n=encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`);return e.replaceAll(`{returnTo}`,n)}function dr(e){let t=e.split(`.`)[1];if(t)try{let e=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),n=JSON.parse(new TextDecoder().decode(Uint8Array.from(e,e=>e.charCodeAt(0))));return typeof n==`object`&&n&&!Array.isArray(n)?Object.fromEntries(Object.entries(n)):void 0}catch{return}}function fr(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?{[t]:n.trim()}:{}}function pr(e){let t=dr(e);return{...fr(t,`name`),...fr(t,`email`)}}function mr(e){let t=dr(e)?.sub;return typeof t==`string`&&t!==``?t:void 0}function hr(){try{return window.top?.location.href??location.href}catch{return location.href}}function gr(e){try{(window.top??window).location.assign(e)}catch{location.assign(e)}}function _r({amount:e,currency:t},n){let r=new Intl.NumberFormat(`en`,{style:`currency`,currency:t}).resolvedOptions().maximumFractionDigits??2;return new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e/10**r)}function vr(e,t){let n=new Date(e);return!/^\d{4}-\d{2}-\d{2}/.test(e)||Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeZone:e.length===10?`UTC`:void 0}).format(n)}function yr(e,t){let n=br(e);return n?new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`,timeZone:`UTC`}).format(n):e}function br(e){let t=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})/.exec(e);return t?Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]),Number(t[4]),Number(t[5])):void 0}function xr(e,t){let[n,r]=[e,t].map(e=>/^\d{4}-\d{2}-\d{2}/.test(e??``)?Date.parse(`${e?.slice(0,10)}T00:00:00Z`):NaN),i=Math.round(((r??NaN)-(n??NaN))/864e5);return i>0?i:void 0}function Sr(e,t){return!/^\d{4}-\d{2}-\d{2}/.test(e)||Number.isNaN(Date.parse(e.slice(0,10)))?e:new Intl.DateTimeFormat(t,{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}).format(Date.parse(e.slice(0,10)))}function Cr(e,t,n){return[e,t].flatMap(e=>e?[Sr(e,n)]:[]).join(` – `)}function wr(e,t){let n=(e,n)=>new Intl.NumberFormat(t,{style:`unit`,unit:n,unitDisplay:`narrow`}).format(e),r=Math.floor(e/60);return[r>0&&n(r,`hour`),e%60>0&&n(e%60,`minute`)].filter(Boolean).join(` `)}function Tr(e,t,n){let r=e.stops===void 0?void 0:e.stops.length===0?t.visualDirect:`${t.visualVia} ${e.stops.join(`, `)}`;return[e.duration===void 0?void 0:wr(e.duration,n),r].filter(Boolean).join(` · `)}function Er(e,t){return e===1?t.visualNight:t.visualNights.replace(`{count}`,String(e))}function Dr(e,t,n){let r=e.typeName===`Stay`?e.props.stay:void 0,i=e.typeName===`Stay`?{...e.props.stay,title:e.props.stay.name,start:e.props.stay.checkIn,end:e.props.stay.checkOut,nights:void 0,priceNote:void 0}:e.props.package,a=i.nights??xr(i.start,i.end);return{...i,stars:r?.stars,room:r?.room,when:[Cr(i.start,i.end,n),a&&Er(a,t)].filter(Boolean).join(` · `),note:r?.nightly?`${_r(r.nightly,n)} ${t.visualPerNight}`:i.priceNote,available:i.available!==!1}}function Or({value:e,best:t}){return t===void 0||t===5?String(e):`${e}/${t}`}function kr(e){return Array.isArray(e)?e:[e]}function Ar({type:e,data:t}){let n=kr(t[0]?.value??[]).length;if(t.some(e=>kr(e.value).length!==n))return!1;if(e!==`pie`)return!0;let r=t.map(e=>kr(e.value)[0]??0);return n===1&&r.every(e=>e>=0)&&r.some(e=>e>0)}const jr=[`#f59e0b`,`#10b981`,`#ef4444`,`#8b5cf6`,`#0ea5e9`];function Mr({type:e,data:t},n){let r=t.map(e=>kr(e.value)),i=Math.max(1,r[0]?.length??1),a=Math.min(0,...r.flat()),o=Math.max(0,...r.flat()),s=o-a||1,c=272/Math.max(1,t.length),l=c*.7/i,u=Math.ceil(t.length/8),d=new Intl.NumberFormat(n,{notation:`compact`,maximumFractionDigits:1});function f(e){return 148-(e-a)/s*136}return{baseline:f(0),barWidth:l,series:Array.from({length:i},(t,n)=>r.map((t,r)=>({x:24+(r+.5)*c+(e===`bar`?(n-(i-1)/2)*l:0),y:f(t[n]??0)}))),labels:t.flatMap((e,t)=>t%u===0?[{x:24+(t+.5)*c,text:e.label.length*5>c*u?`${e.label.slice(0,Math.max(1,Math.floor(c*u/5)-1))}…`:e.label}]:[]),ticks:[.../* @__PURE__ */ new Set([o,a])].map(e=>({y:f(e),text:d.format(e)})),slices:e===`pie`?Nr(r.map(e=>e[0]??0)):[]}}function Nr(e){let t=e.reduce((e,t)=>e+t,0)||1,n=-Math.PI/2;return e.map(e=>{let r=n+e/t*2*Math.PI,i=Pr(n,Math.min(r,n+2*Math.PI-1e-4));return n=r,{path:i,share:e/t}})}function Pr(e,t){let n=+(t-e>Math.PI),r=(e,t)=>`${(160+e*Math.cos(t)).toFixed(2)} ${(84+e*Math.sin(t)).toFixed(2)}`;return`M${r(64,e)}A64 64 0 ${n} 1 ${r(64,t)}L${r(40,t)}A40 40 0 ${n} 0 ${r(40,e)}Z`}function Fr(e){if(!e||e.length<2)return;let t=Math.min(...e),n=Math.max(...e)-t||1;return e.map((r,i)=>`${(i*80/(e.length-1)).toFixed(1)},${(22-(r-t)/n*20).toFixed(1)}`).join(` `)}function Ir(e){let t=/^[^\d\-−+]{0,4}([-−+]?\d[\d.,\s]*?)\s?[^\d]{0,4}$/u.exec(e.trim());if(!t?.[1])return;let n=t[1].replace(/\s/g,``).replace(`−`,`-`),r=n.match(/[.,]/g)??[],i=r.at(-1),a=new Set(r).size>1||r.length===1&&!/^[-+]?[1-9]\d{0,2}[.,]\d{3}$/.test(n)?i:void 0,o=Number(n.replace(a===`,`?/\./g:a===`.`?/,/g:/[.,]/g,``).replace(`,`,`.`));return Number.isFinite(o)?o:void 0}function Lr(e,t){return e.map((e,n)=>{let r=t.map(e=>e[n]??``).filter(e=>e.trim());return r.length>0&&r.every(e=>Ir(e)!==void 0)})}function Rr(e,t,n){if(!t)return e;let r=new Intl.Collator(n,{numeric:!0}),i=t.descending?-1:1;return[...e].sort((e,n)=>{let[a,o]=[e[t.column]??``,n[t.column]??``];return i*(t.numeric?(Ir(a)??0)-(Ir(o)??0):r.compare(a,o))})}new Map(Object.entries({Product:280,Stay:280,Package:280,Flight:300,Cart:480,Order:480,Booking:480}));function zr(e){return e.typeName===`Cell`?e.props.span??1:1}function Br(e,t){let n=e.reduce((e,n)=>e+Math.min(n,t),0);return Math.ceil(n/Math.max(1,Math.ceil(n/t)))||1}function Vr(e){let t=new Set(e.map(e=>{let t=e.typeName===`Cell`?e.props.children.length===1?e.props.children[0]:void 0:e;return t?.typeName===`Metric`?`Card`:t?.typeName}));return t.size===1&&!t.has(void 0)}function Hr({scrollLeft:e,scrollWidth:t,clientWidth:n}){let r=Math.abs(e);return{start:r>1,end:r<t-n-1}}function Ur(e){return/^https:\/\//i.test(e??``)}function Wr(e,t){return(e??[]).flatMap(e=>e.url?Ur(e.url)?[{...e,url:e.url,message:void 0}]:[]:t?[{...e,url:void 0,message:e.label}]:[])}function Gr(e,t,n){return`${e}: ${[t,...Object.entries(n??{}).map(([e,t])=>`${e}: ${t}`)].join(`, `)}`}function Kr(e){return[...e.legs.map(e=>e.number??e.carrier),e.fare].filter(Boolean).join(`, `)}function qr(e,t){return t!==void 0&&t.currency===e.currency&&t.amount>e.amount}function Jr(e,t){let n=e.variants??[],r=(e.options??[]).filter(e=>e.values.length).map(r=>({...r,value:t[r.name]??r.values.find(t=>t===e.selected?.[r.name])??(r.values.length===1?r.values[0]:void 0),unavailable:n.length?r.values.filter(e=>!n.some(t=>t.available!==!1&&t.options[r.name]===e)):[]})),i=r.filter(e=>e.value===void 0).map(e=>e.name),a=Object.fromEntries(r.flatMap(e=>e.value===void 0?[]:[[e.name,e.value]])),o=i.length?void 0:n.find(e=>r.every(t=>e.options[t.name]===t.value)),s=!i.length&&n.length?o!==void 0&&o.available!==!1:e.available!==!1;return{options:r,missing:i,chosen:a,available:s,price:o?.price??e.price,compareAtPrice:o?.price?o.compareAtPrice:e.compareAtPrice,image:o?.image??e.image,canBuy:!i.length&&s}}const Yr={root:`Root`,schema:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{Root:{$ref:`#/$defs/Root`},Grid:{$ref:`#/$defs/Grid`},Cell:{$ref:`#/$defs/Cell`},Carousel:{$ref:`#/$defs/Carousel`},Text:{$ref:`#/$defs/Text`},Card:{$ref:`#/$defs/Card`},Metric:{$ref:`#/$defs/Metric`},Table:{$ref:`#/$defs/Table`},Chart:{$ref:`#/$defs/Chart`},Product:{$ref:`#/$defs/Product`},Cart:{$ref:`#/$defs/Cart`},Order:{$ref:`#/$defs/Order`},Flight:{$ref:`#/$defs/Flight`},Stay:{$ref:`#/$defs/Stay`},Package:{$ref:`#/$defs/Package`},Booking:{$ref:`#/$defs/Booking`}},required:[`Root`,`Grid`,`Cell`,`Carousel`,`Text`,`Card`,`Metric`,`Table`,`Chart`,`Product`,`Cart`,`Order`,`Flight`,`Stay`,`Package`,`Booking`],additionalProperties:!1,$defs:{Root:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Grid`},{$ref:`#/$defs/Carousel`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}}},required:[`children`],additionalProperties:!1},Grid:{type:`object`,properties:{columns:{type:`integer`,enum:[1,2,3,4],default:1},children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Cell`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}}},required:[`columns`,`children`],additionalProperties:!1},Cell:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}},span:{type:`integer`,enum:[1,2,3,4],default:1}},required:[`children`],additionalProperties:!1},Carousel:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Card`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`}]}}},required:[`children`],additionalProperties:!1},Text:{type:`object`,properties:{text:{type:`string`}},required:[`text`],additionalProperties:!1},Card:{type:`object`,properties:{title:{type:`string`},body:{type:`string`},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}},image:{type:`string`}},required:[`title`,`body`],additionalProperties:!1},Metric:{type:`object`,properties:{label:{type:`string`},value:{type:`string`},detail:{type:`string`},change:{type:`object`,properties:{text:{type:`string`},tone:{type:`string`,enum:[`good`,`bad`,`neutral`]}},required:[`text`,`tone`]},trend:{type:`array`,items:{type:`number`}}},required:[`label`,`value`],additionalProperties:!1},Table:{type:`object`,properties:{title:{type:`string`},columns:{type:`array`,items:{type:`string`}},rows:{type:`array`,items:{type:`array`,items:{type:`string`}}}},required:[`title`,`columns`,`rows`],additionalProperties:!1},Chart:{type:`object`,properties:{title:{type:`string`},type:{type:`string`,enum:[`bar`,`line`,`pie`]},data:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},value:{anyOf:[{type:`number`},{type:`array`,items:{type:`number`}}]}},required:[`label`,`value`],additionalProperties:!1}},series:{type:`array`,items:{type:`string`}}},required:[`title`,`type`,`data`],additionalProperties:!1},Product:{type:`object`,properties:{product:{type:`object`,properties:{title:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},description:{type:`string`},badge:{type:`string`},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},available:{type:`boolean`},options:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},values:{type:`array`,items:{type:`string`}}},required:[`name`,`values`]}},variants:{type:`array`,items:{type:`object`,properties:{options:{type:`object`,additionalProperties:{type:`string`}},id:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},available:{type:`boolean`}},required:[`options`]}},selected:{type:`object`,additionalProperties:{type:`string`}},details:{type:`array`,items:{type:`string`}}},required:[`title`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`product`],additionalProperties:!1},Cart:{type:`object`,properties:{cart:{type:`object`,properties:{lines:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},quantity:{type:`integer`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},options:{type:`object`,additionalProperties:{type:`string`}},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`title`,`quantity`,`price`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},messages:{type:`array`,items:{type:`object`,properties:{text:{type:`string`},severity:{type:`string`,enum:[`info`,`warning`,`error`]}},required:[`text`,`severity`]}}},required:[`lines`,`totals`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`cart`],additionalProperties:!1},Order:{type:`object`,properties:{order:{type:`object`,properties:{number:{type:`string`},status:{type:`string`},date:{type:`string`},items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},quantity:{type:`integer`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},options:{type:`object`,additionalProperties:{type:`string`}},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`title`,`quantity`,`price`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},timeline:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},done:{type:`boolean`},date:{type:`string`}},required:[`label`,`done`]}},details:{type:`array`,items:{type:`string`}}},required:[`number`,`status`,`items`,`totals`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`order`],additionalProperties:!1},Flight:{type:`object`,properties:{flight:{type:`object`,properties:{legs:{type:`array`,items:{type:`object`,properties:{from:{type:`string`},to:{type:`string`},departs:{type:`string`},arrives:{type:`string`},carrier:{type:`string`},number:{type:`string`},duration:{type:`integer`},stops:{type:`array`,items:{type:`string`}}},required:[`from`,`to`,`departs`,`arrives`,`carrier`]},minItems:1},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},priceNote:{type:`string`},fare:{type:`string`},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`legs`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`flight`],additionalProperties:!1},Stay:{type:`object`,properties:{stay:{type:`object`,properties:{name:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},image:{type:`string`},url:{type:`string`},location:{type:`string`},stars:{type:`integer`},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},checkIn:{type:`string`},checkOut:{type:`string`},room:{type:`string`},nightly:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`name`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`stay`],additionalProperties:!1},Package:{type:`object`,properties:{package:{type:`object`,properties:{title:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},image:{type:`string`},url:{type:`string`},location:{type:`string`},start:{type:`string`},end:{type:`string`},nights:{type:`integer`},priceNote:{type:`string`},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`title`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`package`],additionalProperties:!1},Booking:{type:`object`,properties:{booking:{type:`object`,properties:{reference:{type:`string`},status:{type:`string`},title:{type:`string`},start:{type:`string`},end:{type:`string`},travellers:{type:`array`,items:{type:`string`}},itinerary:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},date:{type:`string`},time:{type:`string`},detail:{type:`string`}},required:[`title`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},details:{type:`array`,items:{type:`string`}}},required:[`reference`,`status`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`booking`],additionalProperties:!1}}}};function Xr(e){switch(e.k){case`StateRef`:case`RuntimeRef`:case`BinOp`:case`UnaryOp`:case`Ternary`:case`Member`:case`Index`:case`Assign`:return!0;default:return!1}}const Zr=/* @__PURE__ */ new Set([`Comp`,`Ref`,`StateRef`,`RuntimeRef`,`BinOp`,`UnaryOp`,`Ternary`,`Member`,`Index`,`Assign`,`Str`,`Num`,`Bool`,`Null`,`Arr`,`Obj`,`Ph`]);function Qr(e){return!e||typeof e!=`object`||Array.isArray(e)?!1:Zr.has(e.k)}function $r(e,t){let n=e=>{switch(t(e),e.k){case`Comp`:e.args.forEach(n),Object.values(e.mappedProps??{}).forEach(n);break;case`Arr`:e.els.forEach(n);break;case`Obj`:e.entries.forEach(([,e])=>n(e));break;case`BinOp`:n(e.left),n(e.right);break;case`UnaryOp`:n(e.operand);break;case`Ternary`:n(e.cond),n(e.then),n(e.else);break;case`Member`:n(e.obj);break;case`Index`:n(e.obj),n(e.index);break;case`Assign`:n(e.value)}};n(e)}function ei(e){return e==null?{k:`Null`}:typeof e==`string`?{k:`Str`,v:e}:typeof e==`number`?{k:`Num`,v:e}:typeof e==`boolean`?{k:`Bool`,v:e}:Array.isArray(e)?{k:`Arr`,els:e.map(ei)}:typeof e==`object`?{k:`Obj`,entries:Object.entries(e).map(([e,t])=>[e,ei(t)])}:{k:`Null`}}function ti(e){switch(e.k){case`Str`:case`Num`:case`Bool`:return{v:e.v};case`Null`:return{v:null};case`Arr`:{let t=[];for(let n of e.els){let e=ti(n);if(!e)return;t.push(e.v)}return{v:t}}case`Obj`:{let t={};for(let[n,r]of e.entries){let e=ti(r);if(!e)return;t[n]=e.v}return{v:t}}default:return}}const ni=/* @__PURE__ */ new Map([[`Count`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`First`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`Last`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`Sum`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Avg`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Min`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Max`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Sort`,{kind:`function`,params:[{name:`array`,required:!1},{name:`field`,required:!1},{name:`direction`,required:!1}],builtin:!0}],[`Filter`,{kind:`function`,params:[{name:`array`,required:!1},{name:`field`,required:!1},{name:`operator`,required:!1},{name:`value`,required:!1}],builtin:!0}],[`Round`,{kind:`function`,params:[{name:`number`,required:!1},{name:`decimals`,required:!1}],builtin:!0}],[`Abs`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Floor`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Ceil`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Each`,{kind:`function`,params:[{name:`array`,required:!1},{name:`varName`,required:!1},{name:`template`,required:!1}],builtin:!0,lazy:!0}],[`Run`,{kind:`action`,params:[{name:`ref`,required:!1}],builtin:!0,lazy:!0}],[`ToAssistant`,{kind:`action`,params:[{name:`message`,required:!1},{name:`context`,required:!1}],builtin:!0}],[`OpenUrl`,{kind:`action`,params:[{name:`url`,required:!1}],builtin:!0}],[`Set`,{kind:`action`,params:[{name:`variable`,required:!1},{name:`value`,required:!1}],builtin:!0,lazy:!0}],[`Reset`,{kind:`action`,params:[{name:`variable`,required:!1}],builtin:!0,lazy:!0}],[`Action`,{kind:`action`,params:[{name:`steps`,required:!0}],builtin:!0,lazy:!0}]]),ri={ActionExpression:!0,OpenUrl:!0,ToAssistant:!0},ii={Query:`Query`,Mutation:`Mutation`};function ai(e){return e?.callDefs??ni}function oi(e){return ni.has(e)}function si(e){return e in ii}var G;(function(e){e[e.Newline=0]=`Newline`,e[e.LParen=1]=`LParen`,e[e.RParen=2]=`RParen`,e[e.LBrack=3]=`LBrack`,e[e.RBrack=4]=`RBrack`,e[e.LBrace=5]=`LBrace`,e[e.RBrace=6]=`RBrace`,e[e.Comma=7]=`Comma`,e[e.Colon=8]=`Colon`,e[e.Equals=9]=`Equals`,e[e.True=10]=`True`,e[e.False=11]=`False`,e[e.Null=12]=`Null`,e[e.EOF=13]=`EOF`,e[e.Str=14]=`Str`,e[e.Num=15]=`Num`,e[e.Ident=16]=`Ident`,e[e.Type=17]=`Type`,e[e.StateVar=18]=`StateVar`,e[e.Dot=19]=`Dot`,e[e.Plus=20]=`Plus`,e[e.Minus=21]=`Minus`,e[e.Star=22]=`Star`,e[e.Slash=23]=`Slash`,e[e.Percent=24]=`Percent`,e[e.EqEq=25]=`EqEq`,e[e.NotEq=26]=`NotEq`,e[e.Greater=27]=`Greater`,e[e.Less=28]=`Less`,e[e.GreaterEq=29]=`GreaterEq`,e[e.LessEq=30]=`LessEq`,e[e.And=31]=`And`,e[e.Or=32]=`Or`,e[e.Not=33]=`Not`,e[e.Question=34]=`Question`,e[e.BuiltinCall=35]=`BuiltinCall`})(G||(G={}));function ci(e){let t=0,n=()=>e[t]??{t:G.EOF},r=()=>{let e=n();return t++,e},i=e=>{n().t===e&&t++};function a(e){switch(e.t){case G.Question:return 1;case G.Or:return 2;case G.And:return 3;case G.EqEq:case G.NotEq:return 4;case G.Greater:case G.Less:case G.GreaterEq:case G.LessEq:return 5;case G.Plus:case G.Minus:return 6;case G.Star:case G.Slash:case G.Percent:return 7;case G.Dot:case G.LBrack:return 9;default:return 0}}function o(e=0){let t=s();for(;a(n())>e;)t=c(t);return t}function s(){let a=n();if(a.t===G.Str)return r(),{k:`Str`,v:a.v};if(a.t===G.Num)return r(),{k:`Num`,v:a.v};if(a.t===G.True)return r(),{k:`Bool`,v:!0};if(a.t===G.False)return r(),{k:`Bool`,v:!1};if(a.t===G.Null)return r(),{k:`Null`};if(a.t===G.LBrack)return u();if(a.t===G.LBrace)return d();if(a.t===G.StateVar){let e=a.v;return r(),n().t===G.Equals?(r(),{k:`Assign`,target:e,value:o(0)}):{k:`StateRef`,n:e}}if(a.t===G.Type){let n=a.v;return e[t+1]?.t===G.LParen&&(!oi(n)||n===`Action`)?l():(r(),{k:`Ref`,n})}if(a.t===G.BuiltinCall){if(e[t+1]?.t===G.LParen){let e=l();return e.k===`Comp`&&!oi(e.name)&&(e.fn=!0),e}return r(),{k:`Ref`,n:a.v}}if(a.t===G.Ident)return r(),{k:`Ref`,n:a.v};if(a.t===G.Not)return r(),{k:`UnaryOp`,op:`!`,operand:o(8)};if(a.t===G.Minus)return r(),{k:`UnaryOp`,op:`-`,operand:o(8)};if(a.t===G.LParen){r();let e=o(0);return i(G.RParen),e}return r(),{k:`Null`}}function c(e){let t=n();if(t.t===G.Plus)return r(),{k:`BinOp`,op:`+`,left:e,right:o(6)};if(t.t===G.Minus)return r(),{k:`BinOp`,op:`-`,left:e,right:o(6)};if(t.t===G.Star)return r(),{k:`BinOp`,op:`*`,left:e,right:o(7)};if(t.t===G.Slash)return r(),{k:`BinOp`,op:`/`,left:e,right:o(7)};if(t.t===G.Percent)return r(),{k:`BinOp`,op:`%`,left:e,right:o(7)};if(t.t===G.EqEq)return r(),{k:`BinOp`,op:`==`,left:e,right:o(4)};if(t.t===G.NotEq)return r(),{k:`BinOp`,op:`!=`,left:e,right:o(4)};if(t.t===G.Greater)return r(),{k:`BinOp`,op:`>`,left:e,right:o(5)};if(t.t===G.Less)return r(),{k:`BinOp`,op:`<`,left:e,right:o(5)};if(t.t===G.GreaterEq)return r(),{k:`BinOp`,op:`>=`,left:e,right:o(5)};if(t.t===G.LessEq)return r(),{k:`BinOp`,op:`<=`,left:e,right:o(5)};if(t.t===G.And)return r(),{k:`BinOp`,op:`&&`,left:e,right:o(3)};if(t.t===G.Or)return r(),{k:`BinOp`,op:`||`,left:e,right:o(2)};if(t.t===G.Question){r();let t=o(0);return i(G.Colon),{k:`Ternary`,cond:e,then:t,else:o(0)}}if(t.t===G.Dot){r();let t=n();return{k:`Member`,obj:e,field:t.t===G.Ident||t.t===G.Type||t.t===G.Str||t.t===G.Num?(r(),String(t.v)):t.t===G.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`)}}if(t.t===G.LBrack){r();let t=o(0);return i(G.RBrack),{k:`Index`,obj:e,index:t}}return e}function l(){let e=n().v;r(),i(G.LParen);let t=[];for(;n().t!==G.RParen&&n().t!==G.EOF;)t.push(o(0)),n().t===G.Comma&&r();return i(G.RParen),{k:`Comp`,name:e,args:t}}function u(){r();let e=[];for(;n().t!==G.RBrack&&n().t!==G.EOF;)e.push(o(0)),n().t===G.Comma&&r();return i(G.RBrack),{k:`Arr`,els:e}}function d(){r();let e=[];for(;n().t!==G.RBrace&&n().t!==G.EOF;){let t=n(),a=t.t===G.Ident||t.t===G.Str||t.t===G.Type||t.t===G.Num?(r(),String(t.v)):t.t===G.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`);i(G.Colon),e.push([a,o(0)]),n().t===G.Comma&&r()}return i(G.RBrace),{k:`Obj`,entries:e}}return o(0)}function li(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&(e.charAt(n)===` `||e.charAt(n)===` `||e.charAt(n)===`\r`);)n++;if(n>=r)break;let i=e.charAt(n);if(i===`
12
12
  `){t.push({t:G.Newline}),n++;continue}if(i===`(`){t.push({t:G.LParen}),n++;continue}if(i===`)`){t.push({t:G.RParen}),n++;continue}if(i===`[`){t.push({t:G.LBrack}),n++;continue}if(i===`]`){t.push({t:G.RBrack}),n++;continue}if(i===`{`){t.push({t:G.LBrace}),n++;continue}if(i===`}`){t.push({t:G.RBrace}),n++;continue}if(i===`,`){t.push({t:G.Comma}),n++;continue}if(i===`:`){t.push({t:G.Colon}),n++;continue}if(i===`=`){n+1<r&&e.charAt(n+1)===`=`?(t.push({t:G.EqEq}),n+=2):(t.push({t:G.Equals}),n++);continue}if(i===`!`){n+1<r&&e.charAt(n+1)===`=`?(t.push({t:G.NotEq}),n+=2):(t.push({t:G.Not}),n++);continue}if(i===`>`){n+1<r&&e.charAt(n+1)===`=`?(t.push({t:G.GreaterEq}),n+=2):(t.push({t:G.Greater}),n++);continue}if(i===`<`){n+1<r&&e.charAt(n+1)===`=`?(t.push({t:G.LessEq}),n+=2):(t.push({t:G.Less}),n++);continue}if(i===`&`){n+1<r&&e.charAt(n+1)===`&`?(t.push({t:G.And}),n+=2):(t.push({t:G.And}),n++);continue}if(i===`|`){n+1<r&&e.charAt(n+1)===`|`?(t.push({t:G.Or}),n+=2):(t.push({t:G.Or}),n++);continue}if(i===`.`){t.push({t:G.Dot}),n++;continue}if(i===`?`){t.push({t:G.Question}),n++;continue}if(i===`+`){t.push({t:G.Plus}),n++;continue}if(i===`*`){t.push({t:G.Star}),n++;continue}if(i===`/`){t.push({t:G.Slash}),n++;continue}if(i===`%`){t.push({t:G.Percent}),n++;continue}if(i===`"`){let i=n;n++;let a=!1;for(;n<r;)if(e.charAt(n)===`\\`)n+=2;else if(e.charAt(n)===`"`){n++,a=!0;break}else n++;let o=e.slice(i,n);try{let e=a?o:o+`"`;t.push({t:G.Str,v:JSON.parse(e)})}catch{let e=o.replace(/^"|"$/g,``);t.push({t:G.Str,v:e})}continue}if(i===`'`){n++;let i=``;for(;n<r;)if(e.charAt(n)===`\\`){if(n++,n<r){let t=e.charAt(n);i+=t===`'`?`'`:t===`\\`?`\\`:t===`n`?`
13
- `:t===`t`?` `:t,n++}}else if(e.charAt(n)===`'`){n++;break}else i+=e.charAt(n),n++;t.push({t:G.Str,v:i});continue}if(i===`-`){let i=t.length>0?t[t.length-1]:null;if(!((i==null||i.t!==G.Num&&i.t!==G.Str&&i.t!==G.Ident&&i.t!==G.Type&&i.t!==G.RParen&&i.t!==G.RBrack&&i.t!==G.True&&i.t!==G.False&&i.t!==G.Null&&i.t!==G.StateVar&&i.t!==G.BuiltinCall)&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`)){t.push({t:G.Minus}),n++;continue}}let a=i>=`0`&&i<=`9`,o=i===`-`&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`;if(a||o){let i=n;for(e.charAt(n)===`-`&&n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;if(n<r&&e.charAt(n)===`.`&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`)for(n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;if(n<r&&(e.charAt(n)===`e`||e.charAt(n)===`E`))for(n++,n<r&&(e.charAt(n)===`+`||e.charAt(n)===`-`)&&n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;t.push({t:G.Num,v:+e.slice(i,n)})}else if(i===`$`&&n+1<r&&(e.charAt(n+1)>=`a`&&e.charAt(n+1)<=`z`||e.charAt(n+1)>=`A`&&e.charAt(n+1)<=`Z`||e.charAt(n+1)===`_`)){let i=n;for(n++;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;t.push({t:G.StateVar,v:e.slice(i,n)})}else if(i>=`a`&&i<=`z`||i>=`A`&&i<=`Z`||i===`_`){let a=n;for(;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;let o=e.slice(a,n);if(o===`true`){t.push({t:G.True});continue}if(o===`false`){t.push({t:G.False});continue}if(o===`null`){t.push({t:G.Null});continue}let s=i>=`A`&&i<=`Z`?G.Type:G.Ident;t.push({t:s,v:o})}else if(i===`@`&&n+1<r&&(e.charAt(n+1)>=`a`&&e.charAt(n+1)<=`z`||e.charAt(n+1)>=`A`&&e.charAt(n+1)<=`Z`||e.charAt(n+1)===`_`)){n++;let i=n;for(;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;t.push({t:G.BuiltinCall,v:e.slice(i,n)})}else n++}return t.push({t:G.EOF}),t}function ci(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.type===`element`&&typeof t.typeName==`string`&&typeof t.props==`object`&&t.props!==null&&typeof t.partial==`boolean`}var li;(function(e){e.ContinueConversation=`continue_conversation`,e.OpenUrl=`open_url`})(li||(li={}));const ui={},di=[];function fi(e){return Array.isArray(e)?`array`:typeof e}function pi(e){return typeof e.$ref==`string`?e.$ref.split(`/`).pop():void 0}function mi(e){return`$ref`in e||`anyOf`in e||`oneOf`in e||`allOf`in e}function hi(e){if(Array.isArray(e.enum))return{enumValues:e.enum};if(`const`in e)return{enumValues:[e.const]};switch(e.type){case`string`:return{expectedType:`string`};case`number`:case`integer`:return{expectedType:`number`};case`boolean`:return{expectedType:`boolean`};default:return{}}}function gi(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e.default}function _i(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=pi(t);if(n)return n;let r=hi(t);return r.enumValues?r.enumValues.map(e=>JSON.stringify(e)).join(`|`):r.expectedType?r.expectedType:typeof t.type==`string`?t.type:void 0}function vi(e,t){return`${e}(${t.map(e=>{let t=_i(e.schema),n=e.required?`${e.name}*`:e.name;return t?`${n}: ${t}`:n}).join(`, `)})`}function yi(e,t){let n=typeof e;return t.enumValues?t.enumValues.includes(e)?null:{expected:`one of [${t.enumValues.map(e=>JSON.stringify(e)).join(`, `)}]`,actual:fi(e)}:t.expectedType&&t.expectedType!==n?{expected:t.expectedType,actual:fi(e)}:null}function bi(e,t,n){switch(n.code){case`type-mismatch`:return`field "${t}" expects ${n.expected} but got ${n.actual}`;case`pruned-value`:return`field "${t}" lost an unresolved or invalid value`;case`missing-required`:return`missing required field "${t}"${n.signature?` — signature: ${n.signature}`:``}`;case`null-required`:return`required field "${t}" cannot be null${n.signature?` — signature: ${n.signature}`:``}`;case`unknown-component`:return`Unknown component "${e}" — not found in catalog or builtins${n.available?.length?`. Available components: ${n.available.join(`, `)}`:``}`;case`inline-reserved`:return`${e}() must be declared as a top-level statement, not used inline as a value`;case`excess-args`:return`${e} takes ${n.declared} arg(s), got ${n.got} (${n.got-n.declared} excess dropped)`;case`unknown-function`:return`Unknown function "@${e}": not a built-in or action step. The call evaluates to null`;case`no-root`:return n.reason===`not-component`?`root does not evaluate to a component`:n.reason===`fallback`?`No root statement. Rendering the first statement that calls the root component ${e}`:e?`No root statement, and no statement calls the root component ${e}`:`No root statement`}}function xi(e,t,n,r){e.errors.push({code:r.code,component:t,path:n,message:bi(t,n,r),statementId:e.currentStatementId,...r.code===`no-root`&&r.reason===`fallback`&&{severity:`warning`}})}const Si=Symbol(`invalid`);function Ci(e,t){return t===void 0?e?Si:void 0:t}function wi(e,t,n,r,i){return mi(t)?!1:typeof t.type==`string`||Array.isArray(t.enum)||`const`in t?(xi(i,n,r,{code:`type-mismatch`,expected:typeof t.type==`string`?t.type:`a literal value`,actual:`component "${e.typeName}"`}),!0):!1}function Ti(e){return(e.anyOf??e.oneOf??[e]).map(pi)}function Ei(e,t){let n=Ti(e);return n.length>0&&n.every(e=>e!==void 0&&t.cat?.has(e))}function Di(e,t,n,r,i){if(typeof e!=`object`||Array.isArray(e))return xi(i,n,r,{code:`type-mismatch`,expected:`object`,actual:fi(e)}),Si;let a=e,o,s=t.properties&&typeof t.properties==`object`?t.properties:ui,c=Array.isArray(t.required)?t.required:di,l=!1;if(!i.partial)for(let e of c){let t=e in a;if(!t||a[e]==null){let c=gi(s[e]);if(c!==void 0){(o??(o={...a}))[e]=c;continue}xi(i,n,`${r}/${e}`,{code:t?`null-required`:`missing-required`}),l=!0}}for(let e of Object.keys(s)){if(!(e in a))continue;let t=s[e],u=Ai(a[e],t,n,`${r}/${e}`,i);u===Si&&(u=Ci(c.includes(e),gi(t)),u===Si)?l=!0:u!==a[e]&&(o??(o={...a}),u===void 0?delete o[e]:o[e]=u)}return l?Si:o??a}function Oi(e,t,n,r,i){if(!Array.isArray(e))return xi(i,n,r,{code:`type-mismatch`,expected:`array`,actual:fi(e)}),Si;let a=t.items;if(!a||typeof a!=`object`||Array.isArray(a))return e;let o;for(let t=0;t<e.length;t++){let s=Ai(e[t],a,n,`${r}/${t}`,i);s!==e[t]&&!o&&(o=e.slice(0,t)),o&&s!==Si&&o.push(s)}return o??e}function ki(e,t,n,r,i){let a=hi(t);if(a.expectedType==null&&a.enumValues==null||a.enumValues&&i.partial)return!1;let o=yi(e,a);return o?(xi(i,n,r,{code:`type-mismatch`,...o}),!0):!1}function Ai(e,t,n,r,i){if(!t||typeof t!=`object`||Array.isArray(t))return e;let a=t;if(e==null||Xr(e))return e;if(ci(e))return wi(e,a,n,r,i)?Si:e;if(mi(a))return Ei(a,i)?(xi(i,n,r,{code:`type-mismatch`,expected:Ti(a).join(` | `),actual:Array.isArray(e)?`array`:typeof e==`object`?`plain object`:typeof e}),Si):e;let o=a.type;return o===`object`?Di(e,a,n,r,i):o===`array`?Oi(e,a,n,r,i):ki(e,a,n,r,i)?Si:e}function ji(e){if(typeof e!=`object`||!e)return!1;if(Xr(e))return!0;if(Array.isArray(e))return e.some(ji);if(ci(e))return Object.values(e.props).some(ji);let t=e;return Array.isArray(t.steps)?!0:Object.values(t).some(ji)}function Mi(e,t,n){if(t.visited.has(e))return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;let r=t.syms.get(e);if(!r)return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;if(t.unreached?.delete(e),r.k===`Comp`&&ai(r.name))return{k:`RuntimeRef`,n:e,refType:r.name===ni.Mutation?`mutation`:`query`};t.visited.add(e);let i=t.currentStatementId;t.currentStatementId=e;try{let i=n===`value`?Vi(r,t):Bi(r,t);return n===`value`&&ci(i)&&(i.statementId=e),i}finally{t.currentStatementId=i,t.visited.delete(e)}}function Ni(e,t){return ri(t.cat).has(e)||ai(e)}function Pi(e,t){let n={};for(let[r,i]of t.entries()){let t=e[r];if(t===void 0)break;n[i.name]=t}return n}function Fi(e,t,n,r){let{params:i}=n;t.length>i.length&&xi(r,e,``,{code:`excess-args`,declared:i.length,got:t.length});let a=Pi(t,i),o=!1,s=r.errors.length;for(let t of i){let n=a[t.name],s=n?$r(n):{v:void 0};if(!s)continue;if(s.v==null){if(!t.required||t.defaultValue!==void 0)continue;xi(r,e,`/${t.name}`,{code:n?`null-required`:`missing-required`,signature:vi(e,i)}),o=!0;continue}let c=Ai(s.v,t.schema,e,`/${t.name}`,r);c===Si&&(c=Ci(t.required,t.defaultValue)),c===Si?o=!0:c===void 0?delete a[t.name]:c!==s.v&&(a[t.name]=Qr(c))}return n.kind===`action`&&r.errors.length>s&&(o=!0),o?null:a}function Ii(e,t,n){let r=e.args.map(n),i=ri(t.cat).get(e.name);if(!i||i.lazy)return{...e,args:r};let a=i.builtin?Pi(r,i.params):Fi(e.name,r,i,t);return a?{...e,args:r,mappedProps:a}:i.kind===`action`?{k:`Comp`,name:`Action`,args:[{k:`Arr`,els:[]}]}:{k:`Null`}}function Li(e,t,n){let r=t.currentStatementId;t.currentStatementId=n;let i=/* @__PURE__ */ new Set;for(let n of e)Zr(n,e=>{if(e.k!==`Comp`||i.has(e))return;i.add(e);let n=ri(t.cat).get(e.name);n&&!n.lazy&&(e.mappedProps=(n.builtin?null:Fi(e.name,e.args,n,t))??Pi(e.args,n.params))});t.currentStatementId=r}function Ri(e,t,n){let r=ri(t.cat).get(e.name);if(r?.kind!==`function`||!r.lazy||e.args.length<3)return null;let i=e.args[1];if(!i)return null;let a=i.k===`Ref`?i.n:i.k===`Str`?i.v:null;if(!a)return null;let o=new Set(n);o.add(a);let s=e.args.map((e,n)=>n===1?e:zi(e,t,o));return{...e,args:s}}function zi(e,t,n){switch(e.k){case`Ref`:return n.has(e.n)?e:Mi(e.n,t,`expr`);case`Ph`:return e;case`Comp`:{if(e.fn&&!Ni(e.name,t))return xi(t,e.name,``,{code:`unknown-function`}),{k:`Null`};let r=Ri(e,t,n);if(r)return r;if(Ni(e.name,t))return Ii(e,t,e=>zi(e,t,n));let i=e.args.map(e=>zi(e,t,n)),a=t.cat?.get(e.name);if(a){let t={};for(let[e,n]of a.params.entries()){let r=i[e];r&&(t[n.name]=r)}return{...e,args:i,mappedProps:t}}return xi(t,e.name,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),{...e,args:i}}case`Arr`:return{...e,els:e.els.map(e=>zi(e,t,n))};case`Obj`:return{...e,entries:e.entries.map(([e,r])=>[e,zi(r,t,n)])};case`BinOp`:return{...e,left:zi(e.left,t,n),right:zi(e.right,t,n)};case`UnaryOp`:return{...e,operand:zi(e.operand,t,n)};case`Ternary`:return{...e,cond:zi(e.cond,t,n),then:zi(e.then,t,n),else:zi(e.else,t,n)};case`Member`:return{...e,obj:zi(e.obj,t,n)};case`Index`:return{...e,obj:zi(e.obj,t,n),index:zi(e.index,t,n)};case`Assign`:return{...e,value:zi(e.value,t,n)};default:return e}}function Bi(e,t){return zi(e,t,/* @__PURE__ */ new Set)}function Vi(e,t){switch(e.k){case`Ref`:return Mi(e.n,t,`value`);case`Str`:return e.v;case`Num`:return e.v;case`Bool`:return e.v;case`Null`:return null;case`Ph`:return null;case`Arr`:{let n=[];for(let r of e.els){if(r.k===`Ph`){t.prunedValues++;continue}let e=Vi(r,t);e===null&&(r.k===`Comp`||r.k===`Ref`)?t.prunedValues++:n.push(e)}return n}case`Obj`:{let n={};for(let[r,i]of e.entries)n[r]=Vi(i,t);return n}case`Comp`:{let{name:n,args:r}=e;if(e.fn&&!Ni(n,t))return xi(t,n,``,{code:`unknown-function`}),null;if(ai(n))return xi(t,n,``,{code:`inline-reserved`}),null;if(Ni(n,t))return Ri(e,t,/* @__PURE__ */ new Set)||Ii(e,t,e=>Bi(e,t));let i=t.cat?.get(n),a={};if(i){let e=!1;for(let[o,s]of i.params.entries()){let i=r[o];if(!i)break;let c=t.prunedValues,l=Vi(i,t);if(t.prunedValues>c&&xi(t,n,`/${s.name}`,{code:`pruned-value`}),a[s.name]=l,s.schema===void 0)continue;if(l==null&&s.defaultValue!==void 0){xi(t,n,`/${s.name}`,{code:`type-mismatch`,expected:_i(s.schema)??`a defined value`,actual:l===null?`null`:`undefined`}),a[s.name]=s.defaultValue,t.prunedValues=c;continue}let u=Ai(l,s.schema,n,`/${s.name}`,t);u===Si&&(u=Ci(s.required,s.defaultValue),s.defaultValue!==void 0&&(t.prunedValues=c),u===Si?e=!0:u===void 0&&delete a[s.name]),u!==Si&&u!==void 0&&(a[s.name]=u)}r.length>i.params.length&&xi(t,n,``,{code:`excess-args`,declared:i.params.length,got:r.length});let o=i.params.filter(e=>e.required&&(!(e.name in a)||a[e.name]===null));if(o.length){let e=o.filter(e=>e.defaultValue===void 0||(xi(t,n,`/${e.name}`,{code:e.name in a?`null-required`:`missing-required`}),a[e.name]=e.defaultValue,!1));if(e.length){for(let r of e)xi(t,n,`/${r.name}`,{code:r.name in a?`null-required`:`missing-required`,signature:vi(n,i.params)});return null}}if(e)return null}else return xi(t,n,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),null;let o=Object.values(a).some(e=>ji(e));return{type:`element`,typeName:n,props:a,partial:t.partial,hasDynamicProps:o}}default:return Jr(e)?Bi(e,t):e}}function Hi(e){let t=[],n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i];r?r=!1:a===`\\`&&n?r=!0:n?a===n&&(n=!1):a===`"`||a===`'`?n=a:a===`(`||a===`[`||a===`{`?t.push(a):(a===`)`&&t[t.length-1]===`(`||a===`]`&&t[t.length-1]===`[`||a===`}`&&t[t.length-1]===`{`)&&t.pop()}if(!(n||t.length>0))return{text:e,wasIncomplete:!1};let i=e;n&&(r&&(i+=`\\`),i+=n);for(let e=t.length-1;e>=0;e--)i+=t[e]===`(`?`)`:t[e]===`[`?`]`:`}`;return{text:i,wasIncomplete:!0}}function Ui(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&e[n]?.t===G.Newline;)n++;if(n>=e.length||e[n]?.t===G.EOF)break;let r=e[n];if(!r)break;if(r.t!==G.Ident&&r.t!==G.Type&&r.t!==G.StateVar){for(;n<e.length&&e[n]?.t!==G.Newline&&e[n]?.t!==G.EOF;)n++;continue}let i=r.v,a=r.t;if(n++,n>=e.length||e[n]?.t!==G.Equals){for(;n<e.length&&e[n]?.t!==G.Newline&&e[n]?.t!==G.EOF;)n++;continue}n++;let o=[],s=0,c=0;for(;n<e.length&&e[n]?.t!==G.EOF;){let t=e[n]?.t;if(t===G.Newline&&s<=0&&c<=0){let t=n+1;for(;t<e.length&&e[t]?.t===G.Newline;)t++;let r=t<e.length?e[t]?.t:G.EOF;if(r===G.Question||r===G.Colon&&c>0){n++;continue}break}if(t===G.Newline){n++;continue}t===G.LParen||t===G.LBrack||t===G.LBrace?s++:(t===G.RParen||t===G.RBrack||t===G.RBrace)&&s>0?s--:t===G.Question&&s===0?c++:t===G.Colon&&s===0&&c>0&&c--;let r=e[n++];r&&o.push(r)}o.length&&t.push({id:i,idTokenType:a,tokens:o})}return t}function Wi(e=!0){return{root:null,meta:{incomplete:e,unresolved:[],orphaned:[],statementCount:0,errors:[]},stateDeclarations:{},queryStatements:[],mutationStatements:[]}}function Gi(e){if(!Xr(e))return[];let t=/* @__PURE__ */ new Set;return Zr(e,e=>{e.k===`StateRef`&&t.add(e.n)}),[...t]}function Ki(e,t){if(t.k===`Comp`&&t.name===ni.Query){let n=Gi(t.args[1]);return{kind:`query`,id:e.id,call:{callee:ni.Query,args:t.args},expr:t,deps:n.length>0?n:void 0}}return t.k===`Comp`&&t.name===ni.Mutation?{kind:`mutation`,id:e.id,call:{callee:ni.Mutation,args:t.args},expr:t}:e.idTokenType===G.StateVar?{kind:`state`,id:e.id,init:t}:{kind:`value`,id:e.id,expr:t}}function qi(e,t,n){let r={},i=[],a=[];for(let n of e)switch(n.kind){case`state`:r[n.id]=Vi(n.init,t);break;case`query`:Li(n.call.args,t,n.id),i.push({statementId:n.id,toolAST:n.call.args[0]??null,argsAST:n.call.args[1]??null,defaultsAST:n.call.args[2]??null,refreshAST:n.call.args[3]??null,deps:n.deps,complete:!0});break;case`mutation`:Li(n.call.args,t,n.id),a.push({statementId:n.id,toolAST:n.call.args[0]??null,argsAST:n.call.args[1]??null})}for(let t of e){let e=t.kind===`state`?[t.init]:t.kind===`value`?[t.expr]:t.kind===`query`||t.kind===`mutation`?t.call.args:[];for(let i of e)for(let e of Gi(i))e===n?.name&&n.stmts.has(t)||e in r||(r[e]=null)}return{stateDeclarations:r,queryStatements:i,mutationStatements:a}}const Ji=`root`;function Yi(e){return e?.k===`Comp`&&!e.fn&&!ii(e.name)&&!ai(e.name)}function Xi(e,t){if(e.has(Ji))return{id:Ji,fallback:!1};for(let n of e.values())if(n.kind===`value`&&Yi(n.expr)&&n.expr.name===t)return{id:n.id,fallback:!0};return null}function Zi(e,t){let n=/* @__PURE__ */ new Set;for(;e?.k===`Ref`&&!n.has(e.n);)n.add(e.n),e=t.get(e.n);return Yi(e)}function Qi(e){let t=!1;return Zr(e,e=>{Yi(e)&&(t=!0)}),t}function $i(e,t,n,r,i,a,o){let s=Xi(e,a),c=/* @__PURE__ */ new Map;for(let[t,n]of e)c.set(t,n.kind===`state`?n.init:n.expr);let l=[],u=[],d=/* @__PURE__ */ new Set;for(let[t,n]of e)t!==s?.id&&n.kind!==`state`&&n.kind!==`query`&&n.kind!==`mutation`&&d.add(t);let f={syms:c,cat:i,errors:u,unres:l,prunedValues:0,visited:/* @__PURE__ */ new Set,partial:n,currentStatementId:s?.id,unreached:d},p=null,m,h=s&&c.get(s.id);if(s&&h){let e=Vi(h,f);ci(e)?(p=e,p.statementId=s.id):Xr(e)&&Qi(e)&&(m=e)}let{stateDeclarations:g,queryStatements:_,mutationStatements:v}=qi(t,f,o);f.currentStatementId=s?.id;let y=a??``;s?!p&&!m&&!Zi(c.get(s.id),c)?xi(f,y,``,{code:`no-root`,reason:`not-component`}):s.fallback&&xi(f,y,``,{code:`no-root`,reason:p?`fallback`:`missing`}):xi(f,y,``,{code:`no-root`,reason:`missing`});let b=s?[...d]:[];return{root:p,...m?{rootExpression:m}:{},meta:{incomplete:n,unresolved:l,orphaned:b,statementCount:r,errors:u},stateDeclarations:g,queryStatements:_,mutationStatements:v}}function ea(e,t){if(e[t]!==`"`)return t;let n=t+1;for(;n<e.length;){let t=e[n];if(t===`\\`)n+=2;else if(t===`"`)return n+1;else n++}return n}function ta(e){let t=[],n=0;for(;n<e.length;){let r=-1;for(;n<e.length;){let t=ea(e,n);if(t>n)n=t;else{if(e[n]==="`"&&n+1<e.length&&e[n+1]==="`"&&n+2<e.length&&e[n+2]==="`"){r=n;break}n++}}if(r===-1)break;let i=r+3;for(;i<e.length&&e[i]!==`
14
- `;)i++;if(i>=e.length){t.push(e.slice(r+3).replace(/^[^\n]*\n?/,``)),n=e.length;break}i++;let a=-1,o=i;for(;o<e.length;){let t=ea(e,o);if(t>o)o=t;else{if(e[o]==="`"&&o+1<e.length&&e[o+1]==="`"&&o+2<e.length&&e[o+2]==="`"){a=o;break}o++}}a===-1?(t.push(e.slice(i)),n=e.length):(t.push(e.slice(i,a)),n=a+3)}if(t.length>0)return t.join(`
13
+ `:t===`t`?` `:t,n++}}else if(e.charAt(n)===`'`){n++;break}else i+=e.charAt(n),n++;t.push({t:G.Str,v:i});continue}if(i===`-`){let i=t.length>0?t[t.length-1]:null;if(!((i==null||i.t!==G.Num&&i.t!==G.Str&&i.t!==G.Ident&&i.t!==G.Type&&i.t!==G.RParen&&i.t!==G.RBrack&&i.t!==G.True&&i.t!==G.False&&i.t!==G.Null&&i.t!==G.StateVar&&i.t!==G.BuiltinCall)&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`)){t.push({t:G.Minus}),n++;continue}}let a=i>=`0`&&i<=`9`,o=i===`-`&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`;if(a||o){let i=n;for(e.charAt(n)===`-`&&n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;if(n<r&&e.charAt(n)===`.`&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`)for(n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;if(n<r&&(e.charAt(n)===`e`||e.charAt(n)===`E`))for(n++,n<r&&(e.charAt(n)===`+`||e.charAt(n)===`-`)&&n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;t.push({t:G.Num,v:+e.slice(i,n)})}else if(i===`$`&&n+1<r&&(e.charAt(n+1)>=`a`&&e.charAt(n+1)<=`z`||e.charAt(n+1)>=`A`&&e.charAt(n+1)<=`Z`||e.charAt(n+1)===`_`)){let i=n;for(n++;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;t.push({t:G.StateVar,v:e.slice(i,n)})}else if(i>=`a`&&i<=`z`||i>=`A`&&i<=`Z`||i===`_`){let a=n;for(;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;let o=e.slice(a,n);if(o===`true`){t.push({t:G.True});continue}if(o===`false`){t.push({t:G.False});continue}if(o===`null`){t.push({t:G.Null});continue}let s=i>=`A`&&i<=`Z`?G.Type:G.Ident;t.push({t:s,v:o})}else if(i===`@`&&n+1<r&&(e.charAt(n+1)>=`a`&&e.charAt(n+1)<=`z`||e.charAt(n+1)>=`A`&&e.charAt(n+1)<=`Z`||e.charAt(n+1)===`_`)){n++;let i=n;for(;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;t.push({t:G.BuiltinCall,v:e.slice(i,n)})}else n++}return t.push({t:G.EOF}),t}function ui(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.type===`element`&&typeof t.typeName==`string`&&typeof t.props==`object`&&t.props!==null&&typeof t.partial==`boolean`}var di;(function(e){e.ContinueConversation=`continue_conversation`,e.OpenUrl=`open_url`})(di||(di={}));const fi={},pi=[];function mi(e){return Array.isArray(e)?`array`:typeof e}function hi(e){return typeof e.$ref==`string`?e.$ref.split(`/`).pop():void 0}function gi(e){return`$ref`in e||`anyOf`in e||`oneOf`in e||`allOf`in e}function _i(e){if(Array.isArray(e.enum))return{enumValues:e.enum};if(`const`in e)return{enumValues:[e.const]};switch(e.type){case`string`:return{expectedType:`string`};case`number`:case`integer`:return{expectedType:`number`};case`boolean`:return{expectedType:`boolean`};default:return{}}}function vi(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e.default}function yi(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=hi(t);if(n)return n;let r=_i(t);return r.enumValues?r.enumValues.map(e=>JSON.stringify(e)).join(`|`):r.expectedType?r.expectedType:typeof t.type==`string`?t.type:void 0}function bi(e,t){return`${e}(${t.map(e=>{let t=yi(e.schema),n=e.required?`${e.name}*`:e.name;return t?`${n}: ${t}`:n}).join(`, `)})`}function xi(e,t){let n=typeof e;return t.enumValues?t.enumValues.includes(e)?null:{expected:`one of [${t.enumValues.map(e=>JSON.stringify(e)).join(`, `)}]`,actual:mi(e)}:t.expectedType&&t.expectedType!==n?{expected:t.expectedType,actual:mi(e)}:null}function Si(e,t,n){switch(n.code){case`type-mismatch`:return`field "${t}" expects ${n.expected} but got ${n.actual}`;case`pruned-value`:return`field "${t}" lost an unresolved or invalid value`;case`missing-required`:return`missing required field "${t}"${n.signature?` — signature: ${n.signature}`:``}`;case`null-required`:return`required field "${t}" cannot be null${n.signature?` — signature: ${n.signature}`:``}`;case`unknown-component`:return`Unknown component "${e}" — not found in catalog or builtins${n.available?.length?`. Available components: ${n.available.join(`, `)}`:``}`;case`inline-reserved`:return`${e}() must be declared as a top-level statement, not used inline as a value`;case`excess-args`:return`${e} takes ${n.declared} arg(s), got ${n.got} (${n.got-n.declared} excess dropped)`;case`unknown-function`:return`Unknown function "@${e}": not a built-in or action step. The call evaluates to null`;case`no-root`:return n.reason===`not-component`?`root does not evaluate to a component`:n.reason===`fallback`?`No root statement. Rendering the first statement that calls the root component ${e}`:e?`No root statement, and no statement calls the root component ${e}`:`No root statement`}}function Ci(e,t,n,r){e.errors.push({code:r.code,component:t,path:n,message:Si(t,n,r),statementId:e.currentStatementId,...r.code===`no-root`&&r.reason===`fallback`&&{severity:`warning`}})}const wi=Symbol(`invalid`);function Ti(e,t){return t===void 0?e?wi:void 0:t}function Ei(e,t,n,r,i){return gi(t)?!1:typeof t.type==`string`||Array.isArray(t.enum)||`const`in t?(Ci(i,n,r,{code:`type-mismatch`,expected:typeof t.type==`string`?t.type:`a literal value`,actual:`component "${e.typeName}"`}),!0):!1}function Di(e){return(e.anyOf??e.oneOf??[e]).map(hi)}function Oi(e,t){let n=Di(e);return n.length>0&&n.every(e=>e!==void 0&&t.cat?.has(e))}function ki(e,t,n,r,i){if(typeof e!=`object`||Array.isArray(e))return Ci(i,n,r,{code:`type-mismatch`,expected:`object`,actual:mi(e)}),wi;let a=e,o,s=t.properties&&typeof t.properties==`object`?t.properties:fi,c=Array.isArray(t.required)?t.required:pi,l=!1;if(!i.partial)for(let e of c){let t=e in a;if(!t||a[e]==null){let c=vi(s[e]);if(c!==void 0){(o??(o={...a}))[e]=c;continue}Ci(i,n,`${r}/${e}`,{code:t?`null-required`:`missing-required`}),l=!0}}for(let e of Object.keys(s)){if(!(e in a))continue;let t=s[e],u=Mi(a[e],t,n,`${r}/${e}`,i);u===wi&&(u=Ti(c.includes(e),vi(t)),u===wi)?l=!0:u!==a[e]&&(o??(o={...a}),u===void 0?delete o[e]:o[e]=u)}return l?wi:o??a}function Ai(e,t,n,r,i){if(!Array.isArray(e))return Ci(i,n,r,{code:`type-mismatch`,expected:`array`,actual:mi(e)}),wi;let a=t.items;if(!a||typeof a!=`object`||Array.isArray(a))return e;let o;for(let t=0;t<e.length;t++){let s=Mi(e[t],a,n,`${r}/${t}`,i);s!==e[t]&&!o&&(o=e.slice(0,t)),o&&s!==wi&&o.push(s)}return o??e}function ji(e,t,n,r,i){let a=_i(t);if(a.expectedType==null&&a.enumValues==null||a.enumValues&&i.partial)return!1;let o=xi(e,a);return o?(Ci(i,n,r,{code:`type-mismatch`,...o}),!0):!1}function Mi(e,t,n,r,i){if(!t||typeof t!=`object`||Array.isArray(t))return e;let a=t;if(e==null||Qr(e))return e;if(ui(e))return Ei(e,a,n,r,i)?wi:e;if(gi(a))return Oi(a,i)?(Ci(i,n,r,{code:`type-mismatch`,expected:Di(a).join(` | `),actual:Array.isArray(e)?`array`:typeof e==`object`?`plain object`:typeof e}),wi):e;let o=a.type;return o===`object`?ki(e,a,n,r,i):o===`array`?Ai(e,a,n,r,i):ji(e,a,n,r,i)?wi:e}function Ni(e){if(typeof e!=`object`||!e)return!1;if(Qr(e))return!0;if(Array.isArray(e))return e.some(Ni);if(ui(e))return Object.values(e.props).some(Ni);let t=e;return Array.isArray(t.steps)?!0:Object.values(t).some(Ni)}function Pi(e,t,n){if(t.visited.has(e))return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;let r=t.syms.get(e);if(!r)return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;if(t.unreached?.delete(e),r.k===`Comp`&&si(r.name))return{k:`RuntimeRef`,n:e,refType:r.name===ii.Mutation?`mutation`:`query`};t.visited.add(e);let i=t.currentStatementId;t.currentStatementId=e;try{let i=n===`value`?Ui(r,t):Hi(r,t);return n===`value`&&ui(i)&&(i.statementId=e),i}finally{t.currentStatementId=i,t.visited.delete(e)}}function Fi(e,t){return ai(t.cat).has(e)||si(e)}function Ii(e,t){let n={};for(let[r,i]of t.entries()){let t=e[r];if(t===void 0)break;n[i.name]=t}return n}function Li(e,t,n,r){let{params:i}=n;t.length>i.length&&Ci(r,e,``,{code:`excess-args`,declared:i.length,got:t.length});let a=Ii(t,i),o=!1,s=r.errors.length;for(let t of i){let n=a[t.name],s=n?ti(n):{v:void 0};if(!s)continue;if(s.v==null){if(!t.required||t.defaultValue!==void 0)continue;Ci(r,e,`/${t.name}`,{code:n?`null-required`:`missing-required`,signature:bi(e,i)}),o=!0;continue}let c=Mi(s.v,t.schema,e,`/${t.name}`,r);c===wi&&(c=Ti(t.required,t.defaultValue)),c===wi?o=!0:c===void 0?delete a[t.name]:c!==s.v&&(a[t.name]=ei(c))}return n.kind===`action`&&r.errors.length>s&&(o=!0),o?null:a}function Ri(e,t,n){let r=e.args.map(n),i=ai(t.cat).get(e.name);if(!i||i.lazy)return{...e,args:r};let a=i.builtin?Ii(r,i.params):Li(e.name,r,i,t);return a?{...e,args:r,mappedProps:a}:i.kind===`action`?{k:`Comp`,name:`Action`,args:[{k:`Arr`,els:[]}]}:{k:`Null`}}function zi(e,t,n){let r=t.currentStatementId;t.currentStatementId=n;let i=/* @__PURE__ */ new Set;for(let n of e)$r(n,e=>{if(e.k!==`Comp`||i.has(e))return;i.add(e);let n=ai(t.cat).get(e.name);n&&!n.lazy&&(e.mappedProps=(n.builtin?null:Li(e.name,e.args,n,t))??Ii(e.args,n.params))});t.currentStatementId=r}function Bi(e,t,n){let r=ai(t.cat).get(e.name);if(r?.kind!==`function`||!r.lazy||e.args.length<3)return null;let i=e.args[1];if(!i)return null;let a=i.k===`Ref`?i.n:i.k===`Str`?i.v:null;if(!a)return null;let o=new Set(n);o.add(a);let s=e.args.map((e,n)=>n===1?e:Vi(e,t,o));return{...e,args:s}}function Vi(e,t,n){switch(e.k){case`Ref`:return n.has(e.n)?e:Pi(e.n,t,`expr`);case`Ph`:return e;case`Comp`:{if(e.fn&&!Fi(e.name,t))return Ci(t,e.name,``,{code:`unknown-function`}),{k:`Null`};let r=Bi(e,t,n);if(r)return r;if(Fi(e.name,t))return Ri(e,t,e=>Vi(e,t,n));let i=e.args.map(e=>Vi(e,t,n)),a=t.cat?.get(e.name);if(a){let t={};for(let[e,n]of a.params.entries()){let r=i[e];r&&(t[n.name]=r)}return{...e,args:i,mappedProps:t}}return Ci(t,e.name,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),{...e,args:i}}case`Arr`:return{...e,els:e.els.map(e=>Vi(e,t,n))};case`Obj`:return{...e,entries:e.entries.map(([e,r])=>[e,Vi(r,t,n)])};case`BinOp`:return{...e,left:Vi(e.left,t,n),right:Vi(e.right,t,n)};case`UnaryOp`:return{...e,operand:Vi(e.operand,t,n)};case`Ternary`:return{...e,cond:Vi(e.cond,t,n),then:Vi(e.then,t,n),else:Vi(e.else,t,n)};case`Member`:return{...e,obj:Vi(e.obj,t,n)};case`Index`:return{...e,obj:Vi(e.obj,t,n),index:Vi(e.index,t,n)};case`Assign`:return{...e,value:Vi(e.value,t,n)};default:return e}}function Hi(e,t){return Vi(e,t,/* @__PURE__ */ new Set)}function Ui(e,t){switch(e.k){case`Ref`:return Pi(e.n,t,`value`);case`Str`:return e.v;case`Num`:return e.v;case`Bool`:return e.v;case`Null`:return null;case`Ph`:return null;case`Arr`:{let n=[];for(let r of e.els){if(r.k===`Ph`){t.prunedValues++;continue}let e=Ui(r,t);e===null&&(r.k===`Comp`||r.k===`Ref`)?t.prunedValues++:n.push(e)}return n}case`Obj`:{let n={};for(let[r,i]of e.entries)n[r]=Ui(i,t);return n}case`Comp`:{let{name:n,args:r}=e;if(e.fn&&!Fi(n,t))return Ci(t,n,``,{code:`unknown-function`}),null;if(si(n))return Ci(t,n,``,{code:`inline-reserved`}),null;if(Fi(n,t))return Bi(e,t,/* @__PURE__ */ new Set)||Ri(e,t,e=>Hi(e,t));let i=t.cat?.get(n),a={};if(i){let e=!1;for(let[o,s]of i.params.entries()){let i=r[o];if(!i)break;let c=t.prunedValues,l=Ui(i,t);if(t.prunedValues>c&&Ci(t,n,`/${s.name}`,{code:`pruned-value`}),a[s.name]=l,s.schema===void 0)continue;if(l==null&&s.defaultValue!==void 0){Ci(t,n,`/${s.name}`,{code:`type-mismatch`,expected:yi(s.schema)??`a defined value`,actual:l===null?`null`:`undefined`}),a[s.name]=s.defaultValue,t.prunedValues=c;continue}let u=Mi(l,s.schema,n,`/${s.name}`,t);u===wi&&(u=Ti(s.required,s.defaultValue),s.defaultValue!==void 0&&(t.prunedValues=c),u===wi?e=!0:u===void 0&&delete a[s.name]),u!==wi&&u!==void 0&&(a[s.name]=u)}r.length>i.params.length&&Ci(t,n,``,{code:`excess-args`,declared:i.params.length,got:r.length});let o=i.params.filter(e=>e.required&&(!(e.name in a)||a[e.name]===null));if(o.length){let e=o.filter(e=>e.defaultValue===void 0||(Ci(t,n,`/${e.name}`,{code:e.name in a?`null-required`:`missing-required`}),a[e.name]=e.defaultValue,!1));if(e.length){for(let r of e)Ci(t,n,`/${r.name}`,{code:r.name in a?`null-required`:`missing-required`,signature:bi(n,i.params)});return null}}if(e)return null}else return Ci(t,n,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),null;let o=Object.values(a).some(e=>Ni(e));return{type:`element`,typeName:n,props:a,partial:t.partial,hasDynamicProps:o}}default:return Xr(e)?Hi(e,t):e}}function Wi(e){let t=[],n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i];r?r=!1:a===`\\`&&n?r=!0:n?a===n&&(n=!1):a===`"`||a===`'`?n=a:a===`(`||a===`[`||a===`{`?t.push(a):(a===`)`&&t[t.length-1]===`(`||a===`]`&&t[t.length-1]===`[`||a===`}`&&t[t.length-1]===`{`)&&t.pop()}if(!(n||t.length>0))return{text:e,wasIncomplete:!1};let i=e;n&&(r&&(i+=`\\`),i+=n);for(let e=t.length-1;e>=0;e--)i+=t[e]===`(`?`)`:t[e]===`[`?`]`:`}`;return{text:i,wasIncomplete:!0}}function Gi(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&e[n]?.t===G.Newline;)n++;if(n>=e.length||e[n]?.t===G.EOF)break;let r=e[n];if(!r)break;if(r.t!==G.Ident&&r.t!==G.Type&&r.t!==G.StateVar){for(;n<e.length&&e[n]?.t!==G.Newline&&e[n]?.t!==G.EOF;)n++;continue}let i=r.v,a=r.t;if(n++,n>=e.length||e[n]?.t!==G.Equals){for(;n<e.length&&e[n]?.t!==G.Newline&&e[n]?.t!==G.EOF;)n++;continue}n++;let o=[],s=0,c=0;for(;n<e.length&&e[n]?.t!==G.EOF;){let t=e[n]?.t;if(t===G.Newline&&s<=0&&c<=0){let t=n+1;for(;t<e.length&&e[t]?.t===G.Newline;)t++;let r=t<e.length?e[t]?.t:G.EOF;if(r===G.Question||r===G.Colon&&c>0){n++;continue}break}if(t===G.Newline){n++;continue}t===G.LParen||t===G.LBrack||t===G.LBrace?s++:(t===G.RParen||t===G.RBrack||t===G.RBrace)&&s>0?s--:t===G.Question&&s===0?c++:t===G.Colon&&s===0&&c>0&&c--;let r=e[n++];r&&o.push(r)}o.length&&t.push({id:i,idTokenType:a,tokens:o})}return t}function Ki(e=!0){return{root:null,meta:{incomplete:e,unresolved:[],orphaned:[],statementCount:0,errors:[]},stateDeclarations:{},queryStatements:[],mutationStatements:[]}}function qi(e){if(!Qr(e))return[];let t=/* @__PURE__ */ new Set;return $r(e,e=>{e.k===`StateRef`&&t.add(e.n)}),[...t]}function Ji(e,t){if(t.k===`Comp`&&t.name===ii.Query){let n=qi(t.args[1]);return{kind:`query`,id:e.id,call:{callee:ii.Query,args:t.args},expr:t,deps:n.length>0?n:void 0}}return t.k===`Comp`&&t.name===ii.Mutation?{kind:`mutation`,id:e.id,call:{callee:ii.Mutation,args:t.args},expr:t}:e.idTokenType===G.StateVar?{kind:`state`,id:e.id,init:t}:{kind:`value`,id:e.id,expr:t}}function Yi(e,t,n){let r={},i=[],a=[];for(let n of e)switch(n.kind){case`state`:r[n.id]=Ui(n.init,t);break;case`query`:zi(n.call.args,t,n.id),i.push({statementId:n.id,toolAST:n.call.args[0]??null,argsAST:n.call.args[1]??null,defaultsAST:n.call.args[2]??null,refreshAST:n.call.args[3]??null,deps:n.deps,complete:!0});break;case`mutation`:zi(n.call.args,t,n.id),a.push({statementId:n.id,toolAST:n.call.args[0]??null,argsAST:n.call.args[1]??null})}for(let t of e){let e=t.kind===`state`?[t.init]:t.kind===`value`?[t.expr]:t.kind===`query`||t.kind===`mutation`?t.call.args:[];for(let i of e)for(let e of qi(i))e===n?.name&&n.stmts.has(t)||e in r||(r[e]=null)}return{stateDeclarations:r,queryStatements:i,mutationStatements:a}}const Xi=`root`;function Zi(e){return e?.k===`Comp`&&!e.fn&&!oi(e.name)&&!si(e.name)}function Qi(e,t){if(e.has(Xi))return{id:Xi,fallback:!1};for(let n of e.values())if(n.kind===`value`&&Zi(n.expr)&&n.expr.name===t)return{id:n.id,fallback:!0};return null}function $i(e,t){let n=/* @__PURE__ */ new Set;for(;e?.k===`Ref`&&!n.has(e.n);)n.add(e.n),e=t.get(e.n);return Zi(e)}function ea(e){let t=!1;return $r(e,e=>{Zi(e)&&(t=!0)}),t}function ta(e,t,n,r,i,a,o){let s=Qi(e,a),c=/* @__PURE__ */ new Map;for(let[t,n]of e)c.set(t,n.kind===`state`?n.init:n.expr);let l=[],u=[],d=/* @__PURE__ */ new Set;for(let[t,n]of e)t!==s?.id&&n.kind!==`state`&&n.kind!==`query`&&n.kind!==`mutation`&&d.add(t);let f={syms:c,cat:i,errors:u,unres:l,prunedValues:0,visited:/* @__PURE__ */ new Set,partial:n,currentStatementId:s?.id,unreached:d},p=null,m,h=s&&c.get(s.id);if(s&&h){let e=Ui(h,f);ui(e)?(p=e,p.statementId=s.id):Qr(e)&&ea(e)&&(m=e)}let{stateDeclarations:g,queryStatements:_,mutationStatements:v}=Yi(t,f,o);f.currentStatementId=s?.id;let y=a??``;s?!p&&!m&&!$i(c.get(s.id),c)?Ci(f,y,``,{code:`no-root`,reason:`not-component`}):s.fallback&&Ci(f,y,``,{code:`no-root`,reason:p?`fallback`:`missing`}):Ci(f,y,``,{code:`no-root`,reason:`missing`});let b=s?[...d]:[];return{root:p,...m?{rootExpression:m}:{},meta:{incomplete:n,unresolved:l,orphaned:b,statementCount:r,errors:u},stateDeclarations:g,queryStatements:_,mutationStatements:v}}function na(e,t){if(e[t]!==`"`)return t;let n=t+1;for(;n<e.length;){let t=e[n];if(t===`\\`)n+=2;else if(t===`"`)return n+1;else n++}return n}function ra(e){let t=[],n=0;for(;n<e.length;){let r=-1;for(;n<e.length;){let t=na(e,n);if(t>n)n=t;else{if(e[n]==="`"&&n+1<e.length&&e[n+1]==="`"&&n+2<e.length&&e[n+2]==="`"){r=n;break}n++}}if(r===-1)break;let i=r+3;for(;i<e.length&&e[i]!==`
14
+ `;)i++;if(i>=e.length){t.push(e.slice(r+3).replace(/^[^\n]*\n?/,``)),n=e.length;break}i++;let a=-1,o=i;for(;o<e.length;){let t=na(e,o);if(t>o)o=t;else{if(e[o]==="`"&&o+1<e.length&&e[o+1]==="`"&&o+2<e.length&&e[o+2]==="`"){a=o;break}o++}}a===-1?(t.push(e.slice(i)),n=e.length):(t.push(e.slice(i,a)),n=a+3)}if(t.length>0)return t.join(`
15
15
  `);if(e.startsWith("```")){let t=3;for(;t<e.length&&e[t]!==`
16
- `;)t++;let n=t<e.length?t+1:3,r=e.slice(n),i=r.lastIndexOf("```");return i===-1?r:r.slice(0,i)}return e}function na(e){let t=!1;return e.split(`
16
+ `;)t++;let n=t<e.length?t+1:3,r=e.slice(n),i=r.lastIndexOf("```");return i===-1?r:r.slice(0,i)}return e}function ia(e){let t=!1;return e.split(`
17
17
  `).map(e=>{for(let n=0;n<e.length;n++){let r=e[n];if(t){if(r===`\\`&&n+1<e.length){n++;continue}r===t&&(t=!1)}else if(r===`"`||r===`'`)t=r;else if(r===`/`&&e[n+1]===`/`||r===`#`)return e.substring(0,n).trimEnd()}return e}).join(`
18
- `)}function ra(e){return na(ta(e.trim())).trim()}function ia(e,t,n){let r=ra(e);if(!r)return Wi();let{text:i,wasIncomplete:a}=Hi(r),o=Ui(si(i));if(!o.length)return Wi(a);let s=/* @__PURE__ */ new Map;for(let e of o){let t=Ki(e,oi(e.tokens));s.set(e.id,t)}return $i(s,[...s.values()],a,s.size,t,n)}function aa(e,t){let n=``,r=``,i=0,a=/* @__PURE__ */ new Map,o=0;function s(e){let t=e.trim();if(t)for(let e of Ui(si(t))){let t=Ki(e,oi(e.tokens));a.set(e.id,t),o++}}function c(){let e=ra(n);e.startsWith(r.slice(0,i))||(i=0,a.clear(),o=0),r=e}function l(){let e=0,t=0,n=!1,a=!1,o=i;for(let c=i;c<r.length;c++){let l=r[c];if(a)a=!1;else if(l===`\\`&&n)a=!0;else if(n)l===n&&(n=!1);else if(l===`"`||l===`'`)n=l;else if(l===`(`||l===`[`||l===`{`)e++;else if(l===`)`||l===`]`||l===`}`)e=Math.max(0,e-1);else if(l===`?`&&e===0)t++;else if(l===`:`&&e===0&&t>0)t--;else if(l===`
18
+ `)}function aa(e){return ia(ra(e.trim())).trim()}function oa(e,t,n){let r=aa(e);if(!r)return Ki();let{text:i,wasIncomplete:a}=Wi(r),o=Gi(li(i));if(!o.length)return Ki(a);let s=/* @__PURE__ */ new Map;for(let e of o){let t=Ji(e,ci(e.tokens));s.set(e.id,t)}return ta(s,[...s.values()],a,s.size,t,n)}function sa(e,t){let n=``,r=``,i=0,a=/* @__PURE__ */ new Map,o=0;function s(e){let t=e.trim();if(t)for(let e of Gi(li(t))){let t=Ji(e,ci(e.tokens));a.set(e.id,t),o++}}function c(){let e=aa(n);e.startsWith(r.slice(0,i))||(i=0,a.clear(),o=0),r=e}function l(){let e=0,t=0,n=!1,a=!1,o=i;for(let c=i;c<r.length;c++){let l=r[c];if(a)a=!1;else if(l===`\\`&&n)a=!0;else if(n)l===n&&(n=!1);else if(l===`"`||l===`'`)n=l;else if(l===`(`||l===`[`||l===`{`)e++;else if(l===`)`||l===`]`||l===`}`)e=Math.max(0,e-1);else if(l===`?`&&e===0)t++;else if(l===`:`&&e===0&&t>0)t--;else if(l===`
19
19
  `&&e<=0&&t<=0){let e=c+1;for(;e<r.length&&(r[e]===` `||r[e]===` `||r[e]===`\r`||r[e]===`
20
- `);)e++;if(e<r.length&&(r[e]===`?`||r[e]===`:`&&t>0))continue;let n=r.slice(o,c).trim();n&&s(n),o=c+1,i=c+1}}return o}function u(i=!1){c();let s=l(),u=r.slice(s).trim(),d=i?u:u.replace(/(\d)\.$/,`$1`);if(!d)return o===0?Wi():$i(a,[...a.values()],!1,o,e,t);let{text:f,wasIncomplete:p}=Hi(d),m=Ui(si(f));if(!m.length)return o===0?Wi(p):$i(a,[...a.values()],p,o,e,t);let h=new Map(a),g=/* @__PURE__ */ new Set;for(let e of m){if(a.has(e.id)&&p)continue;let t=Ki(e,oi(e.tokens));h.set(e.id,t),g.add(t)}let _=i?void 0:/\$\w+$/.exec(n)?.[0],v=_&&d.endsWith(_)&&!RegExp(`\\${_}(?!\\w)`).test(d.slice(0,-_.length))?_:void 0;return $i(h,[...h.values()],p,o+m.length,e,t,v?{name:v,stmts:g}:void 0)}function d(){n=``,r=``,i=0,a.clear(),o=0}return{push(e,t){return n+=e,u(t)},set(e,t){(e.length<n.length||!e.startsWith(n))&&d();let r=e.slice(n.length);return r&&(n+=r),u(t)},getResult:u}}function oa(e,t){if(!e||typeof e!=`object`)return e;let n=e.$ref;if(typeof n==`string`)return t.has(n)?oa(t.get(n),t):e;let r=Array.isArray(e)?[...e]:{...e},i=!1;for(let[e,n]of Object.entries(r))r[e]=oa(n,t),i||(i=r[e]!==n);return i?r:e}function sa(e,t){let n=e.properties??{},r=e.required??[];return Object.keys(n).map(e=>({name:e,required:r.includes(e),defaultValue:gi(n[e]),schema:t.size?oa(n[e],t):n[e]}))}function ca(e){let t=/* @__PURE__ */ new Map,n=e.properties&&new Set(Object.keys(e.properties)),r=/* @__PURE__ */ new Map;for(let t of[...Object.keys(ti),...Object.keys(e.actions??{})]){let i=e.$defs?.[t];i&&!n?.has(t)&&r.set(`#/$defs/${t}`,i)}for(let[i,a]of Object.entries(e.$defs??{}))(n?!n.has(i):r.has(`#/$defs/${i}`))||t.set(i,{params:sa(a,r)});t.callDefs=new Map(ei);for(let[n,i]of Object.entries(e.functions??{}))t.callDefs.set(n,{kind:`function`,params:sa(i.params,r)});for(let[n,i]of Object.entries(e.actions??{}))t.callDefs.set(n,{kind:`action`,params:sa(i.params,r)});return t}const la=qr.schema.$defs;function ua(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function da(e,t){if(e.$ref)return fa(t)&&t.typeName===e.$ref.split(`/`).at(-1);if(e.anyOf)return e.anyOf.some(e=>da(e,t));if(e.enum&&!e.enum.includes(t))return!1;switch(e.type){case`string`:return typeof t==`string`&&(e.pattern===void 0||new RegExp(e.pattern,`u`).test(t));case`integer`:return Number.isInteger(t);case`number`:return typeof t==`number`&&Number.isFinite(t);case`boolean`:return typeof t==`boolean`;case`array`:return Array.isArray(t)&&t.length>=(e.minItems??0)&&t.every(t=>e.items===void 0||da(e.items,t));case`object`:{if(!ua(t)||!(e.required??[]).every(e=>Object.hasOwn(t,e)))return!1;let{properties:n={},additionalProperties:r}=e;return Object.entries(t).every(([e,t])=>{let i=Object.hasOwn(n,e)?n[e]:void 0;return i?da(i,t):typeof r==`object`?da(r,t):r!==!1})}default:return!0}}function fa(e){if(!ua(e)||typeof e.typeName!=`string`||typeof e.statementId!=`string`||e.typeName===qr.root)return!1;let t=Object.hasOwn(la,e.typeName)?la[e.typeName]:void 0;return t!==void 0&&da(t,e.props)}const pa=ca(qr.schema),ma={parse(e){return ia(e,pa,qr.root)}};function ha(){return aa(pa,qr.root)}const ga=qr.schema.$defs,_a=new Map(Object.entries(ga).map(([e,t])=>[e,new Set(t.properties?.children?.items?.anyOf?.map(e=>e.$ref?.split(`/`).at(-1)))])),va=new Set(Object.entries(ga).flatMap(([e,t])=>Object.values(t.properties??{}).some(e=>e.type===`object`||e.items?.type===`object`)?[e]:[]));function ya(){let e=ha(),t=[];return function(n,r){let i=ba(e.set(n,!r),r,n,xa(t));return r&&t.length>0&&(i.error||i.elements.length===0)?{...i,error:!1,elements:t}:(t=i.elements,i)}}function ba(e,t,n,r){let i=Sa(e,t,n,r);return!t&&(i.error||i.diagnostics.errors.length>0||i.diagnostics.unresolved.length>0||i.diagnostics.incomplete)&&console.warn(`Generative UI diagnostics`,{error:i.error,partial:i.partial,diagnostics:i.diagnostics}),i}function xa(e,t=/* @__PURE__ */ new Map){for(let n of e)t.set(n.statementId,n),`children`in n.props&&xa(n.props.children,t);return t}function Sa(e,t,n,r){let i=t&&!/\n\s*$/.test(n??``)?n?.match(/^\w+(?=\s*=)/gm)?.at(-1):void 0,a=e.root?.props.children,o=/* @__PURE__ */ new Set,s=e.meta,c=e.meta.errors.some(e=>e.severity!==`warning`&&!(e.component===`Grid`&&e.path===`/columns`||e.component===`Cell`&&e.path===`/span`));function l(t,n,r){s===e.meta&&(s={...e.meta,errors:[...e.meta.errors]}),s.errors.push({code:`type-mismatch`,component:t.typeName,path:n,message:r,statementId:t.statementId}),c=!0}function u(n,a,s){if(!ci(n)||typeof n.statementId!=`string`||o.has(n.statementId)){l(a,`/children/${s}`,`Child must be a valid, uniquely named component`);return}if(!_a.get(a.typeName)?.has(n.typeName)){l(a,`/children/${s}`,`Component is not allowed at this nesting level`);return}if(o.add(n.statementId),va.has(n.typeName)&&n.statementId===i)return r?.get(n.statementId);if((n.typeName===`Chart`||n.typeName===`Table`)&&e.meta.errors.some(e=>e.statementId===n.statementId&&e.severity!==`warning`))return;let d=(n.typeName===`Grid`||n.typeName===`Cell`||n.typeName===`Carousel`)&&Array.isArray(n.props.children)?n.props.children.flatMap((e,t)=>{let r=u(e,n,t);return r?[r]:[]}):void 0,f=!1;function p(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t==null?[]:[[e,m(t)]]))}function m(e){return Array.isArray(e)?(e.some(e=>e==null)&&(f=!0),e.flatMap(e=>e==null?[]:[m(e)])):typeof e==`object`&&e&&!ci(e)?p(e):e}let h=p(n.props);if(f&&(n.typeName===`Chart`||n.typeName===`Table`)){l(n,``,`A list item is missing`);return}f&&(c=!0);let g={...n,props:{...h,...d&&{children:d}}};if(!fa(g))l(n,``,`Component does not match the catalog`);else if(g.typeName===`Table`&&g.props.rows.some(e=>e.length!==g.props.columns.length))l(n,`/rows`,`Every table row must contain one value per column`);else if(g.typeName===`Chart`&&!Ar(g.props))l(n,`/data`,`Every chart point must contain one value per series, and a pie one value`);else if(d?.length!==0&&(g.typeName!==`Chart`&&g.typeName!==`Table`||!t&&!e.meta.incomplete))return g}let d=e.root,f=d&&Array.isArray(a)?a.flatMap((e,t)=>{if(ci(e)&&e.typeName===`Cell`)return l(d,`/children/${t}`,`Cell must be inside a Grid`),[];let n=u(e,d,t);return n&&n.typeName!==`Cell`?[n]:[]}):[],p=d?.hasDynamicProps===!0||e.queryStatements.length>0||e.mutationStatements.length>0||Object.keys(e.stateDeclarations).length>0||e.meta.errors.some(e=>e.code===`unknown-function`||e.code===`inline-reserved`);p&&d&&l(d,``,`Executable content is not supported by the static catalog`),d&&d.typeName!==qr.root&&l(d,``,`The block must use the catalog root component`);let m=p||d!==null&&d.typeName!==qr.root||!t&&(!Array.isArray(a)||f.length===0),h=!t&&!m&&(c||e.meta.incomplete);return{elements:m?[]:f,error:m,partial:h,diagnostics:s}}function Ca(e,t){return Sa(ma.parse(e),!1).elements.flatMap(e=>wa(e,t)).join(`
20
+ `);)e++;if(e<r.length&&(r[e]===`?`||r[e]===`:`&&t>0))continue;let n=r.slice(o,c).trim();n&&s(n),o=c+1,i=c+1}}return o}function u(i=!1){c();let s=l(),u=r.slice(s).trim(),d=i?u:u.replace(/(\d)\.$/,`$1`);if(!d)return o===0?Ki():ta(a,[...a.values()],!1,o,e,t);let{text:f,wasIncomplete:p}=Wi(d),m=Gi(li(f));if(!m.length)return o===0?Ki(p):ta(a,[...a.values()],p,o,e,t);let h=new Map(a),g=/* @__PURE__ */ new Set;for(let e of m){if(a.has(e.id)&&p)continue;let t=Ji(e,ci(e.tokens));h.set(e.id,t),g.add(t)}let _=i?void 0:/\$\w+$/.exec(n)?.[0],v=_&&d.endsWith(_)&&!RegExp(`\\${_}(?!\\w)`).test(d.slice(0,-_.length))?_:void 0;return ta(h,[...h.values()],p,o+m.length,e,t,v?{name:v,stmts:g}:void 0)}function d(){n=``,r=``,i=0,a.clear(),o=0}return{push(e,t){return n+=e,u(t)},set(e,t){(e.length<n.length||!e.startsWith(n))&&d();let r=e.slice(n.length);return r&&(n+=r),u(t)},getResult:u}}function ca(e,t){if(!e||typeof e!=`object`)return e;let n=e.$ref;if(typeof n==`string`)return t.has(n)?ca(t.get(n),t):e;let r=Array.isArray(e)?[...e]:{...e},i=!1;for(let[e,n]of Object.entries(r))r[e]=ca(n,t),i||(i=r[e]!==n);return i?r:e}function la(e,t){let n=e.properties??{},r=e.required??[];return Object.keys(n).map(e=>({name:e,required:r.includes(e),defaultValue:vi(n[e]),schema:t.size?ca(n[e],t):n[e]}))}function ua(e){let t=/* @__PURE__ */ new Map,n=e.properties&&new Set(Object.keys(e.properties)),r=/* @__PURE__ */ new Map;for(let t of[...Object.keys(ri),...Object.keys(e.actions??{})]){let i=e.$defs?.[t];i&&!n?.has(t)&&r.set(`#/$defs/${t}`,i)}for(let[i,a]of Object.entries(e.$defs??{}))(n?!n.has(i):r.has(`#/$defs/${i}`))||t.set(i,{params:la(a,r)});t.callDefs=new Map(ni);for(let[n,i]of Object.entries(e.functions??{}))t.callDefs.set(n,{kind:`function`,params:la(i.params,r)});for(let[n,i]of Object.entries(e.actions??{}))t.callDefs.set(n,{kind:`action`,params:la(i.params,r)});return t}const da=Yr.schema.$defs;function fa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pa(e,t){if(e.$ref)return ma(t)&&t.typeName===e.$ref.split(`/`).at(-1);if(e.anyOf)return e.anyOf.some(e=>pa(e,t));if(e.enum&&!e.enum.includes(t))return!1;switch(e.type){case`string`:return typeof t==`string`&&(e.pattern===void 0||new RegExp(e.pattern,`u`).test(t));case`integer`:return Number.isInteger(t);case`number`:return typeof t==`number`&&Number.isFinite(t);case`boolean`:return typeof t==`boolean`;case`array`:return Array.isArray(t)&&t.length>=(e.minItems??0)&&t.every(t=>e.items===void 0||pa(e.items,t));case`object`:{if(!fa(t)||!(e.required??[]).every(e=>Object.hasOwn(t,e)))return!1;let{properties:n={},additionalProperties:r}=e;return Object.entries(t).every(([e,t])=>{let i=Object.hasOwn(n,e)?n[e]:void 0;return i?pa(i,t):typeof r==`object`?pa(r,t):r!==!1})}default:return!0}}function ma(e){if(!fa(e)||typeof e.typeName!=`string`||typeof e.statementId!=`string`||e.typeName===Yr.root)return!1;let t=Object.hasOwn(da,e.typeName)?da[e.typeName]:void 0;return t!==void 0&&pa(t,e.props)}const ha=ua(Yr.schema),ga={parse(e){return oa(e,ha,Yr.root)}};function _a(){return sa(ha,Yr.root)}const va=Yr.schema.$defs,ya=new Map(Object.entries(va).map(([e,t])=>[e,new Set(t.properties?.children?.items?.anyOf?.map(e=>e.$ref?.split(`/`).at(-1)))])),ba=new Set(Object.entries(va).flatMap(([e,t])=>Object.values(t.properties??{}).some(e=>e.type===`object`||e.items?.type===`object`)?[e]:[]));function xa(){let e=_a(),t=[];return function(n,r){let i=Sa(e.set(n,!r),r,n,Ca(t));return r&&t.length>0&&(i.error||i.elements.length===0)?{...i,error:!1,elements:t}:(t=i.elements,i)}}function Sa(e,t,n,r){let i=wa(e,t,n,r);return!t&&(i.error||i.diagnostics.errors.length>0||i.diagnostics.unresolved.length>0||i.diagnostics.incomplete)&&console.warn(`Generative UI diagnostics`,{error:i.error,partial:i.partial,diagnostics:i.diagnostics}),i}function Ca(e,t=/* @__PURE__ */ new Map){for(let n of e)t.set(n.statementId,n),`children`in n.props&&Ca(n.props.children,t);return t}function wa(e,t,n,r){let i=t&&!/\n\s*$/.test(n??``)?n?.match(/^\w+(?=\s*=)/gm)?.at(-1):void 0,a=e.root?.props.children,o=/* @__PURE__ */ new Set,s=e.meta,c=e.meta.errors.some(e=>e.severity!==`warning`&&!(e.component===`Grid`&&e.path===`/columns`||e.component===`Cell`&&e.path===`/span`));function l(t,n,r){s===e.meta&&(s={...e.meta,errors:[...e.meta.errors]}),s.errors.push({code:`type-mismatch`,component:t.typeName,path:n,message:r,statementId:t.statementId}),c=!0}function u(n,a,s){if(!ui(n)||typeof n.statementId!=`string`||o.has(n.statementId)){l(a,`/children/${s}`,`Child must be a valid, uniquely named component`);return}if(!ya.get(a.typeName)?.has(n.typeName)){l(a,`/children/${s}`,`Component is not allowed at this nesting level`);return}if(o.add(n.statementId),ba.has(n.typeName)&&n.statementId===i)return r?.get(n.statementId);if((n.typeName===`Chart`||n.typeName===`Table`)&&e.meta.errors.some(e=>e.statementId===n.statementId&&e.severity!==`warning`))return;let d=(n.typeName===`Grid`||n.typeName===`Cell`||n.typeName===`Carousel`)&&Array.isArray(n.props.children)?n.props.children.flatMap((e,t)=>{let r=u(e,n,t);return r?[r]:[]}):void 0,f=!1;function p(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t==null?[]:[[e,m(t)]]))}function m(e){return Array.isArray(e)?(e.some(e=>e==null)&&(f=!0),e.flatMap(e=>e==null?[]:[m(e)])):typeof e==`object`&&e&&!ui(e)?p(e):e}let h=p(n.props);if(f&&(n.typeName===`Chart`||n.typeName===`Table`)){l(n,``,`A list item is missing`);return}f&&(c=!0);let g={...n,props:{...h,...d&&{children:d}}};if(!ma(g))l(n,``,`Component does not match the catalog`);else if(g.typeName===`Table`&&g.props.rows.some(e=>e.length!==g.props.columns.length))l(n,`/rows`,`Every table row must contain one value per column`);else if(g.typeName===`Chart`&&!Ar(g.props))l(n,`/data`,`Every chart point must contain one value per series, and a pie one value`);else if(d?.length!==0&&(g.typeName!==`Chart`&&g.typeName!==`Table`||!t&&!e.meta.incomplete))return g}let d=e.root,f=d&&Array.isArray(a)?a.flatMap((e,t)=>{if(ui(e)&&e.typeName===`Cell`)return l(d,`/children/${t}`,`Cell must be inside a Grid`),[];let n=u(e,d,t);return n&&n.typeName!==`Cell`?[n]:[]}):[],p=d?.hasDynamicProps===!0||e.queryStatements.length>0||e.mutationStatements.length>0||Object.keys(e.stateDeclarations).length>0||e.meta.errors.some(e=>e.code===`unknown-function`||e.code===`inline-reserved`);p&&d&&l(d,``,`Executable content is not supported by the static catalog`),d&&d.typeName!==Yr.root&&l(d,``,`The block must use the catalog root component`);let m=p||d!==null&&d.typeName!==Yr.root||!t&&(!Array.isArray(a)||f.length===0),h=!t&&!m&&(c||e.meta.incomplete);return{elements:m?[]:f,error:m,partial:h,diagnostics:s}}function Ta(e,t){return wa(ga.parse(e),!1).elements.flatMap(e=>Ea(e,t)).join(`
21
21
 
22
- `)}function wa(e,t){switch(e.typeName){case`Grid`:case`Cell`:case`Carousel`:return e.props.children.flatMap(e=>wa(e,t));case`Text`:return[e.props.text];case`Card`:return[`${e.props.title}\n${e.props.body}`];case`Metric`:return[[e.props.label,e.props.value,e.props.change?.text,e.props.detail].filter(Boolean).join(`
22
+ `)}function Ea(e,t){switch(e.typeName){case`Grid`:case`Cell`:case`Carousel`:return e.props.children.flatMap(e=>Ea(e,t));case`Text`:return[e.props.text];case`Card`:return[`${e.props.title}\n${e.props.body}`];case`Metric`:return[[e.props.label,e.props.value,e.props.change?.text,e.props.detail].filter(Boolean).join(`
23
23
  `)];case`Table`:return[[e.props.title,e.props.columns.join(` `),...e.props.rows.map(e=>e.join(` `))].join(`
24
24
  `)];case`Chart`:return[[e.props.title,...e.props.series?.length?[e.props.series.join(`, `)]:[],...e.props.data.map(e=>`${e.label}: ${kr(e.value).join(`, `)}`)].join(`
25
25
  `)];case`Product`:return[[e.props.product.title,_r(e.props.product.price,t),e.props.product.description,...e.props.product.details??[]].filter(Boolean).join(`
26
- `)];case`Cart`:return[[...e.props.cart.lines.map(e=>Ea(e,t)),...e.props.cart.totals.map(e=>Da(e,t))].join(`
27
- `)];case`Order`:return[[`${e.props.order.number} · ${e.props.order.status}`,...e.props.order.details??[],...e.props.order.items.map(e=>Ea(e,t)),...e.props.order.totals.map(e=>Da(e,t))].join(`
28
- `)];case`Flight`:return[[...e.props.flight.legs.map(e=>Ta(e,t)),[e.props.flight.fare,_r(e.props.flight.price,t),e.props.flight.priceNote].filter(Boolean).join(` · `),...e.props.flight.details??[]].join(`
26
+ `)];case`Cart`:return[[...e.props.cart.lines.map(e=>Oa(e,t)),...e.props.cart.totals.map(e=>ka(e,t))].join(`
27
+ `)];case`Order`:return[[`${e.props.order.number} · ${e.props.order.status}`,...e.props.order.details??[],...e.props.order.items.map(e=>Oa(e,t)),...e.props.order.totals.map(e=>ka(e,t))].join(`
28
+ `)];case`Flight`:return[[...e.props.flight.legs.map(e=>Da(e,t)),[e.props.flight.fare,_r(e.props.flight.price,t),e.props.flight.priceNote].filter(Boolean).join(` · `),...e.props.flight.details??[]].join(`
29
29
  `)];case`Stay`:return[[e.props.stay.name,e.props.stay.location,Cr(e.props.stay.checkIn,e.props.stay.checkOut,t),e.props.stay.room,_r(e.props.stay.price,t),...e.props.stay.details??[]].filter(Boolean).join(`
30
30
  `)];case`Package`:return[[e.props.package.title,e.props.package.location,Cr(e.props.package.start,e.props.package.end,t),[_r(e.props.package.price,t),e.props.package.priceNote].filter(Boolean).join(` `),...e.props.package.details??[]].filter(Boolean).join(`
31
- `)];case`Booking`:return[[`${e.props.booking.reference} · ${e.props.booking.status}`,e.props.booking.title,Cr(e.props.booking.start,e.props.booking.end,t),e.props.booking.travellers?.join(`, `),...(e.props.booking.itinerary??[]).map(e=>[e.date&&Sr(e.date,t),e.time,e.title,e.detail].filter(Boolean).join(` · `)),...(e.props.booking.totals??[]).map(e=>Da(e,t)),...e.props.booking.details??[]].filter(Boolean).join(`
32
- `)]}}function Ta(e,t){let n=xr(e.departs,e.arrives);return`${[e.carrier,e.number].filter(Boolean).join(` `)}: ${e.from} ${Sr(e.departs,t)} ${yr(e.departs,t)} → ${e.to} ${yr(e.arrives,t)}${n?` +${n}`:``}`}function Ea(e,t){return`${[e.title,...Object.values(e.options??{})].join(`, `)} × ${e.quantity}: ${_r(e.price,t)}`}function Da(e,t){return`${e.label}: ${_r(e.amount,t)}`}function Oa(e,{cssPrefix:t,strings:r,locale:i,onAction:a}){let s=[],c=o(!1),l;return{...y.default_renderer(e),set_attr(e,u,d){if(u!==y.LANG||d!==`openui`||e.index!==1)return y.default_set_attr(e,u,d);let f=document.createElement(`div`);e.nodes[e.index]?.parentElement?.replaceWith(f),l={textSig:o(``),doneSig:o(!1)},s.push(f),n(_(ka,{cssPrefix:t,textSig:l.textSig,doneSig:l.doneSig,replyDoneSig:c,strings:r,locale:i,onAction:a}),f)},add_text(e,t){l?l.textSig.value=l.textSig.peek()+t:y.default_add_text(e,t)},end_token(e){l&&(l.doneSig.value=!0,l=void 0),y.default_end_token(e)},finish(){l&&(l.doneSig.value=!0),c.value=!0},dispose(){for(let e of s)n(null,e);s.length=0,l=void 0}}}function ka({textSig:e,doneSig:t,replyDoneSig:n,cssPrefix:r,strings:a,locale:o,onAction:s}){let c=p(()=>{let n=ya();return i(()=>n(e.value,!t.value))},[e,t]),l={cssPrefix:r,strings:a,locale:o,onAction:s,busy:!n.value};return c.value.error?_(`div`,{role:`alert`,children:a.visualError}):v(`div`,{class:`${r}-generative-ui`,"aria-busy":!t.value,children:[c.value.elements.map(e=>_(Aa,{element:e,context:l},e.statementId)),c.value.partial&&_(`p`,{role:`status`,children:a.visualPartial}),c.value.elements.length===0&&!t.value?_(`span`,{role:`status`,children:a.visualPreparing}):null]})}function Aa({element:e,context:t}){let{cssPrefix:n}=t;if(e.typeName===`Grid`)return _(`div`,{class:`${n}-generative-ui-grid-container`,children:_(`div`,{class:`${n}-generative-ui-grid`,"data-columns":e.props.columns,"data-equal-heights":zr(e.props.children)||void 0,children:e.props.children.map(e=>_(`div`,{class:`${n}-generative-ui-cell`,"data-span":e.typeName===`Cell`?e.props.span??1:1,children:e.typeName===`Cell`?e.props.children.map(e=>_(Aa,{element:e,context:t},e.statementId)):_(Aa,{element:e,context:t})},e.statementId))})});switch(e.typeName){case`Carousel`:return _(`div`,{role:`list`,class:`${n}-generative-ui-carousel`,children:e.props.children.map(e=>_(`div`,{role:`listitem`,children:_(Aa,{element:e,context:t})},e.statementId))});case`Text`:return _(`p`,{children:e.props.text});case`Card`:return v(`section`,{class:`${n}-generative-ui-card`,children:[Vr(e.props.image)&&_(Pa,{src:e.props.image,class:`${n}-generative-ui-photo`,wide:!0}),_(`strong`,{class:`${n}-generative-ui-title`,title:e.props.title,children:e.props.title}),_(`p`,{children:e.props.body}),_(Na,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Product`:return _(ja,{...e.props,context:t});case`Flight`:return _(za,{...e.props,context:t});case`Stay`:case`Package`:return _(Ra,{element:e,context:t});case`Booking`:{let{booking:r}=e.props;return v(`section`,{class:`${n}-generative-ui-sheet`,children:[v(`div`,{class:`${n}-generative-ui-heading`,children:[_(`strong`,{dir:`ltr`,children:r.reference}),_(`span`,{class:`${n}-generative-ui-pill`,children:r.status})]}),r.title&&_(`strong`,{children:r.title}),_(Ia,{parts:[Cr(r.start,r.end,t.locale),r.travellers?.length&&`${t.strings.visualTravellers}: ${r.travellers.join(`, `)}`],context:t}),r.itinerary?.length?_(`ol`,{class:`${n}-generative-ui-itinerary`,children:r.itinerary.map((e,r)=>v(`li`,{children:[_(`span`,{class:`${n}-generative-ui-muted`,children:[e.date&&Sr(e.date,t.locale),e.time].filter(Boolean).join(` · `)}),_(`strong`,{children:e.title}),e.detail&&_(`span`,{class:`${n}-generative-ui-muted`,children:e.detail})]},r))}):null,_(Wa,{totals:r.totals??[],context:t}),_(La,{details:r.details,context:t}),_(Na,{actions:e.props.actions,context:t,disabled:t.busy})]})}case`Cart`:return v(`section`,{class:`${n}-generative-ui-sheet`,children:[e.props.cart.messages?.map(e=>_(`p`,{role:e.severity===`info`?`status`:`alert`,class:`${n}-generative-ui-notice`,"data-severity":e.severity,children:e.text},e.text)),e.props.cart.lines.length?_(Ma,{lines:e.props.cart.lines,context:t}):_(`p`,{class:`${n}-generative-ui-muted`,children:t.strings.visualCartEmpty}),e.props.cart.lines.length>0&&_(Wa,{totals:e.props.cart.totals,context:t}),_(Na,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Order`:return v(`section`,{class:`${n}-generative-ui-sheet`,children:[v(`div`,{class:`${n}-generative-ui-heading`,children:[_(`strong`,{dir:`ltr`,children:e.props.order.number}),_(`span`,{class:`${n}-generative-ui-pill`,children:e.props.order.status})]}),e.props.order.date&&_(`p`,{class:`${n}-generative-ui-muted`,children:vr(e.props.order.date,t.locale)}),_(La,{details:e.props.order.details,context:t}),e.props.order.timeline?.length?_(`ol`,{class:`${n}-generative-ui-timeline`,children:e.props.order.timeline.map(e=>v(`li`,{"data-done":e.done,children:[_(`span`,{children:e.label}),e.date&&_(`span`,{class:`${n}-generative-ui-muted`,children:vr(e.date,t.locale)})]},e.label))}):null,_(Ma,{lines:e.props.order.items,context:t}),_(Wa,{totals:e.props.order.totals,context:t}),_(Na,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Metric`:{let t=Fr(e.props.trend);return v(`section`,{children:[_(`strong`,{children:e.props.label}),v(`div`,{class:`${n}-generative-ui-metric`,children:[_(`span`,{children:e.props.value}),t&&_(`svg`,{viewBox:`0 0 80 24`,"aria-hidden":`true`,children:_(`polyline`,{points:t,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linejoin":`round`,"stroke-linecap":`round`})})]}),e.props.change&&_(`span`,{class:`${n}-generative-ui-change`,"data-tone":e.props.change.tone,children:e.props.change.text}),e.props.detail&&_(`p`,{children:e.props.detail})]})}case`Table`:return _(Va,{...e.props,context:t});case`Chart`:return _(Ga,{element:e,context:t})}}function ja({product:e,actions:t,context:n}){let{cssPrefix:r,strings:i}=n,[a,o]=h({}),s=Kr(e,a),c=Hr(t,n.onAction!==void 0).some(e=>e.message!==void 0);return v(`section`,{class:`${r}-generative-ui-offer`,children:[_(Fa,{image:s.image,url:e.url,badge:e.badge,available:s.available,context:n}),_(`strong`,{class:`${r}-generative-ui-title`,title:e.title,children:_(Ha,{title:e.title,url:e.url})}),_(Ua,{price:s.price,compareAtPrice:s.compareAtPrice,context:n}),_(Ia,{parts:[],rating:e.rating,context:n}),e.description&&_(`p`,{class:`${r}-generative-ui-description`,title:e.description,children:e.description}),_(La,{details:e.details,context:n}),v(`div`,{class:`${r}-generative-ui-footer`,children:[s.options.map(e=>v(`fieldset`,{class:`${r}-generative-ui-option`,children:[_(`legend`,{children:e.name}),_(qa,{children:e.values.map(t=>_(`button`,{type:`button`,"aria-pressed":e.value===t,disabled:e.unavailable.includes(t),onClick:()=>o({...a,[e.name]:t}),children:t},t))})]},e.name)),c&&_(`p`,{class:`${r}-generative-ui-hint`,children:s.missing.length>0&&`${i.visualChoose} ${s.missing.join(`, `)}`}),_(Na,{actions:t,context:n,disabled:n.busy||!s.canBuy,getMessage:t=>Ur(t,e.title,s.chosen)})]})]})}function Ma({lines:e,context:t}){let{cssPrefix:n,strings:r}=t;if(!e.length)return null;let i=e.some(e=>e.image);return _(`ul`,{class:`${n}-generative-ui-lines`,children:e.map((e,a)=>v(`li`,{children:[i&&_(Pa,{src:e.image??``,class:`${n}-generative-ui-thumb`},e.image),v(`div`,{children:[v(`div`,{class:`${n}-generative-ui-line-head`,children:[_(`span`,{children:_(Ha,{title:e.title,url:e.url})}),_(`strong`,{children:_r(e.price,t.locale)})]}),_(`span`,{class:`${n}-generative-ui-muted`,children:[...Object.entries(e.options??{}).map(([e,t])=>`${e}: ${t}`),`${r.visualQuantity} ${e.quantity}`].join(` · `)}),_(Na,{actions:e.actions,context:t,disabled:t.busy,small:!0,getMessage:t=>Ur(t,e.title,e.options)})]})]},a))})}function Na({actions:e,context:t,disabled:n,small:r,getMessage:i}){let a=Hr(e,t.onAction!==void 0);return a.length?_(`div`,{class:`${t.cssPrefix}-generative-ui-actions`,"data-small":r,children:a.map(e=>{if(e.message===void 0)return _(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-primary":e.primary,title:e.label,children:_(`span`,{children:e.label})},e.label);let r=e.message;return _(`button`,{type:`button`,disabled:n,"data-primary":e.primary,title:e.label,onClick:()=>t.onAction?.(i?.(r)??r),children:_(`span`,{children:e.label})},e.label)})}):null}function Pa({src:e,href:t,class:n,wide:r,children:i}){let[a,o]=h(!1),s=!a&&Vr(e)&&_(`img`,{src:e,alt:``,loading:`lazy`,referrerpolicy:`no-referrer`,onError:()=>o(!0)});return Vr(t)?v(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,tabIndex:-1,"aria-hidden":`true`,class:n,"data-wide":r,children:[s,i]}):v(`span`,{class:n,"data-wide":r,children:[s,i]})}function Fa({image:e,url:t,badge:n,available:r,context:{cssPrefix:i,strings:a}}){let o=(n||!r)&&v(`span`,{class:`${i}-generative-ui-badges`,children:[n&&_(`span`,{class:`${i}-generative-ui-pill`,children:n}),!r&&_(`span`,{class:`${i}-generative-ui-pill`,children:a.visualSoldOut})]});return Vr(e)?_(Pa,{src:e,href:t,class:`${i}-generative-ui-photo`,children:o},e):o||null}function Ia({parts:e,rating:t,context:{cssPrefix:n}}){let r=e.filter(e=>typeof e==`string`&&e).join(` · `);return!r&&!t?null:v(`span`,{class:`${n}-generative-ui-muted`,children:[t&&v(g,{children:[v(`span`,{"aria-hidden":`true`,class:`${n}-generative-ui-star`,children:[`★`,` `]}),Or(t),t.count!==void 0&&` (${t.count})`,r&&` · `]}),r]})}function La({details:e,context:{cssPrefix:t}}){return e?.length?_(`ul`,{class:`${t}-generative-ui-details`,children:e.map(e=>_(`li`,{children:e},e))}):null}function Ra({element:e,context:t}){let{cssPrefix:n,locale:r}=t,i=Dr(e,t.strings,r);return v(`section`,{class:`${n}-generative-ui-offer`,children:[_(Fa,{image:i.image,url:i.url,badge:i.badge,available:i.available,context:t}),v(`strong`,{class:`${n}-generative-ui-title`,title:i.title,children:[_(Ha,{title:i.title,url:i.url}),i.stars!==void 0&&i.stars>0&&v(`span`,{class:`${n}-generative-ui-stars`,role:`img`,"aria-label":`${i.stars} ★`,children:[` `,`★`.repeat(Math.min(i.stars,5))]})]}),_(Ia,{parts:[i.location],rating:i.rating,context:t}),_(Ia,{parts:[i.when],context:t}),i.room&&_(`p`,{children:i.room}),_(La,{details:i.details,context:t}),v(`div`,{class:`${n}-generative-ui-footer`,children:[_(Ua,{price:i.price,compareAtPrice:i.compareAtPrice,note:i.note,context:t}),_(Na,{actions:e.props.actions,context:t,disabled:t.busy||!i.available,getMessage:e=>Ur(e,i.title,void 0)})]})]})}function za({flight:e,actions:t,context:n}){let{cssPrefix:r,strings:i,locale:a}=n;return v(`section`,{class:`${r}-generative-ui-flight`,children:[e.legs.map((e,t)=>_(Ba,{leg:e,strings:i,locale:a,cssPrefix:r},t)),_(La,{details:e.details,context:n}),v(`div`,{class:`${r}-generative-ui-footer`,children:[_(Fa,{image:void 0,url:void 0,badge:e.badge,available:e.available!==!1,context:n}),_(Ua,{price:e.price,compareAtPrice:void 0,note:[e.fare,e.priceNote].filter(Boolean).join(` · `),context:n}),_(Na,{actions:t,context:n,disabled:n.busy||e.available===!1,getMessage:t=>Ur(t,Wr(e),void 0)})]})]})}function Ba({leg:e,strings:t,locale:n,cssPrefix:r}){let i=xr(e.departs,e.arrives),a=Tr(e,t,n);return v(`div`,{class:`${r}-generative-ui-leg`,children:[_(`span`,{class:`${r}-generative-ui-muted`,children:[e.carrier,e.number,Sr(e.departs,n)].filter(Boolean).join(` · `)}),v(`div`,{class:`${r}-generative-ui-leg-times`,children:[v(`span`,{children:[_(`strong`,{children:yr(e.departs,n)}),_(`span`,{children:e.from})]}),_(`span`,{class:`${r}-generative-ui-leg-path`,children:a}),v(`span`,{children:[v(`strong`,{children:[yr(e.arrives,n),i!==void 0&&v(`sup`,{children:[`+`,i]})]}),_(`span`,{children:e.to})]})]})]})}function Va({title:e,columns:t,rows:n,context:{cssPrefix:r,locale:i}}){let[a,o]=h(void 0),s=Lr(t,n),c=Rr(n,a&&{...a,numeric:s[a.column]??!1},i);return _(`section`,{class:`${r}-generative-ui-table-card`,children:_(`div`,{class:`${r}-generative-ui-table`,children:v(`table`,{children:[_(`caption`,{children:e}),_(`thead`,{children:_(`tr`,{children:t.map((e,t)=>_(`th`,{scope:`col`,"data-numeric":s[t],"aria-sort":a?.column===t?a.descending?`descending`:`ascending`:void 0,children:_(`button`,{type:`button`,onClick:()=>o({column:t,descending:a?.column===t&&!a.descending}),children:e})},t))})}),_(`tbody`,{children:c.map((e,n)=>_(`tr`,{children:e.map((e,n)=>_(`td`,{"data-numeric":s[n],"data-label":t[n],children:e},n))},n))})]})})})}function Ha({title:e,url:t}){return Vr(t)?_(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:e}):_(g,{children:e})}function Ua({price:e,compareAtPrice:t,note:n,context:{cssPrefix:r,locale:i}}){return v(`span`,{class:`${r}-generative-ui-price`,children:[_(`strong`,{children:_r(e,i)}),t&&Gr(e,t)&&_(`s`,{children:_r(t,i)}),n&&_(`span`,{class:`${r}-generative-ui-muted`,children:n})]})}function Wa({totals:e,context:{cssPrefix:t,locale:n}}){return e.length?_(`dl`,{class:`${t}-generative-ui-totals`,children:e.map(e=>v(`div`,{children:[_(`dt`,{children:e.label}),_(`dd`,{children:_r(e.amount,n)})]},e.label))}):null}function Ga({element:e,context:{cssPrefix:t,locale:n}}){let{type:r,data:i,series:a=[],title:o}=e.props,{baseline:s,barWidth:c,series:l,labels:u,ticks:d,slices:f}=Mr(e.props,n),p=[`currentColor`,...jr],m=r===`pie`?i.map((e,t)=>`${e.label} ${Math.round((f[t]?.share??0)*100)}%`):l.length>1?a:[];return v(`section`,{children:[_(`strong`,{children:o}),v(`svg`,{class:`${t}-generative-ui-chart`,viewBox:`0 0 320 168`,role:`img`,"aria-label":`${o}. ${a.length>1?`${a.join(` / `)}. `:``}${i.map(e=>`${e.label}: ${kr(e.value).join(` / `)}`).join(`, `)}`,children:[r===`pie`?f.map((e,t)=>_(`path`,{d:e.path,fill:p[t%p.length]},t)):l.map((e,t)=>r===`line`?v(`g`,{fill:p[t%p.length],children:[_(`polyline`,{points:e.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:p[t%p.length],"stroke-width":2.5,"stroke-linejoin":`round`}),e.map((e,t)=>_(`circle`,{cx:e.x,cy:e.y,r:3},t))]},t):_(`g`,{fill:p[t%p.length],children:e.map((e,t)=>_(`rect`,{x:e.x-c/2,y:Math.min(e.y,s),width:c,height:Math.abs(e.y-s),rx:2},t))},t)),r!==`pie`&&v(`g`,{class:`${t}-generative-ui-axis`,children:[_(`line`,{x1:24,x2:296,y1:s,y2:s}),u.map((e,t)=>_(`text`,{x:e.x,y:164,"text-anchor":`middle`,children:e.text},t)),d.map(e=>_(`text`,{x:20,y:e.y+3,"text-anchor":`end`,children:e.text},e.text))]})]}),m.length>0&&_(`ul`,{class:`${t}-generative-ui-legend`,children:m.map((e,t)=>_(`li`,{style:{color:t?p[t%p.length]:void 0},children:_(`span`,{children:e})},t))})]})}function Ka(e,t){if(!e.includes("```openui"))return e;let n=``,r=0,i=0,a=0,o=0,s;function c(i){s?.language===`openui`&&(n+=e.slice(r,s.start)+Ca(s.source,t)+(e[i-1]===`
31
+ `)];case`Booking`:return[[`${e.props.booking.reference} · ${e.props.booking.status}`,e.props.booking.title,Cr(e.props.booking.start,e.props.booking.end,t),e.props.booking.travellers?.join(`, `),...(e.props.booking.itinerary??[]).map(e=>[e.date&&Sr(e.date,t),e.time,e.title,e.detail].filter(Boolean).join(` · `)),...(e.props.booking.totals??[]).map(e=>ka(e,t)),...e.props.booking.details??[]].filter(Boolean).join(`
32
+ `)]}}function Da(e,t){let n=xr(e.departs,e.arrives);return`${[e.carrier,e.number].filter(Boolean).join(` `)}: ${e.from} ${Sr(e.departs,t)} ${yr(e.departs,t)} → ${e.to} ${yr(e.arrives,t)}${n?` +${n}`:``}`}function Oa(e,t){return`${[e.title,...Object.values(e.options??{})].join(`, `)} × ${e.quantity}: ${_r(e.price,t)}`}function ka(e,t){return`${e.label}: ${_r(e.amount,t)}`}function Aa(e,{cssPrefix:t,strings:r,locale:i,onAction:a}){let s=[],c=o(!1),l;return{...y.default_renderer(e),set_attr(e,u,d){if(u!==y.LANG||d!==`openui`||e.index!==1)return y.default_set_attr(e,u,d);let f=document.createElement(`div`);e.nodes[e.index]?.parentElement?.replaceWith(f),l={textSig:o(``),doneSig:o(!1)},s.push(f),n(_(ja,{cssPrefix:t,textSig:l.textSig,doneSig:l.doneSig,replyDoneSig:c,strings:r,locale:i,onAction:a}),f)},add_text(e,t){l?l.textSig.value=l.textSig.peek()+t:y.default_add_text(e,t)},end_token(e){l&&(l.doneSig.value=!0,l=void 0),y.default_end_token(e)},finish(){l&&(l.doneSig.value=!0),c.value=!0},dispose(){for(let e of s)n(null,e);s.length=0,l=void 0}}}function ja({textSig:e,doneSig:t,replyDoneSig:n,cssPrefix:r,strings:a,locale:o,onAction:s}){let c=p(()=>{let n=xa();return i(()=>n(e.value,!t.value))},[e,t]),l={cssPrefix:r,strings:a,locale:o,onAction:s,busy:!n.value};return c.value.error?_(`div`,{role:`alert`,children:a.visualError}):v(`div`,{class:`${r}-generative-ui`,"aria-busy":!t.value,children:[c.value.elements.map(e=>_(Ma,{element:e,context:l},e.statementId)),c.value.partial&&_(`p`,{role:`status`,children:a.visualPartial}),c.value.elements.length===0&&!t.value?_(`span`,{role:`status`,children:a.visualPreparing}):null]})}function Ma({element:e,context:t}){let{cssPrefix:n}=t;if(e.typeName===`Grid`)return _(`div`,{class:`${n}-generative-ui-grid-container`,children:_(`div`,{class:`${n}-generative-ui-grid`,"data-equal-heights":Vr(e.props.children)||void 0,style:Object.fromEntries([2,3,4].map(t=>[`--${n}-cols-${t}`,Br(e.props.children.map(zr),Math.min(t,e.props.columns))])),children:e.props.children.map(e=>_(`div`,{class:`${n}-generative-ui-cell`,style:{[`--${n}-span`]:zr(e)},children:e.typeName===`Cell`?e.props.children.map(e=>_(Ma,{element:e,context:t},e.statementId)):_(Ma,{element:e,context:t})},e.statementId))})});switch(e.typeName){case`Carousel`:return _(`div`,{role:`list`,class:`${n}-generative-ui-carousel`,children:e.props.children.map(e=>_(`div`,{role:`listitem`,children:_(Ma,{element:e,context:t})},e.statementId))});case`Text`:return _(`p`,{children:e.props.text});case`Card`:return v(`section`,{class:`${n}-generative-ui-card`,children:[Ur(e.props.image)&&_(Ia,{src:e.props.image,class:`${n}-generative-ui-photo`,wide:!0}),_(`strong`,{class:`${n}-generative-ui-title`,title:e.props.title,children:e.props.title}),_(`p`,{children:e.props.body}),_(Fa,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Product`:return _(Na,{...e.props,context:t});case`Flight`:return _(Va,{...e.props,context:t});case`Stay`:case`Package`:return _(Ba,{element:e,context:t});case`Booking`:{let{booking:r}=e.props;return v(`section`,{class:`${n}-generative-ui-sheet`,children:[v(`div`,{class:`${n}-generative-ui-heading`,children:[_(`strong`,{dir:`ltr`,children:r.reference}),_(`span`,{class:`${n}-generative-ui-pill`,children:r.status})]}),r.title&&_(`strong`,{children:r.title}),_(Ra,{parts:[Cr(r.start,r.end,t.locale),r.travellers?.length&&`${t.strings.visualTravellers}: ${r.travellers.join(`, `)}`],context:t}),r.itinerary?.length?_(`ol`,{class:`${n}-generative-ui-itinerary`,children:r.itinerary.map((e,r)=>v(`li`,{children:[_(`span`,{class:`${n}-generative-ui-muted`,children:[e.date&&Sr(e.date,t.locale),e.time].filter(Boolean).join(` · `)}),_(`strong`,{children:e.title}),e.detail&&_(`span`,{class:`${n}-generative-ui-muted`,children:e.detail})]},r))}):null,_(Ka,{totals:r.totals??[],context:t}),_(za,{details:r.details,context:t}),_(Fa,{actions:e.props.actions,context:t,disabled:t.busy})]})}case`Cart`:return v(`section`,{class:`${n}-generative-ui-sheet`,children:[e.props.cart.messages?.map(e=>_(`p`,{role:e.severity===`info`?`status`:`alert`,class:`${n}-generative-ui-notice`,"data-severity":e.severity,children:e.text},e.text)),e.props.cart.lines.length?_(Pa,{lines:e.props.cart.lines,context:t}):_(`p`,{class:`${n}-generative-ui-muted`,children:t.strings.visualCartEmpty}),e.props.cart.lines.length>0&&_(Ka,{totals:e.props.cart.totals,context:t}),_(Fa,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Order`:return v(`section`,{class:`${n}-generative-ui-sheet`,children:[v(`div`,{class:`${n}-generative-ui-heading`,children:[_(`strong`,{dir:`ltr`,children:e.props.order.number}),_(`span`,{class:`${n}-generative-ui-pill`,children:e.props.order.status})]}),e.props.order.date&&_(`p`,{class:`${n}-generative-ui-muted`,children:vr(e.props.order.date,t.locale)}),_(za,{details:e.props.order.details,context:t}),e.props.order.timeline?.length?_(`ol`,{class:`${n}-generative-ui-timeline`,children:e.props.order.timeline.map(e=>v(`li`,{"data-done":e.done,children:[_(`span`,{children:e.label}),e.date&&_(`span`,{class:`${n}-generative-ui-muted`,children:vr(e.date,t.locale)})]},e.label))}):null,_(Pa,{lines:e.props.order.items,context:t}),_(Ka,{totals:e.props.order.totals,context:t}),_(Fa,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Metric`:{let t=Fr(e.props.trend);return v(`section`,{children:[_(`strong`,{children:e.props.label}),v(`div`,{class:`${n}-generative-ui-metric`,children:[_(`span`,{children:e.props.value}),t&&_(`svg`,{viewBox:`0 0 80 24`,"aria-hidden":`true`,children:_(`polyline`,{points:t,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linejoin":`round`,"stroke-linecap":`round`})})]}),e.props.change&&_(`span`,{class:`${n}-generative-ui-change`,"data-tone":e.props.change.tone,children:e.props.change.text}),e.props.detail&&_(`p`,{children:e.props.detail})]})}case`Table`:return _(Ua,{...e.props,context:t});case`Chart`:return _(qa,{element:e,context:t})}}function Na({product:e,actions:t,context:n}){let{cssPrefix:r,strings:i}=n,[a,o]=h({}),s=Jr(e,a),c=Wr(t,n.onAction!==void 0).some(e=>e.message!==void 0);return v(`section`,{class:`${r}-generative-ui-offer`,children:[_(La,{image:s.image,url:e.url,badge:e.badge,available:s.available,context:n}),_(`strong`,{class:`${r}-generative-ui-title`,title:e.title,children:_(Wa,{title:e.title,url:e.url})}),_(Ga,{price:s.price,compareAtPrice:s.compareAtPrice,context:n}),_(Ra,{parts:[],rating:e.rating,context:n}),e.description&&_(`p`,{class:`${r}-generative-ui-description`,title:e.description,children:e.description}),_(za,{details:e.details,context:n}),v(`div`,{class:`${r}-generative-ui-footer`,children:[s.options.map(e=>v(`fieldset`,{class:`${r}-generative-ui-option`,children:[_(`legend`,{children:e.name}),_(Ya,{children:e.values.map(t=>_(`button`,{type:`button`,"aria-pressed":e.value===t,disabled:e.unavailable.includes(t),onClick:()=>o({...a,[e.name]:t}),children:t},t))})]},e.name)),c&&_(`p`,{class:`${r}-generative-ui-hint`,children:s.missing.length>0&&`${i.visualChoose} ${s.missing.join(`, `)}`}),_(Fa,{actions:t,context:n,disabled:n.busy||!s.canBuy,getMessage:t=>Gr(t,e.title,s.chosen)})]})]})}function Pa({lines:e,context:t}){let{cssPrefix:n,strings:r}=t;if(!e.length)return null;let i=e.some(e=>e.image);return _(`ul`,{class:`${n}-generative-ui-lines`,children:e.map((e,a)=>v(`li`,{children:[i&&_(Ia,{src:e.image??``,class:`${n}-generative-ui-thumb`},e.image),v(`div`,{children:[v(`div`,{class:`${n}-generative-ui-line-head`,children:[_(`span`,{children:_(Wa,{title:e.title,url:e.url})}),_(`strong`,{children:_r(e.price,t.locale)})]}),_(`span`,{class:`${n}-generative-ui-muted`,children:[...Object.entries(e.options??{}).map(([e,t])=>`${e}: ${t}`),`${r.visualQuantity} ${e.quantity}`].join(` · `)}),_(Fa,{actions:e.actions,context:t,disabled:t.busy,small:!0,getMessage:t=>Gr(t,e.title,e.options)})]})]},a))})}function Fa({actions:e,context:t,disabled:n,small:r,getMessage:i}){let a=Wr(e,t.onAction!==void 0);return a.length?_(`div`,{class:`${t.cssPrefix}-generative-ui-actions`,"data-small":r,children:a.map(e=>{if(e.message===void 0)return _(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-primary":e.primary,title:e.label,children:_(`span`,{children:e.label})},e.label);let r=e.message;return _(`button`,{type:`button`,disabled:n,"data-primary":e.primary,title:e.label,onClick:()=>t.onAction?.(i?.(r)??r),children:_(`span`,{children:e.label})},e.label)})}):null}function Ia({src:e,href:t,class:n,wide:r,children:i}){let[a,o]=h(!1),s=!a&&Ur(e)&&_(`img`,{src:e,alt:``,loading:`lazy`,referrerpolicy:`no-referrer`,onError:()=>o(!0)});return Ur(t)?v(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,tabIndex:-1,"aria-hidden":`true`,class:n,"data-wide":r,children:[s,i]}):v(`span`,{class:n,"data-wide":r,children:[s,i]})}function La({image:e,url:t,badge:n,available:r,context:{cssPrefix:i,strings:a}}){let o=(n||!r)&&v(`span`,{class:`${i}-generative-ui-badges`,children:[n&&_(`span`,{class:`${i}-generative-ui-pill`,children:n}),!r&&_(`span`,{class:`${i}-generative-ui-pill`,children:a.visualSoldOut})]});return Ur(e)?_(Ia,{src:e,href:t,class:`${i}-generative-ui-photo`,children:o},e):o||null}function Ra({parts:e,rating:t,context:{cssPrefix:n}}){let r=e.filter(e=>typeof e==`string`&&e).join(` · `);return!r&&!t?null:v(`span`,{class:`${n}-generative-ui-muted`,children:[t&&v(g,{children:[v(`span`,{"aria-hidden":`true`,class:`${n}-generative-ui-star`,children:[`★`,` `]}),Or(t),t.count!==void 0&&` (${t.count})`,r&&` · `]}),r]})}function za({details:e,context:{cssPrefix:t}}){return e?.length?_(`ul`,{class:`${t}-generative-ui-details`,children:e.map(e=>_(`li`,{children:e},e))}):null}function Ba({element:e,context:t}){let{cssPrefix:n,locale:r}=t,i=Dr(e,t.strings,r);return v(`section`,{class:`${n}-generative-ui-offer`,children:[_(La,{image:i.image,url:i.url,badge:i.badge,available:i.available,context:t}),v(`strong`,{class:`${n}-generative-ui-title`,title:i.title,children:[_(Wa,{title:i.title,url:i.url}),i.stars!==void 0&&i.stars>0&&v(`span`,{class:`${n}-generative-ui-stars`,role:`img`,"aria-label":`${i.stars} ★`,children:[` `,`★`.repeat(Math.min(i.stars,5))]})]}),_(Ra,{parts:[i.location],rating:i.rating,context:t}),_(Ra,{parts:[i.when],context:t}),i.room&&_(`p`,{children:i.room}),_(za,{details:i.details,context:t}),v(`div`,{class:`${n}-generative-ui-footer`,children:[_(Ga,{price:i.price,compareAtPrice:i.compareAtPrice,note:i.note,context:t}),_(Fa,{actions:e.props.actions,context:t,disabled:t.busy||!i.available,getMessage:e=>Gr(e,i.title,void 0)})]})]})}function Va({flight:e,actions:t,context:n}){let{cssPrefix:r,strings:i,locale:a}=n;return v(`section`,{class:`${r}-generative-ui-flight`,children:[e.legs.map((e,t)=>_(Ha,{leg:e,strings:i,locale:a,cssPrefix:r},t)),_(za,{details:e.details,context:n}),v(`div`,{class:`${r}-generative-ui-footer`,children:[_(La,{image:void 0,url:void 0,badge:e.badge,available:e.available!==!1,context:n}),_(Ga,{price:e.price,compareAtPrice:void 0,note:[e.fare,e.priceNote].filter(Boolean).join(` · `),context:n}),_(Fa,{actions:t,context:n,disabled:n.busy||e.available===!1,getMessage:t=>Gr(t,Kr(e),void 0)})]})]})}function Ha({leg:e,strings:t,locale:n,cssPrefix:r}){let i=xr(e.departs,e.arrives),a=Tr(e,t,n);return v(`div`,{class:`${r}-generative-ui-leg`,children:[_(`span`,{class:`${r}-generative-ui-muted`,children:[e.carrier,e.number,Sr(e.departs,n)].filter(Boolean).join(` · `)}),v(`div`,{class:`${r}-generative-ui-leg-times`,children:[v(`span`,{children:[_(`strong`,{children:yr(e.departs,n)}),_(`span`,{children:e.from})]}),_(`span`,{class:`${r}-generative-ui-leg-path`,children:a}),v(`span`,{children:[v(`strong`,{children:[yr(e.arrives,n),i!==void 0&&v(`sup`,{children:[`+`,i]})]}),_(`span`,{children:e.to})]})]})]})}function Ua({title:e,columns:t,rows:n,context:{cssPrefix:r,locale:i}}){let[a,o]=h(void 0),s=Lr(t,n),c=Rr(n,a&&{...a,numeric:s[a.column]??!1},i);return _(`section`,{class:`${r}-generative-ui-table-card`,children:_(`div`,{class:`${r}-generative-ui-table`,children:v(`table`,{children:[_(`caption`,{children:e}),_(`thead`,{children:_(`tr`,{children:t.map((e,t)=>_(`th`,{scope:`col`,"data-numeric":s[t],"aria-sort":a?.column===t?a.descending?`descending`:`ascending`:void 0,children:_(`button`,{type:`button`,onClick:()=>o({column:t,descending:a?.column===t&&!a.descending}),children:e})},t))})}),_(`tbody`,{children:c.map((e,n)=>_(`tr`,{children:e.map((e,n)=>_(`td`,{"data-numeric":s[n],"data-label":t[n],children:e},n))},n))})]})})})}function Wa({title:e,url:t}){return Ur(t)?_(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:e}):_(g,{children:e})}function Ga({price:e,compareAtPrice:t,note:n,context:{cssPrefix:r,locale:i}}){return v(`span`,{class:`${r}-generative-ui-price`,children:[_(`strong`,{children:_r(e,i)}),t&&qr(e,t)&&_(`s`,{children:_r(t,i)}),n&&_(`span`,{class:`${r}-generative-ui-muted`,children:n})]})}function Ka({totals:e,context:{cssPrefix:t,locale:n}}){return e.length?_(`dl`,{class:`${t}-generative-ui-totals`,children:e.map(e=>v(`div`,{children:[_(`dt`,{children:e.label}),_(`dd`,{children:_r(e.amount,n)})]},e.label))}):null}function qa({element:e,context:{cssPrefix:t,locale:n}}){let{type:r,data:i,series:a=[],title:o}=e.props,{baseline:s,barWidth:c,series:l,labels:u,ticks:d,slices:f}=Mr(e.props,n),p=[`currentColor`,...jr],m=r===`pie`?i.map((e,t)=>`${e.label} ${Math.round((f[t]?.share??0)*100)}%`):l.length>1?a:[];return v(`section`,{children:[_(`strong`,{children:o}),v(`svg`,{class:`${t}-generative-ui-chart`,viewBox:`0 0 320 168`,role:`img`,"aria-label":`${o}. ${a.length>1?`${a.join(` / `)}. `:``}${i.map(e=>`${e.label}: ${kr(e.value).join(` / `)}`).join(`, `)}`,children:[r===`pie`?f.map((e,t)=>_(`path`,{d:e.path,fill:p[t%p.length]},t)):l.map((e,t)=>r===`line`?v(`g`,{fill:p[t%p.length],children:[_(`polyline`,{points:e.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:p[t%p.length],"stroke-width":2.5,"stroke-linejoin":`round`}),e.map((e,t)=>_(`circle`,{cx:e.x,cy:e.y,r:3},t))]},t):_(`g`,{fill:p[t%p.length],children:e.map((e,t)=>_(`rect`,{x:e.x-c/2,y:Math.min(e.y,s),width:c,height:Math.abs(e.y-s),rx:2},t))},t)),r!==`pie`&&v(`g`,{class:`${t}-generative-ui-axis`,children:[_(`line`,{x1:24,x2:296,y1:s,y2:s}),u.map((e,t)=>_(`text`,{x:e.x,y:164,"text-anchor":`middle`,children:e.text},t)),d.map(e=>_(`text`,{x:20,y:e.y+3,"text-anchor":`end`,children:e.text},e.text))]})]}),m.length>0&&_(`ul`,{class:`${t}-generative-ui-legend`,children:m.map((e,t)=>_(`li`,{style:{color:t?p[t%p.length]:void 0},children:_(`span`,{children:e})},t))})]})}function Ja(e,t){if(!e.includes("```openui"))return e;let n=``,r=0,i=0,a=0,o=0,s;function c(i){s?.language===`openui`&&(n+=e.slice(r,s.start)+Ta(s.source,t)+(e[i-1]===`
33
33
  `?`
34
34
  `:``),r=i),s=void 0}let l=y.parser({data:void 0,add_token(e,t){o+=1,t===y.CODE_FENCE&&o===1&&(s={start:a,source:``,language:``})},set_attr(e,t,n){s&&t===y.LANG&&(s.language=n)},add_text(e,t){s&&(s.source+=t)},end_token(){s&&c(Math.min(i+1,e.length)),--o}});for(;i<e.length;i++)y.parser_write(l,e.charAt(i)),e[i]===`
35
- `&&(a=i+1);return y.parser_end(l),s&&c(e.length),n+e.slice(r)}function qa({children:e}){let t=m(null),[n,r]=h({start:!1,end:!1});return u(()=>{let e=t.current;if(!e)return;function n(){if(!e)return;let t=Br(e);r(e=>e.start===t.start&&e.end===t.end?e:t)}n(),e.addEventListener(`scroll`,n,{passive:!0});let i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(n);return i?.observe(e),()=>{e.removeEventListener(`scroll`,n),i?.disconnect()}},[]),_(`div`,{ref:t,"data-cut-start":n.start||void 0,"data-cut-end":n.end||void 0,children:e})}function Ja(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Ya(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function Xa(e){return e.startsWith(`tool-`)?e.slice(5):e}const Za={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`,emailTranscript:`/pai/email-transcript`,cancelOperatorRequest:`/pai/cancel-request-operator`,content:`/pai/content`,contentCollections:`/pai/content/collection/list`,contentVoteSet:`/pai/content/vote/set`},Qa=`context`;function $a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function eo(e){if(!$a(e))return;let t=e,n=t.controlMode,r=t.controlRevision;if(!(n!==`ai-agent`&&n!==`awaiting-operator`&&n!==`operator`||typeof r!=`number`||!Number.isSafeInteger(r)||r<0))return{controlMode:n,controlRevision:r,assignedOperatorInitials:typeof t.assignedOperatorInitials==`string`&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,assignedOperatorName:typeof t.assignedOperatorName==`string`&&t.assignedOperatorName?t.assignedOperatorName:void 0,assignedOperatorAvatar:typeof t.assignedOperatorAvatar==`string`&&t.assignedOperatorAvatar?t.assignedOperatorAvatar:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function to(e){if(!$a(e))return;let t=e.status,n=e.postFinishSequence;if(!(t!==`compacting`&&t!==`ready`||typeof n!=`number`||!Number.isSafeInteger(n)||n<0))return{status:t,postFinishSequence:n}}function no(e){let t=$a(e)?e.suggestions:void 0;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!$a(e))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 ro(e){let t={messages:e.messages.map(e=>({id:e.serverMessageId??e.id,parts:ao(e),role:e.role})),conversationId:e.conversationId,responseType:`ack`};return e.visitorId&&(t.visitorId=e.visitorId),e.userPrefs&&(t.userPrefs=e.userPrefs),e.clientTools?.length&&(t.clientTools=e.clientTools),t}function io(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function ao(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,filename:n.filename,fileId:n.fileId,fileSize:n.fileSize}),n.kind===`tool`&&io(n)){let e=n.dynamic?{type:`dynamic-tool`,toolName:n.toolName,toolCallId:n.toolCallId,state:n.state}:{type:Ya(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?.approved!==void 0&&(e.approval=n.approval),n.toolMetadata&&(e.toolMetadata=n.toolMetadata),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}function oo(e,t,n=$t()){let r=e?[{kind:`text`,id:`t0`,textSig:o(e),doneSig:o(!0)}]:[];return{id:n,role:`user`,createdAt:Date.now(),status:`complete`,attachments:t,partsSig:o(r)}}function so(){return{id:$t(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:o([])}}function co(e){let t=$t();return lo({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function lo(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:o(e.parts.map(Xo))}}function uo(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status===`streaming`?`streaming`:`complete`}function fo(e){let t=/* @__PURE__ */ new Set,n=e.parts.map((t,n)=>t.type===`text`?{kind:`text`,id:`${e.id}-t${n}`,textSig:o(t.text),doneSig:o(!0)}:t.type===`reasoning`?{kind:`reasoning`,id:`${e.id}-r${n}`,textSig:o(t.text),doneSig:o(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,filename:t.filename,fileId:t.fileId,fileSize:t.fileSize}: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===`dynamic-tool`||t.type.startsWith(`tool-`)?{kind:`tool`,toolCallId:t.toolCallId,toolName:t.type===`dynamic-tool`?t.toolName:Xa(t.type),title:t.title,dynamic:t.type===`dynamic-tool`||void 0,toolMetadata:t.toolMetadata,inputPartialSig:o(``),inputSig:o(t.input),outputSig:o(t.output),errorSig:o(t.errorText),stateSig:o(t.state),approvalSig:o(t.approval)}:null).filter(e=>e!==null).filter(e=>e.kind!==`source`||!t.has(e.sourceId)&&(t.add(e.sourceId),!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`?no(r.data):void 0,serverMessageId:e.id,createdAt:Date.parse(e.createdAt),status:uo(e),canceled:e.status===`canceled`,feedback:e.feedback??null,stepTimings:po(e.metadata?.steps),partsSig:o(n)}}function po(e){if(e?.length&&e.every(e=>mo(e.durationMs)))return e.map(({durationMs:e,reasoningMs:t})=>({durationMs:Number(e),...mo(t)?{reasoningMs:t}:{}}))}function mo(e){return typeof e==`number`&&Number.isFinite(e)}function ho(e){return!e.parts.some(e=>e.type===`text`&&e.text.trim()!==``||e.type===`dynamic-tool`||e.type.startsWith(`tool-`)||e.type===`file`||e.type===`source-url`||e.type===`source-document`)}function go(e){return e.role===`assistant`&&e.status===`streaming`&&ho(e)}function _o(e){let t=e.length-1;return e.filter((e,n)=>n===t||!go(e)).map(fo)}function vo(e,t){let n=!t&&e.at(-1)?.role===`assistant`?-2:-1,r=e.at(n);return!r||r.ephemeral?[]:[r]}function yo(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(Zo)}}function bo(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function xo(e,t,n,r,i=t.createdAt){let a=e.find(e=>e.role===`user`&&!e.ephemeral);function o(e,t){return(e.role===`assistant`?Ka(bo(e)):bo(e)).replace(/\s+/g,` `).trim().slice(0,t)}let s=a?o(a,80):``,c=o(t,120);return{conversationId:n,title:s||r,lastMessageAt:new Date(i).toISOString(),preview:c||void 0}}function So(e){return bo(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Co(e){return bo(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function wo(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function To(e){return e.kind===`tool`}function Eo(e){return e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`}function Do(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(Eo)}function Oo(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(To);return t.length>0&&t.every(e=>wo(e.stateSig.value))}function ko(e){return e.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`)&&!Do(e)}function Ao(e,t){return!e.partsSig.value.slice(t+1).some(e=>e.kind===`step-start`||Eo(e))}function jo(e){return e.partsSig.value.some(e=>To(e)&&!wo(e.stateSig.value))}function Mo(e,t){if(t.length===0)return e;let n=/* @__PURE__ */ new Set;for(let t of e)n.add(t.id),t.serverMessageId&&n.add(t.serverMessageId);let r=t.filter(e=>{let t=[e.id,e.serverMessageId].filter(e=>e!==void 0);return!t.some(e=>n.has(e))&&(t.forEach(e=>n.add(e)),!0)});if(r.length===0)return e;let i=e.findIndex(e=>!e.ephemeral),a=i<0?e.length:i;return[...e.slice(0,a),...r,...e.slice(a)]}function No(e,t){return t.id=e.id,e.canceled&&(t.canceled=!0),e.feedback!==void 0&&(t.feedback=e.feedback),t.suggestions??(t.suggestions=e.suggestions),t}function Po(e,t,n,r){if(!Fo(e))return;if(t.length===0){let t=Math.max(...r.values());return n.find(n=>n.role===`assistant`&&r.get(n.serverMessageId??n.id)===t&&bo(n).length>=bo(e).length)}let i=t.at(-1);if(i?.role!==`user`)return;let a=r.get(i.serverMessageId??i.id);if(a!==void 0)return n.find(t=>t.role===`assistant`&&r.get(t.serverMessageId??t.id)===a+1&&bo(t).length>=bo(e).length)}function Fo(e){return e?.role===`assistant`&&e.status===`streaming`&&e.serverMessageId===void 0}function Io(e,t){let n=new Set(e.partsSig.value.filter(To).map(e=>e.toolCallId));return t.partsSig.value.filter(To).every(e=>n.has(e.toolCallId))}function Lo(e,t){let n=new Map(t.partsSig.value.filter(To).filter(e=>wo(e.stateSig.value)).map(e=>[e.toolCallId,e]));if(n.size===0)return;let r=!1,i=e.partsSig.value.map(e=>{if(!To(e))return e;let t=n.get(e.toolCallId);if(!t)return e;let i=e.approvalSig.value,a=t.approvalSig.value,o=i===void 0||i.approved===void 0&&a?.approved!==void 0?t.approvalSig:e.approvalSig,s=e.inputSig.value===void 0?t.inputSig:e.inputSig,c=e.toolName===`tool`?t.toolName:e.toolName,l=e.dynamic??t.dynamic,u=e.toolMetadata??t.toolMetadata;return o===e.approvalSig&&s===e.inputSig&&c===e.toolName&&l===e.dynamic&&u===e.toolMetadata?e:(r=!0,{...e,toolName:c,dynamic:l,toolMetadata:u,inputSig:s,approvalSig:o})});r&&(e.partsSig.value=i)}function Ro(e){let t=e.flatMap(e=>e.role===`assistant`&&e.status!==`streaming`?Ja(e.startedAt)??[]:[]);return new Set(e.filter(e=>e.role===`user`&&t.some(t=>t>=(Ja(e.createdAt)??1/0))).map(e=>e.id))}function zo(e,t){let n=t.filter(e=>!e.ephemeral&&(e.status===`streaming`||e.status===`pending`||e.status===`error`||e.retryAction!==void 0||(e.attachments?.length??0)>0||So(e))),r=/* @__PURE__ */ new Map;for(let e of n)r.set(e.id,e),e.serverMessageId!==void 0&&r.set(e.serverMessageId,e);let i=/* @__PURE__ */ new Set,a=[],o=e.map(e=>{let t=(e.serverMessageId===void 0?void 0:r.get(e.serverMessageId))??r.get(e.id);return t===void 0?(a.push(e),e):(i.add(t),t.role===e.role?t.role===`user`&&t.serverMessageId===void 0&&(t.status===`pending`||t.status===`error`)?No(t,e):t.status!==`streaming`&&bo(t).startsWith(bo(e))&&Io(t,e)?(e.createdAt!==void 0&&(t.createdAt=e.createdAt),Lo(t,e),e.stepTimings&&(t.stepTimings=e.stepTimings),t.suggestions??(t.suggestions=e.suggestions),t.feedback===void 0&&(t.feedback=e.feedback),e.canceled&&(t.canceled=!0),t):No(t,e):e)}),s=n.filter(e=>!i.has(e)),c=s.findLast(Fo),l=/* @__PURE__ */ new Map;e.forEach((e,t)=>{l.set(e.id,t),e.serverMessageId!==void 0&&l.set(e.serverMessageId,t)});let u=Po(c,c?n.slice(0,n.indexOf(c)):[],a,l);if(c&&u){let e=o.indexOf(u);e>=0&&(o[e]=No(c,u)),s=s.filter(e=>e!==c)}return[...o,...s]}function Bo(e,t){let n=new Map(t.flatMap(e=>e.serverMessageId===void 0?[]:[[e.serverMessageId,e]])),r=/* @__PURE__ */ new Map;t.forEach((e,t)=>{r.set(e.id,t),e.serverMessageId!==void 0&&r.set(e.serverMessageId,t)});let i=new Set(e.flatMap(e=>[e.serverMessageId,e.id].filter(e=>e!==void 0))),a=!1,o=e.map(e=>{let t=n.get(e.serverMessageId??e.id);if(t===void 0||t.role!==e.role)return e;if(e.role===`user`&&e.serverMessageId===void 0)return a=!0,No(e,t);if(e.serverMessageId===void 0)return e;t.createdAt!==void 0&&e.createdAt!==t.createdAt&&(e.createdAt=t.createdAt,a=!0);let r=bo(t),i=bo(e),o=t.status!==`streaming`&&r.length>=i.length&&Go(e,t);if(r.length>i.length||r===i&&t.partsSig.value.length>e.partsSig.value.length||o)return a=!0,No(e,t);if((t.stepTimings?.length??0)>(e.stepTimings?.length??0)&&(e.stepTimings=t.stepTimings,a=!0),e.status===`streaming`&&t.status!==`streaming`&&Ho(e,t)){if(e.continuationStreaming&&jo(t))return e;if(!Go(t,e))return a=!0,No(e,t)}return e}),s=[...n].filter(([e])=>!i.has(e)).map(([,e])=>e),c=o.findLastIndex(Fo),l=o[c],u=Po(l,o.slice(0,c),s,r);if(l!==void 0&&u!==void 0&&bo(u).length>=bo(l).length&&(No(l,u),o[c]=u,s.splice(s.indexOf(u),1),a=!0),s.length===0)return{messages:a?o:e,changed:a};for(let e of s){let t=r.get(e.serverMessageId??e.id),n=!1,i=o.findIndex(e=>{let i=r.get(e.serverMessageId??e.id);return t===void 0?!1:i===void 0?n:i>t||(n=!0,!1)});i===-1?o.push(e):o.splice(i,0,e)}return{messages:o,changed:!0}}function Vo(e,t){if(e.role!==t.role)return!1;let n=bo(t),r=bo(e);return n.length>r.length||t.partsSig.value.length>e.partsSig.value.length||Go(e,t)}function Ho(e,t){let n=e.partsSig.value,r=t.partsSig.value;return n.length===r.length&&n.every((e,t)=>{let n=r[t];switch(e.kind){case`text`:return n?.kind===`text`&&n.textSig.value===e.textSig.value;case`reasoning`:return n?.kind===`reasoning`&&n.textSig.value===e.textSig.value;case`step-start`:return n?.kind===`step-start`;case`tool`:return n?.kind===`tool`&&n.toolCallId===e.toolCallId&&Uo(n.toolName,e.toolName);case`file`:return n?.kind===`file`&&n.url===e.url&&n.mediaType===e.mediaType;case`source`:return n?.kind===`source`&&n.sourceId===e.sourceId&&n.url===e.url&&n.title===e.title&&n.filename===e.filename&&n.mediaType===e.mediaType;default:return e}})}function Uo(e,t){return(e.startsWith(`tool:`)?e.slice(5):e)===(t.startsWith(`tool:`)?t.slice(5):t)}const Wo={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function Go(e,t){let n=new Map(e.partsSig.value.filter(To).map(e=>[e.toolCallId,e]));return t.partsSig.value.filter(To).some(e=>{let t=n.get(e.toolCallId);if(!t||Wo[e.stateSig.value]>Wo[t.stateSig.value])return!0;let r=e.approvalSig.value?.approved;return r!==void 0&&r!==t.approvalSig.value?.approved})}function Ko(e){return e.role===`assistant`&&e.status!==`streaming`&&e.canceled!==!0&&!So(e)}function qo(e,t){if(!e.includes(t)||t.retryAction===null)return;if(t.retryAction)return t.retryAction;if(t!==e.at(-1)||t.role!==`assistant`||t.serverMessageId===void 0||t.status!==`error`&&!Ko(t))return;let n=e.indexOf(t);for(let t=n-1;t>=0;t--){let n=e[t];if(n?.role===`user`&&!n.ephemeral)return{kind:`repeat-user`,messageId:n.id}}}function Jo(e,t){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Co(e)&&!t}function Yo(e,t){return e.operatorRoutedTurn?Ko(e)?`drop`:`complete-operator-routed`:t||Ko(e)?`error`:`complete`}function Xo(e){return e.kind===`text`||e.kind===`reasoning`?{kind:e.kind,id:e.id,textSig:o(e.text),doneSig:o(e.done)}:e.kind===`tool`?{kind:`tool`,toolCallId:e.toolCallId,toolName:e.toolName,title:e.title,dynamic:e.dynamic,toolMetadata:e.toolMetadata,inputPartialSig:o(e.inputPartial),inputSig:o(e.input),outputSig:o(e.output),errorSig:o(e.error),stateSig:o(e.state),approvalSig:o(e.approval)}:e}function Zo(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,title:e.title,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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}function Qo(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e);function i(){return a()}t?.addEventListener(`abort`,i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener(`abort`,i),n()}})}function $o(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(/=+$/,``)}function es(e){return e&&Object.keys(e).length>0?e:void 0}function ts(e,t,n=[]){let r=es(e),i=es(t),a=Date.now();for(let e=n.length;;--e){let t=n.slice(n.length-e).map(({name:e,data:t,at:n})=>({name:e,data:t,secondsAgo:Math.round((a-n)/1e3)})),o=t.length>0?{...i,recentEvents:t}:i;if(!r&&!o)return;let s=$o(JSON.stringify({...r&&{user:r},...o&&{page:o}}));if(s.length<=8192||e===0)return s}}var ns=class extends Error{constructor(e,t,n,r,i,a){super(e),this.code=t,this.status=n,this.cause=r,this.retryAfterSeconds=i,this.errorCode=a,this.name=`StreamError`}};const rs=V.scope(`parser`);async function*is(e,t,n){if(!e.ok){let t=await e.text().catch(()=>``);throw new ns(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let r of as(e,t)){let e=os(r,n);if(e===`done`)return;e&&(yield e)}}async function*as(e,t){if(!e.body)throw new ns(`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(`
35
+ `&&(a=i+1);return y.parser_end(l),s&&c(e.length),n+e.slice(r)}function Ya({children:e}){let t=m(null),[n,r]=h({start:!1,end:!1});return u(()=>{let e=t.current;if(!e)return;function n(){if(!e)return;let t=Hr(e);r(e=>e.start===t.start&&e.end===t.end?e:t)}n(),e.addEventListener(`scroll`,n,{passive:!0});let i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(n);return i?.observe(e),()=>{e.removeEventListener(`scroll`,n),i?.disconnect()}},[]),_(`div`,{ref:t,"data-cut-start":n.start||void 0,"data-cut-end":n.end||void 0,children:e})}function Xa(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Za(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function Qa(e){return e.startsWith(`tool-`)?e.slice(5):e}const $a={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`,emailTranscript:`/pai/email-transcript`,cancelOperatorRequest:`/pai/cancel-request-operator`,content:`/pai/content`,contentCollections:`/pai/content/collection/list`,contentVoteSet:`/pai/content/vote/set`},eo=`context`;function to(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function no(e){if(!to(e))return;let t=e,n=t.controlMode,r=t.controlRevision;if(!(n!==`ai-agent`&&n!==`awaiting-operator`&&n!==`operator`||typeof r!=`number`||!Number.isSafeInteger(r)||r<0))return{controlMode:n,controlRevision:r,assignedOperatorInitials:typeof t.assignedOperatorInitials==`string`&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,assignedOperatorName:typeof t.assignedOperatorName==`string`&&t.assignedOperatorName?t.assignedOperatorName:void 0,assignedOperatorAvatar:typeof t.assignedOperatorAvatar==`string`&&t.assignedOperatorAvatar?t.assignedOperatorAvatar:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function ro(e){if(!to(e))return;let t=e.status,n=e.postFinishSequence;if(!(t!==`compacting`&&t!==`ready`||typeof n!=`number`||!Number.isSafeInteger(n)||n<0))return{status:t,postFinishSequence:n}}function io(e){let t=to(e)?e.suggestions:void 0;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!to(e))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 ao(e){let t={messages:e.messages.map(e=>({id:e.serverMessageId??e.id,parts:so(e),role:e.role})),conversationId:e.conversationId,responseType:`ack`};return e.visitorId&&(t.visitorId=e.visitorId),e.userPrefs&&(t.userPrefs=e.userPrefs),e.clientTools?.length&&(t.clientTools=e.clientTools),t}function oo(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function so(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,filename:n.filename,fileId:n.fileId,fileSize:n.fileSize}),n.kind===`tool`&&oo(n)){let e=n.dynamic?{type:`dynamic-tool`,toolName:n.toolName,toolCallId:n.toolCallId,state:n.state}:{type:Za(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?.approved!==void 0&&(e.approval=n.approval),n.toolMetadata&&(e.toolMetadata=n.toolMetadata),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}function co(e,t,n=$t()){let r=e?[{kind:`text`,id:`t0`,textSig:o(e),doneSig:o(!0)}]:[];return{id:n,role:`user`,createdAt:Date.now(),status:`complete`,attachments:t,partsSig:o(r)}}function lo(){return{id:$t(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:o([])}}function uo(e){let t=$t();return fo({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function fo(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:o(e.parts.map(Qo))}}function po(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status===`streaming`?`streaming`:`complete`}function mo(e){let t=/* @__PURE__ */ new Set,n=e.parts.map((t,n)=>t.type===`text`?{kind:`text`,id:`${e.id}-t${n}`,textSig:o(t.text),doneSig:o(!0)}:t.type===`reasoning`?{kind:`reasoning`,id:`${e.id}-r${n}`,textSig:o(t.text),doneSig:o(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,filename:t.filename,fileId:t.fileId,fileSize:t.fileSize}: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===`dynamic-tool`||t.type.startsWith(`tool-`)?{kind:`tool`,toolCallId:t.toolCallId,toolName:t.type===`dynamic-tool`?t.toolName:Qa(t.type),title:t.title,dynamic:t.type===`dynamic-tool`||void 0,toolMetadata:t.toolMetadata,inputPartialSig:o(``),inputSig:o(t.input),outputSig:o(t.output),errorSig:o(t.errorText),stateSig:o(t.state),approvalSig:o(t.approval)}:null).filter(e=>e!==null).filter(e=>e.kind!==`source`||!t.has(e.sourceId)&&(t.add(e.sourceId),!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`?io(r.data):void 0,serverMessageId:e.id,createdAt:Date.parse(e.createdAt),status:po(e),canceled:e.status===`canceled`,feedback:e.feedback??null,stepTimings:ho(e.metadata?.steps),partsSig:o(n)}}function ho(e){if(e?.length&&e.every(e=>go(e.durationMs)))return e.map(({durationMs:e,reasoningMs:t})=>({durationMs:Number(e),...go(t)?{reasoningMs:t}:{}}))}function go(e){return typeof e==`number`&&Number.isFinite(e)}function _o(e){return!e.parts.some(e=>e.type===`text`&&e.text.trim()!==``||e.type===`dynamic-tool`||e.type.startsWith(`tool-`)||e.type===`file`||e.type===`source-url`||e.type===`source-document`)}function vo(e){return e.role===`assistant`&&e.status===`streaming`&&_o(e)}function yo(e){let t=e.length-1;return e.filter((e,n)=>n===t||!vo(e)).map(mo)}function bo(e,t){let n=!t&&e.at(-1)?.role===`assistant`?-2:-1,r=e.at(n);return!r||r.ephemeral?[]:[r]}function xo(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($o)}}function So(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function Co(e,t,n,r,i=t.createdAt){let a=e.find(e=>e.role===`user`&&!e.ephemeral);function o(e,t){return(e.role===`assistant`?Ja(So(e)):So(e)).replace(/\s+/g,` `).trim().slice(0,t)}let s=a?o(a,80):``,c=o(t,120);return{conversationId:n,title:s||r,lastMessageAt:new Date(i).toISOString(),preview:c||void 0}}function wo(e){return So(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function To(e){return So(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function Eo(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function Do(e){return e.kind===`tool`}function Oo(e){return e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`}function ko(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(Oo)}function Ao(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(Do);return t.length>0&&t.every(e=>Eo(e.stateSig.value))}function jo(e){return e.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`)&&!ko(e)}function Mo(e,t){return!e.partsSig.value.slice(t+1).some(e=>e.kind===`step-start`||Oo(e))}function No(e){return e.partsSig.value.some(e=>Do(e)&&!Eo(e.stateSig.value))}function Po(e,t){if(t.length===0)return e;let n=/* @__PURE__ */ new Set;for(let t of e)n.add(t.id),t.serverMessageId&&n.add(t.serverMessageId);let r=t.filter(e=>{let t=[e.id,e.serverMessageId].filter(e=>e!==void 0);return!t.some(e=>n.has(e))&&(t.forEach(e=>n.add(e)),!0)});if(r.length===0)return e;let i=e.findIndex(e=>!e.ephemeral),a=i<0?e.length:i;return[...e.slice(0,a),...r,...e.slice(a)]}function Fo(e,t){return t.id=e.id,e.canceled&&(t.canceled=!0),e.feedback!==void 0&&(t.feedback=e.feedback),t.suggestions??(t.suggestions=e.suggestions),t}function Io(e,t,n,r){if(!Lo(e))return;if(t.length===0){let t=Math.max(...r.values());return n.find(n=>n.role===`assistant`&&r.get(n.serverMessageId??n.id)===t&&So(n).length>=So(e).length)}let i=t.at(-1);if(i?.role!==`user`)return;let a=r.get(i.serverMessageId??i.id);if(a!==void 0)return n.find(t=>t.role===`assistant`&&r.get(t.serverMessageId??t.id)===a+1&&So(t).length>=So(e).length)}function Lo(e){return e?.role===`assistant`&&e.status===`streaming`&&e.serverMessageId===void 0}function Ro(e,t){let n=new Set(e.partsSig.value.filter(Do).map(e=>e.toolCallId));return t.partsSig.value.filter(Do).every(e=>n.has(e.toolCallId))}function zo(e,t){let n=new Map(t.partsSig.value.filter(Do).filter(e=>Eo(e.stateSig.value)).map(e=>[e.toolCallId,e]));if(n.size===0)return;let r=!1,i=e.partsSig.value.map(e=>{if(!Do(e))return e;let t=n.get(e.toolCallId);if(!t)return e;let i=e.approvalSig.value,a=t.approvalSig.value,o=i===void 0||i.approved===void 0&&a?.approved!==void 0?t.approvalSig:e.approvalSig,s=e.inputSig.value===void 0?t.inputSig:e.inputSig,c=e.toolName===`tool`?t.toolName:e.toolName,l=e.dynamic??t.dynamic,u=e.toolMetadata??t.toolMetadata;return o===e.approvalSig&&s===e.inputSig&&c===e.toolName&&l===e.dynamic&&u===e.toolMetadata?e:(r=!0,{...e,toolName:c,dynamic:l,toolMetadata:u,inputSig:s,approvalSig:o})});r&&(e.partsSig.value=i)}function Bo(e){let t=e.flatMap(e=>e.role===`assistant`&&e.status!==`streaming`?Xa(e.startedAt)??[]:[]);return new Set(e.filter(e=>e.role===`user`&&t.some(t=>t>=(Xa(e.createdAt)??1/0))).map(e=>e.id))}function Vo(e,t){let n=t.filter(e=>!e.ephemeral&&(e.status===`streaming`||e.status===`pending`||e.status===`error`||e.retryAction!==void 0||(e.attachments?.length??0)>0||wo(e))),r=/* @__PURE__ */ new Map;for(let e of n)r.set(e.id,e),e.serverMessageId!==void 0&&r.set(e.serverMessageId,e);let i=/* @__PURE__ */ new Set,a=[],o=e.map(e=>{let t=(e.serverMessageId===void 0?void 0:r.get(e.serverMessageId))??r.get(e.id);return t===void 0?(a.push(e),e):(i.add(t),t.role===e.role?t.role===`user`&&t.serverMessageId===void 0&&(t.status===`pending`||t.status===`error`)?Fo(t,e):t.status!==`streaming`&&So(t).startsWith(So(e))&&Ro(t,e)?(e.createdAt!==void 0&&(t.createdAt=e.createdAt),zo(t,e),e.stepTimings&&(t.stepTimings=e.stepTimings),t.suggestions??(t.suggestions=e.suggestions),t.feedback===void 0&&(t.feedback=e.feedback),e.canceled&&(t.canceled=!0),t):Fo(t,e):e)}),s=n.filter(e=>!i.has(e)),c=s.findLast(Lo),l=/* @__PURE__ */ new Map;e.forEach((e,t)=>{l.set(e.id,t),e.serverMessageId!==void 0&&l.set(e.serverMessageId,t)});let u=Io(c,c?n.slice(0,n.indexOf(c)):[],a,l);if(c&&u){let e=o.indexOf(u);e>=0&&(o[e]=Fo(c,u)),s=s.filter(e=>e!==c)}return[...o,...s]}function Ho(e,t){let n=new Map(t.flatMap(e=>e.serverMessageId===void 0?[]:[[e.serverMessageId,e]])),r=/* @__PURE__ */ new Map;t.forEach((e,t)=>{r.set(e.id,t),e.serverMessageId!==void 0&&r.set(e.serverMessageId,t)});let i=new Set(e.flatMap(e=>[e.serverMessageId,e.id].filter(e=>e!==void 0))),a=!1,o=e.map(e=>{let t=n.get(e.serverMessageId??e.id);if(t===void 0||t.role!==e.role)return e;if(e.role===`user`&&e.serverMessageId===void 0)return a=!0,Fo(e,t);if(e.serverMessageId===void 0)return e;t.createdAt!==void 0&&e.createdAt!==t.createdAt&&(e.createdAt=t.createdAt,a=!0);let r=So(t),i=So(e),o=t.status!==`streaming`&&r.length>=i.length&&qo(e,t);if(r.length>i.length||r===i&&t.partsSig.value.length>e.partsSig.value.length||o)return a=!0,Fo(e,t);if((t.stepTimings?.length??0)>(e.stepTimings?.length??0)&&(e.stepTimings=t.stepTimings,a=!0),e.status===`streaming`&&t.status!==`streaming`&&Wo(e,t)){if(e.continuationStreaming&&No(t))return e;if(!qo(t,e))return a=!0,Fo(e,t)}return e}),s=[...n].filter(([e])=>!i.has(e)).map(([,e])=>e),c=o.findLastIndex(Lo),l=o[c],u=Io(l,o.slice(0,c),s,r);if(l!==void 0&&u!==void 0&&So(u).length>=So(l).length&&(Fo(l,u),o[c]=u,s.splice(s.indexOf(u),1),a=!0),s.length===0)return{messages:a?o:e,changed:a};for(let e of s){let t=r.get(e.serverMessageId??e.id),n=!1,i=o.findIndex(e=>{let i=r.get(e.serverMessageId??e.id);return t===void 0?!1:i===void 0?n:i>t||(n=!0,!1)});i===-1?o.push(e):o.splice(i,0,e)}return{messages:o,changed:!0}}function Uo(e,t){if(e.role!==t.role)return!1;let n=So(t),r=So(e);return n.length>r.length||t.partsSig.value.length>e.partsSig.value.length||qo(e,t)}function Wo(e,t){let n=e.partsSig.value,r=t.partsSig.value;return n.length===r.length&&n.every((e,t)=>{let n=r[t];switch(e.kind){case`text`:return n?.kind===`text`&&n.textSig.value===e.textSig.value;case`reasoning`:return n?.kind===`reasoning`&&n.textSig.value===e.textSig.value;case`step-start`:return n?.kind===`step-start`;case`tool`:return n?.kind===`tool`&&n.toolCallId===e.toolCallId&&Go(n.toolName,e.toolName);case`file`:return n?.kind===`file`&&n.url===e.url&&n.mediaType===e.mediaType;case`source`:return n?.kind===`source`&&n.sourceId===e.sourceId&&n.url===e.url&&n.title===e.title&&n.filename===e.filename&&n.mediaType===e.mediaType;default:return e}})}function Go(e,t){return(e.startsWith(`tool:`)?e.slice(5):e)===(t.startsWith(`tool:`)?t.slice(5):t)}const Ko={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function qo(e,t){let n=new Map(e.partsSig.value.filter(Do).map(e=>[e.toolCallId,e]));return t.partsSig.value.filter(Do).some(e=>{let t=n.get(e.toolCallId);if(!t||Ko[e.stateSig.value]>Ko[t.stateSig.value])return!0;let r=e.approvalSig.value?.approved;return r!==void 0&&r!==t.approvalSig.value?.approved})}function Jo(e){return e.role===`assistant`&&e.status!==`streaming`&&e.canceled!==!0&&!wo(e)}function Yo(e,t){if(!e.includes(t)||t.retryAction===null)return;if(t.retryAction)return t.retryAction;if(t!==e.at(-1)||t.role!==`assistant`||t.serverMessageId===void 0||t.status!==`error`&&!Jo(t))return;let n=e.indexOf(t);for(let t=n-1;t>=0;t--){let n=e[t];if(n?.role===`user`&&!n.ephemeral)return{kind:`repeat-user`,messageId:n.id}}}function Xo(e,t){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!To(e)&&!t}function Zo(e,t){return e.operatorRoutedTurn?Jo(e)?`drop`:`complete-operator-routed`:t||Jo(e)?`error`:`complete`}function Qo(e){return e.kind===`text`||e.kind===`reasoning`?{kind:e.kind,id:e.id,textSig:o(e.text),doneSig:o(e.done)}:e.kind===`tool`?{kind:`tool`,toolCallId:e.toolCallId,toolName:e.toolName,title:e.title,dynamic:e.dynamic,toolMetadata:e.toolMetadata,inputPartialSig:o(e.inputPartial),inputSig:o(e.input),outputSig:o(e.output),errorSig:o(e.error),stateSig:o(e.state),approvalSig:o(e.approval)}:e}function $o(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,title:e.title,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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}function es(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e);function i(){return a()}t?.addEventListener(`abort`,i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener(`abort`,i),n()}})}function ts(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(/=+$/,``)}function ns(e){return e&&Object.keys(e).length>0?e:void 0}function rs(e,t,n=[]){let r=ns(e),i=ns(t),a=Date.now();for(let e=n.length;;--e){let t=n.slice(n.length-e).map(({name:e,data:t,at:n})=>({name:e,data:t,secondsAgo:Math.round((a-n)/1e3)})),o=t.length>0?{...i,recentEvents:t}:i;if(!r&&!o)return;let s=ts(JSON.stringify({...r&&{user:r},...o&&{page:o}}));if(s.length<=8192||e===0)return s}}var is=class extends Error{constructor(e,t,n,r,i,a){super(e),this.code=t,this.status=n,this.cause=r,this.retryAfterSeconds=i,this.errorCode=a,this.name=`StreamError`}};const as=V.scope(`parser`);async function*os(e,t,n){if(!e.ok){let t=await e.text().catch(()=>``);throw new is(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let r of ss(e,t)){let e=cs(r,n);if(e===`done`)return;e&&(yield e)}}async function*ss(e,t){if(!e.body)throw new is(`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(`
36
36
 
37
- `))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function os(e,t){let n=``,r;for(let i of e.split(`
38
- `))if(i!==``){if(i.startsWith(`:`))t?.(i.slice(1).trim());else if(i.startsWith(`data:`)){let e=i.slice(5).replace(/^ /,``);n=n?`${n}\n${e}`:e}else i.startsWith(`id:`)&&(r=i.slice(3).trim())}if(n===`[DONE]`)return`done`;if(!n)return null;try{let e=JSON.parse(n);if(!ss(e))throw TypeError(`unrecognized chunk`);return rs.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw rs.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new ns(`invalid SSE frame`,`network`,void 0,e)}}function ss(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof Reflect.get(e,`type`)==`string`}const cs=/* @__PURE__ */ new Set([101,204,205,304]);function ls(e){let t=new Headers;for(let n of e.trim().split(/[\r\n]+/)){let e=n.indexOf(`:`);e>0&&t.append(n.slice(0,e).trim(),n.slice(e+1).trim())}return t}function us(e){return async function(t,n){let r=new Request(t,n),i=await r.blob();return new Promise((t,n)=>{if(r.signal.aborted){n(r.signal.reason);return}let a=new XMLHttpRequest;a.open(r.method,r.url),a.withCredentials=r.credentials===`include`,a.responseType=`blob`,r.headers.forEach((e,t)=>a.setRequestHeader(t,e)),a.upload.addEventListener(`progress`,t=>{t.lengthComputable&&t.total>0&&e(t.loaded/t.total)}),a.addEventListener(`load`,()=>{t(new Response(cs.has(a.status)?null:a.response,{status:a.status,statusText:a.statusText,headers:ls(a.getAllResponseHeaders())}))}),a.addEventListener(`error`,()=>n(/* @__PURE__ */ TypeError(`Failed to fetch`))),a.addEventListener(`abort`,()=>n(r.signal.reason)),r.signal.addEventListener(`abort`,()=>a.abort(),{once:!0}),a.send(i)})}}const ds=V.scope(`transport`);async function fs(e){try{let t=await e.clone().json();if(typeof t!=`object`||!t)return{};let n=Reflect.get(t,`error`);return{error:typeof n==`string`?n:void 0,loginUrl:lr(Reflect.get(t,`login`)).url}}catch{return{}}}const ps=6e4,ms=/* @__PURE__ */ new WeakMap;function hs(e){return ms.get(e)}function gs(e,t){return ms.set(e,t),e}function _s(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function vs(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function ys(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(hs(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>(hs(t)?.activityRevision??0)-(hs(e)?.activityRevision??0)),i=new Set(r.map(e=>e.conversationId));return[...r,...t.result.conversations.filter(e=>!i.has(e.conversationId)).map(e=>{let r=n.get(e.conversationId);if(!r)return e;let i=hs(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?gs({...e,hasUnread:!1},{upsertRevision:0,read:i.read}):e})]}case`read`:{let n=e.findIndex(e=>e.conversationId===t.conversationId&&(t.lastMessageAt===void 0||e.lastMessageAt===t.lastMessageAt)),r=e[n];if(!r)return e;let i=hs(r);if(_s(i)>t.revision)return e;let a=t.lastMessageAt??r.lastMessageAt,o={upsertRevision:i?.upsertRevision??0,...i?.activityRevision===void 0?{}:{activityRevision:i.activityRevision},read:{revision:t.revision,...a?{lastMessageAt:a}:{}}};return r.hasUnread?e.map((e,t)=>t===n?gs({...e,hasUnread:!1},o):e):(gs(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=e[r],a=i?hs(i):void 0;if(_s(a)>t.revision)return e;let o=t.activity?t.revision:a?.activityRevision,s={upsertRevision:t.revision,...o===void 0?{}:{activityRevision:o},...!t.conversation.hasUnread&&a?.read?{read:a.read}:{}},c=i?{...i,...t.conversation,title:i.title}:{...t.conversation};return i&&vs(i,c)?(gs(i,s),e):(gs(c,s),t.activity?[c,...e.filter(e=>e.conversationId!==c.conversationId)]:i?e.map((e,t)=>t===r?c:e):[...e,c])}default:return t}}const bs=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function xs(e){return 400*2**e+Math.floor(Math.random()*250)}function Ss(e){return 6e4+Math.ceil(e/1048576)*15e3}function Cs(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 ws=class{constructor(e){this.ttlMs=e,U(this,`map`,/* @__PURE__ */ new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&performance.now()-n.at<this.ttlMs)return n.result;let r={at:performance.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.get(e)===r&&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&&performance.now()-t.at<this.ttlMs)return t.value}update(e){for(let t of this.map.values())if(t.value!==void 0){let n=e(t.value);t.value=n,t.result=Promise.resolve(n)}else t.result=t.result.then(n=>{let r=e(n);return t.value=r,r})}delete(e){this.map.delete(e)}};function Ts(e,t){let{translations:n,defaultLocale:r,...i}=E(e,t);return i}var Es=class{constructor(e){this.opts=e,U(this,`conversationListeners`,/* @__PURE__ */ new Set),U(this,`conversationRevision`,0),U(this,`visitorId`,void 0),U(this,`conversationId`,void 0),U(this,`userContext`,void 0),U(this,`pageContext`,void 0),U(this,`locale`,void 0),U(this,`userTokenSource`,void 0),U(this,`userToken`,void 0),U(this,`userTokenRequest`,void 0),U(this,`conversationsCache`,new ws(1e4)),U(this,`contentCache`,new ws(ps)),U(this,`contentCollectionsCache`,new ws(ps))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0,this.opts.onLoginState?.(e?{status:`pending`}:{status:`anonymous`})}async userSub(){return this.userTokenRequest&&await this.userTokenRequest,this.userToken?mr(this.userToken):void 0}reportLogin(e){this.opts.onLoginState?.(e===`loggedIn`&&this.userToken?{status:e,...pr(this.userToken)}:{status:e===`loggedIn`?`anonymous`:e})}async refreshUserToken(){let e=this.userToken;return typeof this.userTokenSource==`function`&&(this.userTokenRequest&&await this.userTokenRequest,this.userToken===e&&await this.fetchUserToken(),!!this.userToken&&this.userToken!==e)}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:sn};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=ts(this.userContext,this.pageContext);return t&&(e[Qa]=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){ds.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale});let t=As(`handshake`,await this.postJson(Za.handshake,e,`handshake`),Ms),n=t.loginStatus===`expired`&&await this.refreshUserToken()?As(`handshake`,await this.postJson(Za.handshake,e,`handshake`),Ms):t;return this.reportLogin(n.loginStatus??(this.userToken?`loggedIn`:`anonymous`)),ds.debug(`handshake ←`,{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),this.visitorId=n.visitorId,this.conversationId=n.conversationId,n}async uploadFile(e,t,n){ds.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let r=new FormData;r.append(`file`,e,e.name);let i=As(`upload`,await this.postForm(this.uploadPath,r,`upload`,t,Ss(e.size),n),Ns);return ds.debug(`uploadFile ←`,{id:i.id,url:i.url}),i}async transcribe(e,t=`audio/webm`){ds.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${Ds(t)}`),n.append(`mimeType`,t);let r=As(`transcribe`,await this.postForm(this.transcribePath,n,`transcribe`),Ps);return ds.debug(`transcribe ←`,{textLen:r.text.length}),r}subscribeConversationChanges(e){return this.conversationListeners.add(e),()=>this.conversationListeners.delete(e)}publishConversation(e,t=!1){let n={type:`upsert`,conversation:e,revision:++this.conversationRevision,...t?{activity:!0}:{}};this.conversationsCache.update(r=>{let i=r.pagination.page===1,a=r.conversations.some(t=>t.conversationId===e.conversationId),o=ys(r.conversations,n,i&&t),s=i&&o.length>r.pagination.limit?o.slice(0,r.pagination.limit):o;if(!i||!t||a||r.pagination.hasNext)return s===r.conversations?r:{...r,conversations:s};let c=Math.max(r.pagination.total,r.conversations.length)+1,l=Math.ceil(c/r.pagination.limit);return{...r,conversations:s,pagination:{...r.pagination,total:c,totalPages:l,hasNext:r.pagination.page<l}}});for(let e of this.conversationListeners)e(n)}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={},t=!1){if((e.page??1)>1)return this.fetchConversations(e);let n=this.localeCacheKey(e),r=this.conversationRevision;t&&this.conversationsCache.delete(n);let i=this.conversationsCache.getOrFetch(n,()=>this.fetchConversations(e));return t?i.then(e=>{let t={type:`snapshot`,result:e,requestedRevision:r};for(let e of this.conversationListeners)e(t);return e}):i}async fetchConversations(e){let t=new URL(this.url(Za.listConversations));return e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.page&&t.searchParams.set(`page`,String(e.page)),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.ids?.length&&t.searchParams.set(`ids`,e.ids.join(`,`)),As(`listConversations`,await this.getJson(t.toString(),`listConversations`),Is)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url(Za.listMessages));i.searchParams.set(`conversationId`,e),i.searchParams.set(`limit`,`50`),t.length>0&&i.searchParams.set(`ids`,t.join(`,`)),n&&i.searchParams.set(`beforeId`,n),r&&i.searchParams.set(`beforeCreatedAt`,r);let a=As(`loadConversation`,await this.getJson(i.toString(),`loadConversation`),Ls);return{...a,messages:a.messages.toReversed()}}async markRead(e,t){if(!this.visitorId||!e)return;let n={type:`read`,conversationId:e,...t===void 0?{}:{lastMessageAt:t},revision:++this.conversationRevision};this.conversationsCache.update(e=>{let t=ys(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson(Za.markRead,{conversationId:e},`markRead`,!0)}catch(e){ds.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return js(`requestOperator`,await this.postJson(Za.requestOperator,{},`requestOperator`))}catch(e){ds.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async emailTranscript(e){return As(`emailTranscript`,await this.postJson(Za.emailTranscript,{email:e},`emailTranscript`),Rs)}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return js(`cancelOperatorRequest`,await this.postJson(Za.cancelOperatorRequest,{},`cancelOperatorRequest`))}catch(e){ds.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(JSON.stringify(e,Object.keys(e).toSorted()),()=>this.fetchContent(e)).then(e=>({...e,items:e.items.map(e=>Ts(e,this.locale))}))}async fetchContent(e){let t=new URL(this.dataUrl(Za.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));let n=As(`listContent`,await this.getJson(t.toString(),`listContent`),zs);return{...n,items:n.items??[]}}async setContentVote(e){try{await this.postJson(this.dataUrl(Za.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(e.join(`,`),()=>this.fetchContentCollections(e)).then(e=>({items:e.items.map(e=>Ts(e,this.locale))}))}async fetchContentCollections(e){let t=new URL(this.dataUrl(Za.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:As(`listContentCollections`,await this.getJson(t.toString(),`listContentCollections`),Bs).items??[]}}async saveUserPrefs(e){await this.postJson(Za.updateSettings,{userPrefs:e},`saveUserPrefs`)}get uploadPath(){return this.opts.endpoints?.upload??`/pai/upload-file`}get transcribePath(){return this.opts.endpoints?.transcribe??`/pai/transcribe-audio`}async submitFeedback(e){ds.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(Za.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){ds.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e,t={}){ds.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});let n=JSON.stringify({...this.withEnvelope(e),[Qa]:ts(this.userContext,this.pageContext,this.opts.recentHostEvents)}),r=t.keepalive===!0&&new Blob([n]).size<6e4;try{return await this.runWithAbort(async e=>{let t=await this.withFreshUserToken(()=>this.fetchImpl(this.url(Za.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url(Za.streamMessage))},body:n,keepalive:r,signal:e}));if(t.status!==202)throw new ns(`sendTurn failed: expected 202, received ${t.status}`,`server`,t.status,void 0,Vs(t),(await fs(t)).error);let i;try{i=await t.json()}catch(n){throw e?.aborted?n:new ns(`sendTurn failed: invalid acknowledgement`,`server`,t.status,n)}if(!Os(i))throw new ns(`sendTurn failed: invalid acknowledgement`,`server`,t.status);return i},void 0,3e4)}catch(e){throw e instanceof ns?e:new ns(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(ds.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url(Za.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(Za.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>ds.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t=new AbortController;function n(){return t.abort(e.signal.reason)}e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0});let r=setTimeout(()=>t.abort(),1e4);function i(){clearTimeout(r),e.signal.removeEventListener(`abort`,n)}let a;try{a=await this.withFreshUserToken(()=>this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,cache:`no-store`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal}))}catch(t){return i(),e.signal.aborted||ds.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===409||bs.has(a.status)?(ds.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(ds.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),ds.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),ds.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of is(a,t.signal,t=>{o||t!==`connected`||(o=!0,clearTimeout(r),e.onConnected())})){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;ds.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery(Za.streamResume)}async postJson(e,t,n,r=!1){let i=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(e))},body:JSON.stringify(this.withEnvelope(t)),...r?{keepalive:!0}:{}}],n);return this.assertOk(i,n)}async postForm(e,t,n,r,i,a){let o=a?us(a):this.fetchImpl;return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>o(this.url(e),{method:`POST`,credentials:`omit`,headers:this.headersFor(this.url(e)),body:this.appendEnvelope(t),signal:r}));return this.assertOk(i,n)},r,i)}async runWithAbort(e,t,n){if(!t&&n===void 0)return e();let r=new AbortController;function i(){return r.abort(t?.reason)}t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0});let a=n===void 0?void 0:setTimeout(()=>r.abort(),n);try{return await e(r.signal)}finally{a!==void 0&&clearTimeout(a),t?.removeEventListener(`abort`,i)}}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.headersFor(this.url(e))}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let r;try{r=await this.withFreshUserToken(()=>this.fetchImpl(...e()))}catch(e){if(n>=3)throw new ns(`${t} failed: network error`,`network`,void 0,e);ds.debug(`request network error — retrying`,{label:t,attempt:n}),await Qo(xs(n));continue}if(r.ok||!bs.has(r.status)||n>=3)return r;let i=Cs(r.headers)??xs(n);ds.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await Qo(i)}}async assertOk(e,t){if(!e.ok)throw new ns(`${t} failed: ${e.status}`,`server`,e.status,void 0,void 0,(await fs(e)).error);return await e.json()}fetchUserToken(){let e=this.userTokenSource;if(typeof e!=`function`)return Promise.resolve();let t=Promise.resolve().then(e).then(t=>{this.userTokenSource===e&&(this.userToken=t||void 0)},t=>{ds.warn(`userToken function failed`,{err:t}),this.userTokenSource===e&&(this.userToken=void 0)});return this.userTokenRequest=t,t}headersFor(e){let t=!/^https?:\/\//i.test(e)||e.startsWith(`${this.opts.agentApiBaseUrl}/`);return{...this.opts.auth.headers(),...t&&this.userToken?{"x-user-token":this.userToken}:{},...t&&this.opts.continueLink?{"x-continue-link":this.opts.continueLink}:{}}}async withFreshUserToken(e){this.userTokenRequest&&await this.userTokenRequest;let t=await e();if(t.status!==401)return t;let n=await fs(t);if(n.error===`USER_TOKEN_REQUIRED`)return this.opts.onLoginState?.({status:`required`,loginUrl:n.loginUrl}),t;if(!this.userToken)return t;if(!await this.refreshUserToken())return this.reportLogin(`expired`),t;this.reportLogin(`loggedIn`);let r=await e();return r.status===401&&this.reportLogin(`expired`),r}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Ds(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 Os(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`status`),n=Reflect.get(e,`conversationId`),r=Reflect.get(e,`runId`);return t===`accepted`&&typeof n==`string`&&n.length>0&&(r===void 0||typeof r==`string`&&r.length>0)}function ks(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function As(e,t,n){if(!n(t))throw new ns(`${e} failed: invalid response body`,`server`);return t}function js(e,t){let n=eo(ks(t)?t.controlState:void 0);if(!n)throw new ns(`${e} failed: invalid response body`,`server`);return n}function Ms(e){return!(!ks(e)||typeof e.visitorId!=`string`||typeof e.conversationId!=`string`||e.welcome!==void 0&&(!ks(e.welcome)||e.welcome.messages!==void 0&&!Array.isArray(e.welcome.messages)))}function Ns(e){return ks(e)&&typeof e.id==`string`&&typeof e.url==`string`&&typeof e.originalName==`string`&&typeof e.mimeType==`string`&&typeof e.fileSize==`number`}function Ps(e){return ks(e)&&typeof e.text==`string`}function Fs(e){return ks(e)&&typeof e.page==`number`&&typeof e.limit==`number`&&typeof e.total==`number`&&typeof e.totalPages==`number`&&typeof e.hasNext==`boolean`&&typeof e.hasPrev==`boolean`}function Is(e){return ks(e)&&Array.isArray(e.conversations)&&e.conversations.every(ks)&&Fs(e.pagination)}function Ls(e){return ks(e)&&typeof e.conversationId==`string`&&Array.isArray(e.messages)&&e.messages.every(ks)}function Rs(e){return ks(e)&&typeof e.status==`string`&&typeof e.to==`string`}function zs(e){return ks(e)&&(e.items===void 0||Array.isArray(e.items)&&e.items.every(ks))&&(e.pagination===void 0||Fs(e.pagination))}function Bs(e){return ks(e)&&(e.items===void 0||Array.isArray(e.items)&&e.items.every(ks))}function Vs(e){let t=Number(e.headers.get(`retry-after`));return Number.isInteger(t)&&t>0?t:void 0}function Hs(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`popOut`:return t!==`standalone`&&t!==`page`;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function Us(e,t,n){return Hs(`close`,e,t)?n.includes(`close`):!1}function Ws(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function Gs(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function Ks(e){return Object.fromEntries(e.map(e=>[e,[]]))}function qs(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function Js(e,t,n){let r=[...new Set(t)],i=qs(r,e,``),a=o({activeTab:i,stacks:Ks(r)});return{sig:a,reconcile(e,t){let i=[...new Set(e)],o=a.value,s=qs(i,o.activeTab,t),c=Object.fromEntries(i.map(e=>[e,o.stacks[e]??[]])),l=s===o.activeTab&&i.length===Object.keys(o.stacks).length&&i.every(e=>o.stacks[e]===c[e]);r=i,l||(a.value={activeTab:s,stacks:c},s!==o.activeTab&&s&&n?.(s))},switchTab(e){e in a.value.stacks&&a.value.activeTab!==e&&(a.value={...a.value,activeTab:e},n?.(e))},open(e,t){let r=a.value;e in r.stacks&&(a.value={activeTab:e,stacks:{...r.stacks,[e]:t?[t]:[]}},r.activeTab!==e&&n?.(e))},push(e){let t=a.value,n=t.stacks[t.activeTab]??[];a.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=a.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(a.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){a.value={activeTab:qs(r,e,``),stacks:Ks(r)}}}}function Ys(e){return e.stacks[e.activeTab]??[]}function Xs(e){return Ys(e).at(-1)}function Zs(e){return Ys(e).length===0}function Qs(e){/^(https?:)?\//i.test(e)&&window.open(e,`_blank`,`noopener,noreferrer`)}function $s(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 ec(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 tc(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:ec(e.mode,e.size,t)}}function nc(){return typeof window>`u`?0:window.innerWidth}const K={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},rc=`${P.cssPrefix}-icon-dir`;function ic(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})})}function ac(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function oc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 5v14M5 12h14`})})}function sc(){return/* @__PURE__ */ v(`svg`,{...K,class:rc,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),/* @__PURE__ */ _(`path`,{d:`M22 2 11 13`})]})}function cc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function lc(){return/* @__PURE__ */ _(`svg`,{...K,class:rc,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function uc(){return/* @__PURE__ */ _(`svg`,{...K,class:rc,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`m9 18 6-6-6-6`})})}function dc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function fc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`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`})})}function pc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),/* @__PURE__ */ _(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]})}function mc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`8`,r:`4.5`}),/* @__PURE__ */ _(`path`,{d:`M4.5 20.5a7.5 7.5 0 0 1 15 0`})]})}function hc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function gc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function _c(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function vc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function yc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 3h7v7M21 3l-9 9`}),/* @__PURE__ */ _(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})]})}function bc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ _(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function xc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]})}function Sc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})})}function Cc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function wc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),/* @__PURE__ */ _(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]})}function Tc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M20 6 9 17l-5-5`})})}function Ec(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 3v6h6`}),/* @__PURE__ */ _(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),/* @__PURE__ */ _(`path`,{d:`M12 7v5l3 2`})]})}function Dc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M2 12h20`}),/* @__PURE__ */ _(`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`})]})}function Oc(){return/* @__PURE__ */ _(`svg`,{...K,class:rc,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function kc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M12 20h9`}),/* @__PURE__ */ _(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function Ac(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),/* @__PURE__ */ _(`path`,{d:`m3 7 9 6 9-6`})]})}function jc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`m6 9 6 6 6-6`})})}function Mc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),/* @__PURE__ */ _(`path`,{d:`M14 2v6h6`})]})}function Nc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),/* @__PURE__ */ _(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]})}function Pc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})})}function Fc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),/* @__PURE__ */ _(`path`,{d:`M12 17h.01`})]})}function Ic(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m15 4 3 3-9 9-3-3z`}),/* @__PURE__ */ _(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]})}function Lc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),/* @__PURE__ */ _(`path`,{d:`M12 8V4`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`3`,r:`1`}),/* @__PURE__ */ _(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]})}function Rc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),/* @__PURE__ */ _(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ _(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ _(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]})}function zc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ _(`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`})]})}function Bc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ _(`path`,{d:`m21 21-4.3-4.3`})]})}function Vc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Hc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 9.5 12 3l9 6.5`}),/* @__PURE__ */ _(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]})}function Uc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m3 11 15-5v12L3 13z`}),/* @__PURE__ */ _(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),/* @__PURE__ */ _(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),/* @__PURE__ */ _(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]})}function Wc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),/* @__PURE__ */ _(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]})}function Gc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ _(`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`})]})}function Kc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})}function qc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`M12 3v18`}),/* @__PURE__ */ _(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]})}function Jc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),/* @__PURE__ */ _(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),/* @__PURE__ */ _(`path`,{d:`m20 20-4.4-4.4`})]})}function Yc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`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`}),/* @__PURE__ */ _(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]})}function Xc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M4 18h16`}),/* @__PURE__ */ _(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),/* @__PURE__ */ _(`path`,{d:`M12 8V6`}),/* @__PURE__ */ _(`path`,{d:`M10 6h4`})]})}function Zc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ _(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ _(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),/* @__PURE__ */ _(`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`})]})}function Qc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),/* @__PURE__ */ _(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]})}function $c(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),/* @__PURE__ */ _(`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`})]})}function el(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),/* @__PURE__ */ _(`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`})]})}function tl(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),/* @__PURE__ */ _(`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`})]})}function nl(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`M12 7v5l3 2`})]})}function rl(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function il(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}function al(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 18V5M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294M17.996 5.125a4 4 0 012.526 5.77M18 18a4 4 0 002-7.465M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517M6 18a4 4 0 01-2-7.465M6.004 5.125a4 4 0 00-2.526 5.77`})})}function ol(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M12 8v4M12 16h.01`})]})}const sl={chat:ic,message:Pc,bubbles:Wc,spark:Nc,wand:Ic,bot:Lc,help:Fc,lifebuoy:zc,headset:Rc,search:Jc,sparkles:Yc,concierge:Xc,wave:Zc},q=P.cssPrefix,J={launcher:`${q}-launcher`,callout:`${q}-callout`,calloutDismiss:`${q}-callout-dismiss`,panel:`${q}-panel`,panelHeader:`${q}-panel-header`,resizeGrip:`${q}-resize-grip`,scrollToBottom:`${q}-scroll-to-bottom`,loadPreviousMessages:`${q}-load-previous-messages`,actionHistory:`${q}-action-history`,actionClose:`${q}-action-close`,emailTranscriptSheet:`${q}-email-transcript-sheet`,emailTranscriptEmail:`${q}-email-transcript-email`,emailTranscriptSend:`${q}-email-transcript-send`,langSegment:`${q}-lang-segment`,composer:`${q}-composer`,composerInput:`${q}-composer-input`,composerCount:`${q}-composer-count`,composerSend:`${q}-composer-send`,composerStop:`${q}-composer-stop`,compactionStatus:`${q}-compaction-status`,messageQueue:`${q}-message-queue`,queuedMessage:`${q}-queued-message`,queuedMessageRemove:`${q}-queued-message-remove`,composerAttach:`${q}-composer-attach`,composerFileInput:`${q}-composer-file-input`,composerVoice:`${q}-composer-voice`,attachmentChip:`${q}-attachment-chip`,attachmentRemove:`${q}-attachment-remove`,attachmentRetry:`${q}-attachment-retry`,suggestion:`${q}-suggestion`,messageBubble:`${q}-message`,messageRetry:`${q}-message-retry`,messageFile:`${q}-message-file`,messageFeedback:`${q}-message-feedback`,feedbackUp:`${q}-feedback-up`,feedbackDown:`${q}-feedback-down`,messageCopy:`${q}-message-copy`,historyItem:`${q}-history-item`,historyLoadMore:`${q}-history-load-more`,sidebar:`${q}-sidebar`,sidebarToggle:`${q}-sidebar-toggle`,sidebarNewConversation:`${q}-sidebar-new-conversation`,messengerHome:`${q}-messenger-home`,panelNotice:`${q}-panel-notice`,tab:`${q}-tab`,tabBadge:`${q}-tab-badge`,homeView:`${q}-home-view`,homeGreeting:`${q}-home-greeting`,homeBrand:`${q}-home-brand`,backHeader:`${q}-back-header`,contentView:`${q}-content-view`,contentScroll:`${q}-content-scroll`,homeSearch:`${q}-home-search`,helpSearch:`${q}-help-search`,homeRecent:`${q}-home-recent`,homeAsk:`${q}-home-ask`,homeWhatsNew:`${q}-home-whats-new`,homeContentRow:`${q}-home-content-row`,helpArticle:`${q}-help-article`,newsItem:`${q}-news-item`,newsMore:`${q}-news-more`,formField:`${q}-form-field`,toolAskQuestions:`${q}-tool-ask-questions`,toolInputSubmit:`${q}-tool-input-submit`,toolInputSkip:`${q}-tool-input-skip`,toolApproval:`${q}-tool-approval`,toolPreview:`${q}-tool-preview`,toolApprove:`${q}-tool-approve`,toolDecline:`${q}-tool-decline`,toolEdit:`${q}-tool-edit`,toolDecision:`${q}-tool-decision`,typingDots:`${q}-typing-dots`,reasoning:`${q}-reasoning`,replyStopped:`${q}-reply-stopped`,toolAskSummary:`${q}-ask-questions-summary`,toolAskOptions:`${q}-ask-questions-options-toggle`,toolSteps:`${q}-tool-steps`,toolStep:`${q}-tool-step`,source:`${q}-source`,operatorRequest:`${q}-operator-request`,chatNotice:`${q}-chat-notice`,operatorBanner:`${q}-operator-banner`,cancelOperatorRequest:`${q}-cancel-operator-request`,loginBar:`${q}-login-bar`,loginBarAction:`${q}-login-bar-action`,loginBarHide:`${q}-login-bar-hide`,loginGate:`${q}-login-gate`,loginGateAction:`${q}-login-gate-action`,loginGateGuest:`${q}-login-gate-guest`,loggedIn:`${q}-logged-in`};function cl(e,t){return`${e}-${t}`}const ll=P.cssPrefix;function ul({buttonRef:e,onToggle:t,launcher:n,strings:r,leaving:i,edgeTab:a}){let o=n.variant===`circle`?``:dl(n,r);return/* @__PURE__ */ v(`button`,{ref:e,type:`button`,class:`${ll}-fab`,part:`launcher`,"data-variant":n.variant,"data-size":n.size,"data-edge-tab":a?`true`:void 0,"data-leaving":i?`true`:void 0,"data-testid":J.launcher,onClick:t,"aria-label":r.launcherOpen,children:[fl(n.icon),o?/* @__PURE__ */ _(`span`,{class:`${ll}-fab-label`,children:o}):null]})}function dl(e,t){return e.label?M(t,e.label):e.personaName?t.launcherAsk.replace(`{name}`,M(t,e.personaName)):``}function fl(e){let t=sl[e];return t?/* @__PURE__ */ _(t,{}):/* @__PURE__ */ _(pl,{source:e})}function pl({source:e}){return/* @__PURE__ */ _(`span`,{ref:t=>{t&&ml(t,e)},"aria-hidden":`true`})}function ml(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function hl({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=h(!1),s=m(null),[c,l]=h(!0);return f(()=>{let e=s.current?.parentElement;if(!e)return;let t=()=>l(window.innerWidth-e.getBoundingClientRect().width>=gl);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}),u(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),u(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ v(`div`,{ref:s,class:`${ll}-callout`,role:`status`,"data-shape":e.shape,"data-position":_l(e.position,t,c),"data-animated":e.animated?`true`:void 0,"data-testid":J.callout,children:[/* @__PURE__ */ _(`span`,{children:M(n,e.text)}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${ll}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":J.calloutDismiss,children:/* @__PURE__ */ _(ac,{})})]}):null}const gl=200;function _l(e,t,n=!0){let r=t.endsWith(`-right`),i=t.startsWith(`bottom-`);return e===`vertical`||e===`auto`&&!n?i?`top`:`bottom`:r?`left`:`right`}function vl(e){function 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(),o=a instanceof ShadowRoot?a.activeElement:null;t.shiftKey&&o===r?(t.preventDefault(),i.focus()):!t.shiftKey&&o===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const yl=P.cssPrefix;function bl({title:e,actions:t}){return/* @__PURE__ */ v(`header`,{class:`${yl}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ _(`span`,{class:`${yl}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ _(`h1`,{class:`${yl}-back-title`,children:e}),t??/* @__PURE__ */ _(`span`,{class:`${yl}-back-spacer`,"aria-hidden":`true`})]})}function xl({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ v(`header`,{class:`${yl}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${yl}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ _(Oc,{})}),/* @__PURE__ */ _(`h1`,{class:`${yl}-back-title`,children:e}),r??/* @__PURE__ */ _(`span`,{class:`${yl}-back-spacer`,"aria-hidden":`true`})]})}function Sl({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=D,onCardAction:i}){let o=m(null),s=m(null);return f(()=>{let c=o.current;if(!c)return;c.classList.add(`${P.cssPrefix}-md`);let l=s.current,u={generativeUi:n,strings:r,onCardAction:i},d=()=>{s.current?.renderer?.dispose();let a=document.createElement(`div`),o=n?Oa(a,{cssPrefix:P.cssPrefix,strings:r,onAction:i}):void 0,l=y.parser(Dl(Ml(o??y.default_renderer(a)))),d=e.value,f=d.length-Tl(d);if(!t.value)for(;f>0&&d[f-1]===`_`;)f--;let p=El(d.slice(0,f));return p&&y.parser_write(l,p),t.value&&(y.parser_end(l),o?.finish()),c.replaceChildren(a),{settings:u,container:a,parser:l,renderer:o,lastLen:f,lastText:d.slice(0,f)}},f=l&&l.settings.generativeUi===n&&l.settings.strings===r&&l.settings.onCardAction===i&&e.value.startsWith(l.lastText)?l:d();s.current=f;let p=a(()=>{let n=e.value,r=t.value;if(n.length<f.lastLen){f=d(),s.current=f;return}let i=Math.max(n.length-Tl(n),f.lastLen);if(!r)for(;i>f.lastLen&&n[i-1]===`_`;)i--;let a=Math.max(f.lastLen-1,0),o=El(n.slice(a,i)).slice(f.lastLen-a);o&&y.parser_write(f.parser,o),f.lastLen=i,f.lastText=n.slice(0,i),r&&(y.parser_end(f.parser),f.renderer?.finish())}),m=new MutationObserver(()=>Nl(c));m.observe(c,{childList:!0,subtree:!0}),Nl(c);function h(e){let t=e.target instanceof Element?e.target.closest(`a`):null;if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return c.addEventListener(`click`,h),()=>{p(),m.disconnect(),c.removeEventListener(`click`,h)}},[e,t,n,r,i]),u(()=>()=>{s.current?.renderer?.dispose(),s.current=null},[]),/* @__PURE__ */ _(`div`,{ref:o})}function Cl({text:e}){let t=p(()=>o(e),[e]),n=p(()=>o(!0),[]);return/* @__PURE__ */ _(Sl,{textSig:t,doneSig:n})}const wl=/([\p{L}\p{N}])(_+)(?=[\p{L}\p{N}])/gu;function Tl(e){if((e.match(/^[ \t]*`{3,}/gm)?.length??0)%2==0)return 0;let t=e.trimEnd(),n=t.lastIndexOf(`
39
- `)+1;return/^[ \t]*`{3,}[^`]*$/.test(t.slice(n))?e.length-n:0}function El(e){return e.replace(wl,(e,t,n)=>t+``.repeat(n.length))}function Dl(e){return{...e,add_text:(t,n)=>e.add_text(t,n.replaceAll(``,`_`)),set_attr:(t,n,r)=>e.set_attr(t,n,r.replaceAll(``,`_`))}}const Ol=/<(\/?)(?:(Note|Info|Tip|Warning|Danger|Check|Callout)|Tabs?|Steps?|AccordionGroup|Accordion|Expandable|Columns|CardGroup|Card|Frame|CodeGroup|Badge|Icon|Video|Embed|ParamField|ResponseField)\b((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>|(^|\n)([ \t]*)(```[^]*?(?:\n[ \t]*```|$))?/g;function kl(e){let t=0,n=``;return e.replace(Ol,(e,r,i,a,o,s,c,l)=>{if(r===void 0)return t?s+(l?.split(`\n${c}`).join(`
40
- `)??n):e;if(r)return t--,i&&(n=n.slice(2)),i?`\n${n}`:``;o||(t++,i&&(n+=`> `));let u={};a.replace(/(\w+)=(["'])(.*?)\2/g,(e,t,n,r)=>u[t]=r);let d=u.href??u.src,f=u.title??u.path??u.query??u.body??u.header??u.name??d;return(i?`> `:``)+(f?`**${d?`[${f}](${d})`:f}**${u.type?` \`${u.type}\``:``}\n${n}`:``)})}const Al=/* @__PURE__ */ new Set([`http:`,`https:`,`mailto:`,`tel:`]),jl=/* @__PURE__ */ new Set([`http:`,`https:`]);function Ml(e){let t=document.createElement(`a`);return{...e,set_attr:(n,r,i)=>{if(r!==y.HREF&&r!==y.SRC||(t.href=i,(r===y.HREF?Al:jl).has(t.protocol)))return e.set_attr(n,r,i);let a=r===y.SRC?n.nodes[n.index]:void 0;a?.replaceWith(...a.childNodes)}}}function Nl(e){for(let t of e.querySelectorAll(`a`)){let e=t.getAttribute(`href`)??``;e&&!e.startsWith(`#`)&&(t.target=`_blank`,t.rel=`noopener noreferrer`)}}const Pl=/* @__PURE__ */ new Set([y.CODE_INLINE,y.ITALIC_AST,y.ITALIC_UND,y.STRONG_AST,y.STRONG_UND,y.STRIKE,y.LINK,y.RAW_URL,y.IMAGE,y.EQUATION_INLINE]);function Fl(e){let t=``,n=[],r=y.parser({data:void 0,add_token:(e,r)=>{n.push(r),Pl.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!Pl.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return y.parser_write(r,El(e)),y.parser_end(r),t.replaceAll(``,`_`).replace(/\s+/g,` `).trim()}const Il=P.cssPrefix;function Ll({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ v(`div`,{class:`${Il}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ _(`span`,{children:t}),n?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Il}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const Rl=P.cssPrefix,zl=V.scope(`content`);function Bl({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=h(null),[d,f]=h(!1),[p,m]=h(!1),[y,b]=h(0),[x,S]=h(null),C=l(()=>{m(!1),c(null),b(e=>e+1)},[]);u(()=>{let t=!1,r=n.listContentCollections([]).catch(()=>void 0);return Promise.all([n.listContent({ids:[e],limit:1}),r]).then(([n,r])=>{if(t)return;let a=n.items[0];a?(c(a),f(r?.items.find(e=>e.id===a.contentCollectionId)?.settings?.voteAccess===`portal`),i.emit(`contentOpen`,{contentId:e,contentCollectionId:a.contentCollectionId})):m(!0)}).catch(e=>{t||(zl.warn(`listContent (reader) failed`,{err:e}),m(!0))}),()=>{t=!0}},[n,e,y,i]),u(()=>{if(!s)return;let t=setTimeout(()=>i.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[s,e,i]);let w=l(t=>{let n=(t.target instanceof HTMLElement?t.target.closest(`a`):null)?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&i.emit(`contentLinkClick`,{contentId:e})},[i,e]);function T(t){S(e),n.setContentVote({contentId:e,value:t})}function E(){return p?/* @__PURE__ */ _(Ll,{tone:`error`,message:r.errorGeneric,onRetry:C,strings:r}):s===null?/* @__PURE__ */ _(Ll,{message:r.contentLoading,strings:r}):/* @__PURE__ */ v(`article`,{class:`${Rl}-content`,"data-testid":J.contentView,onClick:w,children:[s.image?/* @__PURE__ */ _(`img`,{class:`${Rl}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ _(`p`,{class:`${Rl}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ _(Cl,{text:kl(s.content??``)}),d?/* @__PURE__ */ _(`div`,{class:`${Rl}-content-vote`,"aria-live":`polite`,children:x===e?r.feedbackThanks:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{children:r.contentHelpful}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Rl}-module-retry`,onClick:()=>T(1),children:r.confirmYes}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Rl}-module-retry`,onClick:()=>T(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ v(`div`,{class:`${Rl}-module`,children:[/* @__PURE__ */ _(xl,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:J.backHeader}),/* @__PURE__ */ _(`div`,{class:`${Rl}-module-scroll`,"data-testid":J.contentScroll,children:E()})]})}function Vl({itemCount:e,initialFocusIndex:t}){let[n,r]=h(!1),i=m(null),a=m(null),[o,s]=h(-1),c=l(()=>{r(!1),s(-1),i.current?.focus()},[]),d=l(()=>r(e=>!e),[]);return u(()=>{if(!n)return;function e(e){let t=a.current,n=i.current;if(!t||!n)return;let o=e.composedPath();o.includes(t)||o.includes(n)||(r(!1),s(-1))}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),u(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),u(()=>{!n||o<0||(a.current?.querySelectorAll(`[role='menuitem']`))?.[o]?.focus()},[n,o]),{open:n,focusIndex:o,triggerRef:i,menuRef:a,toggle:d,close:c,onTriggerKey:l(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},[]),onMenuKey:l(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),t.stopPropagation(),c();return;case`ArrowDown`:t.preventDefault(),s(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),s(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),s(0);return;case`End`:t.preventDefault(),s(e-1)}},[e,c])}}function Hl({items:e,triggerLabel:t}){let n=P.cssPrefix,r=Vl({itemCount:e.length});function i(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function a(e,t){return e.onSelectValue?.(t)}function 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;let o=n[i];o&&(e.preventDefault(),e.stopPropagation(),a(t,o.value))}return/* @__PURE__ */ v(`div`,{class:`${n}-menu-wrap`,children:[/* @__PURE__ */ _(`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:/* @__PURE__ */ _(xc,{})}),r.open?/* @__PURE__ */ _(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?/* @__PURE__ */ v(`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?/* @__PURE__ */ _(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${n}-menu-label`,children:e.label}),/* @__PURE__ */ _(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return/* @__PURE__ */ _(`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":`${J.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):/* @__PURE__ */ v(`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?/* @__PURE__ */ _(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?/* @__PURE__ */ _(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Tc,{})}):null]},e.id))}):null]})}const Ul=P.cssPrefix;function Wl(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 Gl={normal:`large`,large:`small`,small:`normal`};function Kl(e){return _(e===`light`?Gc:e===`dark`?Kc:qc,{})}function ql(e,t){let n=e.split(`-`)[0];return(t.some(t=>t!==e&&t.split(`-`)[0]===n)?e:n??e).toUpperCase()}function Jl(e,t){let n;try{n=new URL(e,window.location.href)}catch{return}if(n.protocol===`http:`||n.protocol===`https:`)return t.conversationId&&n.searchParams.set(`chat`,t.conversationId),n.searchParams.set(`widgetId`,t.widgetId),t.publicKey&&n.searchParams.set(`public_key`,t.publicKey),n.searchParams.set(`ai_agent_deployment_id`,t.aiAgentDeploymentId),n.href}function Yl({panelProps:e,variant:t,onEmailTranscript:n,onLogIn:r}){let{options:i,panelSize:a,feedback:o,onClose:c,onClear:l,onExpand:u,onFullscreen:d,onSoundToggle:f}=e,{onToggleHistory:p,onLocaleChange:m,onThemeChange:h,onTextSizeChange:g}=e,y=i.strings,b=i.mode,x=t===`chat`,S=s(()=>o.mutedSig.value).value,C=new Set(i.actions);function w(e){return C.has(e)}let T=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function E(e){return!T&&Hs(e,b,a)}let D=i.themeMode,O={auto:y.themeAuto,light:y.themeLight,dark:y.themeDark},k=i.textSize,A={small:y.textSizeSmall,normal:y.textSizeNormal,large:y.textSizeLarge},j=[];if(x&&w(`clear`)&&j.push({id:`clear`,icon:/* @__PURE__ */ _(kc,{}),label:y.newConversation,onSelect:l}),x&&n&&j.push({id:`emailTranscript`,icon:/* @__PURE__ */ _(Ac,{}),label:y.emailTranscript,onSelect:n}),x&&r&&j.push({id:`logIn`,icon:/* @__PURE__ */ _(mc,{}),label:y.loginAction,onSelect:r}),w(`expand`)&&E(`expand`)){let e=a===`expanded`;j.push({id:`expand`,icon:_(e?gc:hc,{}),label:e?y.collapse:y.expand,type:`switch`,on:e,onSelect:u})}if(w(`fullscreen`)&&E(`fullscreen`)){let e=a===`fullscreen`;j.push({id:`fullscreen`,icon:_(e?vc:_c,{}),label:e?y.exitFullscreen:y.fullscreen,type:`switch`,on:e,onSelect:d})}let ee=i.popOutUrl,M=i.aiAgentDeploymentId;w(`popOut`)&&ee&&M&&Hs(`popOut`,b,a)&&j.push({id:`popOut`,icon:/* @__PURE__ */ _(yc,{}),label:y.popOut,onSelect:()=>{let t=Jl(ee,{conversationId:e.conversationId,widgetId:i.widgetId,publicKey:i.publicKey,aiAgentDeploymentId:M});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),x&&w(`sound`)&&j.push({id:`sound`,icon:_(S?Cc:Sc,{}),label:S?y.soundOff:y.soundOn,type:`switch`,on:!S,onSelect:f}),w(`theme`)&&D!==`host`&&j.push({id:`theme`,icon:Kl(D),label:`${y.theme}: ${O[D]}`,onSelect:()=>h(Wl(D)),keepOpen:!0}),w(`textSize`)&&j.push({id:`textSize`,icon:/* @__PURE__ */ _(wc,{}),label:`${y.textSize}: ${A[k]}`,onSelect:()=>g(Gl[k]),keepOpen:!0}),w(`language`)&&i.availableLocales.length>1&&j.push({id:`language`,icon:/* @__PURE__ */ _(Dc,{}),label:y.language,segments:i.availableLocales.map(e=>({value:e,label:ql(e,i.availableLocales),lang:e})),value:i.locale,onSelectValue:m});let N=!!c&&Us(b,a,i.actions),P=x&&w(`history`);return/* @__PURE__ */ v(`div`,{class:`${Ul}-header-actions`,children:[P?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Ul}-icon-btn`,onClick:p,"aria-label":y.history,title:y.history,"data-testid":J.actionHistory,children:/* @__PURE__ */ _(Ec,{})}):null,j.length>0?/* @__PURE__ */ _(Hl,{items:j,triggerLabel:y.moreActions}):null,N?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Ul}-icon-btn`,onClick:c,"aria-label":y.close,title:y.close,"data-testid":J.actionClose,children:/* @__PURE__ */ _(ac,{})}):null]})}const Xl={Icon:Wc};function Zl(e,t){return e instanceof ns?e.status===429?e.retryAfterSeconds?t.errorRateLimitedIn.replace(`{seconds}`,String(e.retryAfterSeconds)):t.errorRateLimited:e.code===`network`?t.errorOffline:e.status===403?t.errorOriginNotAllowed:e.errorCode===`MESSAGE_TOO_LONG`?t.errorMessageTooLong:e.status!==void 0&&e.status>=500?t.errorServer:t.errorGeneric:t.errorGeneric}const Ql=P.cssPrefix;function $l({placeholder:e,onActivate:t}){return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Ql}-home-search`,onClick:t,"data-testid":J.homeSearch,children:[/* @__PURE__ */ _(`span`,{class:`${Ql}-home-search-text`,children:e}),/* @__PURE__ */ _(`span`,{class:`${Ql}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Bc,{})})]})}function eu({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ v(`div`,{class:`${Ql}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ _(`input`,{type:`search`,class:`${Ql}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":J.helpSearch}),/* @__PURE__ */ _(`span`,{class:`${Ql}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Bc,{})})]})}const tu=P.cssPrefix;function nu({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ v(`button`,{type:`button`,class:`${tu}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ v(`span`,{class:`${tu}-list-row-body`,children:[/* @__PURE__ */ _(`span`,{class:`${tu}-list-row-title`,children:e}),t?/* @__PURE__ */ _(`span`,{class:`${tu}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ _(`span`,{class:`${tu}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ _(uc,{})})]})}const ru=P.cssPrefix,iu=V.scope(`help`);function au(e,t,n){let r=new Map(n.map(e=>[e.id,e.title]));return t.map(t=>({id:t,title:r.get(t),rows:e.filter(e=>e.contentCollectionId===t)})).filter(e=>e.rows.length>0)}function ou({transport:e,strings:t,bus:n},r,i){let[a,o]=h(),s=m(void 0),c=r?.join(`,`);function l(a){if(!r?.length)return;let c={};s.current=c,o(e=>({search:i,items:[],collections:[],...e,pagination:a>1?e?.pagination:void 0,loading:!0,error:void 0})),Promise.all([e.listContent({contentCollectionIds:r,sortBy:`order`,page:a,limit:20,search:i}),a>1?void 0:e.listContentCollections(r)]).then(([e,t])=>{s.current===c&&(o(n=>({search:i,items:[...a>1?n?.items??[]:[],...e.items],collections:t?.items??n?.collections??[],pagination:e.pagination,loading:!1})),a>1||(i?n.emit(`contentSearch`,{queryLength:i.length,hitCount:e.pagination.total}):n.emit(`contentView`,{section:`help`,count:e.items.length})))}).catch(e=>{s.current===c&&(iu.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:Zl(e,t)}))})}return u(()=>{if(!r?.length)o(void 0);else return l(1),()=>{s.current=void 0}},[e,c,i]),[a,()=>!a?.loading&&l((a?.pagination?.page??0)+1)]}function su(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=h(``),[c,l]=h(``),d=ou(e,a),f=ou(e,c?a:void 0,c),[p,m]=o.trim()?f:d;u(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function y(){if(!a?.length)return/* @__PURE__ */ _(Ll,{message:t.helpEmpty,strings:t});let e=p?.error?/* @__PURE__ */ _(Ll,{tone:`error`,message:p.error,onRetry:m,strings:t}):null;return e&&!p?.pagination?e:!p||!p.pagination&&!p.items.length?/* @__PURE__ */ _(Ll,{message:t.helpLoading,strings:t}):p.items.length?/* @__PURE__ */ v(g,{children:[au(p.items,a,p.collections).map(e=>/* @__PURE__ */ v(`section`,{class:`${ru}-help-group`,children:[e.title?/* @__PURE__ */ _(`h2`,{class:`${ru}-help-section-title`,children:e.title}):null,/* @__PURE__ */ _(`div`,{class:`${ru}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ _(nu,{title:e.title,subtitle:e.description,onClick:()=>e.url?Qs(e.url):r.push({kind:`content`,id:e.id,title:e.title}),testid:cl(J.helpArticle,e.id)},e.id))})]},e.id)),e,p.pagination?.hasNext&&!e?/* @__PURE__ */ _(`div`,{children:/* @__PURE__ */ _(`div`,{class:`${ru}-help-card`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${ru}-list-row ${ru}-help-more`,onClick:m,"aria-busy":p.loading,children:[p.loading?/* @__PURE__ */ _(`span`,{class:`${ru}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ _(Ll,{message:p.search?t.helpSearchEmpty.replace(`{query}`,p.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ v(`div`,{class:`${ru}-module`,children:[/* @__PURE__ */ _(bl,{title:t.helpTitle,actions:/* @__PURE__ */ _(Yl,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ _(`div`,{class:`${ru}-module-pad`,children:/* @__PURE__ */ _(eu,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ _(`div`,{class:`${ru}-help-list`,children:y()})]})}const cu={Icon:Fc,Root:e=>/* @__PURE__ */ _(su,{...e})},lu=V.scope(`attachments`);function uu(e,t,n){let r=hu(e),i=[],a=[],o=bu(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=mu(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(yu(e)),s+=e.size,c+=1)}return(i.length||a.length)&&lu.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function du(e){let t=Math.min(Math.floor(Math.log10(Math.max(e,1))/3),2);return new Intl.NumberFormat(void 0,{style:`unit`,unit:[`byte`,`kilobyte`,`megabyte`][t],unitDisplay:`narrow`,maximumFractionDigits:1}).format(e/1e3**t)}function fu(e,t){let n=bu(t);return!e||n.length===0||n.some(t=>t.kind===`ext`||xu(new File([],``,{type:e}),[t]))}function pu(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){lu.debug(`revokeObjectURL failed`,{error:e})}}function mu(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:xu(e,i)?null:`mime`}function hu(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:gu(e)).filter(e=>e!==null):[]}function gu(e){let t=_u(e)?e:null;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function _u(e){return vu(e)&&(e.getAsFile===void 0||typeof e.getAsFile==`function`)}function vu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yu(e){return{file:e,id:$t(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function bu(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 xu(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===`image`&&e.subtype===`*`&&/\.(heic|heif|avif|bmp|tif|tiff)$/.test(i)?!0:(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const Su=P.cssPrefix,Cu={error:ol,done:Tc};function wu({attachment:e,upload:t,strings:n,onRemove:r,disabled:i=!1}){let a=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType),o=Math.round((t?.fraction??0)*100),s=du(e.size),c=t?.status===`error`||t?.status===`done`?Cu[t.status]:void 0;return/* @__PURE__ */ v(`span`,{class:`${Su}-attachment-chip`,"data-upload":t?.status,title:e.name,"data-testid":cl(J.attachmentChip,e.id),children:[a?/* @__PURE__ */ _(`img`,{class:`${Su}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ _(`span`,{class:`${Su}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Mc,{})}),/* @__PURE__ */ v(`span`,{class:`${Su}-attachment-text`,children:[/* @__PURE__ */ _(`span`,{class:`${Su}-attachment-name`,children:e.name}),/* @__PURE__ */ v(`span`,{class:`${Su}-attachment-meta`,children:[c?/* @__PURE__ */ _(c,{}):null,t?.status===`uploading`?`${o}% · ${s}`:s]})]}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Su}-attachment-remove`,onClick:r,disabled:i,"aria-label":n.removeAttachment.replace(`{name}`,e.name),"data-testid":cl(J.attachmentRemove,e.id),children:/* @__PURE__ */ _(ac,{})}),t?.status===`uploading`?/* @__PURE__ */ _(`span`,{class:`${Su}-attachment-progress`,role:`progressbar`,"aria-label":e.name,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:/* @__PURE__ */ _(`span`,{style:{width:`${o}%`}})}):null]})}const Tu=/* @__PURE__ */ new WeakMap;function Eu(e){e.currentTarget&&Tu.set(e.currentTarget,e.timeStamp)}function Du(e){let t=e.currentTarget?Tu.get(e.currentTarget):void 0;return e.isComposing||t!==void 0&&e.timeStamp-t<100}const Ou=P.cssPrefix;function ku({text:e,retryLabel:t,onRetry:n,retryTestId:r}){return/* @__PURE__ */ v(`div`,{class:`${Ou}-error`,role:`alert`,children:[/* @__PURE__ */ _(`span`,{class:`${Ou}-error-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(ol,{})}),/* @__PURE__ */ _(`span`,{class:`${Ou}-error-text`,children:e}),n&&t?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Ou}-error-retry`,onClick:n,"data-testid":r,children:t}):null]})}const Au={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function ju(e,t,n){return e===`disabled`?Au:e===`server`?Fu(n):Mu(t)}function Mu(e){let t=Nu();if(!t)return Au;let n=null,r=0;return{isSupported:!0,start(i,a){let o=n,s=++r;n=null,o?.abort();let c=new t;n=c,c.continuous=!0,c.interimResults=!0,c.lang=e;let l=!1;c.addEventListener(`result`,e=>{if(r!==s||n!==c)return;let t=e,a=``,o=!1;for(let e=t.resultIndex;e<t.results.length;e++){let n=t.results[e];n&&(a+=n[0].transcript,n.isFinal&&(o=!0))}i(a,o)});function u(e){l||r!==s||n!==c||(l=!0,n=null,a(e))}c.addEventListener(`end`,()=>u(!1)),c.addEventListener(`error`,e=>u(`error`in e&&(e.error===`not-allowed`||e.error===`service-not-allowed`)));try{c.start()}catch{u(!1)}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function Nu(){return window.SpeechRecognition??window.webkitSpeechRecognition}const Pu=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Fu(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return Au;let t=0,n=null;function r(e){for(let t of e.stream?.getTracks()??[])t.stop();e.stream=null}function i(){t++;let e=n;n=null,e&&(r(e),e.recorder?.state!==`inactive`&&e.recorder?.stop())}async function a(i){if(i.finishing)return;i.finishing=!0;let a=i.recorder?.mimeType??`audio/webm`;r(i);let o=new Blob(i.chunks,{type:a});i.chunks=[];try{let{text:r}=await e(o,a);n===i&&t===i.generation&&r&&i.onText(r,!0)}catch{}finally{n===i&&t===i.generation&&(n=null,i.onEnd(!1))}}return{isSupported:!0,async start(e,o){i();let s={generation:t,recorder:null,stream:null,chunks:[],onText:e,onEnd:o,finishing:!1};n=s;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(n!==s||t!==s.generation){for(let t of e.getTracks())t.stop();return}s.stream=e;let r=Iu(),i=new MediaRecorder(e,r?{mimeType:r}:void 0);s.recorder=i,i.addEventListener(`dataavailable`,e=>{n===s&&t===s.generation&&e.data.size>0&&s.chunks.push(e.data)}),i.addEventListener(`stop`,()=>{n===s&&t===s.generation&&a(s)}),i.start()}catch(e){r(s),n===s&&t===s.generation&&(n=null,o(e instanceof DOMException&&e.name===`NotAllowedError`))}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function Iu(){for(let e of Pu)if(MediaRecorder.isTypeSupported(e))return e}function Lu(e,{file:t,reason:n},r){return n===`count`?e.attachmentTooMany.replace(`{count}`,String(r.maxCount)):n===`bytes`?e.attachmentTooLarge.replace(`{name}`,t.name).replace(`{max}`,du(r.maxBytes)):e.attachmentMimeRejected.replace(`{name}`,t.name)}const Y=P.cssPrefix,Ru=V.scope(`composer`);function zu(e){return e.reduce((e,t)=>e+t.size,0)}const Bu={arrowUp:cc,paperPlane:sc,send:lc,chevron:uc};function Vu(e){return`activeElement`in e}function Hu(e){return`host`in e&&`activeElement`in e}function Uu(e){return`clipboardData`in e}function Wu({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,maxMessageCharacters:o,isStreaming:s,pageToolRunning:c=!1,isMemoryCompacting:d=!1,canReleaseQueuedMessages:p=!0,queueManualMessages:g=!1,replyAwaitsCard:y=!1,active:b=!0,isPreparing:x=!1,attachmentUploadsSig:S,operatorRequestEnabled:C,canRequestOperator:w=!1,controlMode:T=`ai-agent`,onRequestOperator:E,onSend:D,onStop:O,apiRef:k}){let A=e.strings,[j,ee]=h(()=>i.loadDraft(a)),[M,N]=h([]),[P,te]=h(),[ne,re]=h(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),F=m(ne),ie=m(!1),ae=m(void 0),[I,oe]=h(!1),[se,ce]=h(!1),[le,ue]=h(!1),[L,de]=h(!1),R=m(!1),fe=m(null),z=m(null),pe=m(null),me=m(0),he=m(a);he.current=a;let B=m(b);B.current=b;let ge=m(x);ge.current=x;let _e=L||x||!b,ve=s&&T===`ai-agent`,ye=ve||d&&T===`ai-agent`,be=T===`ai-agent`&&(ye||g||ne.length>0),xe=l(e=>{re(t=>{let n=e(t);return i.saveMessageQueue(he.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),F.current=n,n})},[i]),Se=l(e=>{xe(t=>(t.find(t=>t.id===e)?.attachments.forEach(pu),t.filter(t=>t.id!==e)))},[xe]),Ce=l(e=>{ee(t=>{let n=(typeof e==`function`?e(t):e).slice(0,o);return n===t?t:(i.saveDraft(he.current,n),n)})},[i,o]),we=e.features.fileUpload,Te=e.features.voice,[Ee,De]=h(()=>ju(Te,e.locale,(e,n)=>t.transcribe(e,n))),Oe=m(Ee);Oe.current=Ee;let ke=m({mode:Te,locale:e.locale,transport:t});u(()=>{let n=ke.current;(n.mode!==Te||n.locale!==e.locale||n.transport!==t)&&(ke.current={mode:Te,locale:e.locale,transport:t},me.current++,Oe.current.cancel(),pe.current=null,ce(!1),De(ju(Te,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,Te,t]),f(()=>()=>{me.current++,Ee.cancel()},[Ee]);let Ae=l(e=>{let t=pe.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return Ru[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),pe.current=null,!0},[r]),je=l(()=>{pe.current!==null&&(Ee.stop(),ce(!1),Ae(`info`)&&n.play(`voiceStop`))},[Ae,n,Ee]),Me=l(()=>{me.current++,Ee.cancel(),ce(!1),Ae(`info`)&&n.play(`voiceStop`)},[Ae,n,Ee]);u(()=>{(x||!b)&&Me()},[b,Me,x]),u(()=>{let e=fe.current;if(!e)return;let t=e.getRootNode(),n=Vu(t)?t.activeElement:null;n&&e.closest(`.${Y}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),u(()=>{let e=fe.current;if(!e)return;if(j.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${Y}-textarea-base-height`)),r=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth),i=Math.min(e.scrollHeight+r,Number.parseFloat(t.maxHeight)),a=Number.parseFloat(t.fontSize)*.7;e.style.height=`${i<n+a?n:i}px`},[j]);let Ne=m(M);Ne.current=M,u(()=>()=>{Ne.current.forEach(pu);for(let e of F.current)e.attachments.forEach(pu)},[]),f(()=>{if(k)return k.current={attachFromDrop:t=>{if(!we||!B.current||R.current||ge.current)return;let n=uu(t,Ne.current,e.attachments);te(n.rejected[0]),n.accepted.length!==0&&(Ru.info(`attach (drop)`,{count:n.accepted.length,totalBytes:zu(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:zu(n.accepted)}),N(e=>[...e,...n.accepted]))},fill:e=>{if(!B.current||R.current||ge.current)return;Ce(e);let t=fe.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:Se},()=>{k.current&&(k.current=null)}},[k,we,x,e.attachments,Se,Ce]),u(()=>{let t=fe.current;if(!t)return;let n=t.closest(`.${Y}-panel`);if(!n)return;let i=n=>{if(!B.current||R.current||ge.current)return;let i=n.clipboardData;if(!i)return;let a=n.target instanceof HTMLElement?n.target.closest(`input, textarea, [contenteditable]:not([contenteditable='false'])`):null;if(a&&a!==t)return;if(we){let t=uu(i.items,Ne.current,e.attachments);if(te(t.rejected[0]),t.accepted.length>0){n.preventDefault(),Ru.info(`attach (paste)`,{count:t.accepted.length,totalBytes:zu(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:zu(t.accepted)}),N(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),Ce(e=>e+o),t.focus())};function a(e){Uu(e)&&i(e)}return n.addEventListener(`paste`,a),()=>n.removeEventListener(`paste`,a)},[we,e.attachments,Ce]);async function Pe(){let e=j.trim();if(!e&&M.length===0||!b||ve||R.current||x)return;Me(),R.current=!0,de(!0);let t=j,n=M;try{await D(e,n)&&(te(void 0),Ce(e=>e===t?``:e),N(e=>e===n?(n.forEach(pu),Ne.current=[],[]):e))}finally{R.current=!1,de(!1),requestAnimationFrame(()=>{let e=fe.current;if(!e||e.disabled||!B.current)return;let t=e.getRootNode(),n=Vu(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==J.composerSend&&r!==J.composerStop)){if(Hu(t)){let e=t.host.ownerDocument;if(!e.hasFocus())return;let n=e.activeElement;if(n&&n!==t.host&&n!==e.body)return}e.focus({preventScroll:!0})}})}}function Fe(){let e=j.trim();if(!e&&M.length===0||!b||!be||R.current||x)return;Me();let t=M;xe(n=>[...n,{id:$t(),text:e,attachments:t}]),ye||oe(!0),Ce(``),N(e=>e===t?(Ne.current=[],[]):e),fe.current?.focus({preventScroll:!0})}u(()=>{ye&&(ie.current=!1,ae.current=void 0,oe(!1))},[ye]),u(()=>{let t=ne[0];if(!t||!p||ye||ie.current||L||x||!b)return;let n=y&&!I?(ae.current??(ae.current=performance.now()+e.cardAnswerWaitSeconds*1e3))-performance.now():0,r=setTimeout(()=>{ie.current=!0,D(t.text,t.attachments,t.id).then(e=>{e?Se(t.id):ie.current=!1})},Math.max(n,300));return()=>clearTimeout(r)},[b,p,I,x,D,e.cardAnswerWaitSeconds,ye,ne,Se,y,L]);function Ie(e){e.key!==`Enter`||e.shiftKey||Du(e)||(e.preventDefault(),be&&(j.trim()||M.length>0)?Fe():ve?O():Pe())}function Le(t){if(!(t.target instanceof HTMLInputElement))return;let n=t.target;if(!b||R.current||x){n.value=``;return}let i=uu(n.files,M,e.attachments);te(i.rejected[0]),i.accepted.length>0&&(Ru.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:zu(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:zu(i.accepted)}),N(e=>[...e,...i.accepted])),n.value=``}function Re(e){!b||R.current||x||(Ru.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),te(void 0),N(t=>{let n=t.find(t=>t.id===e);return n&&pu(n),t.filter(t=>t.id!==e)}))}function ze(){if(se){je();return}if(!b||!Ee.isSupported||R.current||x)return;let e=++me.current;pe.current=performance.now(),Ru.info(`voiceStart`),r.emit(`voiceStart`,void 0),ue(!1),ce(!0),n.play(`voiceStart`),Ee.start((t,n)=>{me.current===e&&B.current&&!ge.current&&!R.current&&n&&Ce(e=>`${e}${t} `)},t=>{me.current===e&&B.current&&(ce(!1),ue(t),Ae(`debug`))})}let Be=Bu[e.composer.sendButton.icon],Ve=!!(j.trim()||M.length>0),He=S?.value,Ue=M.some(e=>He?.get(e.id)?.status===`uploading`),We=M.filter(e=>He?.get(e.id)?.status===`error`),Ge=We.find(e=>He?.get(e.id)?.refusal),Ke=Ge&&(He?.get(Ge.id)?.refusal===`INVALID_FILE_TYPE`?A.attachmentMimeRejected:A.attachmentUploadFailed).replace(`{name}`,Ge.name),qe=ve||Ue||c&&!Ve;return/* @__PURE__ */ v(`div`,{class:`${Y}-composer`,part:`composer`,"data-testid":J.composer,children:[ne.length>0?/* @__PURE__ */ _(`div`,{class:`${Y}-message-queue`,"aria-label":A.queueMessage,"data-testid":J.messageQueue,children:ne.map(e=>/* @__PURE__ */ v(`div`,{class:`${Y}-attachment-chip ${Y}-queued-message`,"data-testid":`${J.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-attachment-name ${Y}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-attachment-remove`,onClick:()=>Se(e.id),"aria-label":A.removeQueuedMessage,title:A.removeQueuedMessage,"data-testid":`${J.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ _(ac,{})})]},e.id))}):null,M.length>0?/* @__PURE__ */ _(`div`,{class:`${Y}-attachments`,children:M.map(e=>/* @__PURE__ */ _(wu,{attachment:e,upload:He?.get(e.id),strings:A,onRemove:()=>Re(e.id),disabled:_e},e.id))}):null,We.length>0&&!_e?/* @__PURE__ */ _(ku,{text:Ke??A.attachmentUploadFailed.replace(`{name}`,We.map(e=>e.name).join(`, `)),retryLabel:A.errorRetry,onRetry:Ge?void 0:()=>void Pe(),retryTestId:J.attachmentRetry}):null,P?/* @__PURE__ */ _(`p`,{class:`${Y}-field-error`,role:`alert`,children:Lu(A,P,e.attachments)}):null,le?/* @__PURE__ */ _(`p`,{class:`${Y}-field-error`,role:`alert`,children:A.micBlocked}):null,o!==void 0&&j.length>=o*.9?/* @__PURE__ */ _(`p`,{class:`${Y}-field-${j.length<o?`hint`:`error`}`,"data-testid":J.composerCount,children:`${j.length} / ${o}`}):null,/* @__PURE__ */ v(`div`,{class:`${Y}-composer-row`,children:[/* @__PURE__ */ v(`div`,{class:`${Y}-composer-actions`,children:[we?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-icon-btn`,onClick:()=>z.current?.click(),disabled:_e,"aria-label":A.attach,title:A.attach,"data-testid":J.composerAttach,children:/* @__PURE__ */ _(fc,{})}):null,Ee.isSupported?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-icon-btn`,onClick:ze,disabled:_e,"aria-label":se?A.micStop:A.micStart,title:se?A.micStop:A.micStart,"aria-pressed":se,"data-recording":se?`true`:void 0,"data-testid":J.composerVoice,children:/* @__PURE__ */ _(pc,{})}):null,C&&T===`ai-agent`&&E?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-icon-btn`,onClick:E,disabled:_e||!w,"aria-label":A.talkToOperator,title:A.talkToOperator,"data-testid":J.operatorRequest,children:/* @__PURE__ */ _(mc,{})}):null]}),/* @__PURE__ */ _(`textarea`,{ref:fe,name:`message`,class:`${Y}-textarea`,rows:1,value:j,maxLength:o,placeholder:A.composerPlaceholder,onInput:e=>Ce(e.currentTarget.value),onKeyDown:Ie,onCompositionEnd:Eu,disabled:_e,"aria-label":A.composerPlaceholder,"data-testid":J.composerInput}),be&&Ve?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Fe,disabled:_e,"aria-label":A.queueMessage,title:A.queueMessage,"data-testid":J.composerSend,children:/* @__PURE__ */ _(Be,{})}):null,qe?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-send`,onClick:O,disabled:_e&&!Ue,"aria-label":A.stop,"data-testid":J.composerStop,children:/* @__PURE__ */ _(dc,{})}):null,!qe&&(!be||!Ve)?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void Pe(),disabled:_e||!j.trim()&&M.length===0,"aria-label":A.send,"data-testid":J.composerSend,children:/* @__PURE__ */ _(Be,{})}):null]}),/* @__PURE__ */ _(`input`,{ref:z,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:Le,disabled:_e,class:`${Y}-sr-only`,"data-testid":J.composerFileInput})]})}const Gu=P.cssPrefix;function Ku({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Gu}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ _(`div`,{class:`${Gu}-home-card`,"data-testid":n,children:t})}function qu(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const Ju=P.cssPrefix,Yu=V.scope(`news`);function Xu(e,t){let n=e?new Date(e):void 0;if(n&&!Number.isNaN(n.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`}).format(n)}function Zu({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,l=c?.join(`,`),[d,f]=h({items:[],loading:!0}),p=m(void 0);function g(e){if(!c?.length)return;let r={};p.current=r,f(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(p.current!==r||(f(n=>({items:e>1?[...n.items,...t.items]:t.items,pagination:t.pagination,loading:!1})),e>1))return;a.emit(`contentView`,{section:`news`,count:t.items.length});let n=t.items[0];n&&s.markSeen(n.id)}).catch(t=>{p.current===r&&(Yu.warn(`listContent (news) failed`,{err:t,page:e}),f(e=>({...e,loading:!1,error:Zl(t,n)})))})}function y(){d.loading||g((d.pagination?.page??0)+1)}u(()=>(f({items:[],loading:!0}),g(1),()=>{p.current=void 0}),[t,l]);function b(t){let n=Xu(t.publishedAt,e.locale);return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Ju}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":cl(J.newsItem,t.id),children:[t.image?/* @__PURE__ */ _(`img`,{class:`${Ju}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ v(`span`,{class:`${Ju}-news-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Ju}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ v(`span`,{class:`${Ju}-news-meta`,children:[n?/* @__PURE__ */ _(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ _(`span`,{class:`${Ju}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ _(`span`,{class:`${Ju}-news-summary`,children:t.description}):null]})]},t.id)}function x(){if(!c?.length)return/* @__PURE__ */ _(Ll,{message:n.newsEmpty,strings:n});let e=d.error?/* @__PURE__ */ _(Ll,{tone:`error`,message:d.error,onRetry:y,strings:n}):null;return e&&!d.pagination?e:d.pagination?d.items.length?/* @__PURE__ */ v(`div`,{class:`${Ju}-news-list`,children:[d.items.map(b),e,d.pagination.hasNext&&!e?/* @__PURE__ */ v(`button`,{type:`button`,class:`${Ju}-news-more`,onClick:y,"aria-busy":d.loading,"data-testid":J.newsMore,children:[d.loading?/* @__PURE__ */ _(`span`,{class:`${Ju}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ _(Ll,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ _(Ll,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ v(`div`,{class:`${Ju}-module`,children:[/* @__PURE__ */ _(bl,{title:n.newsTitle,actions:/* @__PURE__ */ _(Yl,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ _(`div`,{class:`${Ju}-module-scroll`,children:x()})]})}const Qu={Icon:Uc,Root:e=>/* @__PURE__ */ _(Zu,{...e})},X=P.cssPrefix,$u=V.scope(`home`);function ed(e){let t=e.options.userContext?.name,n=e.config.greetingText?M(e.strings,e.config.greetingText):void 0;if(n){let r=t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),i=e.strings.homeGreetingLead;return{title:r,subtitle:r.toLowerCase()===i.toLowerCase()?void 0:i}}return t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}function td(e,t){return t.url?Qs(t.url):e.push({kind:`content`,id:t.id,title:t.title})}function nd({options:e,onAsk:t}){let[n,r]=h(``),{sendButton:i}=e.composer,a=Bu[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ v(`form`,{class:`${X}-home-search ${X}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":J.homeAsk,children:[/* @__PURE__ */ _(`input`,{type:`text`,class:`${X}-home-search-input`,placeholder:e.strings.homeAskPlaceholder,"aria-label":e.strings.homeAskPlaceholder,value:n,enterKeyHint:`send`,onInput:e=>r(e.currentTarget.value)}),/* @__PURE__ */ _(`button`,{type:`submit`,class:`${X}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ _(a,{})})]})}function rd(e,t){return ys(e,t,t.type!==`upsert`||t.activity===!0)}function id(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=h(null),[d,f]=h([]),p=r.contentCollectionIds?.join(`,`),m=e.options.modules.list.some(e=>e.layout===`chat`);u(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>rd(t?[t]:[],e)[0]??null)});return t.listConversations({limit:m?50:1}).then(t=>{if(e)return;let r=i.reduce(rd,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,$u.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,m]),u(()=>{if(!r.contentCollectionIds?.length)return;let e=!1;return t.listContent({contentCollectionIds:r.contentCollectionIds,pinned:!0,limit:6}).then(t=>{e||(f(t.items),a.emit(`contentView`,{section:`home`,count:t.items.length}))}).catch(t=>!e&&$u.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,p,a]);let y=ed(e),b=r.userAvatars??[],x=r.status,S=x?.text?M(n,x.text):n.homeStatus,C=x?.url,w=r.contentBlockTitle?M(n,r.contentBlockTitle):n.homeContentTitle,T=s.item,E=Xu(T?.publishedAt,e.options.locale);return/* @__PURE__ */ _(`div`,{class:`${X}-module ${X}-home`,"data-testid":J.homeView,children:/* @__PURE__ */ v(`div`,{class:`${X}-home-scroll`,children:[/* @__PURE__ */ v(`div`,{class:`${X}-home-hero`,children:[/* @__PURE__ */ v(`div`,{class:`${X}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ _(`span`,{class:`${X}-home-brand`,"data-testid":J.homeBrand,children:r.brandName}):/* @__PURE__ */ _(`span`,{class:`${X}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ v(`div`,{class:`${X}-home-hero-actions`,children:[b.length>0?/* @__PURE__ */ _(`div`,{class:`${X}-home-avatars`,children:b.map(e=>/* @__PURE__ */ _(`span`,{class:`${X}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?/* @__PURE__ */ _(`img`,{src:e.avatar,alt:``,loading:`lazy`}):/* @__PURE__ */ _(`span`,{children:qu(e.name)})},e.name))}):null,/* @__PURE__ */ _(Yl,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`h1`,{class:`${X}-home-greeting`,"data-testid":J.homeGreeting,children:y.title}),y.subtitle?/* @__PURE__ */ _(`p`,{class:`${X}-home-lead`,children:y.subtitle}):null]})]}),/* @__PURE__ */ v(`div`,{class:`${X}-home-cards`,children:[m?/* @__PURE__ */ _(nd,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ _($l,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),T?/* @__PURE__ */ _(Ku,{onClick:()=>{s.markSeen(T.id),i.push({kind:`content`,id:T.id,title:T.title})},testid:J.homeWhatsNew,children:/* @__PURE__ */ v(`div`,{class:`${X}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Uc,{})}),/* @__PURE__ */ v(`span`,{class:`${X}-home-recent-body`,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-preview`,children:E?`${T.title} · ${E}`:T.title})]}),s.unseen?/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ _(Ku,{onClick:()=>i.selectConversation(c),testid:J.homeRecent,children:/* @__PURE__ */ v(`div`,{class:`${X}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Wc,{})}),/* @__PURE__ */ v(`span`,{class:`${X}-home-recent-body`,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-preview`,children:Fl(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-dot`,role:`img`,"aria-label":n.unread}):null]})}):null,x?/* @__PURE__ */ _(Ku,{onClick:C?()=>Qs(C):void 0,children:/* @__PURE__ */ v(`div`,{class:`${X}-home-status`,"data-level":x.level??`operational`,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Vc,{})}),/* @__PURE__ */ _(`span`,{class:`${X}-home-status-text`,children:S})]})}):null,d.length>0?/* @__PURE__ */ v(`section`,{class:`${X}-home-content`,children:[/* @__PURE__ */ _(`div`,{class:`${X}-home-content-title`,children:w}),/* @__PURE__ */ _(`div`,{class:`${X}-home-content-list`,children:d.map(e=>/* @__PURE__ */ _(nu,{title:e.title,subtitle:e.description,onClick:()=>td(i,e),testid:cl(J.homeContentRow,e.id)},e.id))})]}):null]})]})})}const ad={chat:Xl,home:{Icon:Hc,Root:e=>/* @__PURE__ */ _(id,{...e})},help:cu,news:Qu},od=P.cssPrefix;function sd({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ _(`nav`,{class:`${od}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=ad[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ v(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${od}-tab`,onClick:()=>i(e.id),"data-testid":cl(J.tab,e.id),children:[/* @__PURE__ */ v(`span`,{class:`${od}-tab-icon`,children:[/* @__PURE__ */ _(a,{}),s?/* @__PURE__ */ _(`span`,{class:`${od}-tab-badge`,"data-testid":J.tabBadge,role:`img`,"aria-label":n.unread}):null]}),/* @__PURE__ */ _(`span`,{class:`${od}-tab-label`,children:M(n,e.label)})]},e.id)})})}const cd=P.cssPrefix;function ld({agent:e,strings:t,ticketReference:n,person:r=!1}){let i=e.status??`online`,a=M(t,e.name),o=e.title?M(t,e.title):null,s=r?/* @__PURE__ */ _(mc,{}):/* @__PURE__ */ _(`span`,{children:qu(a)});return/* @__PURE__ */ v(`div`,{class:`${cd}-agent`,children:[/* @__PURE__ */ _(`div`,{class:`${cd}-agent-avatar`,"data-status":i,children:e.avatar?/* @__PURE__ */ _(`img`,{src:e.avatar,alt:``}):s}),/* @__PURE__ */ v(`div`,{class:`${cd}-agent-meta`,children:[/* @__PURE__ */ _(`strong`,{children:a}),o||n?/* @__PURE__ */ v(`div`,{class:`${cd}-agent-sub`,children:[n?/* @__PURE__ */ _(ud,{reference:n,strings:t}):null,o?/* @__PURE__ */ _(`span`,{children:o}):null]}):null]})]})}function ud({reference:e,strings:t}){let[n,r]=h(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}return/* @__PURE__ */ _(`button`,{type:`button`,class:`${cd}-agent-ticket`,onClick:i,title:t.copy,"aria-label":n?t.copied:t.copyTicketReference.replace(`{reference}`,e),children:n?t.copied:e})}const dd=[`today`,`yesterday`,`lastWeek`,`older`];function fd(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.round((md(e)-md(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function pd(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=fd(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return dd.flatMap(e=>{let t=n.get(e);return t?[{bucket:e,conversations:t}]:[]})}function md(e){return new Date(e).setHours(0,0,0,0)}const hd=V.scope(`history`),gd={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function _d(e,t){let n=t.type!==`upsert`||t.activity===!0;if(t.type===`snapshot`&&t.result.pagination.page===1&&e.pagination.page>1){let r=ys(e.conversations.slice(0,t.result.pagination.limit),t,n);if(t.result.conversations.length===0){if(r.length===0)return t.result;let e=Math.max(t.result.pagination.total,r.length);return{...t.result,conversations:r,pagination:{...t.result.pagination,total:e,totalPages:Math.ceil(e/t.result.pagination.limit)}}}let i=new Set(r.map(e=>e.conversationId)),a=e.conversations.slice(t.result.pagination.limit).filter(e=>!i.has(e.conversationId)),o=e.pagination.page,s={...t.result.pagination,page:o,hasPrev:o>1,hasNext:o<t.result.pagination.totalPages};return{conversations:[...r,...a],pagination:s}}let r=ys(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function vd(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<6048e5?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function yd({transport:e,strings:t,locale:n,persistence:r,onSelect:i,onNewConversation:a}){let o=P.cssPrefix,s=e.peekConversations({limit:50}),[c,l]=h(s?`loaded`:`loading`),[d,f]=h(0),[p,y]=h(s),[b,x]=h(!1),S=m(void 0),C=p?.conversations??[],w=p?.pagination;u(()=>{let n=!1,i=!0,a=[],o=e.subscribeConversationChanges(e=>{i&&a.push(e),y(t=>t&&_d(t,e))});S.current=void 0,x(!1);let s=e.peekConversations({limit:50});return y(s),l(s?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(n)return;let t=e;for(let e of a)t=_d(t,e);a=[],i=!1,y(t),l(`loaded`),r.saveHistoryCount(t.conversations.length)}).catch(e=>{n||(a=[],i=!1,hd.warn(`listConversations failed`,{err:e}),l({failure:Zl(e,t)}))}),()=>{n=!0,o(),S.current=void 0}},[e,r,n,d]);async function T(){if(S.current||!w?.hasNext)return;let t={};S.current=t,x(!0);try{let n=await e.listConversations({page:w.page+1,limit:w.limit});if(S.current!==t)return;y(e=>{if(!e)return e;let t=new Set(e.conversations.map(e=>e.conversationId)),i=n.conversations.filter(e=>!t.has(e.conversationId)&&(t.add(e.conversationId),!0)),a={conversations:[...e.conversations,...i],pagination:n.pagination};return r.saveHistoryCount(a.conversations.length),a})}catch(e){if(S.current!==t)return;hd.warn(`listConversations page failed`,{err:e,page:w.page+1})}finally{S.current===t&&(S.current=void 0,x(!1))}}let E=a?/* @__PURE__ */ _(`div`,{class:`${o}-history-footer`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${o}-history-new`,onClick:a,"data-testid":J.sidebarNewConversation,children:[/* @__PURE__ */ _(oc,{}),t.newConversation]})}):null;if(c===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`div`,{class:`${o}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ v(`div`,{class:`${o}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-heading`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-heading`})}),/* @__PURE__ */ _(`div`,{class:`${o}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ v(`div`,{class:`${o}-history-item ${o}-history-item-skeleton`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-avatar ${o}-skeleton`}),/* @__PURE__ */ v(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-title`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-title`})}),/* @__PURE__ */ _(`span`,{class:`${o}-history-time`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-time`})})]}),/* @__PURE__ */ _(`span`,{class:`${o}-history-row`,children:/* @__PURE__ */ _(`span`,{class:`${o}-history-preview`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-preview`})})})]})]},t))})]})}),E]})}if(typeof c==`object`)return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(Ll,{tone:`error`,message:c.failure,onRetry:()=>f(e=>e+1),strings:t}),E]});if(C.length===0)return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-empty`,children:t.historyEmpty}),E]});let D=Date.now(),O=pd(D,C);return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`div`,{class:`${o}-history`,role:`list`,children:[O.map(e=>/* @__PURE__ */ v(`div`,{class:`${o}-history-group`,children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-heading`,children:t[gd[e.bucket]]}),/* @__PURE__ */ _(`div`,{class:`${o}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ _(`div`,{role:`listitem`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${o}-history-item`,onClick:()=>i(e),"data-unread":e.hasUnread?`true`:void 0,"data-testid":cl(J.historyItem,e.conversationId),children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Pc,{})}),/* @__PURE__ */ v(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-title`,children:e.title}),/* @__PURE__ */ v(`span`,{class:`${o}-history-time`,children:[e.ticketReference&&`${e.ticketReference} · `,vd(e.lastMessageAt,D,n)]})]}),/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-preview`,children:e.preview&&Fl(e.preview)||t.historyContinue}),e.hasUnread?/* @__PURE__ */ _(`span`,{class:`${o}-history-dot`,role:`img`,"aria-label":t.unread}):null]})]})]})},e.conversationId))})]},e.bucket)),w?.hasNext?/* @__PURE__ */ _(`div`,{class:`${o}-history-more`,children:/* @__PURE__ */ _(`button`,{type:`button`,onClick:T,disabled:b,"aria-busy":b,"data-testid":J.historyLoadMore,children:t.loadMoreConversations})}):null]}),E]})}const bd=P.cssPrefix;function xd({state:e,strings:t}){return e?/* @__PURE__ */ v(`div`,{class:`${bd}-dropzone`,"data-state":e,role:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ _(`span`,{class:`${bd}-dropzone-icon`,"aria-hidden":`true`,children:_(e===`reject`?ol:fc,{})}),e===`reject`?t.dropZoneRejected:t.dropZone]}):null}const Sd=new RegExp(String.raw`^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$`),Cd=/^[+]?[\d\s().-]{6,}$/;function wd(e,t,n){let r=Array.isArray(t)?t.join(``):t?.trim()??``;if(!r)return e.required?n.formRequired:void 0;if(e.type===`email`&&!Sd.test(r))return n.formInvalidEmail;if(e.type===`tel`&&!Cd.test(r))return n.formInvalidTel;if(e.type===`number`&&!Number.isFinite(Number(r)))return n.formInvalidNumber}function Td(e,t,n){return Object.fromEntries(e.flatMap(e=>{let r=wd(e,t[e.name],n);return r?[[e.name,r]]:[]}))}const Ed=P.cssPrefix;function Dd(e){return e.tokenEmail||e.userContext?.email?.trim()}function Od(e,t){let n=e instanceof ns?e.status:void 0;return n===400?t.formInvalidEmail:n===409?t.emailTranscriptAlreadySent:n===422?t.emailTranscriptNotDelivered:n===429?t.emailTranscriptLimited:t.emailTranscriptFailed}function kd(e){return`host`in e&&`activeElement`in e}function Ad({transport:e,strings:t,knownEmail:n,onClose:r}){let[i,a]=h(n??``),[o,s]=h(!1),[c,l]=h({status:`idle`}),u=m(null),p=d(),y=`${p}-title`,b=`${p}-error`,x=c.status===`sending`,S=c.status===`sent`;f(()=>{let e=u.current;if(!e)return;let t=e.getRootNode(),n=kd(t)?t.activeElement:null,r=vl(e);return()=>{r(),n instanceof HTMLElement&&n.isConnected&&n.focus({preventScroll:!0})}},[]),f(()=>{u.current?.querySelector(`[data-autofocus]`)?.focus({preventScroll:!0})},[S]);async function C(n){if(n.preventDefault(),x)return;let r=i.trim();if(!Sd.test(r)){s(!0),u.current?.querySelector(`input`)?.focus();return}s(!1),l({status:`sending`});let a=await e.emailTranscript(r).then(e=>({status:`sent`,to:e.to}),e=>({status:`failed`,message:Od(e,t)}));l(a)}function w(e){e.key===`Tab`&&e.stopPropagation(),e.key===`Escape`&&(e.stopPropagation(),r())}return/* @__PURE__ */ v(`div`,{class:`${Ed}-transcript-layer`,children:[/* @__PURE__ */ _(`div`,{class:`${Ed}-transcript-backdrop`,"aria-hidden":`true`,onClick:r}),/* @__PURE__ */ v(`section`,{ref:u,class:`${Ed}-transcript-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":y,onKeyDown:w,"data-testid":J.emailTranscriptSheet,children:[/* @__PURE__ */ v(`header`,{class:`${Ed}-transcript-sheet-head`,children:[/* @__PURE__ */ _(`span`,{class:`${Ed}-transcript-sheet-icon`,children:/* @__PURE__ */ _(Ac,{})}),/* @__PURE__ */ _(`h2`,{id:y,class:`${Ed}-transcript-sheet-title`,children:t.emailTranscript}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Ed}-icon-btn`,onClick:r,"aria-label":t.emailTranscriptCancel,title:t.emailTranscriptCancel,children:/* @__PURE__ */ _(ac,{})})]}),c.status===`sent`?/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`p`,{class:`${Ed}-transcript-sheet-text ${Ed}-transcript-sheet-sent`,role:`status`,children:[/* @__PURE__ */ _(rl,{}),/* @__PURE__ */ _(`span`,{children:t.emailTranscriptSent.replace(`{email}`,c.to)})]}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Ed}-form-submit ${Ed}-transcript-sheet-action`,onClick:r,"data-autofocus":!0,children:t.emailTranscriptDone})]}):/* @__PURE__ */ v(`form`,{class:`${Ed}-transcript-sheet-form`,onSubmit:e=>void C(e),noValidate:!0,children:[/* @__PURE__ */ _(`p`,{class:`${Ed}-transcript-sheet-text`,children:t.emailTranscriptPrompt}),/* @__PURE__ */ v(`label`,{class:`${Ed}-field`,"data-invalid":o?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Ed}-field-label`,children:t.emailTranscriptEmailLabel}),/* @__PURE__ */ _(`input`,{class:`${Ed}-field-input`,type:`email`,name:`email`,autocomplete:`email`,inputMode:`email`,autocapitalize:`off`,spellcheck:!1,value:i,readOnly:x,"aria-invalid":o,"aria-describedby":o?b:void 0,onInput:e=>{a(e.currentTarget.value),s(!1)},"data-autofocus":!0,"data-testid":J.emailTranscriptEmail}),o?/* @__PURE__ */ _(`span`,{id:b,class:`${Ed}-field-error`,role:`alert`,children:t.formInvalidEmail}):null]}),/* @__PURE__ */ _(`button`,{type:`submit`,class:`${Ed}-form-submit ${Ed}-transcript-sheet-action`,disabled:x,"aria-busy":x,"data-testid":J.emailTranscriptSend,children:x?t.emailTranscriptSending:t.emailTranscriptSend}),c.status===`failed`?/* @__PURE__ */ _(`p`,{class:`${Ed}-field-error`,role:`alert`,children:c.message}):null]})]})]})}const jd=/* @__PURE__ */ new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`,`password`]);function Md(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Nd(e){return!Md(e)||e.name===``||e.disabled?!1:!(e instanceof HTMLInputElement&&jd.has(e.type))}function Pd(e){let t=e.labels?.[0]?.textContent?.trim();return e.getAttribute(`toolparamdescription`)??(t||e.getAttribute(`aria-description`))??void 0}function Fd(e,t){let n=Pd(e),r=n?{description:n}:{};return e instanceof HTMLSelectElement?{...r,type:`string`,enum:[...e.options].map(e=>e.value)}:e instanceof HTMLTextAreaElement?{...r,type:`string`}:e.type===`checkbox`?{...r,type:`boolean`}:e.type===`radio`?{...r,type:`string`,enum:t}:e.type===`number`||e.type===`range`?{...r,type:`number`}:{...r,type:`string`}}function Id(e,t){Object.getOwnPropertyDescriptor(Reflect.getPrototypeOf(e)??e,`value`)?.set?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function Ld(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function Rd(e,t){e instanceof HTMLInputElement&&e.type===`checkbox`?e.checked!==(t===!0||t===`true`)&&e.click():e instanceof HTMLInputElement&&e.type===`radio`?e.value===Ld(t)&&!e.checked&&e.click():Id(e,Ld(t))}function zd(e,t,n){let r=[...e.elements].filter(Nd),i={},a=/* @__PURE__ */ new Set;for(let e of r){var o;let t=r.flatMap(t=>t instanceof HTMLInputElement&&t.type===`radio`&&t.name===e.name?[t.value]:[]);i[o=e.name]??(i[o]=Fd(e,t)),e.required&&a.add(e.name)}return{name:t,description:n,inputSchema:{type:`object`,properties:i,...a.size>0?{required:[...a]}:{}},execute(t){let n=typeof t==`object`&&t?Object.entries(t):[];for(let[e,t]of n)for(let n of r)n.name===e&&Rd(n,t);if(!e.hasAttribute(`toolautosubmit`))return`Filled in the form. The visitor still needs to check it and press its submit button.`;let i=[...new Set([...e.elements].flatMap(e=>Md(e)&&e.name&&!e.checkValidity()?[e.name]:[]))];return i.length>0?`Filled in the form, but it can't be submitted yet: ${i.join(`, `)} still needs the visitor. Ask them to complete it and press the submit button.`:(setTimeout(()=>e.requestSubmit(),0),`Filled in the form and submitted it.`)}}}function Bd(){return[...document.querySelectorAll(`form[toolname][tooldescription]`)].flatMap(e=>{let t=e.getAttribute(`toolname`)?.trim()??``,n=e.getAttribute(`tooldescription`)?.trim()??``;return t&&n?[zd(e,t,n)]:[]})}const Vd=`${P.cssPrefix}.page-tools`;function Hd(e){return typeof e==`object`&&!!e}function Ud(e){return Hd(e)&&(e.state===`running`||e.state===`stopped`||e.state===`finished`&&Hd(e.outcome))}function Wd(e){let t=e?JSON.parse(e):void 0;return Hd(t)?{sent:Array.isArray(t.sent)?t.sent.filter(e=>typeof e==`string`):[],calls:Object.fromEntries(Object.entries(Hd(t.calls)?t.calls:{}).filter(e=>Ud(e[1])))}:{sent:[],calls:{}}}let Gd={sent:[],calls:{}};function Kd(){try{Gd=Wd(sessionStorage.getItem(Vd))}catch{}return Gd}function qd(e){Gd=e;try{sessionStorage.setItem(Vd,JSON.stringify(e))}catch{}}const Jd={markSent(e){let t=Kd();qd({...t,sent:[...t.sent.filter(t=>t!==e),e].slice(-20)})},sentHere(e){return Kd().sent.includes(e)},get(e){return Kd().calls[e]},set(e,t){let n=Kd(),r=Object.entries(n.calls).filter(([t])=>t!==e);qd({...n,calls:Object.fromEntries([...r,[e,t]].slice(-50))})},clear(e){let t=Kd();e.some(e=>e in t.calls)&&qd({...t,calls:Object.fromEntries(Object.entries(t.calls).filter(([t])=>!e.includes(t)))})}},Yd=V.scope(`page-tools`),Xd=3e4,Zd=Symbol.for(`${P.cssPrefix}.page-tools`),Qd={state:`output-error`,errorText:`The page reloaded before this finished, so it may or may not have taken effect. Check with the visitor before trying it again.`},$d=`The visitor stopped this before it finished.`;function ef(e){return typeof e==`object`&&!!e}function tf(e){return ef(e)&&Array.isArray(e.registered)&&e.runs instanceof Map}function nf(){let e=Reflect.get(globalThis,Zd);if(tf(e))return e;let t={registered:[],runs:/* @__PURE__ */ new Map};return Reflect.set(globalThis,Zd,t),t}function rf(e,t){let n=ef(t)&&t.signal instanceof AbortSignal?t.signal:void 0;if(n?.aborted)return;let r=nf().registered;r.push(e);function i(){let t=r.indexOf(e);t>=0&&r.splice(t,1)}n?.addEventListener(`abort`,i,{once:!0})}function af(e){return e.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,58)}function of(e){if(!ef(e)||typeof e.name!=`string`||!af(e.name))return;let t=typeof e.title==`string`&&e.title.trim()!==``?e.title.trim().slice(0,120):void 0,n=[e.description,t].find(e=>typeof e==`string`&&e.trim()!==``)??e.name,r=e.preview;return{name:af(e.name),...t?{title:t}:{},...typeof r==`function`?{preview:t=>Reflect.apply(r,e,[t])}:{},description:n.trim().slice(0,1024),inputSchema:{properties:{},...ef(e.inputSchema)?e.inputSchema:{},type:`object`},consequential:ef(e.annotations)&&e.annotations.consequentialHint===!0}}function sf(e){return e.flatMap(e=>{let t=of(e),n=ef(e)?e.execute:void 0;return!t||typeof n!=`function`?(Yd.warn(`skipped a tool without a name or an execute function`,e),[]):[{...t,run:(t,r)=>Reflect.apply(n,e,[t,{signal:r}])}]})}async function cf(){let e=Reflect.get(document,`modelContext`)??Reflect.get(navigator,`modelContext`);if(!ef(e)||typeof e.getTools!=`function`||typeof e.executeTool!=`function`)return[];let t=e.getTools,n=e.executeTool,r=await Promise.race([Promise.resolve().then(()=>Reflect.apply(t,e,[])),Qo(1e3).then(()=>[])]).catch(()=>[]);return(Array.isArray(r)?r:[]).flatMap(t=>{let r=of(t);return r?[{...r,run:(r,i)=>Reflect.apply(n,e,[t,r,{signal:i}])}]:[]})}async function lf(e=[]){let t=sf(Bd()),n=new Set(t.map(e=>e.name)),r=[...(await cf()).filter(e=>!n.has(e.name)),...t,...sf(e),...sf(nf().registered)];return new Map(r.map(e=>[e.name,e]))}function uf(e){return[...e.values()].map(({name:e,title:t,description:n,inputSchema:r,consequential:i})=>{let a={name:e,description:n,inputSchema:r};return t&&(a.title=t),i&&(a.annotations={consequentialHint:!0}),a})}function df(e){return e?.execution===`client`}function ff(e){return e.startsWith(`site__`)?e.slice(6):e}function pf(e){if(e===void 0||typeof e==`function`||typeof e==`symbol`)return null;let t=/* @__PURE__ */ new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`)return n instanceof Node?`[${n.nodeName.toLowerCase()}]`:ef(n)?t.has(n)?`[circular]`:(t.add(n),n):n});return n.length>Xd?{truncated:!0,preview:n.slice(0,Xd)}:JSON.parse(n)}async function mf(e){let t=(await lf(e.optionTools)).get(ff(e.toolName));if(!t?.preview)return;let n=t.preview;return Promise.resolve().then(()=>n(e.input)).catch(e=>{Yd.warn(`a page tool preview failed`,{name:t.name,error:e})})}async function hf(e){let t=ff(e.toolName),n=(await lf(e.optionTools)).get(t);return n?Promise.resolve().then(()=>n.run(e.input,e.signal)).then(e=>({state:`output-available`,output:pf(e)})).catch(e=>(Yd.warn(`a page tool failed`,{name:t,error:e}),{state:`output-error`,errorText:(e instanceof Error?e.message:String(e)).slice(0,1e3)||`The page tool failed.`})):{state:`output-error`,errorText:`This page doesn't offer "${t}" right now; the visitor may have moved on. Tell them, or continue without it.`}}function gf(e){let{toolCallId:t}=e,n=Jd.get(t);if(n?.state===`finished`)return Promise.resolve(n.outcome);let{runs:r}=nf(),i=r.get(t);if(i)return i.outcome;if(n?.state===`running`)return Jd.set(t,{state:`finished`,outcome:Qd}),e.onSettled(`interrupted`,0),Promise.resolve(Qd);let a=new AbortController,o=performance.now();Jd.set(t,{state:`running`});let s=hf({...e,signal:a.signal}).then(n=>(r.delete(t),Jd.get(t)?.state===`running`&&(Jd.set(t,{state:`finished`,outcome:n}),e.onSettled(n.state===`output-available`?`completed`:`failed`,Math.round(performance.now()-o))),n));return r.set(t,{outcome:s,controller:a}),s}function _f(e){return e===Qd.errorText||e===$d}function vf(e){return Jd.set(e,{state:`stopped`}),nf().runs.get(e)?.controller.abort(),$d}function yf(e){Jd.clear([e]),nf().runs.get(e)?.controller.abort()}const bf=P.cssPrefix;function xf({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=h(t);u(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ v(`div`,{class:`${bf}-feedback`,role:`group`,"data-testid":J.messageFeedback,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${bf}-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":J.feedbackUp,children:/* @__PURE__ */ _($c,{})}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${bf}-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":J.feedbackDown,children:/* @__PURE__ */ _(el,{})}),/* @__PURE__ */ _(`span`,{class:`${bf}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}function Sf(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Cf(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function wf(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function Tf(e){let{streaming:t,reasoningVisible:n,emptyReply:r,hidden:i}=e,a=e.responseMode===`buffered`&&t,o=t&&!e.hasAnswerText;return{streaming:t,bufferedHold:a,reasoningVisible:n,working:o,showStreamDots:wf({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}const Ef=P.cssPrefix;function Df({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ v(`a`,{class:`${Ef}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":J.source,children:[/* @__PURE__ */ _(`span`,{class:`${Ef}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ _(`span`,{class:`${Ef}-source-label`,children:n})]}):/* @__PURE__ */ v(`span`,{class:`${Ef}-source`,"data-testid":J.source,children:[/* @__PURE__ */ _(`span`,{class:`${Ef}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ _(`span`,{class:`${Ef}-source-label`,children:n})]})}const Of=P.cssPrefix;function kf(e){return{toolCallId:e.toolCallId,toolName:e.toolName,...e.title?{title:e.title}:{},state:e.stateSig.value,input:e.inputSig.value,output:e.outputSig.value,...e.errorSig.value?{errorText:e.errorSig.value}:{},...e.approvalSig.value?{approval:e.approvalSig.value}:{},...e.toolMetadata?{toolMetadata:e.toolMetadata}:{}}}function Af(e,t){if(t?.replacedByMessageId)return{terminal:!1,responded:!1,decided:!1};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 jf({status:e,label:t,icon:n}){return/* @__PURE__ */ v(`span`,{class:`${Of}-toolui-badge ${Of}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ _(`span`,{class:`${Of}-toolui-status-icon`,children:n??/* @__PURE__ */ _(Mf,{status:e})}),t]})}function Mf({status:e}){return e===`running`?/* @__PURE__ */ _(`span`,{class:`${Of}-loading-spinner`}):_(e===`stopped`?dc:e===`waiting`||e===`submitted`?nl:e===`failed`||e===`declined`||e===`replaced`?il:rl,{})}function Nf({decision:e}){return/* @__PURE__ */ v(`span`,{class:`${Of}-steps-decision`,"data-approved":e.approved?`true`:`false`,title:e.title,children:[e.approved?/* @__PURE__ */ _(rl,{}):/* @__PURE__ */ _(il,{}),e.label]})}function Pf({view:e,strings:t}){let n=e.raw;return/* @__PURE__ */ v(g,{children:[e.error?/* @__PURE__ */ _(`p`,{class:`${Of}-steps-row-error`,children:e.error}):null,e.fields.length>0?/* @__PURE__ */ _(Ff,{fields:e.fields,label:e.tables?t.stepInput:void 0,plain:!e.tables}):null,e.resultFields?/* @__PURE__ */ _(Ff,{fields:e.resultFields,label:t.toolResult}):null,n?.input||n?.output?/* @__PURE__ */ v(`details`,{class:`${Of}-toolui-raw`,open:!e.tables,children:[/* @__PURE__ */ _(`summary`,{children:t.stepRawData}),n.input?/* @__PURE__ */ _(If,{label:t.stepInput,text:n.input}):null,n.output?/* @__PURE__ */ _(If,{label:t.toolResult,text:n.output}):null]}):null]})}function Ff({fields:e,label:t,plain:n=!1}){let r=/* @__PURE__ */ _(`div`,{class:`${Of}-toolui-fields`,"data-plain":n?`true`:void 0,children:/* @__PURE__ */ _(`table`,{children:/* @__PURE__ */ _(`tbody`,{children:e.map(({label:e,value:t},n)=>/* @__PURE__ */ v(`tr`,{children:[/* @__PURE__ */ _(`th`,{scope:`row`,children:e}),/* @__PURE__ */ _(`td`,{children:t})]},`${e}#${n}`))})})});return t?/* @__PURE__ */ v(`div`,{class:`${Of}-toolui-section`,children:[/* @__PURE__ */ _(`span`,{class:`${Of}-toolui-label`,children:t}),r]}):r}function If({label:e,text:t}){return/* @__PURE__ */ v(`div`,{class:`${Of}-toolui-section`,children:[/* @__PURE__ */ _(`span`,{class:`${Of}-toolui-label`,children:e}),/* @__PURE__ */ _(`pre`,{class:`${Of}-toolui-code`,children:t})]})}const Lf=P.cssPrefix;function Rf({part:e,view:t,strings:n,locale:r,canAct:i,onDecision:a,onEdit:o,preview:s}){let c=t.approval,l=t.status===`waiting`||t.status===`submitted`||t.status===`approved`,u=e.toolCallId;return/* @__PURE__ */ v(`details`,{class:`${Lf}-toolui ${Lf}-toolui-collapsible`,open:l||c?.buttons===`change`||void 0,"data-testid":t.status===`waiting`?J.toolApproval:J.toolDecision,"data-status":t.status,children:[/* @__PURE__ */ v(`summary`,{class:`${Lf}-toolui-head`,children:[/* @__PURE__ */ _(`span`,{class:`${Lf}-toolui-prompt`,children:l&&c?c.ask:t.name}),t.system?/* @__PURE__ */ _(`span`,{class:`${Lf}-toolui-system`,children:t.system}):null,/* @__PURE__ */ v(`span`,{class:`${Lf}-toolui-head-end`,children:[t.decision?/* @__PURE__ */ _(Nf,{decision:t.decision}):null,t.statusLabel?/* @__PURE__ */ _(jf,{status:t.status,label:t.statusLabel}):null,/* @__PURE__ */ _(`span`,{class:`${Lf}-toolui-chevron`,children:/* @__PURE__ */ _(jc,{})})]})]}),/* @__PURE__ */ v(`div`,{class:`${Lf}-toolui-collapse-body`,children:[l&&s&&df(e.toolMetadata)?/* @__PURE__ */ _(Bf,{toolName:e.toolName,input:e.inputSig.value,preview:s,strings:n,locale:r}):null,/* @__PURE__ */ _(Pf,{view:t,strings:n}),c?.note?/* @__PURE__ */ _(`p`,{class:`${Lf}-toolui-subtle`,children:c.note}):null,c?.buttons===`decide`?/* @__PURE__ */ v(`div`,{class:`${Lf}-toolui-actions`,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${Lf}-form-skip`,disabled:!i,onClick:()=>a(u,!1),"data-testid":J.toolDecline,children:n.decline}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Lf}-form-submit`,disabled:!i,onClick:()=>a(u,!0),"data-testid":J.toolApprove,children:n.approve})]}):null,c?.buttons===`change`?/* @__PURE__ */ _(`div`,{class:`${Lf}-toolui-actions`,children:/* @__PURE__ */ _(`button`,{type:`button`,class:`${Lf}-form-skip`,onClick:()=>o(u),"data-testid":J.toolEdit,children:n.changeAnswer})}):null]})]})}function zf(e){if(typeof e==`object`&&e&&`totals`in e)return`number`in e&&`items`in e?`root = Root([preview])\npreview = Order(${JSON.stringify(e)})`:`lines`in e?`root = Root([preview])\npreview = Cart(${JSON.stringify(e)})`:void 0}function Bf({toolName:e,input:t,preview:n,strings:r,locale:i}){let[a,s]=h();u(()=>{let r=!0;return n(e,t).then(e=>{r&&s(zf(e))}),()=>{r=!1}},[e,t,n]);let c=p(()=>a?{textSig:o(a),doneSig:o(!0),replyDoneSig:o(!0)}:void 0,[a]);return c?/* @__PURE__ */ _(`div`,{class:`${Lf}-toolui-preview`,"data-testid":J.toolPreview,children:/* @__PURE__ */ _(ka,{cssPrefix:Lf,textSig:c.textSig,doneSig:c.doneSig,replyDoneSig:c.replyDoneSig,strings:r,locale:i})}):null}const Vf=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function Hf(e){return typeof e==`object`&&!!e}function Uf(e,t){let n=Hf(e)?e:{},r=(Array.isArray(n.questions)?n.questions:[]).map((e,n)=>Wf(e,n,t)).filter(e=>e!==null);return{intro:qf(n.intro),questions:r}}function Wf(e,t,n){if(!Hf(e))return null;let r=Vf.find(t=>t===e.type)??`text`;return{key:qf(e.key)??`q${t+1}`,question:qf(e.question)??n,type:r,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof e.required==`boolean`?e.required:void 0,helpText:qf(e.helpText)}}function Gf(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 Kf(e,t,n){return e.questions.map(e=>{let r=Gf(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 qf(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const Jf=P.cssPrefix;function Yf({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:c,initialValues:l,hideActions:u,fieldTypeLabels:d,rootTestId:f,submitTestId:p,skipTestId:m}){let[g,y]=h(()=>l??{}),[b,x]=h({}),[S,C]=h({});function w(e){S[e]&&C(t=>({...t,[e]:``}))}function T(e,t){y(n=>({...n,[e]:t})),w(e)}function E(e,t){x(n=>({...n,[e]:t})),w(e)}function D(n){if(n.preventDefault(),c)return;let i=$f(e,g,b),a=Td(e,i,t);Object.keys(a).length>0?C(a):r(i)}function O(e){!s||e.key!==`Enter`||e.shiftKey||Du(e)||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&D(e)}return/* @__PURE__ */ v(`form`,{class:`${Jf}-form`,onSubmit:D,onKeyDown:O,onCompositionEnd:Eu,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ _(Xf,{field:e,value:g[e.name],otherText:b[e.name]??``,error:S[e.name],disabled:c,typeLabel:d?.[e.name],strings:t,onChange:t=>T(e.name,t),onOtherChange:t=>E(e.name,t)},e.name)),u?null:/* @__PURE__ */ v(`div`,{class:`${Jf}-form-actions`,children:[o?/* @__PURE__ */ _(`span`,{class:`${Jf}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Jf}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ _(`button`,{type:`submit`,class:`${Jf}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function Xf({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=cl(J.formField,e.name),u=d(),f=Zf({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:l,labelId:u}),p=e.type===`radio`||e.type===`multiselect`?`div`:`label`;return/* @__PURE__ */ v(p,{class:`${Jf}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ v(`span`,{class:`${Jf}-field-head`,children:[/* @__PURE__ */ v(`span`,{class:`${Jf}-field-label`,id:u,children:[e.label,e.required?/* @__PURE__ */ _(`span`,{class:`${Jf}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ _(`span`,{class:`${Jf}-field-type`,children:a}):null]}),f,e.validationHint&&!r?/* @__PURE__ */ _(`span`,{class:`${Jf}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ _(`span`,{class:`${Jf}-field-error`,role:`alert`,children:r}):null]})}function Zf(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c,labelId:l}=e,u=typeof n==`string`?n:``;switch(t.type){case`textarea`:return/* @__PURE__ */ _(`textarea`,{class:`${Jf}-field-input`,rows:3,value:u,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`radio`:return/* @__PURE__ */ _(`div`,{class:`${Jf}-field-choices`,role:`radiogroup`,"aria-labelledby":l,"data-testid":c,children:(t.options??[]).map(e=>/* @__PURE__ */ v(`label`,{class:`${Jf}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`radio`,name:`${Jf}-${t.name}`,checked:u===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ _(`span`,{children:e.label})]},e.value))});case`multiselect`:{let e=Array.isArray(n)?n:[];function u(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ v(`div`,{class:`${Jf}-field-choices`,role:`group`,"aria-labelledby":l,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ v(`label`,{class:`${Jf}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>u(t.value,e.currentTarget.checked)}),/* @__PURE__ */ _(`span`,{children:t.label})]},t.value)),(t.options??[]).length===0?/* @__PURE__ */ _(`textarea`,{class:`${Jf}-field-input`,rows:2,value:r,placeholder:a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ _(`input`,{...Qf(t.type),class:`${Jf}-field-input`,value:u,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function Qf(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`date`:return{type:e};default:return{type:`text`}}}function $f(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=t[i.name];r[i.name]=[...Array.isArray(a)?a:[],...n]}}return r}const ep=P.cssPrefix;function tp({skipped:e,submitted:t,strings:n}){return e?{status:`replaced`,statusLabel:n.inputSkipped}:t?{status:`submitted`,statusLabel:n.stepWorkingOnIt}:{status:`done`,statusLabel:n.inputAnswered}}const np={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function rp(e,t){let n={};for(let r of e)n[r.key]=t[np[r.type]];return n}function ip({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:a=!1,folded:o=!1,onDecision:s,onEdit:c}){let l=p(()=>i(()=>e.stateSig.value),[e]).value,u=p(()=>i(()=>e.approvalSig.value),[e]).value,d=p(()=>i(()=>Uf(e.inputSig.value,t.askFallbackQuestion)),[e,t]).value,{terminal:f,decided:m}=Af(l,u),g=m&&u?.approved===!0,y=a&&!m,b=!m&&!r&&!y,x=!b&&!g&&!y,S=g&&n&&!f,C=d.questions,[w,T]=h(null),E=w??(b||g||y),[D,O]=h(!1),k=C.length>1?ic:Fc,A=b?t.inputRequired:t.inputBadge,j=y?/* @__PURE__ */ _(`p`,{class:`${ep}-toolui-subtle`,children:t.stepWorkingOnIt}):b?/* @__PURE__ */ _(ap,{req:d,strings:t,active:n,resolve:(t,n)=>s(e.toolCallId,n,t)}):D?/* @__PURE__ */ _(Yf,{fields:Kf(d,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:rp(C,t),initialValues:g?fp(C,u?.reason):void 0}):/* @__PURE__ */ _(op,{questions:C,answers:g?dp(u?.reason):{},strings:t}),{status:ee,statusLabel:M}=tp({skipped:x,submitted:y,strings:t});return/* @__PURE__ */ v(`details`,{class:`${ep}-toolui ${ep}-toolui-collapsible${r?` ${ep}-toolui-stale`:``}`,open:E,onToggle:e=>{let t=e.currentTarget.open;t!==E&&T(t)},"data-testid":b?J.toolAskQuestions:J.toolDecision,children:[/* @__PURE__ */ v(`summary`,{class:`${ep}-toolui-head`,children:[/* @__PURE__ */ v(`span`,{class:`${ep}-toolui-q-pill`,children:[/* @__PURE__ */ _(k,{}),A]}),/* @__PURE__ */ v(`span`,{class:`${ep}-toolui-head-end`,children:[b||o?null:/* @__PURE__ */ _(jf,{status:ee,icon:_(x?il:rl,{}),label:M}),/* @__PURE__ */ _(`span`,{class:`${ep}-toolui-chevron`,children:/* @__PURE__ */ _(jc,{})})]})]}),/* @__PURE__ */ v(`div`,{class:`${ep}-toolui-collapse-body`,children:[d.intro?/* @__PURE__ */ _(`div`,{class:`${ep}-toolui-desc`,children:d.intro}):null,j,b||y?null:/* @__PURE__ */ v(`div`,{class:`${ep}-toolui-footer`,children:[/* @__PURE__ */ v(`button`,{type:`button`,class:`${ep}-toolui-options-toggle`,onClick:()=>O(e=>!e),"data-testid":J.toolAskOptions,children:[/* @__PURE__ */ _(`span`,{class:`${ep}-toolui-options-chevron${D?` ${ep}-open`:``}`,children:/* @__PURE__ */ _(jc,{})}),D?t.hideOptions:t.showOptions]}),S?/* @__PURE__ */ _(`button`,{type:`button`,class:`${ep}-form-skip`,onClick:()=>c(e.toolCallId),"data-testid":J.toolEdit,children:t.edit}):null]})]})]})}function ap({req:e,strings:t,active:n,resolve:r}){let i=Kf(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ _(Yf,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(cp(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:rp(e.questions,t),submitTestId:J.toolInputSubmit,skipTestId:J.toolInputSkip})}function op({questions:e,answers:t,strings:n}){return/* @__PURE__ */ _(`div`,{class:`${ep}-toolui-summary`,"data-testid":J.toolAskSummary,children:e.map(e=>/* @__PURE__ */ v(`div`,{class:`${ep}-field`,children:[/* @__PURE__ */ _(`span`,{class:`${ep}-field-head`,children:/* @__PURE__ */ v(`span`,{class:`${ep}-field-label`,children:[e.question,e.required?/* @__PURE__ */ _(`span`,{class:`${ep}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ _(`p`,{class:`${ep}-toolui-answer`,children:sp(e,t[e.key],n)||`—`})]},e.key))})}function sp(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function cp(e,t){let n=e.flatMap(e=>{let n=t[e.key],r=typeof n==`string`?n.trim():n;return r?.length?[{key:e.key,value:r}]:[]});return JSON.stringify({answers:n})}function lp(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})(),n=up(t)?t.answers:void 0;if(!Array.isArray(n))return{};let r={};for(let e of n)if(up(e)){let{key:t,value:n}=e;if(typeof t!=`string`)continue;typeof n==`string`?r[t]=n:Array.isArray(n)&&(r[t]=n.filter(e=>typeof e==`string`))}return r}function up(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function dp(e){let t=lp(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function fp(e,t){let n=lp(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}const Z=P.cssPrefix;function pp(e,t){let n=[];for(let[r,i]of e.entries()){let e=n.at(-1),a=i.kind===`tool`?t.viewOf(i):void 0,o=mp(i,a,t.showReasoning);o?e?.kind===`steps`?(e.rows.push(o),e.indices.push(r)):n.push({kind:`steps`,rows:[o],indices:[r]}):i.kind===`step-start`||i.kind===`reasoning`||i.kind===`source`&&!t.showSources||a?.placement===`hidden`||n.push({kind:`part`,part:i,index:r})}return n}function mp(e,t,n){return e.kind===`reasoning`?n?{kind:`thought`,part:e}:void 0:e.kind===`tool`&&t?.placement===`step`?{kind:`tool`,part:e,view:t}:void 0}function hp(e,t){let n=[...new Set(t)];if(e&&n.length!==0&&!n.some(t=>t<0||t>=e.length))return n.reduce((t,n)=>t+(e[n]?.durationMs??0),0)}function gp(e){let t=[];for(let n of e)t.push((t.at(-1)??-1)+ +(n.kind===`step-start`));return t}function _p(e,t){return e.streaming?t.thinking:e.reasoningMs===void 0?t.thought:t.thoughtFor.replace(`{time}`,vp(e.reasoningMs))}function vp(e){if(e<1e4)return`${Number((e/1e3).toFixed(1))} s`;let t=Math.round(e/1e3);return t<60?`${t} s`:`${Math.floor(t/60)} m ${t%60} s`}function yp(e){return e.split(`
41
- `).map(e=>e.trim()).findLast(e=>/^\*\*[^*].*\*\*$/.test(e))?.slice(2,-2).trim()}function bp(e,t){return e?.kind===`tool`?`${e.view.name}…`:(e&&yp(e.part.textSig.value))??t.thinking}function xp({rows:e,steps:t=[],stepTimings:n,timed:r=!0,strings:a,running:o,runStartedAt:s,renderCard:c}){let[l,u]=h(!1),[d,f]=h(!1),m=Oe(e.flatMap(e=>e.kind===`tool`?[e.view]:[])),g=e.at(-1),y=p(()=>i(()=>bp(g,a)),[g,a]).value,b=r?hp(n,t):void 0;function x(){u(!l),f(!0)}let[S]=e;return!o&&e.length===1&&S?.kind===`tool`?/* @__PURE__ */ _(`div`,{class:`${Z}-steps`,"data-testid":J.toolSteps,"data-stopped":m.stopped?`true`:void 0,children:/* @__PURE__ */ _(Dp,{part:S.part,view:S.view,strings:a,durationMs:b,standalone:!0,renderCard:c})}):/* @__PURE__ */ v(`div`,{class:`${Z}-steps`,"data-testid":J.toolSteps,"data-running":o?`true`:void 0,"data-stopped":m.stopped?`true`:void 0,children:[/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-head`,"aria-expanded":l,onClick:x,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Cp,{running:o,stopped:m.stopped!==void 0})}),/* @__PURE__ */ _(`span`,{class:`${Z}-steps-label`,children:o?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-live`,children:y}):/* @__PURE__ */ _(wp,{line:m,strings:a})}),!o&&m.failed>0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-failed`,children:a.toolStepsFailed.replace(`{count}`,String(m.failed))}):null,o?null:m.marks.map(e=>/* @__PURE__ */ _(Nf,{decision:e},e.title)),o&&s?/* @__PURE__ */ _(Sp,{since:s}):null,!o&&b!==void 0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-time`,children:vp(b)}):null,/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":l?`true`:void 0,children:/* @__PURE__ */ _(jc,{})})]}),/* @__PURE__ */ _(`span`,{class:`${Z}-sr-only`,role:`status`,children:o?y:``}),/* @__PURE__ */ _(`div`,{class:`${Z}-steps-body`,"data-open":l?`true`:void 0,inert:!l,children:/* @__PURE__ */ _(`div`,{class:`${Z}-steps-body-inner`,children:d?/* @__PURE__ */ _(`ol`,{class:`${Z}-steps-list`,children:e.map((r,i)=>r.kind===`tool`?/* @__PURE__ */ _(Dp,{part:r.part,view:r.view,strings:a,renderCard:c},r.part.toolCallId):/* @__PURE__ */ _(Op,{part:r.part,current:o&&i===e.length-1,reasoningMs:n?.[t[i]??-1]?.reasoningMs,strings:a},`${r.part.id}#${i}`))}):null})})]})}function Sp({since:e}){let[t,n]=h(()=>Date.now());u(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((t-Date.parse(e))/1e3));return/* @__PURE__ */ _(`span`,{class:`${Z}-steps-time`,children:vp(r*1e3)})}function Cp({running:e,stopped:t}){return e?/* @__PURE__ */ _(`span`,{class:`${Z}-loading-spinner`}):_(t?dc:tl,{})}function wp({line:e,strings:t}){return e.stopped?/* @__PURE__ */ _(g,{children:Ae(e.stopped.finished,t)}):e.single?/* @__PURE__ */ v(g,{children:[e.single.name,e.single.summary?/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ _(`span`,{class:`${Z}-steps-summary`,children:e.single.summary})]}):null,e.single.outcome?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-denied`,children:e.single.outcome}):null]}):/* @__PURE__ */ _(g,{children:e.tools.map(({name:e,count:t},n)=>/* @__PURE__ */ v(`span`,{class:`${Z}-steps-name`,children:[n>0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}):null,e,t>1?/* @__PURE__ */ v(`span`,{class:`${Z}-steps-count`,children:[`×`,t]}):null]},e))})}function Tp({view:e}){let t=e.statusLabel&&e.status!==`running`?/* @__PURE__ */ _(`span`,{class:e.status===`failed`?`${Z}-steps-failed`:`${Z}-steps-denied`,children:e.statusLabel}):null;return/* @__PURE__ */ v(g,{children:[e.decision?/* @__PURE__ */ _(Nf,{decision:e.decision}):null,t]})}function Ep({view:e,durationMs:t}){return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`span`,{class:`${Z}-steps-row-label`,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-name`,children:e.name}),e.system?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-system`,children:e.system}):null,e.summary?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-summary`,children:e.summary}):null]}),/* @__PURE__ */ _(Tp,{view:e}),t===void 0?null:/* @__PURE__ */ _(`span`,{class:`${Z}-steps-time`,children:vp(t)})]})}function Dp({part:e,view:t,strings:n,durationMs:r,standalone:i=!1,renderCard:a}){let[o,s]=h(!1);return/* @__PURE__ */ v(i?`div`:`li`,{class:`${Z}-steps-row`,"data-testid":J.toolStep,"data-status":t.status,"data-standalone":i?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Mf,{status:t.status})}),/* @__PURE__ */ _(`div`,{class:`${Z}-steps-row-main`,children:t.opens?/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":o,onClick:()=>s(!o),children:[/* @__PURE__ */ _(Ep,{view:t,durationMs:r}),/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":o?`true`:void 0,children:/* @__PURE__ */ _(jc,{})})]}):/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-head`,children:/* @__PURE__ */ _(Ep,{view:t,durationMs:r})})}),o&&t.opens?/* @__PURE__ */ _(`div`,{class:`${Z}-steps-row-body`,children:(t.card?a?.(e,t):void 0)??/* @__PURE__ */ _(Pf,{view:t,strings:n})}):null]})}function Op({part:e,current:t,reasoningMs:n,strings:r,standalone:a=!1}){let[o,s]=h(!1),c=p(()=>i(()=>e.textSig.value.trim()===``),[e]).value,l=/* @__PURE__ */ _(`span`,{class:t?`${Z}-steps-thought-label ${Z}-steps-live`:`${Z}-steps-thought-label`,children:_p({streaming:t,reasoningMs:n},r)});return/* @__PURE__ */ v(a?`div`:`li`,{class:`${Z}-steps-row ${Z}-steps-thought`,"data-status":`thought`,"data-testid":a?J.reasoning:void 0,"data-standalone":a?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(al,{})}),/* @__PURE__ */ _(`div`,{class:`${Z}-steps-row-main`,children:c?l:/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":o,onClick:()=>s(!o),children:[l,/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":o?`true`:void 0,children:/* @__PURE__ */ _(jc,{})})]})}),o&&!c?/* @__PURE__ */ _(`div`,{class:`${Z}-steps-thought-text ${Z}-reasoning-body`,children:/* @__PURE__ */ _(Sl,{textSig:e.textSig,doneSig:e.doneSig})}):null]})}const kp=P.cssPrefix,Ap=b(jp);function jp({message:e,status:t,createdAt:n,strings:r,locale:a,responseMode:o,showReasoning:s,stepDisplay:c,showSources:l,interactive:u=!1,superseded:d=!1,tool:f,onRetry:m,enableMessageFeedback:h=!1,onFeedback:g,reconnecting:y=!1,clientToolRunning:b=!1,onCardAction:x}){let S=[...p(()=>i(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!S.some(e=>e.kind===`file`&&e.url===t.url)&&S.push({kind:`file`,url:t.url,mediaType:t.mediaType,filename:t.name,fileId:t.id,fileSize:t.size});let C=p(()=>i(()=>Ko(e)),[e,t,e.canceled]),w=p(()=>i(()=>Sf(e)),[e]),T=p(()=>i(()=>s&&Cf(e)),[e,s]),E=p(()=>i(()=>Jo(e,T.value)),[e,T,t,e.canceled]),D=p(()=>i(()=>!Co(e)),[e]),O=t===`streaming`,k=e.role===`assistant`&&b,A=e.role===`assistant`&&(O||k),j=O||k,ee=Tf({streaming:A,responseMode:o,reasoningVisible:T.value,hasAnswerText:w.value,emptyReply:C.value,hidden:E.value}),{bufferedHold:M,showStreamDots:N}=ee;if(ee.hidden)return null;let P=Np(n,a),te=e.role===`assistant`||e.role===`operator`,ne=h&&!!g&&!!e.serverMessageId&&te&&!j&&t!==`error`&&!C.value,re=j?``:S.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?Ka(t.textSig.peek()):t.textSig.peek()).join(`
37
+ `))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function cs(e,t){let n=``,r;for(let i of e.split(`
38
+ `))if(i!==``){if(i.startsWith(`:`))t?.(i.slice(1).trim());else if(i.startsWith(`data:`)){let e=i.slice(5).replace(/^ /,``);n=n?`${n}\n${e}`:e}else i.startsWith(`id:`)&&(r=i.slice(3).trim())}if(n===`[DONE]`)return`done`;if(!n)return null;try{let e=JSON.parse(n);if(!ls(e))throw TypeError(`unrecognized chunk`);return as.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw as.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new is(`invalid SSE frame`,`network`,void 0,e)}}function ls(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof Reflect.get(e,`type`)==`string`}const us=/* @__PURE__ */ new Set([101,204,205,304]);function ds(e){let t=new Headers;for(let n of e.trim().split(/[\r\n]+/)){let e=n.indexOf(`:`);e>0&&t.append(n.slice(0,e).trim(),n.slice(e+1).trim())}return t}function fs(e){return async function(t,n){let r=new Request(t,n),i=await r.blob();return new Promise((t,n)=>{if(r.signal.aborted){n(r.signal.reason);return}let a=new XMLHttpRequest;a.open(r.method,r.url),a.withCredentials=r.credentials===`include`,a.responseType=`blob`,r.headers.forEach((e,t)=>a.setRequestHeader(t,e)),a.upload.addEventListener(`progress`,t=>{t.lengthComputable&&t.total>0&&e(t.loaded/t.total)}),a.addEventListener(`load`,()=>{t(new Response(us.has(a.status)?null:a.response,{status:a.status,statusText:a.statusText,headers:ds(a.getAllResponseHeaders())}))}),a.addEventListener(`error`,()=>n(/* @__PURE__ */ TypeError(`Failed to fetch`))),a.addEventListener(`abort`,()=>n(r.signal.reason)),r.signal.addEventListener(`abort`,()=>a.abort(),{once:!0}),a.send(i)})}}const ps=V.scope(`transport`);async function ms(e){try{let t=await e.clone().json();if(typeof t!=`object`||!t)return{};let n=Reflect.get(t,`error`);return{error:typeof n==`string`?n:void 0,loginUrl:lr(Reflect.get(t,`login`)).url}}catch{return{}}}const hs=6e4,gs=/* @__PURE__ */ new WeakMap;function _s(e){return gs.get(e)}function vs(e,t){return gs.set(e,t),e}function ys(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function bs(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function xs(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(_s(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>(_s(t)?.activityRevision??0)-(_s(e)?.activityRevision??0)),i=new Set(r.map(e=>e.conversationId));return[...r,...t.result.conversations.filter(e=>!i.has(e.conversationId)).map(e=>{let r=n.get(e.conversationId);if(!r)return e;let i=_s(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?vs({...e,hasUnread:!1},{upsertRevision:0,read:i.read}):e})]}case`read`:{let n=e.findIndex(e=>e.conversationId===t.conversationId&&(t.lastMessageAt===void 0||e.lastMessageAt===t.lastMessageAt)),r=e[n];if(!r)return e;let i=_s(r);if(ys(i)>t.revision)return e;let a=t.lastMessageAt??r.lastMessageAt,o={upsertRevision:i?.upsertRevision??0,...i?.activityRevision===void 0?{}:{activityRevision:i.activityRevision},read:{revision:t.revision,...a?{lastMessageAt:a}:{}}};return r.hasUnread?e.map((e,t)=>t===n?vs({...e,hasUnread:!1},o):e):(vs(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=e[r],a=i?_s(i):void 0;if(ys(a)>t.revision)return e;let o=t.activity?t.revision:a?.activityRevision,s={upsertRevision:t.revision,...o===void 0?{}:{activityRevision:o},...!t.conversation.hasUnread&&a?.read?{read:a.read}:{}},c=i?{...i,...t.conversation,title:i.title}:{...t.conversation};return i&&bs(i,c)?(vs(i,s),e):(vs(c,s),t.activity?[c,...e.filter(e=>e.conversationId!==c.conversationId)]:i?e.map((e,t)=>t===r?c:e):[...e,c])}default:return t}}const Ss=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function Cs(e){return 400*2**e+Math.floor(Math.random()*250)}function ws(e){return 6e4+Math.ceil(e/1048576)*15e3}function Ts(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 Es=class{constructor(e){this.ttlMs=e,U(this,`map`,/* @__PURE__ */ new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&performance.now()-n.at<this.ttlMs)return n.result;let r={at:performance.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.get(e)===r&&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&&performance.now()-t.at<this.ttlMs)return t.value}update(e){for(let t of this.map.values())if(t.value!==void 0){let n=e(t.value);t.value=n,t.result=Promise.resolve(n)}else t.result=t.result.then(n=>{let r=e(n);return t.value=r,r})}delete(e){this.map.delete(e)}};function Ds(e,t){let{translations:n,defaultLocale:r,...i}=E(e,t);return i}var Os=class{constructor(e){this.opts=e,U(this,`conversationListeners`,/* @__PURE__ */ new Set),U(this,`conversationRevision`,0),U(this,`visitorId`,void 0),U(this,`conversationId`,void 0),U(this,`userContext`,void 0),U(this,`pageContext`,void 0),U(this,`locale`,void 0),U(this,`userTokenSource`,void 0),U(this,`userToken`,void 0),U(this,`userTokenRequest`,void 0),U(this,`conversationsCache`,new Es(1e4)),U(this,`contentCache`,new Es(hs)),U(this,`contentCollectionsCache`,new Es(hs))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0,this.opts.onLoginState?.(e?{status:`pending`}:{status:`anonymous`})}async userSub(){return this.userTokenRequest&&await this.userTokenRequest,this.userToken?mr(this.userToken):void 0}reportLogin(e){this.opts.onLoginState?.(e===`loggedIn`&&this.userToken?{status:e,...pr(this.userToken)}:{status:e===`loggedIn`?`anonymous`:e})}async refreshUserToken(){let e=this.userToken;return typeof this.userTokenSource==`function`&&(this.userTokenRequest&&await this.userTokenRequest,this.userToken===e&&await this.fetchUserToken(),!!this.userToken&&this.userToken!==e)}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:sn};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=rs(this.userContext,this.pageContext);return t&&(e[eo]=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){ps.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale});let t=Ms(`handshake`,await this.postJson($a.handshake,e,`handshake`),Ps),n=t.loginStatus===`expired`&&await this.refreshUserToken()?Ms(`handshake`,await this.postJson($a.handshake,e,`handshake`),Ps):t;return this.reportLogin(n.loginStatus??(this.userToken?`loggedIn`:`anonymous`)),ps.debug(`handshake ←`,{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),this.visitorId=n.visitorId,this.conversationId=n.conversationId,n}async uploadFile(e,t,n){ps.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let r=new FormData;r.append(`file`,e,e.name);let i=Ms(`upload`,await this.postForm(this.uploadPath,r,`upload`,t,ws(e.size),n),Fs);return ps.debug(`uploadFile ←`,{id:i.id,url:i.url}),i}async transcribe(e,t=`audio/webm`){ps.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${ks(t)}`),n.append(`mimeType`,t);let r=Ms(`transcribe`,await this.postForm(this.transcribePath,n,`transcribe`),Is);return ps.debug(`transcribe ←`,{textLen:r.text.length}),r}subscribeConversationChanges(e){return this.conversationListeners.add(e),()=>this.conversationListeners.delete(e)}publishConversation(e,t=!1){let n={type:`upsert`,conversation:e,revision:++this.conversationRevision,...t?{activity:!0}:{}};this.conversationsCache.update(r=>{let i=r.pagination.page===1,a=r.conversations.some(t=>t.conversationId===e.conversationId),o=xs(r.conversations,n,i&&t),s=i&&o.length>r.pagination.limit?o.slice(0,r.pagination.limit):o;if(!i||!t||a||r.pagination.hasNext)return s===r.conversations?r:{...r,conversations:s};let c=Math.max(r.pagination.total,r.conversations.length)+1,l=Math.ceil(c/r.pagination.limit);return{...r,conversations:s,pagination:{...r.pagination,total:c,totalPages:l,hasNext:r.pagination.page<l}}});for(let e of this.conversationListeners)e(n)}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={},t=!1){if((e.page??1)>1)return this.fetchConversations(e);let n=this.localeCacheKey(e),r=this.conversationRevision;t&&this.conversationsCache.delete(n);let i=this.conversationsCache.getOrFetch(n,()=>this.fetchConversations(e));return t?i.then(e=>{let t={type:`snapshot`,result:e,requestedRevision:r};for(let e of this.conversationListeners)e(t);return e}):i}async fetchConversations(e){let t=new URL(this.url($a.listConversations));return e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.page&&t.searchParams.set(`page`,String(e.page)),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.ids?.length&&t.searchParams.set(`ids`,e.ids.join(`,`)),Ms(`listConversations`,await this.getJson(t.toString(),`listConversations`),Rs)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url($a.listMessages));i.searchParams.set(`conversationId`,e),i.searchParams.set(`limit`,`50`),t.length>0&&i.searchParams.set(`ids`,t.join(`,`)),n&&i.searchParams.set(`beforeId`,n),r&&i.searchParams.set(`beforeCreatedAt`,r);let a=Ms(`loadConversation`,await this.getJson(i.toString(),`loadConversation`),zs);return{...a,messages:a.messages.toReversed()}}async markRead(e,t){if(!this.visitorId||!e)return;let n={type:`read`,conversationId:e,...t===void 0?{}:{lastMessageAt:t},revision:++this.conversationRevision};this.conversationsCache.update(e=>{let t=xs(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson($a.markRead,{conversationId:e},`markRead`,!0)}catch(e){ps.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return Ns(`requestOperator`,await this.postJson($a.requestOperator,{},`requestOperator`))}catch(e){ps.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async emailTranscript(e){return Ms(`emailTranscript`,await this.postJson($a.emailTranscript,{email:e},`emailTranscript`),Bs)}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return Ns(`cancelOperatorRequest`,await this.postJson($a.cancelOperatorRequest,{},`cancelOperatorRequest`))}catch(e){ps.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(JSON.stringify(e,Object.keys(e).toSorted()),()=>this.fetchContent(e)).then(e=>({...e,items:e.items.map(e=>Ds(e,this.locale))}))}async fetchContent(e){let t=new URL(this.dataUrl($a.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));let n=Ms(`listContent`,await this.getJson(t.toString(),`listContent`),Vs);return{...n,items:n.items??[]}}async setContentVote(e){try{await this.postJson(this.dataUrl($a.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(e.join(`,`),()=>this.fetchContentCollections(e)).then(e=>({items:e.items.map(e=>Ds(e,this.locale))}))}async fetchContentCollections(e){let t=new URL(this.dataUrl($a.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:Ms(`listContentCollections`,await this.getJson(t.toString(),`listContentCollections`),Hs).items??[]}}async saveUserPrefs(e){await this.postJson($a.updateSettings,{userPrefs:e},`saveUserPrefs`)}get uploadPath(){return this.opts.endpoints?.upload??`/pai/upload-file`}get transcribePath(){return this.opts.endpoints?.transcribe??`/pai/transcribe-audio`}async submitFeedback(e){ps.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson($a.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){ps.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e,t={}){ps.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});let n=JSON.stringify({...this.withEnvelope(e),[eo]:rs(this.userContext,this.pageContext,this.opts.recentHostEvents)}),r=t.keepalive===!0&&new Blob([n]).size<6e4;try{return await this.runWithAbort(async e=>{let t=await this.withFreshUserToken(()=>this.fetchImpl(this.url($a.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url($a.streamMessage))},body:n,keepalive:r,signal:e}));if(t.status!==202)throw new is(`sendTurn failed: expected 202, received ${t.status}`,`server`,t.status,void 0,Us(t),(await ms(t)).error);let i;try{i=await t.json()}catch(n){throw e?.aborted?n:new is(`sendTurn failed: invalid acknowledgement`,`server`,t.status,n)}if(!As(i))throw new is(`sendTurn failed: invalid acknowledgement`,`server`,t.status);return i},void 0,3e4)}catch(e){throw e instanceof is?e:new is(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(ps.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url($a.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url($a.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>ps.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t=new AbortController;function n(){return t.abort(e.signal.reason)}e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0});let r=setTimeout(()=>t.abort(),1e4);function i(){clearTimeout(r),e.signal.removeEventListener(`abort`,n)}let a;try{a=await this.withFreshUserToken(()=>this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,cache:`no-store`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal}))}catch(t){return i(),e.signal.aborted||ps.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===409||Ss.has(a.status)?(ps.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(ps.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),ps.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),ps.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of os(a,t.signal,t=>{o||t!==`connected`||(o=!0,clearTimeout(r),e.onConnected())})){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;ps.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery($a.streamResume)}async postJson(e,t,n,r=!1){let i=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(e))},body:JSON.stringify(this.withEnvelope(t)),...r?{keepalive:!0}:{}}],n);return this.assertOk(i,n)}async postForm(e,t,n,r,i,a){let o=a?fs(a):this.fetchImpl;return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>o(this.url(e),{method:`POST`,credentials:`omit`,headers:this.headersFor(this.url(e)),body:this.appendEnvelope(t),signal:r}));return this.assertOk(i,n)},r,i)}async runWithAbort(e,t,n){if(!t&&n===void 0)return e();let r=new AbortController;function i(){return r.abort(t?.reason)}t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0});let a=n===void 0?void 0:setTimeout(()=>r.abort(),n);try{return await e(r.signal)}finally{a!==void 0&&clearTimeout(a),t?.removeEventListener(`abort`,i)}}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.headersFor(this.url(e))}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let r;try{r=await this.withFreshUserToken(()=>this.fetchImpl(...e()))}catch(e){if(n>=3)throw new is(`${t} failed: network error`,`network`,void 0,e);ps.debug(`request network error — retrying`,{label:t,attempt:n}),await es(Cs(n));continue}if(r.ok||!Ss.has(r.status)||n>=3)return r;let i=Ts(r.headers)??Cs(n);ps.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await es(i)}}async assertOk(e,t){if(!e.ok)throw new is(`${t} failed: ${e.status}`,`server`,e.status,void 0,void 0,(await ms(e)).error);return await e.json()}fetchUserToken(){let e=this.userTokenSource;if(typeof e!=`function`)return Promise.resolve();let t=Promise.resolve().then(e).then(t=>{this.userTokenSource===e&&(this.userToken=t||void 0)},t=>{ps.warn(`userToken function failed`,{err:t}),this.userTokenSource===e&&(this.userToken=void 0)});return this.userTokenRequest=t,t}headersFor(e){let t=!/^https?:\/\//i.test(e)||e.startsWith(`${this.opts.agentApiBaseUrl}/`);return{...this.opts.auth.headers(),...t&&this.userToken?{"x-user-token":this.userToken}:{},...t&&this.opts.continueLink?{"x-continue-link":this.opts.continueLink}:{}}}async withFreshUserToken(e){this.userTokenRequest&&await this.userTokenRequest;let t=await e();if(t.status!==401)return t;let n=await ms(t);if(n.error===`USER_TOKEN_REQUIRED`)return this.opts.onLoginState?.({status:`required`,loginUrl:n.loginUrl}),t;if(!this.userToken)return t;if(!await this.refreshUserToken())return this.reportLogin(`expired`),t;this.reportLogin(`loggedIn`);let r=await e();return r.status===401&&this.reportLogin(`expired`),r}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function ks(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 As(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`status`),n=Reflect.get(e,`conversationId`),r=Reflect.get(e,`runId`);return t===`accepted`&&typeof n==`string`&&n.length>0&&(r===void 0||typeof r==`string`&&r.length>0)}function js(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ms(e,t,n){if(!n(t))throw new is(`${e} failed: invalid response body`,`server`);return t}function Ns(e,t){let n=no(js(t)?t.controlState:void 0);if(!n)throw new is(`${e} failed: invalid response body`,`server`);return n}function Ps(e){return!(!js(e)||typeof e.visitorId!=`string`||typeof e.conversationId!=`string`||e.welcome!==void 0&&(!js(e.welcome)||e.welcome.messages!==void 0&&!Array.isArray(e.welcome.messages)))}function Fs(e){return js(e)&&typeof e.id==`string`&&typeof e.url==`string`&&typeof e.originalName==`string`&&typeof e.mimeType==`string`&&typeof e.fileSize==`number`}function Is(e){return js(e)&&typeof e.text==`string`}function Ls(e){return js(e)&&typeof e.page==`number`&&typeof e.limit==`number`&&typeof e.total==`number`&&typeof e.totalPages==`number`&&typeof e.hasNext==`boolean`&&typeof e.hasPrev==`boolean`}function Rs(e){return js(e)&&Array.isArray(e.conversations)&&e.conversations.every(js)&&Ls(e.pagination)}function zs(e){return js(e)&&typeof e.conversationId==`string`&&Array.isArray(e.messages)&&e.messages.every(js)}function Bs(e){return js(e)&&typeof e.status==`string`&&typeof e.to==`string`}function Vs(e){return js(e)&&(e.items===void 0||Array.isArray(e.items)&&e.items.every(js))&&(e.pagination===void 0||Ls(e.pagination))}function Hs(e){return js(e)&&(e.items===void 0||Array.isArray(e.items)&&e.items.every(js))}function Us(e){let t=Number(e.headers.get(`retry-after`));return Number.isInteger(t)&&t>0?t:void 0}function Ws(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`popOut`:return t!==`standalone`&&t!==`page`;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function Gs(e,t,n){return Ws(`close`,e,t)?n.includes(`close`):!1}function Ks(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function qs(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function Js(e){return Object.fromEntries(e.map(e=>[e,[]]))}function Ys(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function Xs(e,t,n){let r=[...new Set(t)],i=Ys(r,e,``),a=o({activeTab:i,stacks:Js(r)});return{sig:a,reconcile(e,t){let i=[...new Set(e)],o=a.value,s=Ys(i,o.activeTab,t),c=Object.fromEntries(i.map(e=>[e,o.stacks[e]??[]])),l=s===o.activeTab&&i.length===Object.keys(o.stacks).length&&i.every(e=>o.stacks[e]===c[e]);r=i,l||(a.value={activeTab:s,stacks:c},s!==o.activeTab&&s&&n?.(s))},switchTab(e){e in a.value.stacks&&a.value.activeTab!==e&&(a.value={...a.value,activeTab:e},n?.(e))},open(e,t){let r=a.value;e in r.stacks&&(a.value={activeTab:e,stacks:{...r.stacks,[e]:t?[t]:[]}},r.activeTab!==e&&n?.(e))},push(e){let t=a.value,n=t.stacks[t.activeTab]??[];a.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=a.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(a.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){a.value={activeTab:Ys(r,e,``),stacks:Js(r)}}}}function Zs(e){return e.stacks[e.activeTab]??[]}function Qs(e){return Zs(e).at(-1)}function $s(e){return Zs(e).length===0}function ec(e){/^(https?:)?\//i.test(e)&&window.open(e,`_blank`,`noopener,noreferrer`)}function tc(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 nc(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 rc(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:nc(e.mode,e.size,t)}}function ic(){return typeof window>`u`?0:window.innerWidth}const K={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},ac=`${P.cssPrefix}-icon-dir`;function oc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})})}function sc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function cc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 5v14M5 12h14`})})}function lc(){return/* @__PURE__ */ v(`svg`,{...K,class:ac,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),/* @__PURE__ */ _(`path`,{d:`M22 2 11 13`})]})}function uc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function dc(){return/* @__PURE__ */ _(`svg`,{...K,class:ac,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function fc(){return/* @__PURE__ */ _(`svg`,{...K,class:ac,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`m9 18 6-6-6-6`})})}function pc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function mc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`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`})})}function hc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),/* @__PURE__ */ _(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]})}function gc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`8`,r:`4.5`}),/* @__PURE__ */ _(`path`,{d:`M4.5 20.5a7.5 7.5 0 0 1 15 0`})]})}function _c(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function vc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function yc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function bc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function xc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 3h7v7M21 3l-9 9`}),/* @__PURE__ */ _(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})]})}function Sc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ _(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function Cc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]})}function wc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})})}function Tc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function Ec(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),/* @__PURE__ */ _(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]})}function Dc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M20 6 9 17l-5-5`})})}function Oc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 3v6h6`}),/* @__PURE__ */ _(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),/* @__PURE__ */ _(`path`,{d:`M12 7v5l3 2`})]})}function kc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M2 12h20`}),/* @__PURE__ */ _(`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`})]})}function Ac(){return/* @__PURE__ */ _(`svg`,{...K,class:ac,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function jc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M12 20h9`}),/* @__PURE__ */ _(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function Mc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),/* @__PURE__ */ _(`path`,{d:`m3 7 9 6 9-6`})]})}function Nc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`m6 9 6 6 6-6`})})}function Pc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),/* @__PURE__ */ _(`path`,{d:`M14 2v6h6`})]})}function Fc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),/* @__PURE__ */ _(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]})}function Ic(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})})}function Lc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),/* @__PURE__ */ _(`path`,{d:`M12 17h.01`})]})}function Rc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m15 4 3 3-9 9-3-3z`}),/* @__PURE__ */ _(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]})}function zc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),/* @__PURE__ */ _(`path`,{d:`M12 8V4`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`3`,r:`1`}),/* @__PURE__ */ _(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]})}function Bc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),/* @__PURE__ */ _(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ _(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ _(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]})}function Vc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ _(`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`})]})}function Hc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ _(`path`,{d:`m21 21-4.3-4.3`})]})}function Uc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Wc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 9.5 12 3l9 6.5`}),/* @__PURE__ */ _(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]})}function Gc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m3 11 15-5v12L3 13z`}),/* @__PURE__ */ _(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),/* @__PURE__ */ _(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),/* @__PURE__ */ _(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]})}function Kc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),/* @__PURE__ */ _(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]})}function qc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ _(`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`})]})}function Jc(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})}function Yc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`M12 3v18`}),/* @__PURE__ */ _(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]})}function Xc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),/* @__PURE__ */ _(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),/* @__PURE__ */ _(`path`,{d:`m20 20-4.4-4.4`})]})}function Zc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`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`}),/* @__PURE__ */ _(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]})}function Qc(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M4 18h16`}),/* @__PURE__ */ _(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),/* @__PURE__ */ _(`path`,{d:`M12 8V6`}),/* @__PURE__ */ _(`path`,{d:`M10 6h4`})]})}function $c(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ _(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ _(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),/* @__PURE__ */ _(`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`})]})}function el(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),/* @__PURE__ */ _(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]})}function tl(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),/* @__PURE__ */ _(`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`})]})}function nl(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),/* @__PURE__ */ _(`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`})]})}function rl(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),/* @__PURE__ */ _(`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`})]})}function il(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`M12 7v5l3 2`})]})}function al(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function ol(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}function sl(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 18V5M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294M17.996 5.125a4 4 0 012.526 5.77M18 18a4 4 0 002-7.465M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517M6 18a4 4 0 01-2-7.465M6.004 5.125a4 4 0 00-2.526 5.77`})})}function cl(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M12 8v4M12 16h.01`})]})}const ll={chat:oc,message:Ic,bubbles:Kc,spark:Fc,wand:Rc,bot:zc,help:Lc,lifebuoy:Vc,headset:Bc,search:Xc,sparkles:Zc,concierge:Qc,wave:$c},q=P.cssPrefix,J={launcher:`${q}-launcher`,callout:`${q}-callout`,calloutDismiss:`${q}-callout-dismiss`,panel:`${q}-panel`,panelHeader:`${q}-panel-header`,resizeGrip:`${q}-resize-grip`,scrollToBottom:`${q}-scroll-to-bottom`,loadPreviousMessages:`${q}-load-previous-messages`,actionHistory:`${q}-action-history`,actionClose:`${q}-action-close`,emailTranscriptSheet:`${q}-email-transcript-sheet`,emailTranscriptEmail:`${q}-email-transcript-email`,emailTranscriptSend:`${q}-email-transcript-send`,langSegment:`${q}-lang-segment`,composer:`${q}-composer`,composerInput:`${q}-composer-input`,composerCount:`${q}-composer-count`,composerSend:`${q}-composer-send`,composerStop:`${q}-composer-stop`,compactionStatus:`${q}-compaction-status`,messageQueue:`${q}-message-queue`,queuedMessage:`${q}-queued-message`,queuedMessageRemove:`${q}-queued-message-remove`,composerAttach:`${q}-composer-attach`,composerFileInput:`${q}-composer-file-input`,composerVoice:`${q}-composer-voice`,attachmentChip:`${q}-attachment-chip`,attachmentRemove:`${q}-attachment-remove`,attachmentRetry:`${q}-attachment-retry`,suggestion:`${q}-suggestion`,messageBubble:`${q}-message`,messageRetry:`${q}-message-retry`,messageFile:`${q}-message-file`,messageFeedback:`${q}-message-feedback`,feedbackUp:`${q}-feedback-up`,feedbackDown:`${q}-feedback-down`,messageCopy:`${q}-message-copy`,historyItem:`${q}-history-item`,historyLoadMore:`${q}-history-load-more`,sidebar:`${q}-sidebar`,sidebarToggle:`${q}-sidebar-toggle`,sidebarNewConversation:`${q}-sidebar-new-conversation`,messengerHome:`${q}-messenger-home`,panelNotice:`${q}-panel-notice`,tab:`${q}-tab`,tabBadge:`${q}-tab-badge`,homeView:`${q}-home-view`,homeGreeting:`${q}-home-greeting`,homeBrand:`${q}-home-brand`,backHeader:`${q}-back-header`,contentView:`${q}-content-view`,contentScroll:`${q}-content-scroll`,homeSearch:`${q}-home-search`,helpSearch:`${q}-help-search`,homeRecent:`${q}-home-recent`,homeAsk:`${q}-home-ask`,homeWhatsNew:`${q}-home-whats-new`,homeContentRow:`${q}-home-content-row`,helpArticle:`${q}-help-article`,newsItem:`${q}-news-item`,newsMore:`${q}-news-more`,formField:`${q}-form-field`,toolAskQuestions:`${q}-tool-ask-questions`,toolInputSubmit:`${q}-tool-input-submit`,toolInputSkip:`${q}-tool-input-skip`,toolApproval:`${q}-tool-approval`,toolPreview:`${q}-tool-preview`,toolApprove:`${q}-tool-approve`,toolDecline:`${q}-tool-decline`,toolEdit:`${q}-tool-edit`,toolDecision:`${q}-tool-decision`,typingDots:`${q}-typing-dots`,reasoning:`${q}-reasoning`,replyStopped:`${q}-reply-stopped`,toolAskSummary:`${q}-ask-questions-summary`,toolAskOptions:`${q}-ask-questions-options-toggle`,toolSteps:`${q}-tool-steps`,toolStep:`${q}-tool-step`,source:`${q}-source`,operatorRequest:`${q}-operator-request`,chatNotice:`${q}-chat-notice`,operatorBanner:`${q}-operator-banner`,cancelOperatorRequest:`${q}-cancel-operator-request`,loginBar:`${q}-login-bar`,loginBarAction:`${q}-login-bar-action`,loginBarHide:`${q}-login-bar-hide`,loginGate:`${q}-login-gate`,loginGateAction:`${q}-login-gate-action`,loginGateGuest:`${q}-login-gate-guest`,loggedIn:`${q}-logged-in`};function ul(e,t){return`${e}-${t}`}const dl=P.cssPrefix;function fl({buttonRef:e,onToggle:t,launcher:n,strings:r,leaving:i,edgeTab:a}){let o=n.variant===`circle`?``:pl(n,r);return/* @__PURE__ */ v(`button`,{ref:e,type:`button`,class:`${dl}-fab`,part:`launcher`,"data-variant":n.variant,"data-size":n.size,"data-edge-tab":a?`true`:void 0,"data-leaving":i?`true`:void 0,"data-testid":J.launcher,onClick:t,"aria-label":r.launcherOpen,children:[ml(n.icon),o?/* @__PURE__ */ _(`span`,{class:`${dl}-fab-label`,children:o}):null]})}function pl(e,t){return e.label?M(t,e.label):e.personaName?t.launcherAsk.replace(`{name}`,M(t,e.personaName)):``}function ml(e){let t=ll[e];return t?/* @__PURE__ */ _(t,{}):/* @__PURE__ */ _(hl,{source:e})}function hl({source:e}){return/* @__PURE__ */ _(`span`,{ref:t=>{t&&gl(t,e)},"aria-hidden":`true`})}function gl(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function _l({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=h(!1),s=m(null),[c,l]=h(!0);return f(()=>{let e=s.current?.parentElement;if(!e)return;let t=()=>l(window.innerWidth-e.getBoundingClientRect().width>=vl);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}),u(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),u(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ v(`div`,{ref:s,class:`${dl}-callout`,role:`status`,"data-shape":e.shape,"data-position":yl(e.position,t,c),"data-animated":e.animated?`true`:void 0,"data-testid":J.callout,children:[/* @__PURE__ */ _(`span`,{children:M(n,e.text)}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${dl}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":J.calloutDismiss,children:/* @__PURE__ */ _(sc,{})})]}):null}const vl=200;function yl(e,t,n=!0){let r=t.endsWith(`-right`),i=t.startsWith(`bottom-`);return e===`vertical`||e===`auto`&&!n?i?`top`:`bottom`:r?`left`:`right`}function bl(e){function 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(),o=a instanceof ShadowRoot?a.activeElement:null;t.shiftKey&&o===r?(t.preventDefault(),i.focus()):!t.shiftKey&&o===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const xl=P.cssPrefix;function Sl({title:e,actions:t}){return/* @__PURE__ */ v(`header`,{class:`${xl}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ _(`span`,{class:`${xl}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ _(`h1`,{class:`${xl}-back-title`,children:e}),t??/* @__PURE__ */ _(`span`,{class:`${xl}-back-spacer`,"aria-hidden":`true`})]})}function Cl({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ v(`header`,{class:`${xl}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${xl}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ _(Ac,{})}),/* @__PURE__ */ _(`h1`,{class:`${xl}-back-title`,children:e}),r??/* @__PURE__ */ _(`span`,{class:`${xl}-back-spacer`,"aria-hidden":`true`})]})}function wl({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=D,onCardAction:i}){let o=m(null),s=m(null);return f(()=>{let c=o.current;if(!c)return;c.classList.add(`${P.cssPrefix}-md`);let l=s.current,u={generativeUi:n,strings:r,onCardAction:i},d=()=>{s.current?.renderer?.dispose();let a=document.createElement(`div`),o=n?Aa(a,{cssPrefix:P.cssPrefix,strings:r,onAction:i}):void 0,l=y.parser(kl(Pl(o??y.default_renderer(a)))),d=e.value,f=d.length-Dl(d);if(!t.value)for(;f>0&&d[f-1]===`_`;)f--;let p=Ol(d.slice(0,f));return p&&y.parser_write(l,p),t.value&&(y.parser_end(l),o?.finish()),c.replaceChildren(a),{settings:u,container:a,parser:l,renderer:o,lastLen:f,lastText:d.slice(0,f)}},f=l&&l.settings.generativeUi===n&&l.settings.strings===r&&l.settings.onCardAction===i&&e.value.startsWith(l.lastText)?l:d();s.current=f;let p=a(()=>{let n=e.value,r=t.value;if(n.length<f.lastLen){f=d(),s.current=f;return}let i=Math.max(n.length-Dl(n),f.lastLen);if(!r)for(;i>f.lastLen&&n[i-1]===`_`;)i--;let a=Math.max(f.lastLen-1,0),o=Ol(n.slice(a,i)).slice(f.lastLen-a);o&&y.parser_write(f.parser,o),f.lastLen=i,f.lastText=n.slice(0,i),r&&(y.parser_end(f.parser),f.renderer?.finish())}),m=new MutationObserver(()=>Fl(c));m.observe(c,{childList:!0,subtree:!0}),Fl(c);function h(e){let t=e.target instanceof Element?e.target.closest(`a`):null;if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return c.addEventListener(`click`,h),()=>{p(),m.disconnect(),c.removeEventListener(`click`,h)}},[e,t,n,r,i]),u(()=>()=>{s.current?.renderer?.dispose(),s.current=null},[]),/* @__PURE__ */ _(`div`,{ref:o})}function Tl({text:e}){let t=p(()=>o(e),[e]),n=p(()=>o(!0),[]);return/* @__PURE__ */ _(wl,{textSig:t,doneSig:n})}const El=/([\p{L}\p{N}])(_+)(?=[\p{L}\p{N}])/gu;function Dl(e){if((e.match(/^[ \t]*`{3,}/gm)?.length??0)%2==0)return 0;let t=e.trimEnd(),n=t.lastIndexOf(`
39
+ `)+1;return/^[ \t]*`{3,}[^`]*$/.test(t.slice(n))?e.length-n:0}function Ol(e){return e.replace(El,(e,t,n)=>t+``.repeat(n.length))}function kl(e){return{...e,add_text:(t,n)=>e.add_text(t,n.replaceAll(``,`_`)),set_attr:(t,n,r)=>e.set_attr(t,n,r.replaceAll(``,`_`))}}const Al=/<(\/?)(?:(Note|Info|Tip|Warning|Danger|Check|Callout)|Tabs?|Steps?|AccordionGroup|Accordion|Expandable|Columns|CardGroup|Card|Frame|CodeGroup|Badge|Icon|Video|Embed|ParamField|ResponseField)\b((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>|(^|\n)([ \t]*)(```[^]*?(?:\n[ \t]*```|$))?/g;function jl(e){let t=0,n=``;return e.replace(Al,(e,r,i,a,o,s,c,l)=>{if(r===void 0)return t?s+(l?.split(`\n${c}`).join(`
40
+ `)??n):e;if(r)return t--,i&&(n=n.slice(2)),i?`\n${n}`:``;o||(t++,i&&(n+=`> `));let u={};a.replace(/(\w+)=(["'])(.*?)\2/g,(e,t,n,r)=>u[t]=r);let d=u.href??u.src,f=u.title??u.path??u.query??u.body??u.header??u.name??d;return(i?`> `:``)+(f?`**${d?`[${f}](${d})`:f}**${u.type?` \`${u.type}\``:``}\n${n}`:``)})}const Ml=/* @__PURE__ */ new Set([`http:`,`https:`,`mailto:`,`tel:`]),Nl=/* @__PURE__ */ new Set([`http:`,`https:`]);function Pl(e){let t=document.createElement(`a`);return{...e,set_attr:(n,r,i)=>{if(r!==y.HREF&&r!==y.SRC||(t.href=i,(r===y.HREF?Ml:Nl).has(t.protocol)))return e.set_attr(n,r,i);let a=r===y.SRC?n.nodes[n.index]:void 0;a?.replaceWith(...a.childNodes)}}}function Fl(e){for(let t of e.querySelectorAll(`a`)){let e=t.getAttribute(`href`)??``;e&&!e.startsWith(`#`)&&(t.target=`_blank`,t.rel=`noopener noreferrer`)}}const Il=/* @__PURE__ */ new Set([y.CODE_INLINE,y.ITALIC_AST,y.ITALIC_UND,y.STRONG_AST,y.STRONG_UND,y.STRIKE,y.LINK,y.RAW_URL,y.IMAGE,y.EQUATION_INLINE]);function Ll(e){let t=``,n=[],r=y.parser({data:void 0,add_token:(e,r)=>{n.push(r),Il.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!Il.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return y.parser_write(r,Ol(e)),y.parser_end(r),t.replaceAll(``,`_`).replace(/\s+/g,` `).trim()}const Rl=P.cssPrefix;function zl({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ v(`div`,{class:`${Rl}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ _(`span`,{children:t}),n?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Rl}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const Bl=P.cssPrefix,Vl=V.scope(`content`);function Hl({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=h(null),[d,f]=h(!1),[p,m]=h(!1),[y,b]=h(0),[x,S]=h(null),C=l(()=>{m(!1),c(null),b(e=>e+1)},[]);u(()=>{let t=!1,r=n.listContentCollections([]).catch(()=>void 0);return Promise.all([n.listContent({ids:[e],limit:1}),r]).then(([n,r])=>{if(t)return;let a=n.items[0];a?(c(a),f(r?.items.find(e=>e.id===a.contentCollectionId)?.settings?.voteAccess===`portal`),i.emit(`contentOpen`,{contentId:e,contentCollectionId:a.contentCollectionId})):m(!0)}).catch(e=>{t||(Vl.warn(`listContent (reader) failed`,{err:e}),m(!0))}),()=>{t=!0}},[n,e,y,i]),u(()=>{if(!s)return;let t=setTimeout(()=>i.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[s,e,i]);let w=l(t=>{let n=(t.target instanceof HTMLElement?t.target.closest(`a`):null)?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&i.emit(`contentLinkClick`,{contentId:e})},[i,e]);function T(t){S(e),n.setContentVote({contentId:e,value:t})}function E(){return p?/* @__PURE__ */ _(zl,{tone:`error`,message:r.errorGeneric,onRetry:C,strings:r}):s===null?/* @__PURE__ */ _(zl,{message:r.contentLoading,strings:r}):/* @__PURE__ */ v(`article`,{class:`${Bl}-content`,"data-testid":J.contentView,onClick:w,children:[s.image?/* @__PURE__ */ _(`img`,{class:`${Bl}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ _(`p`,{class:`${Bl}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ _(Tl,{text:jl(s.content??``)}),d?/* @__PURE__ */ _(`div`,{class:`${Bl}-content-vote`,"aria-live":`polite`,children:x===e?r.feedbackThanks:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{children:r.contentHelpful}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Bl}-module-retry`,onClick:()=>T(1),children:r.confirmYes}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Bl}-module-retry`,onClick:()=>T(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ v(`div`,{class:`${Bl}-module`,children:[/* @__PURE__ */ _(Cl,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:J.backHeader}),/* @__PURE__ */ _(`div`,{class:`${Bl}-module-scroll`,"data-testid":J.contentScroll,children:E()})]})}function Ul({itemCount:e,initialFocusIndex:t}){let[n,r]=h(!1),i=m(null),a=m(null),[o,s]=h(-1),c=l(()=>{r(!1),s(-1),i.current?.focus()},[]),d=l(()=>r(e=>!e),[]);return u(()=>{if(!n)return;function e(e){let t=a.current,n=i.current;if(!t||!n)return;let o=e.composedPath();o.includes(t)||o.includes(n)||(r(!1),s(-1))}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),u(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),u(()=>{!n||o<0||(a.current?.querySelectorAll(`[role='menuitem']`))?.[o]?.focus()},[n,o]),{open:n,focusIndex:o,triggerRef:i,menuRef:a,toggle:d,close:c,onTriggerKey:l(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},[]),onMenuKey:l(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),t.stopPropagation(),c();return;case`ArrowDown`:t.preventDefault(),s(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),s(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),s(0);return;case`End`:t.preventDefault(),s(e-1)}},[e,c])}}function Wl({items:e,triggerLabel:t}){let n=P.cssPrefix,r=Ul({itemCount:e.length});function i(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function a(e,t){return e.onSelectValue?.(t)}function 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;let o=n[i];o&&(e.preventDefault(),e.stopPropagation(),a(t,o.value))}return/* @__PURE__ */ v(`div`,{class:`${n}-menu-wrap`,children:[/* @__PURE__ */ _(`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:/* @__PURE__ */ _(Cc,{})}),r.open?/* @__PURE__ */ _(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?/* @__PURE__ */ v(`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?/* @__PURE__ */ _(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${n}-menu-label`,children:e.label}),/* @__PURE__ */ _(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return/* @__PURE__ */ _(`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":`${J.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):/* @__PURE__ */ v(`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?/* @__PURE__ */ _(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?/* @__PURE__ */ _(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Dc,{})}):null]},e.id))}):null]})}const Gl=P.cssPrefix;function Kl(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 ql={normal:`large`,large:`small`,small:`normal`};function Jl(e){return _(e===`light`?qc:e===`dark`?Jc:Yc,{})}function Yl(e,t){let n=e.split(`-`)[0];return(t.some(t=>t!==e&&t.split(`-`)[0]===n)?e:n??e).toUpperCase()}function Xl(e,t){let n;try{n=new URL(e,window.location.href)}catch{return}if(n.protocol===`http:`||n.protocol===`https:`)return t.conversationId&&n.searchParams.set(`chat`,t.conversationId),n.searchParams.set(`widgetId`,t.widgetId),t.publicKey&&n.searchParams.set(`public_key`,t.publicKey),n.searchParams.set(`ai_agent_deployment_id`,t.aiAgentDeploymentId),n.href}function Zl({panelProps:e,variant:t,onEmailTranscript:n,onLogIn:r}){let{options:i,panelSize:a,feedback:o,onClose:c,onClear:l,onExpand:u,onFullscreen:d,onSoundToggle:f}=e,{onToggleHistory:p,onLocaleChange:m,onThemeChange:h,onTextSizeChange:g}=e,y=i.strings,b=i.mode,x=t===`chat`,S=s(()=>o.mutedSig.value).value,C=new Set(i.actions);function w(e){return C.has(e)}let T=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function E(e){return!T&&Ws(e,b,a)}let D=i.themeMode,O={auto:y.themeAuto,light:y.themeLight,dark:y.themeDark},k=i.textSize,A={small:y.textSizeSmall,normal:y.textSizeNormal,large:y.textSizeLarge},j=[];if(x&&w(`clear`)&&j.push({id:`clear`,icon:/* @__PURE__ */ _(jc,{}),label:y.newConversation,onSelect:l}),x&&n&&j.push({id:`emailTranscript`,icon:/* @__PURE__ */ _(Mc,{}),label:y.emailTranscript,onSelect:n}),x&&r&&j.push({id:`logIn`,icon:/* @__PURE__ */ _(gc,{}),label:y.loginAction,onSelect:r}),w(`expand`)&&E(`expand`)){let e=a===`expanded`;j.push({id:`expand`,icon:_(e?vc:_c,{}),label:e?y.collapse:y.expand,type:`switch`,on:e,onSelect:u})}if(w(`fullscreen`)&&E(`fullscreen`)){let e=a===`fullscreen`;j.push({id:`fullscreen`,icon:_(e?bc:yc,{}),label:e?y.exitFullscreen:y.fullscreen,type:`switch`,on:e,onSelect:d})}let ee=i.popOutUrl,M=i.aiAgentDeploymentId;w(`popOut`)&&ee&&M&&Ws(`popOut`,b,a)&&j.push({id:`popOut`,icon:/* @__PURE__ */ _(xc,{}),label:y.popOut,onSelect:()=>{let t=Xl(ee,{conversationId:e.conversationId,widgetId:i.widgetId,publicKey:i.publicKey,aiAgentDeploymentId:M});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),x&&w(`sound`)&&j.push({id:`sound`,icon:_(S?Tc:wc,{}),label:S?y.soundOff:y.soundOn,type:`switch`,on:!S,onSelect:f}),w(`theme`)&&D!==`host`&&j.push({id:`theme`,icon:Jl(D),label:`${y.theme}: ${O[D]}`,onSelect:()=>h(Kl(D)),keepOpen:!0}),w(`textSize`)&&j.push({id:`textSize`,icon:/* @__PURE__ */ _(Ec,{}),label:`${y.textSize}: ${A[k]}`,onSelect:()=>g(ql[k]),keepOpen:!0}),w(`language`)&&i.availableLocales.length>1&&j.push({id:`language`,icon:/* @__PURE__ */ _(kc,{}),label:y.language,segments:i.availableLocales.map(e=>({value:e,label:Yl(e,i.availableLocales),lang:e})),value:i.locale,onSelectValue:m});let N=!!c&&Gs(b,a,i.actions),P=x&&w(`history`);return/* @__PURE__ */ v(`div`,{class:`${Gl}-header-actions`,children:[P?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Gl}-icon-btn`,onClick:p,"aria-label":y.history,title:y.history,"data-testid":J.actionHistory,children:/* @__PURE__ */ _(Oc,{})}):null,j.length>0?/* @__PURE__ */ _(Wl,{items:j,triggerLabel:y.moreActions}):null,N?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Gl}-icon-btn`,onClick:c,"aria-label":y.close,title:y.close,"data-testid":J.actionClose,children:/* @__PURE__ */ _(sc,{})}):null]})}const Ql={Icon:Kc};function $l(e,t){return e instanceof is?e.status===429?e.retryAfterSeconds?t.errorRateLimitedIn.replace(`{seconds}`,String(e.retryAfterSeconds)):t.errorRateLimited:e.code===`network`?t.errorOffline:e.status===403?t.errorOriginNotAllowed:e.errorCode===`MESSAGE_TOO_LONG`?t.errorMessageTooLong:e.status!==void 0&&e.status>=500?t.errorServer:t.errorGeneric:t.errorGeneric}const eu=P.cssPrefix;function tu({placeholder:e,onActivate:t}){return/* @__PURE__ */ v(`button`,{type:`button`,class:`${eu}-home-search`,onClick:t,"data-testid":J.homeSearch,children:[/* @__PURE__ */ _(`span`,{class:`${eu}-home-search-text`,children:e}),/* @__PURE__ */ _(`span`,{class:`${eu}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Hc,{})})]})}function nu({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ v(`div`,{class:`${eu}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ _(`input`,{type:`search`,class:`${eu}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":J.helpSearch}),/* @__PURE__ */ _(`span`,{class:`${eu}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Hc,{})})]})}const ru=P.cssPrefix;function iu({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ v(`button`,{type:`button`,class:`${ru}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ v(`span`,{class:`${ru}-list-row-body`,children:[/* @__PURE__ */ _(`span`,{class:`${ru}-list-row-title`,children:e}),t?/* @__PURE__ */ _(`span`,{class:`${ru}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ _(`span`,{class:`${ru}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ _(fc,{})})]})}const au=P.cssPrefix,ou=V.scope(`help`);function su(e,t,n){let r=new Map(n.map(e=>[e.id,e.title]));return t.map(t=>({id:t,title:r.get(t),rows:e.filter(e=>e.contentCollectionId===t)})).filter(e=>e.rows.length>0)}function cu({transport:e,strings:t,bus:n},r,i){let[a,o]=h(),s=m(void 0),c=r?.join(`,`);function l(a){if(!r?.length)return;let c={};s.current=c,o(e=>({search:i,items:[],collections:[],...e,pagination:a>1?e?.pagination:void 0,loading:!0,error:void 0})),Promise.all([e.listContent({contentCollectionIds:r,sortBy:`order`,page:a,limit:20,search:i}),a>1?void 0:e.listContentCollections(r)]).then(([e,t])=>{s.current===c&&(o(n=>({search:i,items:[...a>1?n?.items??[]:[],...e.items],collections:t?.items??n?.collections??[],pagination:e.pagination,loading:!1})),a>1||(i?n.emit(`contentSearch`,{queryLength:i.length,hitCount:e.pagination.total}):n.emit(`contentView`,{section:`help`,count:e.items.length})))}).catch(e=>{s.current===c&&(ou.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:$l(e,t)}))})}return u(()=>{if(!r?.length)o(void 0);else return l(1),()=>{s.current=void 0}},[e,c,i]),[a,()=>!a?.loading&&l((a?.pagination?.page??0)+1)]}function lu(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=h(``),[c,l]=h(``),d=cu(e,a),f=cu(e,c?a:void 0,c),[p,m]=o.trim()?f:d;u(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function y(){if(!a?.length)return/* @__PURE__ */ _(zl,{message:t.helpEmpty,strings:t});let e=p?.error?/* @__PURE__ */ _(zl,{tone:`error`,message:p.error,onRetry:m,strings:t}):null;return e&&!p?.pagination?e:!p||!p.pagination&&!p.items.length?/* @__PURE__ */ _(zl,{message:t.helpLoading,strings:t}):p.items.length?/* @__PURE__ */ v(g,{children:[su(p.items,a,p.collections).map(e=>/* @__PURE__ */ v(`section`,{class:`${au}-help-group`,children:[e.title?/* @__PURE__ */ _(`h2`,{class:`${au}-help-section-title`,children:e.title}):null,/* @__PURE__ */ _(`div`,{class:`${au}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ _(iu,{title:e.title,subtitle:e.description,onClick:()=>e.url?ec(e.url):r.push({kind:`content`,id:e.id,title:e.title}),testid:ul(J.helpArticle,e.id)},e.id))})]},e.id)),e,p.pagination?.hasNext&&!e?/* @__PURE__ */ _(`div`,{children:/* @__PURE__ */ _(`div`,{class:`${au}-help-card`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${au}-list-row ${au}-help-more`,onClick:m,"aria-busy":p.loading,children:[p.loading?/* @__PURE__ */ _(`span`,{class:`${au}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ _(zl,{message:p.search?t.helpSearchEmpty.replace(`{query}`,p.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ v(`div`,{class:`${au}-module`,children:[/* @__PURE__ */ _(Sl,{title:t.helpTitle,actions:/* @__PURE__ */ _(Zl,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ _(`div`,{class:`${au}-module-pad`,children:/* @__PURE__ */ _(nu,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ _(`div`,{class:`${au}-help-list`,children:y()})]})}const uu={Icon:Lc,Root:e=>/* @__PURE__ */ _(lu,{...e})},du=V.scope(`attachments`);function fu(e,t,n){let r=_u(e),i=[],a=[],o=Su(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=gu(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(xu(e)),s+=e.size,c+=1)}return(i.length||a.length)&&du.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function pu(e){let t=Math.min(Math.floor(Math.log10(Math.max(e,1))/3),2);return new Intl.NumberFormat(void 0,{style:`unit`,unit:[`byte`,`kilobyte`,`megabyte`][t],unitDisplay:`narrow`,maximumFractionDigits:1}).format(e/1e3**t)}function mu(e,t){let n=Su(t);return!e||n.length===0||n.some(t=>t.kind===`ext`||Cu(new File([],``,{type:e}),[t]))}function hu(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){du.debug(`revokeObjectURL failed`,{error:e})}}function gu(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:Cu(e,i)?null:`mime`}function _u(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:vu(e)).filter(e=>e!==null):[]}function vu(e){let t=yu(e)?e:null;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function yu(e){return bu(e)&&(e.getAsFile===void 0||typeof e.getAsFile==`function`)}function bu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xu(e){return{file:e,id:$t(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function Su(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 Cu(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===`image`&&e.subtype===`*`&&/\.(heic|heif|avif|bmp|tif|tiff)$/.test(i)?!0:(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const wu=P.cssPrefix,Tu={error:cl,done:Dc};function Eu({attachment:e,upload:t,strings:n,onRemove:r,disabled:i=!1}){let a=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType),o=Math.round((t?.fraction??0)*100),s=pu(e.size),c=t?.status===`error`||t?.status===`done`?Tu[t.status]:void 0;return/* @__PURE__ */ v(`span`,{class:`${wu}-attachment-chip`,"data-upload":t?.status,title:e.name,"data-testid":ul(J.attachmentChip,e.id),children:[a?/* @__PURE__ */ _(`img`,{class:`${wu}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ _(`span`,{class:`${wu}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Pc,{})}),/* @__PURE__ */ v(`span`,{class:`${wu}-attachment-text`,children:[/* @__PURE__ */ _(`span`,{class:`${wu}-attachment-name`,children:e.name}),/* @__PURE__ */ v(`span`,{class:`${wu}-attachment-meta`,children:[c?/* @__PURE__ */ _(c,{}):null,t?.status===`uploading`?`${o}% · ${s}`:s]})]}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${wu}-attachment-remove`,onClick:r,disabled:i,"aria-label":n.removeAttachment.replace(`{name}`,e.name),"data-testid":ul(J.attachmentRemove,e.id),children:/* @__PURE__ */ _(sc,{})}),t?.status===`uploading`?/* @__PURE__ */ _(`span`,{class:`${wu}-attachment-progress`,role:`progressbar`,"aria-label":e.name,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:/* @__PURE__ */ _(`span`,{style:{width:`${o}%`}})}):null]})}const Du=/* @__PURE__ */ new WeakMap;function Ou(e){e.currentTarget&&Du.set(e.currentTarget,e.timeStamp)}function ku(e){let t=e.currentTarget?Du.get(e.currentTarget):void 0;return e.isComposing||t!==void 0&&e.timeStamp-t<100}const Au=P.cssPrefix;function ju({text:e,retryLabel:t,onRetry:n,retryTestId:r}){return/* @__PURE__ */ v(`div`,{class:`${Au}-error`,role:`alert`,children:[/* @__PURE__ */ _(`span`,{class:`${Au}-error-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(cl,{})}),/* @__PURE__ */ _(`span`,{class:`${Au}-error-text`,children:e}),n&&t?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Au}-error-retry`,onClick:n,"data-testid":r,children:t}):null]})}const Mu={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function Nu(e,t,n){return e===`disabled`?Mu:e===`server`?Lu(n):Pu(t)}function Pu(e){let t=Fu();if(!t)return Mu;let n=null,r=0;return{isSupported:!0,start(i,a){let o=n,s=++r;n=null,o?.abort();let c=new t;n=c,c.continuous=!0,c.interimResults=!0,c.lang=e;let l=!1;c.addEventListener(`result`,e=>{if(r!==s||n!==c)return;let t=e,a=``,o=!1;for(let e=t.resultIndex;e<t.results.length;e++){let n=t.results[e];n&&(a+=n[0].transcript,n.isFinal&&(o=!0))}i(a,o)});function u(e){l||r!==s||n!==c||(l=!0,n=null,a(e))}c.addEventListener(`end`,()=>u(!1)),c.addEventListener(`error`,e=>u(`error`in e&&(e.error===`not-allowed`||e.error===`service-not-allowed`)));try{c.start()}catch{u(!1)}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function Fu(){return window.SpeechRecognition??window.webkitSpeechRecognition}const Iu=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Lu(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return Mu;let t=0,n=null;function r(e){for(let t of e.stream?.getTracks()??[])t.stop();e.stream=null}function i(){t++;let e=n;n=null,e&&(r(e),e.recorder?.state!==`inactive`&&e.recorder?.stop())}async function a(i){if(i.finishing)return;i.finishing=!0;let a=i.recorder?.mimeType??`audio/webm`;r(i);let o=new Blob(i.chunks,{type:a});i.chunks=[];try{let{text:r}=await e(o,a);n===i&&t===i.generation&&r&&i.onText(r,!0)}catch{}finally{n===i&&t===i.generation&&(n=null,i.onEnd(!1))}}return{isSupported:!0,async start(e,o){i();let s={generation:t,recorder:null,stream:null,chunks:[],onText:e,onEnd:o,finishing:!1};n=s;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(n!==s||t!==s.generation){for(let t of e.getTracks())t.stop();return}s.stream=e;let r=Ru(),i=new MediaRecorder(e,r?{mimeType:r}:void 0);s.recorder=i,i.addEventListener(`dataavailable`,e=>{n===s&&t===s.generation&&e.data.size>0&&s.chunks.push(e.data)}),i.addEventListener(`stop`,()=>{n===s&&t===s.generation&&a(s)}),i.start()}catch(e){r(s),n===s&&t===s.generation&&(n=null,o(e instanceof DOMException&&e.name===`NotAllowedError`))}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function Ru(){for(let e of Iu)if(MediaRecorder.isTypeSupported(e))return e}function zu(e,{file:t,reason:n},r){return n===`count`?e.attachmentTooMany.replace(`{count}`,String(r.maxCount)):n===`bytes`?e.attachmentTooLarge.replace(`{name}`,t.name).replace(`{max}`,pu(r.maxBytes)):e.attachmentMimeRejected.replace(`{name}`,t.name)}const Y=P.cssPrefix,Bu=V.scope(`composer`);function Vu(e){return e.reduce((e,t)=>e+t.size,0)}const Hu={arrowUp:uc,paperPlane:lc,send:dc,chevron:fc};function Uu(e){return`activeElement`in e}function Wu(e){return`host`in e&&`activeElement`in e}function Gu(e){return`clipboardData`in e}function Ku({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,maxMessageCharacters:o,isStreaming:s,pageToolRunning:c=!1,isMemoryCompacting:d=!1,canReleaseQueuedMessages:p=!0,queueManualMessages:g=!1,replyAwaitsCard:y=!1,active:b=!0,isPreparing:x=!1,attachmentUploadsSig:S,operatorRequestEnabled:C,canRequestOperator:w=!1,controlMode:T=`ai-agent`,onRequestOperator:E,onSend:D,onStop:O,apiRef:k}){let A=e.strings,[j,ee]=h(()=>i.loadDraft(a)),[M,N]=h([]),[P,te]=h(),[ne,re]=h(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),F=m(ne),ie=m(!1),ae=m(void 0),[I,oe]=h(!1),[se,ce]=h(!1),[le,ue]=h(!1),[L,de]=h(!1),R=m(!1),fe=m(null),z=m(null),pe=m(null),me=m(0),he=m(a);he.current=a;let B=m(b);B.current=b;let ge=m(x);ge.current=x;let _e=L||x||!b,ve=s&&T===`ai-agent`,ye=ve||d&&T===`ai-agent`,be=T===`ai-agent`&&(ye||g||ne.length>0),xe=l(e=>{re(t=>{let n=e(t);return i.saveMessageQueue(he.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),F.current=n,n})},[i]),Se=l(e=>{xe(t=>(t.find(t=>t.id===e)?.attachments.forEach(hu),t.filter(t=>t.id!==e)))},[xe]),Ce=l(e=>{ee(t=>{let n=(typeof e==`function`?e(t):e).slice(0,o);return n===t?t:(i.saveDraft(he.current,n),n)})},[i,o]),we=e.features.fileUpload,Te=e.features.voice,[Ee,De]=h(()=>Nu(Te,e.locale,(e,n)=>t.transcribe(e,n))),Oe=m(Ee);Oe.current=Ee;let ke=m({mode:Te,locale:e.locale,transport:t});u(()=>{let n=ke.current;(n.mode!==Te||n.locale!==e.locale||n.transport!==t)&&(ke.current={mode:Te,locale:e.locale,transport:t},me.current++,Oe.current.cancel(),pe.current=null,ce(!1),De(Nu(Te,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,Te,t]),f(()=>()=>{me.current++,Ee.cancel()},[Ee]);let Ae=l(e=>{let t=pe.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return Bu[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),pe.current=null,!0},[r]),je=l(()=>{pe.current!==null&&(Ee.stop(),ce(!1),Ae(`info`)&&n.play(`voiceStop`))},[Ae,n,Ee]),Me=l(()=>{me.current++,Ee.cancel(),ce(!1),Ae(`info`)&&n.play(`voiceStop`)},[Ae,n,Ee]);u(()=>{(x||!b)&&Me()},[b,Me,x]),u(()=>{let e=fe.current;if(!e)return;let t=e.getRootNode(),n=Uu(t)?t.activeElement:null;n&&e.closest(`.${Y}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),u(()=>{let e=fe.current;if(!e)return;if(j.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${Y}-textarea-base-height`)),r=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth),i=Math.min(e.scrollHeight+r,Number.parseFloat(t.maxHeight)),a=Number.parseFloat(t.fontSize)*.7;e.style.height=`${i<n+a?n:i}px`},[j]);let Ne=m(M);Ne.current=M,u(()=>()=>{Ne.current.forEach(hu);for(let e of F.current)e.attachments.forEach(hu)},[]),f(()=>{if(k)return k.current={attachFromDrop:t=>{if(!we||!B.current||R.current||ge.current)return;let n=fu(t,Ne.current,e.attachments);te(n.rejected[0]),n.accepted.length!==0&&(Bu.info(`attach (drop)`,{count:n.accepted.length,totalBytes:Vu(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:Vu(n.accepted)}),N(e=>[...e,...n.accepted]))},fill:e=>{if(!B.current||R.current||ge.current)return;Ce(e);let t=fe.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:Se},()=>{k.current&&(k.current=null)}},[k,we,x,e.attachments,Se,Ce]),u(()=>{let t=fe.current;if(!t)return;let n=t.closest(`.${Y}-panel`);if(!n)return;let i=n=>{if(!B.current||R.current||ge.current)return;let i=n.clipboardData;if(!i)return;let a=n.target instanceof HTMLElement?n.target.closest(`input, textarea, [contenteditable]:not([contenteditable='false'])`):null;if(a&&a!==t)return;if(we){let t=fu(i.items,Ne.current,e.attachments);if(te(t.rejected[0]),t.accepted.length>0){n.preventDefault(),Bu.info(`attach (paste)`,{count:t.accepted.length,totalBytes:Vu(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:Vu(t.accepted)}),N(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),Ce(e=>e+o),t.focus())};function a(e){Gu(e)&&i(e)}return n.addEventListener(`paste`,a),()=>n.removeEventListener(`paste`,a)},[we,e.attachments,Ce]);async function Pe(){let e=j.trim();if(!e&&M.length===0||!b||ve||R.current||x)return;Me(),R.current=!0,de(!0);let t=j,n=M;try{await D(e,n)&&(te(void 0),Ce(e=>e===t?``:e),N(e=>e===n?(n.forEach(hu),Ne.current=[],[]):e))}finally{R.current=!1,de(!1),requestAnimationFrame(()=>{let e=fe.current;if(!e||e.disabled||!B.current)return;let t=e.getRootNode(),n=Uu(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==J.composerSend&&r!==J.composerStop)){if(Wu(t)){let e=t.host.ownerDocument;if(!e.hasFocus())return;let n=e.activeElement;if(n&&n!==t.host&&n!==e.body)return}e.focus({preventScroll:!0})}})}}function Fe(){let e=j.trim();if(!e&&M.length===0||!b||!be||R.current||x)return;Me();let t=M;xe(n=>[...n,{id:$t(),text:e,attachments:t}]),ye||oe(!0),Ce(``),N(e=>e===t?(Ne.current=[],[]):e),fe.current?.focus({preventScroll:!0})}u(()=>{ye&&(ie.current=!1,ae.current=void 0,oe(!1))},[ye]),u(()=>{let t=ne[0];if(!t||!p||ye||ie.current||L||x||!b)return;let n=y&&!I?(ae.current??(ae.current=performance.now()+e.cardAnswerWaitSeconds*1e3))-performance.now():0,r=setTimeout(()=>{ie.current=!0,D(t.text,t.attachments,t.id).then(e=>{e?Se(t.id):ie.current=!1})},Math.max(n,300));return()=>clearTimeout(r)},[b,p,I,x,D,e.cardAnswerWaitSeconds,ye,ne,Se,y,L]);function Ie(e){e.key!==`Enter`||e.shiftKey||ku(e)||(e.preventDefault(),be&&(j.trim()||M.length>0)?Fe():ve?O():Pe())}function Le(t){if(!(t.target instanceof HTMLInputElement))return;let n=t.target;if(!b||R.current||x){n.value=``;return}let i=fu(n.files,M,e.attachments);te(i.rejected[0]),i.accepted.length>0&&(Bu.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:Vu(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:Vu(i.accepted)}),N(e=>[...e,...i.accepted])),n.value=``}function Re(e){!b||R.current||x||(Bu.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),te(void 0),N(t=>{let n=t.find(t=>t.id===e);return n&&hu(n),t.filter(t=>t.id!==e)}))}function ze(){if(se){je();return}if(!b||!Ee.isSupported||R.current||x)return;let e=++me.current;pe.current=performance.now(),Bu.info(`voiceStart`),r.emit(`voiceStart`,void 0),ue(!1),ce(!0),n.play(`voiceStart`),Ee.start((t,n)=>{me.current===e&&B.current&&!ge.current&&!R.current&&n&&Ce(e=>`${e}${t} `)},t=>{me.current===e&&B.current&&(ce(!1),ue(t),Ae(`debug`))})}let Be=Hu[e.composer.sendButton.icon],Ve=!!(j.trim()||M.length>0),He=S?.value,Ue=M.some(e=>He?.get(e.id)?.status===`uploading`),We=M.filter(e=>He?.get(e.id)?.status===`error`),Ge=We.find(e=>He?.get(e.id)?.refusal),Ke=Ge&&(He?.get(Ge.id)?.refusal===`INVALID_FILE_TYPE`?A.attachmentMimeRejected:A.attachmentUploadFailed).replace(`{name}`,Ge.name),qe=ve||Ue||c&&!Ve;return/* @__PURE__ */ v(`div`,{class:`${Y}-composer`,part:`composer`,"data-testid":J.composer,children:[ne.length>0?/* @__PURE__ */ _(`div`,{class:`${Y}-message-queue`,"aria-label":A.queueMessage,"data-testid":J.messageQueue,children:ne.map(e=>/* @__PURE__ */ v(`div`,{class:`${Y}-attachment-chip ${Y}-queued-message`,"data-testid":`${J.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-attachment-name ${Y}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-attachment-remove`,onClick:()=>Se(e.id),"aria-label":A.removeQueuedMessage,title:A.removeQueuedMessage,"data-testid":`${J.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ _(sc,{})})]},e.id))}):null,M.length>0?/* @__PURE__ */ _(`div`,{class:`${Y}-attachments`,children:M.map(e=>/* @__PURE__ */ _(Eu,{attachment:e,upload:He?.get(e.id),strings:A,onRemove:()=>Re(e.id),disabled:_e},e.id))}):null,We.length>0&&!_e?/* @__PURE__ */ _(ju,{text:Ke??A.attachmentUploadFailed.replace(`{name}`,We.map(e=>e.name).join(`, `)),retryLabel:A.errorRetry,onRetry:Ge?void 0:()=>void Pe(),retryTestId:J.attachmentRetry}):null,P?/* @__PURE__ */ _(`p`,{class:`${Y}-field-error`,role:`alert`,children:zu(A,P,e.attachments)}):null,le?/* @__PURE__ */ _(`p`,{class:`${Y}-field-error`,role:`alert`,children:A.micBlocked}):null,o!==void 0&&j.length>=o*.9?/* @__PURE__ */ _(`p`,{class:`${Y}-field-${j.length<o?`hint`:`error`}`,"data-testid":J.composerCount,children:`${j.length} / ${o}`}):null,/* @__PURE__ */ v(`div`,{class:`${Y}-composer-row`,children:[/* @__PURE__ */ v(`div`,{class:`${Y}-composer-actions`,children:[we?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-icon-btn`,onClick:()=>z.current?.click(),disabled:_e,"aria-label":A.attach,title:A.attach,"data-testid":J.composerAttach,children:/* @__PURE__ */ _(mc,{})}):null,Ee.isSupported?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-icon-btn`,onClick:ze,disabled:_e,"aria-label":se?A.micStop:A.micStart,title:se?A.micStop:A.micStart,"aria-pressed":se,"data-recording":se?`true`:void 0,"data-testid":J.composerVoice,children:/* @__PURE__ */ _(hc,{})}):null,C&&T===`ai-agent`&&E?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-icon-btn`,onClick:E,disabled:_e||!w,"aria-label":A.talkToOperator,title:A.talkToOperator,"data-testid":J.operatorRequest,children:/* @__PURE__ */ _(gc,{})}):null]}),/* @__PURE__ */ _(`textarea`,{ref:fe,name:`message`,class:`${Y}-textarea`,rows:1,value:j,maxLength:o,placeholder:A.composerPlaceholder,onInput:e=>Ce(e.currentTarget.value),onKeyDown:Ie,onCompositionEnd:Ou,disabled:_e,"aria-label":A.composerPlaceholder,"data-testid":J.composerInput}),be&&Ve?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Fe,disabled:_e,"aria-label":A.queueMessage,title:A.queueMessage,"data-testid":J.composerSend,children:/* @__PURE__ */ _(Be,{})}):null,qe?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-send`,onClick:O,disabled:_e&&!Ue,"aria-label":A.stop,"data-testid":J.composerStop,children:/* @__PURE__ */ _(pc,{})}):null,!qe&&(!be||!Ve)?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Y}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void Pe(),disabled:_e||!j.trim()&&M.length===0,"aria-label":A.send,"data-testid":J.composerSend,children:/* @__PURE__ */ _(Be,{})}):null]}),/* @__PURE__ */ _(`input`,{ref:z,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:Le,disabled:_e,class:`${Y}-sr-only`,"data-testid":J.composerFileInput})]})}const qu=P.cssPrefix;function Ju({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ _(`button`,{type:`button`,class:`${qu}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ _(`div`,{class:`${qu}-home-card`,"data-testid":n,children:t})}function Yu(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const Xu=P.cssPrefix,Zu=V.scope(`news`);function Qu(e,t){let n=e?new Date(e):void 0;if(n&&!Number.isNaN(n.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`}).format(n)}function $u({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,l=c?.join(`,`),[d,f]=h({items:[],loading:!0}),p=m(void 0);function g(e){if(!c?.length)return;let r={};p.current=r,f(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(p.current!==r||(f(n=>({items:e>1?[...n.items,...t.items]:t.items,pagination:t.pagination,loading:!1})),e>1))return;a.emit(`contentView`,{section:`news`,count:t.items.length});let n=t.items[0];n&&s.markSeen(n.id)}).catch(t=>{p.current===r&&(Zu.warn(`listContent (news) failed`,{err:t,page:e}),f(e=>({...e,loading:!1,error:$l(t,n)})))})}function y(){d.loading||g((d.pagination?.page??0)+1)}u(()=>(f({items:[],loading:!0}),g(1),()=>{p.current=void 0}),[t,l]);function b(t){let n=Qu(t.publishedAt,e.locale);return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Xu}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":ul(J.newsItem,t.id),children:[t.image?/* @__PURE__ */ _(`img`,{class:`${Xu}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ v(`span`,{class:`${Xu}-news-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Xu}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ v(`span`,{class:`${Xu}-news-meta`,children:[n?/* @__PURE__ */ _(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ _(`span`,{class:`${Xu}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ _(`span`,{class:`${Xu}-news-summary`,children:t.description}):null]})]},t.id)}function x(){if(!c?.length)return/* @__PURE__ */ _(zl,{message:n.newsEmpty,strings:n});let e=d.error?/* @__PURE__ */ _(zl,{tone:`error`,message:d.error,onRetry:y,strings:n}):null;return e&&!d.pagination?e:d.pagination?d.items.length?/* @__PURE__ */ v(`div`,{class:`${Xu}-news-list`,children:[d.items.map(b),e,d.pagination.hasNext&&!e?/* @__PURE__ */ v(`button`,{type:`button`,class:`${Xu}-news-more`,onClick:y,"aria-busy":d.loading,"data-testid":J.newsMore,children:[d.loading?/* @__PURE__ */ _(`span`,{class:`${Xu}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ _(zl,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ _(zl,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ v(`div`,{class:`${Xu}-module`,children:[/* @__PURE__ */ _(Sl,{title:n.newsTitle,actions:/* @__PURE__ */ _(Zl,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ _(`div`,{class:`${Xu}-module-scroll`,children:x()})]})}const ed={Icon:Gc,Root:e=>/* @__PURE__ */ _($u,{...e})},X=P.cssPrefix,td=V.scope(`home`);function nd(e){let t=e.options.userContext?.name,n=e.config.greetingText?M(e.strings,e.config.greetingText):void 0;if(n){let r=t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),i=e.strings.homeGreetingLead;return{title:r,subtitle:r.toLowerCase()===i.toLowerCase()?void 0:i}}return t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}function rd(e,t){return t.url?ec(t.url):e.push({kind:`content`,id:t.id,title:t.title})}function id({options:e,onAsk:t}){let[n,r]=h(``),{sendButton:i}=e.composer,a=Hu[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ v(`form`,{class:`${X}-home-search ${X}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":J.homeAsk,children:[/* @__PURE__ */ _(`input`,{type:`text`,class:`${X}-home-search-input`,placeholder:e.strings.homeAskPlaceholder,"aria-label":e.strings.homeAskPlaceholder,value:n,enterKeyHint:`send`,onInput:e=>r(e.currentTarget.value)}),/* @__PURE__ */ _(`button`,{type:`submit`,class:`${X}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ _(a,{})})]})}function ad(e,t){return xs(e,t,t.type!==`upsert`||t.activity===!0)}function od(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=h(null),[d,f]=h([]),p=r.contentCollectionIds?.join(`,`),m=e.options.modules.list.some(e=>e.layout===`chat`);u(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>ad(t?[t]:[],e)[0]??null)});return t.listConversations({limit:m?50:1}).then(t=>{if(e)return;let r=i.reduce(ad,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,td.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,m]),u(()=>{if(!r.contentCollectionIds?.length)return;let e=!1;return t.listContent({contentCollectionIds:r.contentCollectionIds,pinned:!0,limit:6}).then(t=>{e||(f(t.items),a.emit(`contentView`,{section:`home`,count:t.items.length}))}).catch(t=>!e&&td.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,p,a]);let y=nd(e),b=r.userAvatars??[],x=r.status,S=x?.text?M(n,x.text):n.homeStatus,C=x?.url,w=r.contentBlockTitle?M(n,r.contentBlockTitle):n.homeContentTitle,T=s.item,E=Qu(T?.publishedAt,e.options.locale);return/* @__PURE__ */ _(`div`,{class:`${X}-module ${X}-home`,"data-testid":J.homeView,children:/* @__PURE__ */ v(`div`,{class:`${X}-home-scroll`,children:[/* @__PURE__ */ v(`div`,{class:`${X}-home-hero`,children:[/* @__PURE__ */ v(`div`,{class:`${X}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ _(`span`,{class:`${X}-home-brand`,"data-testid":J.homeBrand,children:r.brandName}):/* @__PURE__ */ _(`span`,{class:`${X}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ v(`div`,{class:`${X}-home-hero-actions`,children:[b.length>0?/* @__PURE__ */ _(`div`,{class:`${X}-home-avatars`,children:b.map(e=>/* @__PURE__ */ _(`span`,{class:`${X}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?/* @__PURE__ */ _(`img`,{src:e.avatar,alt:``,loading:`lazy`}):/* @__PURE__ */ _(`span`,{children:Yu(e.name)})},e.name))}):null,/* @__PURE__ */ _(Zl,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`h1`,{class:`${X}-home-greeting`,"data-testid":J.homeGreeting,children:y.title}),y.subtitle?/* @__PURE__ */ _(`p`,{class:`${X}-home-lead`,children:y.subtitle}):null]})]}),/* @__PURE__ */ v(`div`,{class:`${X}-home-cards`,children:[m?/* @__PURE__ */ _(id,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ _(tu,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),T?/* @__PURE__ */ _(Ju,{onClick:()=>{s.markSeen(T.id),i.push({kind:`content`,id:T.id,title:T.title})},testid:J.homeWhatsNew,children:/* @__PURE__ */ v(`div`,{class:`${X}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Gc,{})}),/* @__PURE__ */ v(`span`,{class:`${X}-home-recent-body`,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-preview`,children:E?`${T.title} · ${E}`:T.title})]}),s.unseen?/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ _(Ju,{onClick:()=>i.selectConversation(c),testid:J.homeRecent,children:/* @__PURE__ */ v(`div`,{class:`${X}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Kc,{})}),/* @__PURE__ */ v(`span`,{class:`${X}-home-recent-body`,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-preview`,children:Ll(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ _(`span`,{class:`${X}-home-recent-dot`,role:`img`,"aria-label":n.unread}):null]})}):null,x?/* @__PURE__ */ _(Ju,{onClick:C?()=>ec(C):void 0,children:/* @__PURE__ */ v(`div`,{class:`${X}-home-status`,"data-level":x.level??`operational`,children:[/* @__PURE__ */ _(`span`,{class:`${X}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Uc,{})}),/* @__PURE__ */ _(`span`,{class:`${X}-home-status-text`,children:S})]})}):null,d.length>0?/* @__PURE__ */ v(`section`,{class:`${X}-home-content`,children:[/* @__PURE__ */ _(`div`,{class:`${X}-home-content-title`,children:w}),/* @__PURE__ */ _(`div`,{class:`${X}-home-content-list`,children:d.map(e=>/* @__PURE__ */ _(iu,{title:e.title,subtitle:e.description,onClick:()=>rd(i,e),testid:ul(J.homeContentRow,e.id)},e.id))})]}):null]})]})})}const sd={chat:Ql,home:{Icon:Wc,Root:e=>/* @__PURE__ */ _(od,{...e})},help:uu,news:ed},cd=P.cssPrefix;function ld({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ _(`nav`,{class:`${cd}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=sd[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ v(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${cd}-tab`,onClick:()=>i(e.id),"data-testid":ul(J.tab,e.id),children:[/* @__PURE__ */ v(`span`,{class:`${cd}-tab-icon`,children:[/* @__PURE__ */ _(a,{}),s?/* @__PURE__ */ _(`span`,{class:`${cd}-tab-badge`,"data-testid":J.tabBadge,role:`img`,"aria-label":n.unread}):null]}),/* @__PURE__ */ _(`span`,{class:`${cd}-tab-label`,children:M(n,e.label)})]},e.id)})})}const ud=P.cssPrefix;function dd({agent:e,strings:t,ticketReference:n,person:r=!1}){let i=e.status??`online`,a=M(t,e.name),o=e.title?M(t,e.title):null,s=r?/* @__PURE__ */ _(gc,{}):/* @__PURE__ */ _(`span`,{children:Yu(a)});return/* @__PURE__ */ v(`div`,{class:`${ud}-agent`,children:[/* @__PURE__ */ _(`div`,{class:`${ud}-agent-avatar`,"data-status":i,children:e.avatar?/* @__PURE__ */ _(`img`,{src:e.avatar,alt:``}):s}),/* @__PURE__ */ v(`div`,{class:`${ud}-agent-meta`,children:[/* @__PURE__ */ _(`strong`,{children:a}),o||n?/* @__PURE__ */ v(`div`,{class:`${ud}-agent-sub`,children:[n?/* @__PURE__ */ _(fd,{reference:n,strings:t}):null,o?/* @__PURE__ */ _(`span`,{children:o}):null]}):null]})]})}function fd({reference:e,strings:t}){let[n,r]=h(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}return/* @__PURE__ */ _(`button`,{type:`button`,class:`${ud}-agent-ticket`,onClick:i,title:t.copy,"aria-label":n?t.copied:t.copyTicketReference.replace(`{reference}`,e),children:n?t.copied:e})}const pd=[`today`,`yesterday`,`lastWeek`,`older`];function md(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.round((gd(e)-gd(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function hd(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=md(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return pd.flatMap(e=>{let t=n.get(e);return t?[{bucket:e,conversations:t}]:[]})}function gd(e){return new Date(e).setHours(0,0,0,0)}const _d=V.scope(`history`),vd={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function yd(e,t){let n=t.type!==`upsert`||t.activity===!0;if(t.type===`snapshot`&&t.result.pagination.page===1&&e.pagination.page>1){let r=xs(e.conversations.slice(0,t.result.pagination.limit),t,n);if(t.result.conversations.length===0){if(r.length===0)return t.result;let e=Math.max(t.result.pagination.total,r.length);return{...t.result,conversations:r,pagination:{...t.result.pagination,total:e,totalPages:Math.ceil(e/t.result.pagination.limit)}}}let i=new Set(r.map(e=>e.conversationId)),a=e.conversations.slice(t.result.pagination.limit).filter(e=>!i.has(e.conversationId)),o=e.pagination.page,s={...t.result.pagination,page:o,hasPrev:o>1,hasNext:o<t.result.pagination.totalPages};return{conversations:[...r,...a],pagination:s}}let r=xs(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function bd(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<6048e5?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function xd({transport:e,strings:t,locale:n,persistence:r,onSelect:i,onNewConversation:a}){let o=P.cssPrefix,s=e.peekConversations({limit:50}),[c,l]=h(s?`loaded`:`loading`),[d,f]=h(0),[p,y]=h(s),[b,x]=h(!1),S=m(void 0),C=p?.conversations??[],w=p?.pagination;u(()=>{let n=!1,i=!0,a=[],o=e.subscribeConversationChanges(e=>{i&&a.push(e),y(t=>t&&yd(t,e))});S.current=void 0,x(!1);let s=e.peekConversations({limit:50});return y(s),l(s?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(n)return;let t=e;for(let e of a)t=yd(t,e);a=[],i=!1,y(t),l(`loaded`),r.saveHistoryCount(t.conversations.length)}).catch(e=>{n||(a=[],i=!1,_d.warn(`listConversations failed`,{err:e}),l({failure:$l(e,t)}))}),()=>{n=!0,o(),S.current=void 0}},[e,r,n,d]);async function T(){if(S.current||!w?.hasNext)return;let t={};S.current=t,x(!0);try{let n=await e.listConversations({page:w.page+1,limit:w.limit});if(S.current!==t)return;y(e=>{if(!e)return e;let t=new Set(e.conversations.map(e=>e.conversationId)),i=n.conversations.filter(e=>!t.has(e.conversationId)&&(t.add(e.conversationId),!0)),a={conversations:[...e.conversations,...i],pagination:n.pagination};return r.saveHistoryCount(a.conversations.length),a})}catch(e){if(S.current!==t)return;_d.warn(`listConversations page failed`,{err:e,page:w.page+1})}finally{S.current===t&&(S.current=void 0,x(!1))}}let E=a?/* @__PURE__ */ _(`div`,{class:`${o}-history-footer`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${o}-history-new`,onClick:a,"data-testid":J.sidebarNewConversation,children:[/* @__PURE__ */ _(cc,{}),t.newConversation]})}):null;if(c===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`div`,{class:`${o}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ v(`div`,{class:`${o}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-heading`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-heading`})}),/* @__PURE__ */ _(`div`,{class:`${o}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ v(`div`,{class:`${o}-history-item ${o}-history-item-skeleton`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-avatar ${o}-skeleton`}),/* @__PURE__ */ v(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-title`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-title`})}),/* @__PURE__ */ _(`span`,{class:`${o}-history-time`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-time`})})]}),/* @__PURE__ */ _(`span`,{class:`${o}-history-row`,children:/* @__PURE__ */ _(`span`,{class:`${o}-history-preview`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-preview`})})})]})]},t))})]})}),E]})}if(typeof c==`object`)return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(zl,{tone:`error`,message:c.failure,onRetry:()=>f(e=>e+1),strings:t}),E]});if(C.length===0)return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-empty`,children:t.historyEmpty}),E]});let D=Date.now(),O=hd(D,C);return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`div`,{class:`${o}-history`,role:`list`,children:[O.map(e=>/* @__PURE__ */ v(`div`,{class:`${o}-history-group`,children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-heading`,children:t[vd[e.bucket]]}),/* @__PURE__ */ _(`div`,{class:`${o}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ _(`div`,{role:`listitem`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${o}-history-item`,onClick:()=>i(e),"data-unread":e.hasUnread?`true`:void 0,"data-testid":ul(J.historyItem,e.conversationId),children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Ic,{})}),/* @__PURE__ */ v(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-title`,children:e.title}),/* @__PURE__ */ v(`span`,{class:`${o}-history-time`,children:[e.ticketReference&&`${e.ticketReference} · `,bd(e.lastMessageAt,D,n)]})]}),/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-preview`,children:e.preview&&Ll(e.preview)||t.historyContinue}),e.hasUnread?/* @__PURE__ */ _(`span`,{class:`${o}-history-dot`,role:`img`,"aria-label":t.unread}):null]})]})]})},e.conversationId))})]},e.bucket)),w?.hasNext?/* @__PURE__ */ _(`div`,{class:`${o}-history-more`,children:/* @__PURE__ */ _(`button`,{type:`button`,onClick:T,disabled:b,"aria-busy":b,"data-testid":J.historyLoadMore,children:t.loadMoreConversations})}):null]}),E]})}const Sd=P.cssPrefix;function Cd({state:e,strings:t}){return e?/* @__PURE__ */ v(`div`,{class:`${Sd}-dropzone`,"data-state":e,role:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ _(`span`,{class:`${Sd}-dropzone-icon`,"aria-hidden":`true`,children:_(e===`reject`?cl:mc,{})}),e===`reject`?t.dropZoneRejected:t.dropZone]}):null}const wd=new RegExp(String.raw`^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$`),Td=/^[+]?[\d\s().-]{6,}$/;function Ed(e,t,n){let r=Array.isArray(t)?t.join(``):t?.trim()??``;if(!r)return e.required?n.formRequired:void 0;if(e.type===`email`&&!wd.test(r))return n.formInvalidEmail;if(e.type===`tel`&&!Td.test(r))return n.formInvalidTel;if(e.type===`number`&&!Number.isFinite(Number(r)))return n.formInvalidNumber}function Dd(e,t,n){return Object.fromEntries(e.flatMap(e=>{let r=Ed(e,t[e.name],n);return r?[[e.name,r]]:[]}))}const Od=P.cssPrefix;function kd(e){return e.tokenEmail||e.userContext?.email?.trim()}function Ad(e,t){let n=e instanceof is?e.status:void 0;return n===400?t.formInvalidEmail:n===409?t.emailTranscriptAlreadySent:n===422?t.emailTranscriptNotDelivered:n===429?t.emailTranscriptLimited:t.emailTranscriptFailed}function jd(e){return`host`in e&&`activeElement`in e}function Md({transport:e,strings:t,knownEmail:n,onClose:r}){let[i,a]=h(n??``),[o,s]=h(!1),[c,l]=h({status:`idle`}),u=m(null),p=d(),y=`${p}-title`,b=`${p}-error`,x=c.status===`sending`,S=c.status===`sent`;f(()=>{let e=u.current;if(!e)return;let t=e.getRootNode(),n=jd(t)?t.activeElement:null,r=bl(e);return()=>{r(),n instanceof HTMLElement&&n.isConnected&&n.focus({preventScroll:!0})}},[]),f(()=>{u.current?.querySelector(`[data-autofocus]`)?.focus({preventScroll:!0})},[S]);async function C(n){if(n.preventDefault(),x)return;let r=i.trim();if(!wd.test(r)){s(!0),u.current?.querySelector(`input`)?.focus();return}s(!1),l({status:`sending`});let a=await e.emailTranscript(r).then(e=>({status:`sent`,to:e.to}),e=>({status:`failed`,message:Ad(e,t)}));l(a)}function w(e){e.key===`Tab`&&e.stopPropagation(),e.key===`Escape`&&(e.stopPropagation(),r())}return/* @__PURE__ */ v(`div`,{class:`${Od}-transcript-layer`,children:[/* @__PURE__ */ _(`div`,{class:`${Od}-transcript-backdrop`,"aria-hidden":`true`,onClick:r}),/* @__PURE__ */ v(`section`,{ref:u,class:`${Od}-transcript-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":y,onKeyDown:w,"data-testid":J.emailTranscriptSheet,children:[/* @__PURE__ */ v(`header`,{class:`${Od}-transcript-sheet-head`,children:[/* @__PURE__ */ _(`span`,{class:`${Od}-transcript-sheet-icon`,children:/* @__PURE__ */ _(Mc,{})}),/* @__PURE__ */ _(`h2`,{id:y,class:`${Od}-transcript-sheet-title`,children:t.emailTranscript}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Od}-icon-btn`,onClick:r,"aria-label":t.emailTranscriptCancel,title:t.emailTranscriptCancel,children:/* @__PURE__ */ _(sc,{})})]}),c.status===`sent`?/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`p`,{class:`${Od}-transcript-sheet-text ${Od}-transcript-sheet-sent`,role:`status`,children:[/* @__PURE__ */ _(al,{}),/* @__PURE__ */ _(`span`,{children:t.emailTranscriptSent.replace(`{email}`,c.to)})]}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Od}-form-submit ${Od}-transcript-sheet-action`,onClick:r,"data-autofocus":!0,children:t.emailTranscriptDone})]}):/* @__PURE__ */ v(`form`,{class:`${Od}-transcript-sheet-form`,onSubmit:e=>void C(e),noValidate:!0,children:[/* @__PURE__ */ _(`p`,{class:`${Od}-transcript-sheet-text`,children:t.emailTranscriptPrompt}),/* @__PURE__ */ v(`label`,{class:`${Od}-field`,"data-invalid":o?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Od}-field-label`,children:t.emailTranscriptEmailLabel}),/* @__PURE__ */ _(`input`,{class:`${Od}-field-input`,type:`email`,name:`email`,autocomplete:`email`,inputMode:`email`,autocapitalize:`off`,spellcheck:!1,value:i,readOnly:x,"aria-invalid":o,"aria-describedby":o?b:void 0,onInput:e=>{a(e.currentTarget.value),s(!1)},"data-autofocus":!0,"data-testid":J.emailTranscriptEmail}),o?/* @__PURE__ */ _(`span`,{id:b,class:`${Od}-field-error`,role:`alert`,children:t.formInvalidEmail}):null]}),/* @__PURE__ */ _(`button`,{type:`submit`,class:`${Od}-form-submit ${Od}-transcript-sheet-action`,disabled:x,"aria-busy":x,"data-testid":J.emailTranscriptSend,children:x?t.emailTranscriptSending:t.emailTranscriptSend}),c.status===`failed`?/* @__PURE__ */ _(`p`,{class:`${Od}-field-error`,role:`alert`,children:c.message}):null]})]})]})}const Nd=/* @__PURE__ */ new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`,`password`]);function Pd(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Fd(e){return!Pd(e)||e.name===``||e.disabled?!1:!(e instanceof HTMLInputElement&&Nd.has(e.type))}function Id(e){let t=e.labels?.[0]?.textContent?.trim();return e.getAttribute(`toolparamdescription`)??(t||e.getAttribute(`aria-description`))??void 0}function Ld(e,t){let n=Id(e),r=n?{description:n}:{};return e instanceof HTMLSelectElement?{...r,type:`string`,enum:[...e.options].map(e=>e.value)}:e instanceof HTMLTextAreaElement?{...r,type:`string`}:e.type===`checkbox`?{...r,type:`boolean`}:e.type===`radio`?{...r,type:`string`,enum:t}:e.type===`number`||e.type===`range`?{...r,type:`number`}:{...r,type:`string`}}function Rd(e,t){Object.getOwnPropertyDescriptor(Reflect.getPrototypeOf(e)??e,`value`)?.set?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function zd(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function Bd(e,t){e instanceof HTMLInputElement&&e.type===`checkbox`?e.checked!==(t===!0||t===`true`)&&e.click():e instanceof HTMLInputElement&&e.type===`radio`?e.value===zd(t)&&!e.checked&&e.click():Rd(e,zd(t))}function Vd(e,t,n){let r=[...e.elements].filter(Fd),i={},a=/* @__PURE__ */ new Set;for(let e of r){var o;let t=r.flatMap(t=>t instanceof HTMLInputElement&&t.type===`radio`&&t.name===e.name?[t.value]:[]);i[o=e.name]??(i[o]=Ld(e,t)),e.required&&a.add(e.name)}return{name:t,description:n,inputSchema:{type:`object`,properties:i,...a.size>0?{required:[...a]}:{}},execute(t){let n=typeof t==`object`&&t?Object.entries(t):[];for(let[e,t]of n)for(let n of r)n.name===e&&Bd(n,t);if(!e.hasAttribute(`toolautosubmit`))return`Filled in the form. The visitor still needs to check it and press its submit button.`;let i=[...new Set([...e.elements].flatMap(e=>Pd(e)&&e.name&&!e.checkValidity()?[e.name]:[]))];return i.length>0?`Filled in the form, but it can't be submitted yet: ${i.join(`, `)} still needs the visitor. Ask them to complete it and press the submit button.`:(setTimeout(()=>e.requestSubmit(),0),`Filled in the form and submitted it.`)}}}function Hd(){return[...document.querySelectorAll(`form[toolname][tooldescription]`)].flatMap(e=>{let t=e.getAttribute(`toolname`)?.trim()??``,n=e.getAttribute(`tooldescription`)?.trim()??``;return t&&n?[Vd(e,t,n)]:[]})}const Ud=`${P.cssPrefix}.page-tools`;function Wd(e){return typeof e==`object`&&!!e}function Gd(e){return Wd(e)&&(e.state===`running`||e.state===`stopped`||e.state===`finished`&&Wd(e.outcome))}function Kd(e){let t=e?JSON.parse(e):void 0;return Wd(t)?{sent:Array.isArray(t.sent)?t.sent.filter(e=>typeof e==`string`):[],calls:Object.fromEntries(Object.entries(Wd(t.calls)?t.calls:{}).filter(e=>Gd(e[1])))}:{sent:[],calls:{}}}let qd={sent:[],calls:{}};function Jd(){try{qd=Kd(sessionStorage.getItem(Ud))}catch{}return qd}function Yd(e){qd=e;try{sessionStorage.setItem(Ud,JSON.stringify(e))}catch{}}const Xd={markSent(e){let t=Jd();Yd({...t,sent:[...t.sent.filter(t=>t!==e),e].slice(-20)})},sentHere(e){return Jd().sent.includes(e)},get(e){return Jd().calls[e]},set(e,t){let n=Jd(),r=Object.entries(n.calls).filter(([t])=>t!==e);Yd({...n,calls:Object.fromEntries([...r,[e,t]].slice(-50))})},clear(e){let t=Jd();e.some(e=>e in t.calls)&&Yd({...t,calls:Object.fromEntries(Object.entries(t.calls).filter(([t])=>!e.includes(t)))})}},Zd=V.scope(`page-tools`),Qd=3e4,$d=Symbol.for(`${P.cssPrefix}.page-tools`),ef={state:`output-error`,errorText:`The page reloaded before this finished, so it may or may not have taken effect. Check with the visitor before trying it again.`},tf=`The visitor stopped this before it finished.`;function nf(e){return typeof e==`object`&&!!e}function rf(e){return nf(e)&&Array.isArray(e.registered)&&e.runs instanceof Map}function af(){let e=Reflect.get(globalThis,$d);if(rf(e))return e;let t={registered:[],runs:/* @__PURE__ */ new Map};return Reflect.set(globalThis,$d,t),t}function of(e,t){let n=nf(t)&&t.signal instanceof AbortSignal?t.signal:void 0;if(n?.aborted)return;let r=af().registered;r.push(e);function i(){let t=r.indexOf(e);t>=0&&r.splice(t,1)}n?.addEventListener(`abort`,i,{once:!0})}function sf(e){return e.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,58)}function cf(e){if(!nf(e)||typeof e.name!=`string`||!sf(e.name))return;let t=typeof e.title==`string`&&e.title.trim()!==``?e.title.trim().slice(0,120):void 0,n=[e.description,t].find(e=>typeof e==`string`&&e.trim()!==``)??e.name,r=e.preview;return{name:sf(e.name),...t?{title:t}:{},...typeof r==`function`?{preview:t=>Reflect.apply(r,e,[t])}:{},description:n.trim().slice(0,1024),inputSchema:{properties:{},...nf(e.inputSchema)?e.inputSchema:{},type:`object`},consequential:nf(e.annotations)&&e.annotations.consequentialHint===!0}}function lf(e){return e.flatMap(e=>{let t=cf(e),n=nf(e)?e.execute:void 0;return!t||typeof n!=`function`?(Zd.warn(`skipped a tool without a name or an execute function`,e),[]):[{...t,run:(t,r)=>Reflect.apply(n,e,[t,{signal:r}])}]})}async function uf(){let e=Reflect.get(document,`modelContext`)??Reflect.get(navigator,`modelContext`);if(!nf(e)||typeof e.getTools!=`function`||typeof e.executeTool!=`function`)return[];let t=e.getTools,n=e.executeTool,r=await Promise.race([Promise.resolve().then(()=>Reflect.apply(t,e,[])),es(1e3).then(()=>[])]).catch(()=>[]);return(Array.isArray(r)?r:[]).flatMap(t=>{let r=cf(t);return r?[{...r,run:(r,i)=>Reflect.apply(n,e,[t,r,{signal:i}])}]:[]})}async function df(e=[]){let t=lf(Hd()),n=new Set(t.map(e=>e.name)),r=[...(await uf()).filter(e=>!n.has(e.name)),...t,...lf(e),...lf(af().registered)];return new Map(r.map(e=>[e.name,e]))}function ff(e){return[...e.values()].map(({name:e,title:t,description:n,inputSchema:r,consequential:i})=>{let a={name:e,description:n,inputSchema:r};return t&&(a.title=t),i&&(a.annotations={consequentialHint:!0}),a})}function pf(e){return e?.execution===`client`}function mf(e){return e.startsWith(`site__`)?e.slice(6):e}function hf(e){if(e===void 0||typeof e==`function`||typeof e==`symbol`)return null;let t=/* @__PURE__ */ new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`)return n instanceof Node?`[${n.nodeName.toLowerCase()}]`:nf(n)?t.has(n)?`[circular]`:(t.add(n),n):n});return n.length>Qd?{truncated:!0,preview:n.slice(0,Qd)}:JSON.parse(n)}async function gf(e){let t=(await df(e.optionTools)).get(mf(e.toolName));if(!t?.preview)return;let n=t.preview;return Promise.resolve().then(()=>n(e.input)).catch(e=>{Zd.warn(`a page tool preview failed`,{name:t.name,error:e})})}async function _f(e){let t=mf(e.toolName),n=(await df(e.optionTools)).get(t);return n?Promise.resolve().then(()=>n.run(e.input,e.signal)).then(e=>({state:`output-available`,output:hf(e)})).catch(e=>(Zd.warn(`a page tool failed`,{name:t,error:e}),{state:`output-error`,errorText:(e instanceof Error?e.message:String(e)).slice(0,1e3)||`The page tool failed.`})):{state:`output-error`,errorText:`This page doesn't offer "${t}" right now; the visitor may have moved on. Tell them, or continue without it.`}}function vf(e){let{toolCallId:t}=e,n=Xd.get(t);if(n?.state===`finished`)return Promise.resolve(n.outcome);let{runs:r}=af(),i=r.get(t);if(i)return i.outcome;if(n?.state===`running`)return Xd.set(t,{state:`finished`,outcome:ef}),e.onSettled(`interrupted`,0),Promise.resolve(ef);let a=new AbortController,o=performance.now();Xd.set(t,{state:`running`});let s=_f({...e,signal:a.signal}).then(n=>(r.delete(t),Xd.get(t)?.state===`running`&&(Xd.set(t,{state:`finished`,outcome:n}),e.onSettled(n.state===`output-available`?`completed`:`failed`,Math.round(performance.now()-o))),n));return r.set(t,{outcome:s,controller:a}),s}function yf(e){return e===ef.errorText||e===tf}function bf(e){return Xd.set(e,{state:`stopped`}),af().runs.get(e)?.controller.abort(),tf}function xf(e){Xd.clear([e]),af().runs.get(e)?.controller.abort()}const Sf=P.cssPrefix;function Cf({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=h(t);u(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ v(`div`,{class:`${Sf}-feedback`,role:`group`,"data-testid":J.messageFeedback,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${Sf}-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":J.feedbackUp,children:/* @__PURE__ */ _(tl,{})}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Sf}-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":J.feedbackDown,children:/* @__PURE__ */ _(nl,{})}),/* @__PURE__ */ _(`span`,{class:`${Sf}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}function wf(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Tf(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function Ef(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function Df(e){let{streaming:t,reasoningVisible:n,emptyReply:r,hidden:i}=e,a=e.responseMode===`buffered`&&t,o=t&&!e.hasAnswerText;return{streaming:t,bufferedHold:a,reasoningVisible:n,working:o,showStreamDots:Ef({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}const Of=P.cssPrefix;function kf({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ v(`a`,{class:`${Of}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":J.source,children:[/* @__PURE__ */ _(`span`,{class:`${Of}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ _(`span`,{class:`${Of}-source-label`,children:n})]}):/* @__PURE__ */ v(`span`,{class:`${Of}-source`,"data-testid":J.source,children:[/* @__PURE__ */ _(`span`,{class:`${Of}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ _(`span`,{class:`${Of}-source-label`,children:n})]})}const Af=P.cssPrefix;function jf(e){return{toolCallId:e.toolCallId,toolName:e.toolName,...e.title?{title:e.title}:{},state:e.stateSig.value,input:e.inputSig.value,output:e.outputSig.value,...e.errorSig.value?{errorText:e.errorSig.value}:{},...e.approvalSig.value?{approval:e.approvalSig.value}:{},...e.toolMetadata?{toolMetadata:e.toolMetadata}:{}}}function Mf(e,t){if(t?.replacedByMessageId)return{terminal:!1,responded:!1,decided:!1};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 Nf({status:e,label:t,icon:n}){return/* @__PURE__ */ v(`span`,{class:`${Af}-toolui-badge ${Af}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ _(`span`,{class:`${Af}-toolui-status-icon`,children:n??/* @__PURE__ */ _(Pf,{status:e})}),t]})}function Pf({status:e}){return e===`running`?/* @__PURE__ */ _(`span`,{class:`${Af}-loading-spinner`}):_(e===`stopped`?pc:e===`waiting`||e===`submitted`?il:e===`failed`||e===`declined`||e===`replaced`?ol:al,{})}function Ff({decision:e}){return/* @__PURE__ */ v(`span`,{class:`${Af}-steps-decision`,"data-approved":e.approved?`true`:`false`,title:e.title,children:[e.approved?/* @__PURE__ */ _(al,{}):/* @__PURE__ */ _(ol,{}),e.label]})}function If({view:e,strings:t}){let n=e.raw;return/* @__PURE__ */ v(g,{children:[e.error?/* @__PURE__ */ _(`p`,{class:`${Af}-steps-row-error`,children:e.error}):null,e.fields.length>0?/* @__PURE__ */ _(Lf,{fields:e.fields,label:e.tables?t.stepInput:void 0,plain:!e.tables}):null,e.resultFields?/* @__PURE__ */ _(Lf,{fields:e.resultFields,label:t.toolResult}):null,n?.input||n?.output?/* @__PURE__ */ v(`details`,{class:`${Af}-toolui-raw`,open:!e.tables,children:[/* @__PURE__ */ _(`summary`,{children:t.stepRawData}),n.input?/* @__PURE__ */ _(Rf,{label:t.stepInput,text:n.input}):null,n.output?/* @__PURE__ */ _(Rf,{label:t.toolResult,text:n.output}):null]}):null]})}function Lf({fields:e,label:t,plain:n=!1}){let r=/* @__PURE__ */ _(`div`,{class:`${Af}-toolui-fields`,"data-plain":n?`true`:void 0,children:/* @__PURE__ */ _(`table`,{children:/* @__PURE__ */ _(`tbody`,{children:e.map(({label:e,value:t},n)=>/* @__PURE__ */ v(`tr`,{children:[/* @__PURE__ */ _(`th`,{scope:`row`,children:e}),/* @__PURE__ */ _(`td`,{children:t})]},`${e}#${n}`))})})});return t?/* @__PURE__ */ v(`div`,{class:`${Af}-toolui-section`,children:[/* @__PURE__ */ _(`span`,{class:`${Af}-toolui-label`,children:t}),r]}):r}function Rf({label:e,text:t}){return/* @__PURE__ */ v(`div`,{class:`${Af}-toolui-section`,children:[/* @__PURE__ */ _(`span`,{class:`${Af}-toolui-label`,children:e}),/* @__PURE__ */ _(`pre`,{class:`${Af}-toolui-code`,children:t})]})}const zf=P.cssPrefix;function Bf({part:e,view:t,strings:n,locale:r,canAct:i,onDecision:a,onEdit:o,preview:s}){let c=t.approval,l=t.status===`waiting`||t.status===`submitted`||t.status===`approved`,u=e.toolCallId;return/* @__PURE__ */ v(`details`,{class:`${zf}-toolui ${zf}-toolui-collapsible`,open:l||c?.buttons===`change`||void 0,"data-testid":t.status===`waiting`?J.toolApproval:J.toolDecision,"data-status":t.status,children:[/* @__PURE__ */ v(`summary`,{class:`${zf}-toolui-head`,children:[/* @__PURE__ */ _(`span`,{class:`${zf}-toolui-prompt`,children:l&&c?c.ask:t.name}),t.system?/* @__PURE__ */ _(`span`,{class:`${zf}-toolui-system`,children:t.system}):null,/* @__PURE__ */ v(`span`,{class:`${zf}-toolui-head-end`,children:[t.decision?/* @__PURE__ */ _(Ff,{decision:t.decision}):null,t.statusLabel?/* @__PURE__ */ _(Nf,{status:t.status,label:t.statusLabel}):null,/* @__PURE__ */ _(`span`,{class:`${zf}-toolui-chevron`,children:/* @__PURE__ */ _(Nc,{})})]})]}),/* @__PURE__ */ v(`div`,{class:`${zf}-toolui-collapse-body`,children:[l&&s&&pf(e.toolMetadata)?/* @__PURE__ */ _(Hf,{toolName:e.toolName,input:e.inputSig.value,preview:s,strings:n,locale:r}):null,/* @__PURE__ */ _(If,{view:t,strings:n}),c?.note?/* @__PURE__ */ _(`p`,{class:`${zf}-toolui-subtle`,children:c.note}):null,c?.buttons===`decide`?/* @__PURE__ */ v(`div`,{class:`${zf}-toolui-actions`,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${zf}-form-skip`,disabled:!i,onClick:()=>a(u,!1),"data-testid":J.toolDecline,children:n.decline}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${zf}-form-submit`,disabled:!i,onClick:()=>a(u,!0),"data-testid":J.toolApprove,children:n.approve})]}):null,c?.buttons===`change`?/* @__PURE__ */ _(`div`,{class:`${zf}-toolui-actions`,children:/* @__PURE__ */ _(`button`,{type:`button`,class:`${zf}-form-skip`,onClick:()=>o(u),"data-testid":J.toolEdit,children:n.changeAnswer})}):null]})]})}function Vf(e){if(typeof e==`object`&&e&&`totals`in e)return`number`in e&&`items`in e?`root = Root([preview])\npreview = Order(${JSON.stringify(e)})`:`lines`in e?`root = Root([preview])\npreview = Cart(${JSON.stringify(e)})`:void 0}function Hf({toolName:e,input:t,preview:n,strings:r,locale:i}){let[a,s]=h();u(()=>{let r=!0;return n(e,t).then(e=>{r&&s(Vf(e))}),()=>{r=!1}},[e,t,n]);let c=p(()=>a?{textSig:o(a),doneSig:o(!0),replyDoneSig:o(!0)}:void 0,[a]);return c?/* @__PURE__ */ _(`div`,{class:`${zf}-toolui-preview`,"data-testid":J.toolPreview,children:/* @__PURE__ */ _(ja,{cssPrefix:zf,textSig:c.textSig,doneSig:c.doneSig,replyDoneSig:c.replyDoneSig,strings:r,locale:i})}):null}const Uf=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function Wf(e){return typeof e==`object`&&!!e}function Gf(e,t){let n=Wf(e)?e:{},r=(Array.isArray(n.questions)?n.questions:[]).map((e,n)=>Kf(e,n,t)).filter(e=>e!==null);return{intro:Yf(n.intro),questions:r}}function Kf(e,t,n){if(!Wf(e))return null;let r=Uf.find(t=>t===e.type)??`text`;return{key:Yf(e.key)??`q${t+1}`,question:Yf(e.question)??n,type:r,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof e.required==`boolean`?e.required:void 0,helpText:Yf(e.helpText)}}function qf(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 Jf(e,t,n){return e.questions.map(e=>{let r=qf(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 Yf(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const Xf=P.cssPrefix;function Zf({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:c,initialValues:l,hideActions:u,fieldTypeLabels:d,rootTestId:f,submitTestId:p,skipTestId:m}){let[g,y]=h(()=>l??{}),[b,x]=h({}),[S,C]=h({});function w(e){S[e]&&C(t=>({...t,[e]:``}))}function T(e,t){y(n=>({...n,[e]:t})),w(e)}function E(e,t){x(n=>({...n,[e]:t})),w(e)}function D(n){if(n.preventDefault(),c)return;let i=tp(e,g,b),a=Dd(e,i,t);Object.keys(a).length>0?C(a):r(i)}function O(e){!s||e.key!==`Enter`||e.shiftKey||ku(e)||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&D(e)}return/* @__PURE__ */ v(`form`,{class:`${Xf}-form`,onSubmit:D,onKeyDown:O,onCompositionEnd:Ou,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ _(Qf,{field:e,value:g[e.name],otherText:b[e.name]??``,error:S[e.name],disabled:c,typeLabel:d?.[e.name],strings:t,onChange:t=>T(e.name,t),onOtherChange:t=>E(e.name,t)},e.name)),u?null:/* @__PURE__ */ v(`div`,{class:`${Xf}-form-actions`,children:[o?/* @__PURE__ */ _(`span`,{class:`${Xf}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Xf}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ _(`button`,{type:`submit`,class:`${Xf}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function Qf({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=ul(J.formField,e.name),u=d(),f=$f({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:l,labelId:u}),p=e.type===`radio`||e.type===`multiselect`?`div`:`label`;return/* @__PURE__ */ v(p,{class:`${Xf}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ v(`span`,{class:`${Xf}-field-head`,children:[/* @__PURE__ */ v(`span`,{class:`${Xf}-field-label`,id:u,children:[e.label,e.required?/* @__PURE__ */ _(`span`,{class:`${Xf}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ _(`span`,{class:`${Xf}-field-type`,children:a}):null]}),f,e.validationHint&&!r?/* @__PURE__ */ _(`span`,{class:`${Xf}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ _(`span`,{class:`${Xf}-field-error`,role:`alert`,children:r}):null]})}function $f(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c,labelId:l}=e,u=typeof n==`string`?n:``;switch(t.type){case`textarea`:return/* @__PURE__ */ _(`textarea`,{class:`${Xf}-field-input`,rows:3,value:u,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`radio`:return/* @__PURE__ */ _(`div`,{class:`${Xf}-field-choices`,role:`radiogroup`,"aria-labelledby":l,"data-testid":c,children:(t.options??[]).map(e=>/* @__PURE__ */ v(`label`,{class:`${Xf}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`radio`,name:`${Xf}-${t.name}`,checked:u===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ _(`span`,{children:e.label})]},e.value))});case`multiselect`:{let e=Array.isArray(n)?n:[];function u(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ v(`div`,{class:`${Xf}-field-choices`,role:`group`,"aria-labelledby":l,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ v(`label`,{class:`${Xf}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>u(t.value,e.currentTarget.checked)}),/* @__PURE__ */ _(`span`,{children:t.label})]},t.value)),(t.options??[]).length===0?/* @__PURE__ */ _(`textarea`,{class:`${Xf}-field-input`,rows:2,value:r,placeholder:a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ _(`input`,{...ep(t.type),class:`${Xf}-field-input`,value:u,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function ep(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`date`:return{type:e};default:return{type:`text`}}}function tp(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=t[i.name];r[i.name]=[...Array.isArray(a)?a:[],...n]}}return r}const np=P.cssPrefix;function rp({skipped:e,submitted:t,strings:n}){return e?{status:`replaced`,statusLabel:n.inputSkipped}:t?{status:`submitted`,statusLabel:n.stepWorkingOnIt}:{status:`done`,statusLabel:n.inputAnswered}}const ip={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function ap(e,t){let n={};for(let r of e)n[r.key]=t[ip[r.type]];return n}function op({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:a=!1,folded:o=!1,onDecision:s,onEdit:c}){let l=p(()=>i(()=>e.stateSig.value),[e]).value,u=p(()=>i(()=>e.approvalSig.value),[e]).value,d=p(()=>i(()=>Gf(e.inputSig.value,t.askFallbackQuestion)),[e,t]).value,{terminal:f,decided:m}=Mf(l,u),g=m&&u?.approved===!0,y=a&&!m,b=!m&&!r&&!y,x=!b&&!g&&!y,S=g&&n&&!f,C=d.questions,[w,T]=h(null),E=w??(b||g||y),[D,O]=h(!1),k=C.length>1?oc:Lc,A=b?t.inputRequired:t.inputBadge,j=y?/* @__PURE__ */ _(`p`,{class:`${np}-toolui-subtle`,children:t.stepWorkingOnIt}):b?/* @__PURE__ */ _(sp,{req:d,strings:t,active:n,resolve:(t,n)=>s(e.toolCallId,n,t)}):D?/* @__PURE__ */ _(Zf,{fields:Jf(d,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:ap(C,t),initialValues:g?mp(C,u?.reason):void 0}):/* @__PURE__ */ _(cp,{questions:C,answers:g?pp(u?.reason):{},strings:t}),{status:ee,statusLabel:M}=rp({skipped:x,submitted:y,strings:t});return/* @__PURE__ */ v(`details`,{class:`${np}-toolui ${np}-toolui-collapsible${r?` ${np}-toolui-stale`:``}`,open:E,onToggle:e=>{let t=e.currentTarget.open;t!==E&&T(t)},"data-testid":b?J.toolAskQuestions:J.toolDecision,children:[/* @__PURE__ */ v(`summary`,{class:`${np}-toolui-head`,children:[/* @__PURE__ */ v(`span`,{class:`${np}-toolui-q-pill`,children:[/* @__PURE__ */ _(k,{}),A]}),/* @__PURE__ */ v(`span`,{class:`${np}-toolui-head-end`,children:[b||o?null:/* @__PURE__ */ _(Nf,{status:ee,icon:_(x?ol:al,{}),label:M}),/* @__PURE__ */ _(`span`,{class:`${np}-toolui-chevron`,children:/* @__PURE__ */ _(Nc,{})})]})]}),/* @__PURE__ */ v(`div`,{class:`${np}-toolui-collapse-body`,children:[d.intro?/* @__PURE__ */ _(`div`,{class:`${np}-toolui-desc`,children:d.intro}):null,j,b||y?null:/* @__PURE__ */ v(`div`,{class:`${np}-toolui-footer`,children:[/* @__PURE__ */ v(`button`,{type:`button`,class:`${np}-toolui-options-toggle`,onClick:()=>O(e=>!e),"data-testid":J.toolAskOptions,children:[/* @__PURE__ */ _(`span`,{class:`${np}-toolui-options-chevron${D?` ${np}-open`:``}`,children:/* @__PURE__ */ _(Nc,{})}),D?t.hideOptions:t.showOptions]}),S?/* @__PURE__ */ _(`button`,{type:`button`,class:`${np}-form-skip`,onClick:()=>c(e.toolCallId),"data-testid":J.toolEdit,children:t.edit}):null]})]})]})}function sp({req:e,strings:t,active:n,resolve:r}){let i=Jf(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ _(Zf,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(up(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:ap(e.questions,t),submitTestId:J.toolInputSubmit,skipTestId:J.toolInputSkip})}function cp({questions:e,answers:t,strings:n}){return/* @__PURE__ */ _(`div`,{class:`${np}-toolui-summary`,"data-testid":J.toolAskSummary,children:e.map(e=>/* @__PURE__ */ v(`div`,{class:`${np}-field`,children:[/* @__PURE__ */ _(`span`,{class:`${np}-field-head`,children:/* @__PURE__ */ v(`span`,{class:`${np}-field-label`,children:[e.question,e.required?/* @__PURE__ */ _(`span`,{class:`${np}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ _(`p`,{class:`${np}-toolui-answer`,children:lp(e,t[e.key],n)||`—`})]},e.key))})}function lp(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function up(e,t){let n=e.flatMap(e=>{let n=t[e.key],r=typeof n==`string`?n.trim():n;return r?.length?[{key:e.key,value:r}]:[]});return JSON.stringify({answers:n})}function dp(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})(),n=fp(t)?t.answers:void 0;if(!Array.isArray(n))return{};let r={};for(let e of n)if(fp(e)){let{key:t,value:n}=e;if(typeof t!=`string`)continue;typeof n==`string`?r[t]=n:Array.isArray(n)&&(r[t]=n.filter(e=>typeof e==`string`))}return r}function fp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pp(e){let t=dp(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function mp(e,t){let n=dp(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}const Z=P.cssPrefix;function hp(e,t){let n=[];for(let[r,i]of e.entries()){let e=n.at(-1),a=i.kind===`tool`?t.viewOf(i):void 0,o=gp(i,a,t.showReasoning);o?e?.kind===`steps`?(e.rows.push(o),e.indices.push(r)):n.push({kind:`steps`,rows:[o],indices:[r]}):i.kind===`step-start`||i.kind===`reasoning`||i.kind===`source`&&!t.showSources||a?.placement===`hidden`||n.push({kind:`part`,part:i,index:r})}return n}function gp(e,t,n){return e.kind===`reasoning`?n?{kind:`thought`,part:e}:void 0:e.kind===`tool`&&t?.placement===`step`?{kind:`tool`,part:e,view:t}:void 0}function _p(e,t){let n=[...new Set(t)];if(e&&n.length!==0&&!n.some(t=>t<0||t>=e.length))return n.reduce((t,n)=>t+(e[n]?.durationMs??0),0)}function vp(e){let t=[];for(let n of e)t.push((t.at(-1)??-1)+ +(n.kind===`step-start`));return t}function yp(e,t){return e.streaming?t.thinking:e.reasoningMs===void 0?t.thought:t.thoughtFor.replace(`{time}`,bp(e.reasoningMs))}function bp(e){if(e<1e4)return`${Number((e/1e3).toFixed(1))} s`;let t=Math.round(e/1e3);return t<60?`${t} s`:`${Math.floor(t/60)} m ${t%60} s`}function xp(e){return e.split(`
41
+ `).map(e=>e.trim()).findLast(e=>/^\*\*[^*].*\*\*$/.test(e))?.slice(2,-2).trim()}function Sp(e,t){return e?.kind===`tool`?`${e.view.name}…`:(e&&xp(e.part.textSig.value))??t.thinking}function Cp({rows:e,steps:t=[],stepTimings:n,timed:r=!0,strings:a,running:o,runStartedAt:s,renderCard:c}){let[l,u]=h(!1),[d,f]=h(!1),m=Oe(e.flatMap(e=>e.kind===`tool`?[e.view]:[])),g=e.at(-1),y=p(()=>i(()=>Sp(g,a)),[g,a]).value,b=r?_p(n,t):void 0;function x(){u(!l),f(!0)}let[S]=e;return!o&&e.length===1&&S?.kind===`tool`?/* @__PURE__ */ _(`div`,{class:`${Z}-steps`,"data-testid":J.toolSteps,"data-stopped":m.stopped?`true`:void 0,children:/* @__PURE__ */ _(kp,{part:S.part,view:S.view,strings:a,durationMs:b,standalone:!0,renderCard:c})}):/* @__PURE__ */ v(`div`,{class:`${Z}-steps`,"data-testid":J.toolSteps,"data-running":o?`true`:void 0,"data-stopped":m.stopped?`true`:void 0,children:[/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-head`,"aria-expanded":l,onClick:x,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Tp,{running:o,stopped:m.stopped!==void 0})}),/* @__PURE__ */ _(`span`,{class:`${Z}-steps-label`,children:o?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-live`,children:y}):/* @__PURE__ */ _(Ep,{line:m,strings:a})}),!o&&m.failed>0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-failed`,children:a.toolStepsFailed.replace(`{count}`,String(m.failed))}):null,o?null:m.marks.map(e=>/* @__PURE__ */ _(Ff,{decision:e},e.title)),o&&s?/* @__PURE__ */ _(wp,{since:s}):null,!o&&b!==void 0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-time`,children:bp(b)}):null,/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":l?`true`:void 0,children:/* @__PURE__ */ _(Nc,{})})]}),/* @__PURE__ */ _(`span`,{class:`${Z}-sr-only`,role:`status`,children:o?y:``}),/* @__PURE__ */ _(`div`,{class:`${Z}-steps-body`,"data-open":l?`true`:void 0,inert:!l,children:/* @__PURE__ */ _(`div`,{class:`${Z}-steps-body-inner`,children:d?/* @__PURE__ */ _(`ol`,{class:`${Z}-steps-list`,children:e.map((r,i)=>r.kind===`tool`?/* @__PURE__ */ _(kp,{part:r.part,view:r.view,strings:a,renderCard:c},r.part.toolCallId):/* @__PURE__ */ _(Ap,{part:r.part,current:o&&i===e.length-1,reasoningMs:n?.[t[i]??-1]?.reasoningMs,strings:a},`${r.part.id}#${i}`))}):null})})]})}function wp({since:e}){let[t,n]=h(()=>Date.now());u(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((t-Date.parse(e))/1e3));return/* @__PURE__ */ _(`span`,{class:`${Z}-steps-time`,children:bp(r*1e3)})}function Tp({running:e,stopped:t}){return e?/* @__PURE__ */ _(`span`,{class:`${Z}-loading-spinner`}):_(t?pc:rl,{})}function Ep({line:e,strings:t}){return e.stopped?/* @__PURE__ */ _(g,{children:Ae(e.stopped.finished,t)}):e.single?/* @__PURE__ */ v(g,{children:[e.single.name,e.single.summary?/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ _(`span`,{class:`${Z}-steps-summary`,children:e.single.summary})]}):null,e.single.outcome?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-denied`,children:e.single.outcome}):null]}):/* @__PURE__ */ _(g,{children:e.tools.map(({name:e,count:t},n)=>/* @__PURE__ */ v(`span`,{class:`${Z}-steps-name`,children:[n>0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}):null,e,t>1?/* @__PURE__ */ v(`span`,{class:`${Z}-steps-count`,children:[`×`,t]}):null]},e))})}function Dp({view:e}){let t=e.statusLabel&&e.status!==`running`?/* @__PURE__ */ _(`span`,{class:e.status===`failed`?`${Z}-steps-failed`:`${Z}-steps-denied`,children:e.statusLabel}):null;return/* @__PURE__ */ v(g,{children:[e.decision?/* @__PURE__ */ _(Ff,{decision:e.decision}):null,t]})}function Op({view:e,durationMs:t}){return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`span`,{class:`${Z}-steps-row-label`,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-name`,children:e.name}),e.system?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-system`,children:e.system}):null,e.summary?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-summary`,children:e.summary}):null]}),/* @__PURE__ */ _(Dp,{view:e}),t===void 0?null:/* @__PURE__ */ _(`span`,{class:`${Z}-steps-time`,children:bp(t)})]})}function kp({part:e,view:t,strings:n,durationMs:r,standalone:i=!1,renderCard:a}){let[o,s]=h(!1);return/* @__PURE__ */ v(i?`div`:`li`,{class:`${Z}-steps-row`,"data-testid":J.toolStep,"data-status":t.status,"data-standalone":i?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Pf,{status:t.status})}),/* @__PURE__ */ _(`div`,{class:`${Z}-steps-row-main`,children:t.opens?/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":o,onClick:()=>s(!o),children:[/* @__PURE__ */ _(Op,{view:t,durationMs:r}),/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":o?`true`:void 0,children:/* @__PURE__ */ _(Nc,{})})]}):/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-head`,children:/* @__PURE__ */ _(Op,{view:t,durationMs:r})})}),o&&t.opens?/* @__PURE__ */ _(`div`,{class:`${Z}-steps-row-body`,children:(t.card?a?.(e,t):void 0)??/* @__PURE__ */ _(If,{view:t,strings:n})}):null]})}function Ap({part:e,current:t,reasoningMs:n,strings:r,standalone:a=!1}){let[o,s]=h(!1),c=p(()=>i(()=>e.textSig.value.trim()===``),[e]).value,l=/* @__PURE__ */ _(`span`,{class:t?`${Z}-steps-thought-label ${Z}-steps-live`:`${Z}-steps-thought-label`,children:yp({streaming:t,reasoningMs:n},r)});return/* @__PURE__ */ v(a?`div`:`li`,{class:`${Z}-steps-row ${Z}-steps-thought`,"data-status":`thought`,"data-testid":a?J.reasoning:void 0,"data-standalone":a?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(sl,{})}),/* @__PURE__ */ _(`div`,{class:`${Z}-steps-row-main`,children:c?l:/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":o,onClick:()=>s(!o),children:[l,/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":o?`true`:void 0,children:/* @__PURE__ */ _(Nc,{})})]})}),o&&!c?/* @__PURE__ */ _(`div`,{class:`${Z}-steps-thought-text ${Z}-reasoning-body`,children:/* @__PURE__ */ _(wl,{textSig:e.textSig,doneSig:e.doneSig})}):null]})}const jp=P.cssPrefix,Mp=b(Np);function Np({message:e,status:t,createdAt:n,strings:r,locale:a,responseMode:o,showReasoning:s,stepDisplay:c,showSources:l,interactive:u=!1,superseded:d=!1,tool:f,onRetry:m,enableMessageFeedback:h=!1,onFeedback:g,reconnecting:y=!1,clientToolRunning:b=!1,onCardAction:x}){let S=[...p(()=>i(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!S.some(e=>e.kind===`file`&&e.url===t.url)&&S.push({kind:`file`,url:t.url,mediaType:t.mediaType,filename:t.name,fileId:t.id,fileSize:t.size});let C=p(()=>i(()=>Jo(e)),[e,t,e.canceled]),w=p(()=>i(()=>wf(e)),[e]),T=p(()=>i(()=>s&&Tf(e)),[e,s]),E=p(()=>i(()=>Xo(e,T.value)),[e,T,t,e.canceled]),D=p(()=>i(()=>!To(e)),[e]),O=t===`streaming`,k=e.role===`assistant`&&b,A=e.role===`assistant`&&(O||k),j=O||k,ee=Df({streaming:A,responseMode:o,reasoningVisible:T.value,hasAnswerText:w.value,emptyReply:C.value,hidden:E.value}),{bufferedHold:M,showStreamDots:N}=ee;if(ee.hidden)return null;let P=Fp(n,a),te=e.role===`assistant`||e.role===`operator`,ne=h&&!!g&&!!e.serverMessageId&&te&&!j&&t!==`error`&&!C.value,re=j?``:S.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?Ja(t.textSig.peek()):t.textSig.peek()).join(`
42
42
 
43
- `).trim(),F=!j&&t!==`error`&&!C.value&&re.length>0,ie=e.canceled===!0||t===`error`;function ae(n){return u&&t===`complete`&&Ao(e,n)}let I=/* @__PURE__ */ new Map;for(let[t,n]of S.entries()){if(n.kind!==`tool`)continue;let i=df(n.toolMetadata),a=Ee(kf(n),{turn:{live:A||i&&!d,cutOff:ie,superseded:d,submitted:e.continuationStreaming===!0&&n.approvalSig.value?.approved===void 0,canAct:ae(t),interrupted:i&&_f(n.errorSig.value)},reader:{decides:!0},display:c,strings:r});I.set(n.toolCallId,a.placement===`card`&&!f?.humanInLoop?{...a,placement:`hidden`}:a)}function oe(e){let t=I.get(e.toolCallId);if(!t)throw Error(`no step view for ${e.toolCallId}`);return t}let se=pp(S,{showReasoning:s,showSources:l,viewOf:oe}),ce=gp(S),le=e.canceled===!0&&!O&&D.value&&T.value,ue=se.at(-1),L=ue?.kind===`steps`?ue.indices.at(-1):ue?.index;function de(t,n){return/* @__PURE__ */ _(Pp,{part:t,generativeUi:e.role===`assistant`,onCardAction:x,current:A&&n===L,reasoningMs:e.stepTimings?.[ce[n]??-1]?.reasoningMs,strings:r,locale:a,showReasoning:s,showSources:l,view:t.kind===`tool`?I.get(t.toolCallId):void 0,canAct:ae(n),superseded:d,continuationStreaming:e.continuationStreaming===!0,tool:f},`${Lp(t)}#${n}`)}let R=ne||F;return/* @__PURE__ */ _(`div`,{class:`${kp}-bubble-row`,"data-role":e.role,"aria-busy":A?`true`:void 0,"data-testid":cl(J.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ v(`div`,{class:`${kp}-bubble-col`,children:[/* @__PURE__ */ v(`div`,{class:`${kp}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ _(`span`,{class:`${kp}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ v(`div`,{class:`${kp}-bubble-body`,children:[M?/* @__PURE__ */ _(zp,{label:r.loading}):se.flatMap((t,n)=>t.kind===`part`?[de(t.part,t.index)]:t.rows.some(e=>e.kind===`tool`)?[/* @__PURE__ */ _(xp,{rows:t.rows,steps:t.indices.map(e=>ce[e]??-1),stepTimings:e.stepTimings,timed:!ie,strings:r,running:A&&n===se.length-1,runStartedAt:e.runStartedAt,renderCard:(e,t)=>t.card===`questions`&&f?/* @__PURE__ */ _(ip,{part:e,strings:r,active:!1,superseded:t.status===`replaced`,folded:!0,onDecision:f.onDecision,onEdit:f.onEdit}):void 0},`steps#${t.indices[0]}`)]:t.rows.map((e,n)=>de(e.part,t.indices[n]??n))),le?/* @__PURE__ */ v(`div`,{class:`${kp}-steps-row`,"data-status":`stopped`,"data-testid":J.replyStopped,children:[/* @__PURE__ */ _(`span`,{class:`${kp}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(dc,{})}),/* @__PURE__ */ _(`div`,{class:`${kp}-steps-row-main`,children:/* @__PURE__ */ _(`span`,{class:`${kp}-steps-stopped-label`,children:r.statusStopped})})]}):null,N&&!y?/* @__PURE__ */ _(Rp,{}):null,t===`error`||C.value?/* @__PURE__ */ _(ku,{text:Ip(e,t,r),retryLabel:r.errorRetry,onRetry:m?()=>m(e):void 0,retryTestId:J.messageRetry}):null,y&&A?/* @__PURE__ */ _(ku,{text:r.errorReconnecting,retryTestId:J.messageRetry}):null]})]}),P||R?/* @__PURE__ */ v(`div`,{class:`${kp}-bubble-meta`,children:[P?/* @__PURE__ */ _(`time`,{class:`${kp}-bubble-time`,dateTime:P.iso,title:P.full,children:P.short}):null,R?/* @__PURE__ */ v(`div`,{class:`${kp}-bubble-actions`,children:[ne&&e.serverMessageId?/* @__PURE__ */ _(xf,{messageId:e.serverMessageId,initial:e.feedback??null,strings:r,onFeedback:g}):null,F?/* @__PURE__ */ _(Mp,{text:re,strings:r}):null]}):null]}):null]})})}function Mp({text:e,strings:t}){let[n,r]=h(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}let a=n?t.copied:t.copy;return/* @__PURE__ */ _(`button`,{type:`button`,class:`${kp}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":J.messageCopy,children:_(n?Tc:Qc,{})})}function Np(e,t){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let n=new Date(e);return{short:n.toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),full:n.toLocaleString(t,{dateStyle:`full`,timeStyle:`short`}),iso:n.toISOString()}}catch{return null}}function Pp({part:e,generativeUi:t,onCardAction:n,current:r,reasoningMs:i,strings:a,locale:o,showReasoning:s,showSources:c,view:l,canAct:u,superseded:d,continuationStreaming:f,tool:p}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ _(Sl,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:a,onCardAction:n});case`reasoning`:return s?/* @__PURE__ */ _(Op,{part:e,current:r,reasoningMs:i,strings:a,standalone:!0}):null;case`tool`:return l?.placement!==`card`||!p?null:l.card===`questions`?/* @__PURE__ */ _(ip,{part:e,strings:a,active:u,superseded:d,continuationStreaming:f,onDecision:p.onDecision,onEdit:p.onEdit}):/* @__PURE__ */ _(Rf,{part:e,view:l,strings:a,locale:o,canAct:u,onDecision:p.onDecision,onEdit:p.onEdit,preview:p.preview});case`file`:return/* @__PURE__ */ _(Fp,{part:e,strings:a});case`source`:return c?/* @__PURE__ */ _(Df,{part:e,strings:a}):null}}function Fp({part:e,strings:t}){let n=e.filename??t.file;if(e.mediaType.startsWith(`image/`))return/* @__PURE__ */ _(`a`,{class:`${kp}-file-image`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":J.messageFile,children:/* @__PURE__ */ _(`img`,{src:e.url,alt:n,loading:`lazy`})});let r=(n.includes(`.`)?n.split(`.`).pop():e.mediaType.split(`/`).pop())?.toUpperCase(),i=e.fileSize===void 0?void 0:du(e.fileSize);return/* @__PURE__ */ v(`a`,{class:`${kp}-file-chip`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":J.messageFile,children:[/* @__PURE__ */ _(`span`,{class:`${kp}-file-chip-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Mc,{})}),/* @__PURE__ */ v(`span`,{class:`${kp}-file-chip-text`,children:[/* @__PURE__ */ _(`span`,{class:`${kp}-file-chip-name`,children:n}),/* @__PURE__ */ _(`span`,{class:`${kp}-file-chip-meta`,children:[r,i].filter(Boolean).join(` · `)})]})]})}function Ip(e,t,n){return e.errorText?e.errorText:t===`error`&&e.role===`assistant`?n.errorServer:n.errorGeneric}function Lp(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 Rp(){return/* @__PURE__ */ v(`span`,{class:`${kp}-typing`,"data-testid":J.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`span`,{}),/* @__PURE__ */ _(`span`,{}),/* @__PURE__ */ _(`span`,{})]})}function zp({label:e}){return/* @__PURE__ */ v(`span`,{class:`${kp}-loading`,role:`status`,children:[/* @__PURE__ */ _(`span`,{class:`${kp}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ _(`span`,{class:`${kp}-loading-label`,children:e})]})}const Bp=P.cssPrefix;function Vp({messagesSig:e,reconnectingSig:t,pageToolRunning:n,strings:r,notice:i,locale:a,responseMode:o,showReasoning:c,stepDisplay:l,showSources:d,enableMessageFeedback:p,onFeedback:g,loading:y,onLoadPreviousMessages:b,idle:x,controlMode:S=`ai-agent`,tool:C,onRetry:w,onCardAction:T}){let E=m(null),D=s(()=>e.value),O=Hp(a),[k,A]=h(!1),[j,ee]=h(!1),M=m(!1),N=m(!1),[P,te]=h(),ne=m(!1),re=m(!1),F=m(!1),ie=m(0);function ae(){return F.current||performance.now()-ie.current<350}let I=m(0);function oe(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`}function se(e){return A(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function ce(e){I.current=performance.now(),e.scrollTop=e.scrollHeight,oe(e)}function le(e,t){ce(e);let n=t,r=0;function i(){re.current||ae()||(ce(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function ue(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(re.current||ae()||a>=0&&e.scrollTop<a-4)return o();ce(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}let L=D.value[0]?.id;f(()=>{let e=E.current;if(e&&D.value.length!==0&&!N.current&&(ne.current=!0,D.value.some(e=>e.role===`user`)))return ue(e,300)},[L]);let de=m(0);u(()=>{let e=E.current,t=D.value,n=de.current;if(de.current=t.length,e&&ne.current&&!N.current){if(t.slice(n).some(e=>e.role===`user`))return re.current=!1,le(e,3);t.some(e=>e.role===`user`)&&(re.current||ae()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&ce(e))}},[D.value.length]);let R=m(null);u(()=>{let e=E.current,t=D.value.at(-1),n=R.current;if(R.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&ne.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return re.current=!1,le(e,3)},[D.value]),u(()=>{let e=E.current;if(!e)return;let t=D.value.at(-1);if(!t||t.status!==`streaming`&&!D.value.some(e=>e.role===`user`))return;let n=()=>{re.current||ae()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&ce(e)};if(t.status!==`streaming`)return ue(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[D.value]),u(()=>{let e=E.current;if(!e)return;let t=()=>{se(e),oe(e),performance.now()-I.current>150&&(re.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){re.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,F.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){F.current=!1,ie.current=performance.now()}function c(){F.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}),se(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)}},[]),u(()=>{let e=E.current;if(!e)return;let t=e.clientHeight,n=new ResizeObserver(()=>{if(e.clientHeight===t)return;let n=e.scrollHeight-e.scrollTop-t<=120;t=e.clientHeight,n&&!N.current&&D.value.some(e=>e.role===`user`)&&(re.current=!1,ce(e))});return n.observe(e),()=>n.disconnect()},[]);function fe(){let e=E.current;e&&(re.current=!1,ce(e))}let z=D.value.filter(e=>!e.ephemeral),pe=z[0],me=pe?.serverMessageId??pe?.id,he=!!(b&&z.length>=50&&me!==P);async function B(){if(!b||M.current)return;let e=E.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;M.current=!0,N.current=!0,ee(!0);try{let r=await b();r===!1&&me&&te(me),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,oe(e),se(e))}finally{N.current=!1,M.current=!1,ee(!1)}}let ge=[],_e=``,ve=D.value.at(-1)?.id,ye=t?.value===!0,be=n===!0;for(let e of D.value){if(e.role===`assistant`&&e.id!==ve&&Ko(e))continue;let t=Up(e.createdAt);t&&t!==_e&&(ge.push(/* @__PURE__ */ _(`div`,{class:`${Bp}-date-divider`,children:/* @__PURE__ */ _(`span`,{class:`${Bp}-date-pill`,title:Wp(e.createdAt,O),children:Gp(e.createdAt,r,O)})},`day:${t}`)),_e=t);let n=e.retryAction!==void 0||e.role===`assistant`&&e.id===ve?qo(D.value,e):void 0,i=n!==void 0&&(n.kind!==`continue-assistant`||S===`ai-agent`);ge.push(/* @__PURE__ */ _(Ap,{message:e,status:e.status,createdAt:e.createdAt,strings:r,locale:O,responseMode:o,showReasoning:c,stepDisplay:l,showSources:d,interactive:!!x&&S===`ai-agent`&&e.id===ve,superseded:e.id!==ve,tool:C,onRetry:x&&i&&(e.role===`user`||e.id===ve)?w:void 0,enableMessageFeedback:p,onFeedback:g,reconnecting:ye&&e.id===ve,clientToolRunning:be&&e.id===ve&&e.role===`assistant`,onCardAction:T},e.id))}return/* @__PURE__ */ v(`div`,{class:`${Bp}-list-wrap`,children:[/* @__PURE__ */ v(`div`,{ref:E,class:`${Bp}-list ${Bp}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[y&&D.value.length===0?/* @__PURE__ */ _(`div`,{class:`${Bp}-list-loading`,role:`status`,children:r.conversationLoading}):null,i&&!he?/* @__PURE__ */ _(`div`,{class:`${Bp}-chat-notice`,role:`note`,"data-testid":J.chatNotice,children:/* @__PURE__ */ _(Cl,{text:i})}):null,he?/* @__PURE__ */ _(`div`,{class:`${Bp}-load-previous`,children:/* @__PURE__ */ _(`button`,{type:`button`,onClick:B,disabled:j,"aria-busy":j,"data-testid":J.loadPreviousMessages,children:r.loadPreviousMessages})}):null,ge]}),k?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Bp}-jump`,onClick:fe,"aria-label":r.scrollToBottom,title:r.scrollToBottom,"data-testid":J.scrollToBottom,children:/* @__PURE__ */ _(jc,{})}):null]})}function Hp(e){try{return Intl.getCanonicalLocales(e)[0]}catch{return}}function Up(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Wp(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(t,{dateStyle:`full`})}catch{return``}}function Gp(e,t,n){let r=new Date(e);function i(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let a=Math.round((i(/* @__PURE__ */ new Date)-i(r))/864e5);return a<=0?t.dateToday:a===1?t.dateYesterday:a<7?r.toLocaleDateString(n,{weekday:`long`}):r.toLocaleDateString(n,{month:`long`,day:`numeric`,year:`numeric`})}function Kp({panelEl:e,resize:t,position:n,edge:r,initialSize:i,onSizeChange:a,onResizeStart:o,strings:s}){let c=P.cssPrefix,l=m(null),[d,f]=h(null),p=i?.width,g=i?.height;if(u(()=>{if(!e)return;let n=e.style;n.setProperty(`--${c}-resize-min-w`,t.minWidth??`320px`),n.setProperty(`--${c}-resize-min-h`,t.minHeight??`400px`),t.maxWidth&&n.setProperty(`--${c}-resize-max-w`,t.maxWidth),t.maxHeight&&n.setProperty(`--${c}-resize-max-h`,t.maxHeight),p!==void 0&&g!==void 0&&(n.setProperty(`--${c}-widget-w`,`${p}px`),n.setProperty(`--${c}-widget-h`,`${g}px`)),f(Math.round(e.getBoundingClientRect().width/window.innerWidth*100))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,c,p,g]),!e)return null;let v=n.startsWith(`top-`),y=n.endsWith(`-right`),b=y?-1:1,x=v?1:-1,S=`${c}-resize-grip--${r?`edge`:`${v?`bottom`:`top`}-${y?`left`:`right`}`}`;function C(e){e.setAttribute(`data-resizing`,``),o?.()}function w(e,t,n){e.style.setProperty(`--${c}-widget-w`,`${t}px`),r||e.style.setProperty(`--${c}-widget-h`,`${n}px`)}function T(e){let t=e.getBoundingClientRect(),n={width:Math.round(t.width),height:Math.round(t.height)};e.style.setProperty(`--${c}-widget-w`,`${n.width}px`),r||e.style.setProperty(`--${c}-widget-h`,`${n.height}px`),f(Math.round(n.width/window.innerWidth*100)),a(n)}function E(t){if(!e)return;let n=e.getBoundingClientRect();l.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:n.width,startH:n.height,moved:!1},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault()}function D(t){let n=l.current;if(!n||t.pointerId!==n.pointerId||!e)return;let i=(t.clientX-n.startX)*b,a=r?0:(t.clientY-n.startY)*x;(n.moved||i!==0||a!==0)&&(n.moved||C(e),n.moved=!0,w(e,n.startW+i,n.startH+a))}function O(t){let n=l.current;n&&t.pointerId===n.pointerId&&e&&(t.currentTarget.releasePointerCapture(t.pointerId),l.current=null,n.moved&&(e.removeAttribute(`data-resizing`),T(e)))}function k(e){return e===`ArrowLeft`?[-1,0]:e===`ArrowRight`?[1,0]:r?null:e===`ArrowUp`?[0,-1]:e===`ArrowDown`?[0,1]:null}function A(t){let n=k(t.key);if(!n||!e)return;t.preventDefault();let r=t.shiftKey?64:16;t.repeat||C(e);let i=e.getBoundingClientRect();w(e,i.width+n[0]*r*b,i.height+n[1]*r*x)}function j(t){k(t.key)&&e&&(e.removeAttribute(`data-resizing`),T(e))}return/* @__PURE__ */ _(`div`,{class:`${c}-resize-grip ${S}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":s.resizeHandle,"aria-valuenow":d??void 0,tabIndex:0,title:s.resizeHandle,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerCancel:O,onKeyDown:A,onKeyUp:j,"data-testid":J.resizeGrip,children:r?null:/* @__PURE__ */ _(bc,{})})}const qp=P.cssPrefix;function Jp({suggestions:e,strings:t,onPick:n,disabled:r=!1}){let i=m(null),[a,o]=h({start:!1,end:!1});return u(()=>{let e=i.current;if(!e)return;function t(){if(!e)return;let t=Math.abs(e.scrollLeft),n=t>1,r=t<e.scrollWidth-e.clientWidth-1;o(e=>e.start===n&&e.end===r?e:{start:n,end:r})}t(),e.addEventListener(`scroll`,t,{passive:!0});let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);return n?.observe(e),()=>{e.removeEventListener(`scroll`,t),n?.disconnect()}},[e]),e.length===0?null:/* @__PURE__ */ _(`div`,{ref:i,class:`${qp}-suggestions`,role:`group`,"aria-label":t.suggestedReplies,"data-cut-start":a.start?`true`:void 0,"data-cut-end":a.end?`true`:void 0,children:e.map((e,t)=>/* @__PURE__ */ _(`button`,{type:`button`,class:`${qp}-suggestion`,onClick:()=>n(e),disabled:r,"data-testid":cl(J.suggestion,t),children:e.label},e.id))})}const Yp=P.cssPrefix,Xp=`.${Yp}-header, .${Yp}-back-header, .${Yp}-home-hero`;function Zp(e,t){u(()=>{if(!t||!e)return;function n(e){return Number.parseFloat(e)||0}function r(e,t){return Math.min(t,Math.max(-t,e))}let i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(Xp)||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(`--${Yp}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Yp}-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(`--${Yp}-modal-dx`,`${n}px`),e.style.setProperty(`--${Yp}-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 Qp({containerRef:e,onDrop:t,accept:n,disabled:r=!1}){let[i,a]=h();return u(()=>{if(r){a(void 0);return}let i=e.current;if(!i)return;let o=0;function s(e){o+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),a([...e.dataTransfer.items].every(e=>e.kind!==`file`||fu(e.type,n))?`accept`:`reject`))}function c(){--o,o>0||(o=0,a(void 0))}function l(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function u(e){o=0,a(void 0),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return i.addEventListener(`dragenter`,s),i.addEventListener(`dragleave`,c),i.addEventListener(`dragover`,l),i.addEventListener(`drop`,u),()=>{i.removeEventListener(`dragenter`,s),i.removeEventListener(`dragleave`,c),i.removeEventListener(`dragover`,l),i.removeEventListener(`drop`,u)}},[n,e,r,t]),r?void 0:i}const Q=P.cssPrefix;function $p(e){let{options:t,onClose:n}=e,r=t.strings,i=m(null);u(()=>{let e=i.current;if(!e||!n)return;let t=vl(e);function r(e){e.key===`Escape`&&n?.()}return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let a=e.composerApiRef,o=e.composerActive&&e.view===`chat`&&!e.sendPreparing&&e.options.features.fileUpload,s=Qp({containerRef:i,onDrop:l(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),accept:e.options.attachments.accept,disabled:!o});return Zp(i.current,t.mode===`modal`),/* @__PURE__ */ v(`div`,{ref:i,class:`${Q}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":J.panel,children:[/* @__PURE__ */ _(em,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ _(cm,{poweredBy:e.options.poweredBy,strings:e.options.strings})]})}function em(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:c,panelSize:l,view:u,isStreaming:d,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,replyAwaitsCard:y,sendPreparing:b,attachmentUploadsSig:x,controlMode:S,assignedOperator:C,operatorAvailable:w,operatorRequestEnabled:T,onRequestOperator:E,onCancelOperatorRequest:D,loadingMessages:O,onLoadPreviousMessages:k,messagesSig:A,reconnectingSig:j,agent:ee,ticketReference:N,login:P,onStartAsGuest:te,suggestions:ne,initialWidgetSize:re,onClose:F,onBack:ie,onExpand:ae,onToggleHistory:I,onSelectHistoryConversation:oe,onNewConversation:se,onWidgetSizeChange:ce,onSend:le,onStop:ue,onSuggestion:L,tool:de,onRetry:R,onMessageFeedback:fe,onCardAction:z,containerEl:pe,dragOver:me,composerApiRef:he}=e,B=t.strings,ge=S===`operator`?C:void 0,_e=ge?{name:ge.name??ge.initials,avatar:ge.avatar,title:B.operatorBadgeTitle,status:`online`}:ee,ve=t.header.showNotice?M(B,t.header.notice||`chatNotice`):void 0,ye=s(()=>A.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,be=s(()=>A.value.length>0).value,[xe,Se]=h(),Ce=xe===o,we=t.features.emailTranscript&&ye?()=>Se(o):void 0,Te=P.gate?/* @__PURE__ */ _(sm,{login:{...P,gate:P.gate},alone:!be,onStartAsGuest:te,strings:B}):/* @__PURE__ */ v(g,{children:[S&&S!==`ai-agent`?/* @__PURE__ */ _(nm,{controlMode:S,operatorName:C?.name??C?.initials,operatorAvailable:w,onCancelOperatorRequest:D,strings:B}):null,f&&S===`ai-agent`?/* @__PURE__ */ v(`div`,{class:`${Q}-loading ${Q}-compaction-status`,role:`status`,"data-testid":J.compactionStatus,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-loading-spinner`,"aria-hidden":`true`}),B.compactingContext]}):null,!d&&!f&&S===`ai-agent`&&/* @__PURE__ */ _(Jp,{suggestions:ne,strings:B,onPick:L,disabled:b}),/* @__PURE__ */ _(Wu,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,maxMessageCharacters:e.maxMessageCharacters,isStreaming:d,pageToolRunning:e.pageToolRunning,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,replyAwaitsCard:y,active:e.composerActive&&u===`chat`,isPreparing:b,attachmentUploadsSig:x,operatorRequestEnabled:T,canRequestOperator:ye,controlMode:S,onRequestOperator:E,onSend:le,onStop:ue,apiRef:he},c)]});return/* @__PURE__ */ v(g,{children:[u===`history`?/* @__PURE__ */ _(tm,{strings:B,onBack:I,onClose:F,showClose:Us(t.mode,l,t.actions)}):/* @__PURE__ */ v(`header`,{class:`${Q}-header`,part:`header`,"data-variant":t.header.variant,"data-testid":J.panelHeader,children:[ie?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:ie,"aria-label":B.moduleBack,title:B.moduleBack,children:/* @__PURE__ */ _(Oc,{})}):null,_e?/* @__PURE__ */ _(ld,{agent:_e,strings:B,ticketReference:N,person:!!ge}):/* @__PURE__ */ _(`h1`,{children:B.panelTitle}),/* @__PURE__ */ _(Yl,{panelProps:P.gate?{...e,options:{...t,actions:t.actions.filter(e=>e!==`history`)}}:e,variant:`chat`,onEmailTranscript:we,onLogIn:P.menuLogIn})]}),u===`history`?/* @__PURE__ */ _(yd,{transport:n,strings:B,locale:t.locale,persistence:a,onSelect:oe,onNewConversation:se}):/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(xd,{state:me,strings:B}),P.strip?/* @__PURE__ */ _(am,{strip:P.strip,onLogIn:P.onLogIn,onHide:P.onHidePrompt,strings:B}):null,P.gate&&!be?null:/* @__PURE__ */ _(Vp,{messagesSig:A,reconnectingSig:j,pageToolRunning:e.pageToolRunning,strings:B,notice:ve,locale:t.locale,responseMode:t.responseMode,showReasoning:t.showReasoning,stepDisplay:t.stepDisplay,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:fe,loading:O,onLoadPreviousMessages:k,idle:!d&&!b,controlMode:S,tool:de,onRetry:R,onCardAction:z}),Te,/* @__PURE__ */ _(im,{disclaimer:t.composerDisclaimer}),Ce?/* @__PURE__ */ _(Ad,{transport:n,strings:B,knownEmail:Dd({tokenEmail:P.email,userContext:t.userContext}),onClose:()=>Se(void 0)}):null]}),t.size.resize?.enabled?/* @__PURE__ */ _(Kp,{panelEl:pe,resize:t.size.resize,position:t.position,edge:t.mode===`drawer`,initialSize:re,onSizeChange:ce,onResizeStart:t.mode===`floating`&&l===`expanded`?ae:void 0,strings:B}):null]})}function tm({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ v(`header`,{class:`${Q}-header`,part:`header`,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ _(Oc,{})}),/* @__PURE__ */ _(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ _(ac,{})}):null]})}function nm({controlMode:e,operatorName:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let[a,o]=h(!1),s=rm(e,t,n,i);function c(){r&&(o(!0),r().finally(()=>o(!1)))}return/* @__PURE__ */ v(`div`,{class:`${Q}-operator-banner`,"data-mode":e,"data-available":n===!1?`false`:void 0,"data-testid":J.operatorBanner,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ _(`span`,{class:`${Q}-operator-label`,role:`status`,children:s}),e===`awaiting-operator`&&r?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn ${Q}-operator-dismiss`,onClick:c,disabled:a,"aria-label":i.cancelOperatorRequest,title:i.cancelOperatorRequest,"data-testid":J.cancelOperatorRequest,children:/* @__PURE__ */ _(ac,{})}):null]})}function rm(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function im({disclaimer:e}){return e?/* @__PURE__ */ _(`div`,{class:`${Q}-composer-footer`,children:/* @__PURE__ */ _(`div`,{class:`${Q}-disclaimer`,children:e})}):null}function am({strip:e,onLogIn:t,onHide:n,strings:r}){let i=e.kind===`user`;return/* @__PURE__ */ v(`div`,{class:`${Q}-login-bar`,"data-kind":e.kind,role:i?`status`:`note`,"data-testid":i?J.loggedIn:J.loginBar,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-login-bar-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(mc,{})}),i?/* @__PURE__ */ _(`span`,{class:`${Q}-login-bar-text`,children:e.who?r.loggedInAs.replace(`{name}`,e.who):r.loggedIn}):/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{class:`${Q}-login-bar-text`,children:r.loginPrompt}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-login-bar-action`,onClick:t,"data-testid":J.loginBarAction,children:r.loginAction}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn ${Q}-login-bar-hide`,onClick:n,"aria-label":r.dismissLoginPrompt,title:r.dismissLoginPrompt,"data-testid":J.loginBarHide,children:/* @__PURE__ */ _(ac,{})})]})]})}function om(e,t){return e.gate===`required`?t.loginRequired:e.canStartAsGuest?t.loginExpiredGuest:t.loginExpired}function sm({login:e,alone:t,onStartAsGuest:n,strings:r}){return/* @__PURE__ */ v(`div`,{class:`${Q}-login-gate`,"data-gate":e.gate,"data-alone":t?``:void 0,"data-testid":J.loginGate,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-login-gate-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(mc,{})}),/* @__PURE__ */ _(`p`,{class:`${Q}-login-gate-title`,role:`status`,children:om(e,r)}),e.canLogIn||e.canStartAsGuest?/* @__PURE__ */ v(`div`,{class:`${Q}-form-actions ${Q}-login-gate-actions`,children:[e.canStartAsGuest?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-form-skip`,onClick:n,"data-testid":J.loginGateGuest,children:r.startAsGuest}):null,e.canLogIn?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-form-submit`,onClick:e.onLogIn,"data-testid":J.loginGateAction,children:r.loginAction}):null]}):null]})}function cm({poweredBy:e,strings:t}){return e?/* @__PURE__ */ _(`div`,{class:`${Q}-poweredby-bar`,children:/* @__PURE__ */ _(lm,{logoUrl:e.logoUrl,text:e.text??t.poweredBy.replace(`{name}`,P.displayName),href:e.href})}):null}function lm({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ v(g,{children:[e?/* @__PURE__ */ _(`img`,{class:`${Q}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ _(`span`,{children:t}):null]});return n?/* @__PURE__ */ _(`a`,{class:`${Q}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ _(`span`,{class:`${Q}-poweredby`,children:r})}const um=P.cssPrefix;function dm({panelProps:e,enabledModules:t,nav:n,bus:r,hasUnread:i,latestNews:a,onSelectConversation:o,onStartNewConversation:c,onSetPanelSize:d}){let f=e.options,p=f.strings,h=m(null),g=m(/* @__PURE__ */ new Set);u(()=>{let t=h.current;if(!t||!e.onClose)return;let n=vl(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let y=s(()=>n.sig.value).value,b=Xs(y),x=f.modules.byId[y.activeTab],S=e.composerActive&&x?.layout===`chat`&&b===void 0,C=e.composerApiRef,w=S&&e.view===`chat`&&!e.sendPreparing&&e.options.features.fileUpload,T=Qp({containerRef:h,onDrop:l(e=>{w&&C.current?.attachFromDrop(e)},[C,w]),accept:e.options.attachments.accept,disabled:!w});Zp(h.current,f.mode===`modal`);let E=b?.kind===`content`,D=t.length>1&&Zs(y),O=m(null);u(()=>{if(E&&O.current===null)O.current=e.panelSize,e.panelSize===`normal`&&d(`expanded`);else if(!E&&O.current!==null){let e=O.current;O.current=null,d(e)}},[E]);let k={push:e=>n.push(e),pop:()=>n.pop(),switchTab:e=>n.switchTab(e),switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:o,startNewConversation:c};function A(t){return{options:f,transport:e.transport,strings:p,config:t,nav:k,bus:r,panelProps:e,latestNews:a}}let j=/* @__PURE__ */ _(Yl,{panelProps:e,variant:`plain`});x&&g.current.add(x.id);let ee=t.filter(e=>g.current.has(e.id));function M(t){if(t.layout===`chat`)return/* @__PURE__ */ _(em,{...e,composerActive:S,containerEl:h.current,dragOver:T});let n=ad[t.layout].Root;return n?/* @__PURE__ */ _(n,{...A(t)}):null}function N(){return b?.kind===`content`?/* @__PURE__ */ _(Bl,{id:b.id,title:b.title,transport:e.transport,strings:p,bus:r,onBack:()=>n.pop(),actions:j}):null}return/* @__PURE__ */ v(`div`,{ref:h,class:`${um}-panel ${um}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p.panelTitle,style:{position:`relative`},"data-testid":J.messengerHome,children:[/* @__PURE__ */ v(`div`,{class:`${um}-messenger-body`,children:[ee.map(e=>/* @__PURE__ */ _(`div`,{class:`${um}-messenger-pane`,hidden:E||e.id!==x?.id,children:M(e)},e.id)),N()]}),D?/* @__PURE__ */ _(sd,{modules:t,activeTab:y.activeTab,strings:p,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ _(cm,{poweredBy:f.poweredBy,strings:f.strings}),f.size.resize?.enabled&&(x?.layout!==`chat`||b)?/* @__PURE__ */ _(Kp,{panelEl:h.current,resize:f.size.resize,position:f.position,edge:f.mode===`drawer`,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,onResizeStart:f.mode===`floating`&&e.panelSize===`expanded`?e.onExpand:void 0,strings:p}):null]})}function fm(e){let t=P.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return/* @__PURE__ */ v(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":J.sidebar,children:[/* @__PURE__ */ v(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ _(pm,{site:n}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":J.sidebarToggle,children:/* @__PURE__ */ _(mm,{collapsed:a})})]}),a?null:/* @__PURE__ */ v(g,{children:[o.length>0?/* @__PURE__ */ _(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ _(hm,{items:o})}):null,s.length>0?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ _(gm,{items:s})}):null,e.showConversations?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ _(yd,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function pm({site:e}){let t=P.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return/* @__PURE__ */ v(`picture`,{children:[e.logoDark?.url?/* @__PURE__ */ _(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,/* @__PURE__ */ _(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-title`,children:e?.title??P.name})}function mm({collapsed:e}){return/* @__PURE__ */ _(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?/* @__PURE__ */ _(`polyline`,{points:`9 6 15 12 9 18`}):/* @__PURE__ */ _(`polyline`,{points:`15 6 9 12 15 18`})})}function hm({items:e}){let t=P.cssPrefix;return/* @__PURE__ */ _(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>/* @__PURE__ */ _(`li`,{children:/* @__PURE__ */ v(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?/* @__PURE__ */ _(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function gm({items:e}){let t=P.cssPrefix;return/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>/* @__PURE__ */ v(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const _m=P.cssPrefix;function vm(e){return/* @__PURE__ */ v(`main`,{class:`${_m}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ _(fm,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),/* @__PURE__ */ _(`section`,{class:`${_m}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const ym=P.cssPrefix;function bm({strings:e,text:t,onClose:n}){return/* @__PURE__ */ v(`div`,{class:`${ym}-panel ${ym}-panel-notice`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":J.panelNotice,children:[n?/* @__PURE__ */ _(`button`,{type:`button`,class:`${ym}-icon-btn ${ym}-panel-notice-close`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ _(ac,{})}):null,/* @__PURE__ */ _(`p`,{class:`${ym}-panel-notice-text`,children:t})]})}const xm=V.scope(`hitl`);function Sm(e){return e.kind===`tool`&&df(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function Cm(e,t){t.errorSig.value=vf(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function wm(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&Jd.sentHere(n.id)}function Tm(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:c}=e,d=m(t);d.current=t;let f=m(c);f.current=c;let h=m(/* @__PURE__ */ new Map),g=s(()=>{let e=r.value,t=e.at(-1);return n.value!==`ai-agent`||t?.role!==`assistant`||t.status!==`complete`?!1:t.partsSig.value.some(e=>Sm(e)&&Jd.get(e.toolCallId)?.state!==`stopped`)&&wm(e,t)}).value,_=l((e,t,a)=>{if(d.current||n.value!==`ai-agent`)return!1;let o=r.value.at(-1),s=o?.partsSig.value.findIndex(t=>t.kind===`tool`&&t.toolCallId===e)??-1,c=o?.partsSig.value[s];if(!o||c?.kind!==`tool`)return xm.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Ao(o,s)||!t(c))return!1;if(a(c),o.partsSig.value=[...o.partsSig.value],!Oo(o)||o.partsSig.value.some(Sm))return!0;o.status=`streaming`,o.retryAction={kind:`continue-assistant`,messageId:o.serverMessageId??o.id},o.awaitingContinuation=!0,r.value=[...r.value];let l=o.partsSig.value.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]);return i({continueExisting:!0}).then(e=>e&&Jd.clear(l)),!0},[n,r,i]),v=l((e,t)=>{let{toolCallId:n,toolName:r}=t;h.current.has(n)||(h.current.set(n,e),gf({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:f.current??[],onSettled:(e,t)=>{xm.info(`toolResult`,{toolCallId:n,status:e}),a.emit(`toolResult`,{toolCallId:n,name:ff(r),status:e,durationMs:t})}}).then(e=>{h.current.delete(n)&&_(n,Sm,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state})}))},[a,_]),y=l(()=>{let e=r.value;for(let[t,n]of h.current){let r=e.findIndex(e=>e.id===n);r<0||r===e.length-1||(h.current.delete(t),yf(t))}let t=e.at(-1);if(d.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(Sm);if(n.length!==0&&wm(e,t))for(let e of n)Jd.get(e.toolCallId)?.state===`stopped`?Cm(t,e):v(t.id,e)},[r,v]);u(()=>y(),[t,y]),u(()=>r.subscribe(()=>y()),[r,y]);let b=l((e,t,n)=>{let i=!1,o;if(!_(e,e=>e.stateSig.value===`approval-requested`,r=>{df(r.toolMetadata)&&(o=r),i=r.toolMetadata?.card===`questions`;let a=r.approvalSig.value?.id??e;r.approvalSig.value={id:a,approved:t,reason:n},r.stateSig.value=`approval-responded`}))return;let s=r.value.at(-1);o&&t&&s&&v(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:ff(o.toolName),status:`declined`,durationMs:0}),i?(xm.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(xm.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,_,r,v]),x=l(e=>{_(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!Sm(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[_]);return{toolInteraction:p(()=>({humanInLoop:o,onDecision:b,onEdit:x,preview:(e,t)=>mf({toolName:e,input:t,optionTools:f.current??[]})}),[o,b,x]),pageToolsRunning:g,stopPageTools:l(()=>{let e=r.value.at(-1);for(let t of h.current.keys()){let n=e?.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);e&&n?Cm(e,n):vf(t),xm.info(`toolResult`,{toolCallId:t,status:`stopped`}),a.emit(`toolResult`,{toolCallId:t,name:n?ff(n.toolName):void 0,status:`stopped`,durationMs:0})}h.current.clear()},[a,r])}}const Em=V.scope(`latest-news`);function Dm({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=h(),[c,d]=h(()=>n.loadSeenNewsId());u(()=>{if(!r||!i?.length)return;let t=!1;return e.listContent({contentCollectionIds:i,sortBy:`publishedAt`,sortOrder:`desc`,limit:1}).then(e=>{t||s(e.items[0])}).catch(e=>Em.debug(`listContent (latest news) failed (non-fatal)`,{err:e})),()=>{t=!0}},[e,r,a]);let f=l(e=>{n.saveSeenNewsId(e),d(e)},[n]);return{item:o,unseen:o!==void 0&&o.id!==c,markSeen:f}}function Om({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=h(()=>!r&&t.loadCalloutDismissed(n));return u(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:l(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}const km=V.scope(`login`);function Am(e,t){switch(e.status){case`required`:return`required`;case`expired`:return`expired`;case`anonymous`:return t?`required`:void 0;case`pending`:case`loggedIn`:return;default:return e}}function jm(e,t,n){if(e.status===`loggedIn`)return t.hideUser?void 0:{kind:`user`,who:e.name??e.email};if(!(e.status!==`anonymous`||!t.url||t.hidePrompt||n))return{kind:`prompt`}}function Mm(e){let{state:t,deployment:n,bus:r,persistence:i,conversationIdSig:a}=e,[o,c]=h(()=>i.loadLoginPromptDismissedIn()),u=s(()=>a.value).value,d=o!==void 0&&o===u,f=(t.status===`required`?t.loginUrl:void 0)??n.url,p=Am(t,n.required),m=l(()=>{let e=hr(),t=r.listensTo(`loginRequested`);if(km.info(`loginRequested`,{pageLogsIn:t}),r.emit(`loginRequested`,{returnTo:e}),t||!f)return;let n=a.value;n&&i.saveLoginReturn({conversationId:n,draft:i.loadDraft(n)}),i.savePanelOpen(!1),gr(ur(f,e))},[r,a,f,i]),g=l(()=>{let e=a.value;e&&(i.dismissLoginPromptIn(e),c(e))},[a,i]),_=!!f||r.listensTo(`loginRequested`);return{strip:jm(t,n,!!p||d),gate:p,canStartAsGuest:p===`expired`&&!n.required,email:t.status===`loggedIn`?t.email:void 0,canLogIn:_,onLogIn:m,menuLogIn:t.status===`anonymous`&&!p&&_?m:void 0,onHidePrompt:g}}function Nm(e){let{transport:t,conversationIdSig:n}=e,r=c(`ai-agent`),i=c(void 0),a=c(void 0),o=m(void 0),s=l(e=>{let t=e.controlRevision,s=o.current;if(s&&s.conversationId===n.value&&t<s.revision)return;o.current={conversationId:n.value,revision:t},r.value=e.controlMode;let c=e.assignedOperatorInitials;i.value=c?{initials:c,name:e.assignedOperatorName,avatar:e.assignedOperatorAvatar}:void 0,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0},[n,r,i,a]);return{controlModeSig:r,assignedOperatorSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:l(e=>{if(e.type!==`data-control-state`)return;let t=eo(e.data);t&&s(t)},[s]),requestOperator:l(async()=>{let e=n.value,r=await t.requestOperator();r&&n.value===e&&s(r)},[t,n,s]),cancelOperatorRequest:l(async()=>{let e=n.value,r=await t.cancelOperatorRequest();r&&n.value===e&&s(r)},[t,n,s])}}const Pm=P.cssPrefix,Fm=`--${Pm}-visual-viewport-height`,Im=`--${Pm}-visual-viewport-top`;function Lm(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,onClose:o}=e;f(()=>{An(t,$s(n,r,i))},[t,i,r,n]),f(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${Pm}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(Fm,`${n.height}px`),r.style.setProperty(Im,`${n.offsetTop}px`)},s=0,c=()=>{e.cancelAnimationFrame(s),s=e.requestAnimationFrame(()=>{s=e.requestAnimationFrame(o)})};return o(),n.addEventListener(`resize`,c),n.addEventListener(`scroll`,c),()=>{e.cancelAnimationFrame(s),n.removeEventListener(`resize`,c),n.removeEventListener(`scroll`,c),r.style.removeProperty(Fm),r.style.removeProperty(Im)}},[t,i,a]),u(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${Pm}-panel`))||o()}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),u(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&!e.composedPath().includes(t)&&o()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,i,n,o])}const Rm=V.scope(`reducer`);var zm=class{constructor(e,t){this.messagesSig=e,this.onReconcileNeeded=t,U(this,`active`,null),U(this,`openTextParts`,/* @__PURE__ */ new Map),U(this,`partSeq`,0),U(this,`replay`,null),U(this,`turnChunks`,[]),U(this,`turnRow`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=so();n.id=e.id;let r=Bm(e)||ko(e)&&(e.status!==`streaming`||Oo(e)),i=e.status===`streaming`&&Oo(e)&&Do(e);this.replay={baseline:e,shadow:n,chunks:[t],probeContinuation:r,continuationTailReplay:i,liveCatchUp:e.status===`streaming`&&!r},this.attach(n),this.apply(t)}refreshReplayBaseline(){let e=this.replay;if(!e)return null;let t=e.shadow.serverMessageId??e.baseline.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e.baseline||r?.id===e.baseline.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e.baseline)??n.find(n=>n.id===e.baseline.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e.baseline)return e;let a=e.baseline;return e.baseline=i,Vm(a,i),e.liveCatchUp&&Bm(e.shadow)&&(i.status===`streaming`||ko(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=Bm(i)||ko(i)&&(i.status!==`streaming`||Oo(i)),e.continuationTailReplay=i.status===`streaming`&&Oo(i)&&Do(i),e.liveCatchUp=i.status===`streaming`&&!e.probeContinuation,e)}refreshActive(){let e=this.active;if(!e)return null;let t=e.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e||r?.id===e.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e)??n.find(n=>n.id===e.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e)return e;Vm(e,i);let a=Bm(e)&&ko(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replayTurn(),this.replay?this.replay.shadow:this.active)}replayTurn(){let[e,...t]=this.turnChunks;if(e?.type!==`start`)return;let n=this.messagesSig.value.find(t=>t.serverMessageId===e.messageId);if(n!==void 0&&n!==this.turnRow){this.detach();for(let n of[e,...t])this.applyResume(n)}}promoteReplay(e){let{baseline:t,shadow:n}=e;return r(()=>{t.role=n.role,t.serverMessageId=n.serverMessageId,t.operatorInitials=n.operatorInitials,t.status=n.status,n.canceled&&(t.canceled=!0),t.finishReason=n.finishReason,t.errorText=n.errorText,t.suggestions=n.suggestions??t.suggestions,t.runStartedAt=n.runStartedAt??t.runStartedAt,t.stepTimings=n.stepTimings??t.stepTimings,t.partsSig.value=n.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=t,t}promoteContinuation(e){let{baseline:t,chunks:n}=e,i=jo(t);return this.replay=null,r(()=>{t.partsSig.value=t.partsSig.value.slice(0,Hm(t,n)+1),t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t);for(let e of n)this.apply(e);t.continuationStreaming=i||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}settleOwnedContinuation(e,t){let{baseline:n}=e,i=jo(n);return this.replay=null,r(()=>{n.awaitingContinuation=!1,n.status=`streaming`,n.finishReason=void 0,n.errorText=void 0,n.suggestions=void 0,this.attach(n),this.apply(t),n.continuationStreaming=i||void 0,this.messagesSig.value=[...this.messagesSig.value]}),n}applyResume(e){e.type===`start`&&(this.turnChunks=[]);let t=this.applyTurnChunk(e);return this.turnChunks.push(e),this.turnRow=t??this.replay?.baseline??this.active??this.turnRow,t}applyTurnChunk(e){if(e.type===`start`){let t=(this.replay?.baseline??this.active)?.serverMessageId;t!==void 0&&e.messageId!==void 0&&t!==e.messageId&&this.onReconcileNeeded?.({messageId:t}),this.detach();let n=e.messageId,r=n===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===n||e.id===n);if(r!==void 0)return e.messageMetadata?.senderRole===`visitor`&&r.role===`user`&&(r.status===`pending`||r.status===`error`)&&(r.serverMessageId=n,r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,this.messagesSig.value=[...this.messagesSig.value]),this.beginReplay(r,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&&!So(a))return this.attach(a),this.apply(e),null;let o=so();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.replay){let t=this.refreshReplayBaseline();if(!t)return null;t.chunks.push(e),e.type===`data-control-state`&&(t.baseline.operatorRoutedTurn=e.data.controlMode!==`ai-agent`),this.apply(e);let{baseline:n,shadow:r,probeContinuation:i,continuationTailReplay:a,liveCatchUp:o}=t,s=e.type===`finish`||e.type===`error`||e.type===`abort`;if(i){if(!Km(n,r,e)){if(s){if(n.status===`streaming`&&n.awaitingContinuation!==!0){let n=this.settleOwnedContinuation(t,e);return this.detach(),n}Xm(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()}return null}let i=Bm(n)&&s?this.settleOwnedContinuation(t,e):this.promoteContinuation(t);return s?(i.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:i.serverMessageId??i.id}):i.continuationStreaming=!1),this.detach(),i):null}if(a&&Wm(n,r)){let e=this.promoteContinuation(t);return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!So(n)&&So(r)){let e=this.promoteReplay(t);return this.detach(),e}if(!Um(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay(t);return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyTurnChunk(e);if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let n=t;return n.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}):n.continuationStreaming=!1),this.detach(),n}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:o(``),doneSig:o(!1)};return this.openTextParts.set(r,a),Qm(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?.runStartedAt&&(t.runStartedAt=n.runStartedAt),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`:Qm(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`message-metadata`:t.stepTimings=po(e.messageMetadata?.steps)??t.stepTimings;return;case`finish`:Rm.debug(`finish`,{reason:e.finishReason}),t.stepTimings=po(e.messageMetadata?.steps)??t.stepTimings,t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:Rm.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=void 0,this.bumpDone(t);return;case`abort`:Rm.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,t.retryAction=void 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-input-error`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:case`tool-approval-response`:eh(t,e);return;case`file`:Qm(t,{kind:`file`,url:e.url,mediaType:e.mediaType,filename:e.filename,fileId:e.fileId,fileSize:e.fileSize});return;case`source-url`:$m(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:$m(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=no(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){r(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};function Bm(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function Vm(e,t){e.canceled&&(t.canceled=!0),Bm(e)&&(t.status===`streaming`||ko(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function Hm(e,t){let n=e.partsSig.value,r=t.findIndex(e=>e.type===`start-step`),i=new Set(t.slice(0,r<0?t.length:r).flatMap(e=>`toolCallId`in e&&e.type.startsWith(`tool-output`)?[e.toolCallId]:[])),a=n.findLastIndex(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`||i.has(e.toolCallId)));if(a>=0)return a;let o=new Set(t.flatMap(e=>e.type===`tool-input-start`||e.type===`tool-input-available`?[e.toolCallId]:[]));return n.some(e=>e.kind===`tool`&&o.has(e.toolCallId))?-1:n.findLastIndex(e=>e.kind===`tool`)}function Um(e,t){let n=e.partsSig.value,r=t.partsSig.value;return e.role!==t.role||r.length<n.length?!1:n.every((e,t)=>Gm(e,r[t]))}function Wm(e,t){let n=e.partsSig.value,r=n.findLastIndex(e=>e.kind===`tool`),i=new Set(n.slice(0,r+1).flatMap(e=>e.kind===`tool`?[e.toolCallId]:[])),a=t.partsSig.value.filter(e=>e.kind!==`tool`||!i.has(e.toolCallId)),o=n.slice(r+1);return a.length<o.length?!1:o.every((e,t)=>Gm(e,a[t]))}function Gm(e,t){switch(e.kind){case`text`:case`reasoning`:return t?.kind===e.kind&&t.textSig.value.startsWith(e.textSig.value);case`step-start`:return t?.kind===`step-start`;case`tool`:{if(t?.kind!==`tool`||t.toolCallId!==e.toolCallId||!Uo(t.toolName,e.toolName)||Wo[t.stateSig.value]<Wo[e.stateSig.value])return!1;let n=e.approvalSig.value?.approved;return n===void 0||t.approvalSig.value?.approved===n}case`file`:return t?.kind===`file`&&t.url===e.url&&t.mediaType===e.mediaType;case`source`:return t?.kind===`source`&&t.sourceId===e.sourceId&&t.url===e.url&&t.title===e.title&&t.filename===e.filename&&t.mediaType===e.mediaType;default:return e}}function Km(e,t,n){return qm(e,n)||!Jm(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:Do(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function qm(e,t){if(t.type!==`tool-output-available`&&t.type!==`tool-output-error`&&t.type!==`tool-output-denied`)return!1;let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t.toolCallId);return n!==void 0&&Wo[n.stateSig.value]<4}function Jm(e,t){let n=t.partsSig.value;if(n.length===0)return!0;let r=e.partsSig.value;return r.some((e,t)=>n.every((e,n)=>Ym(r[t+n],e)))}function Ym(e,t){switch(t.kind){case`text`:case`reasoning`:return e?.kind===t.kind&&e.textSig.value.startsWith(t.textSig.value);case`step-start`:return e?.kind===`step-start`;case`tool`:return e?.kind===`tool`&&e.toolCallId===t.toolCallId&&(t.toolName===`tool`||Uo(e.toolName,t.toolName));case`file`:return e?.kind===`file`&&e.url===t.url&&e.mediaType===t.mediaType;case`source`:return e?.kind===`source`&&e.sourceId===t.sourceId&&e.url===t.url&&e.title===t.title&&e.filename===t.filename&&e.mediaType===t.mediaType;default:return t}}function Xm(e,t){if(Bm(e)||!ko(e))return!1;let n=new Set(e.partsSig.value.filter(e=>e.kind===`tool`).map(e=>e.toolCallId));return!t.partsSig.value.some(e=>e.kind===`tool`&&n.has(e.toolCallId))}function Zm(e,t,n={}){let r=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(r)return n.dynamic&&(r.dynamic=!0),r.toolMetadata??(r.toolMetadata=n.toolMetadata),r.title=n.title??r.title,r;let i={kind:`tool`,toolCallId:t,toolName:n.toolName??`tool`,title:n.title,dynamic:n.dynamic?!0:void 0,toolMetadata:n.toolMetadata,inputPartialSig:o(``),inputSig:o(void 0),outputSig:o(void 0),errorSig:o(void 0),stateSig:o(`input-streaming`),approvalSig:o(void 0)};return Qm(e,i),i}function Qm(e,t){e.partsSig.value=[...e.partsSig.value,t]}function $m(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||Qm(e,t)}function eh(e,t){switch(t.type){case`tool-input-start`:Zm(e,t.toolCallId,t);return;case`tool-input-delta`:{let n=Zm(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=Zm(e,t.toolCallId,t);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=Zm(e,t.toolCallId,t);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=Zm(e,t.toolCallId,t);if(t.isAutomatic){n.approvalSig.value={id:t.approvalId,isAutomatic:!0};return}n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-approval-response`:{let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.approvalSig.value?.id===t.approvalId);n?.approvalSig.value&&(n.approvalSig.value={...n.approvalSig.value,approved:t.approved,reason:t.reason});return}case`tool-output-available`:{let n=Zm(e,t.toolCallId,t);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=Zm(e,t.toolCallId,t);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=Zm(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const th=1e3;async function nh(e){let t=th,n=!1,r=!1,i=!1;function a(){i||e.signal.aborted||(i=!0,e.onInitialBoundaryReady())}for(;!e.signal.aborted;){let o,s=`held`;try{s=await e.connect(()=>{if(e.signal.aborted)return;o=e.now();let t=n||r;n=!0,r=!1,i?t&&e.backfill():a()})}catch{}if(e.signal.aborted||(!n&&o===void 0&&(r=!0,a()),s===`unavailable`))return;e.onDropped?.(),o!==void 0&&e.now()-o>=1e3&&(t=th),await e.sleep(t),t=Math.min(t*2,15e3)}}function rh(e){let{activated:t,conversationReady:n,paused:r,conversationIdSig:i,messagesSig:a,optionsRef:o,transport:s,visitorId:c,adoptControlStateChunk:l,adoptMemoryCompactionStateChunk:d,settleSuggestions:f,recordConversationReply:p,transcriptRecoverySig:h,beginConversationTranscript:g,commitConversationTranscript:_,runCancellation:v,feedback:y,bus:b,loadInitialThread:x,shouldReconcileOnConnect:S,reconnectingSig:C}=e,w=m(0);u(()=>{if(!t||!n||r||!i.value)return;let e=i.value,u=new AbortController,m=e=>{},T=new zm(a,e=>m(e));s.primeIdentity(c,e);let E=!1,D=!1,O,k=!1,A,j=0,ee,M,N=Date.now(),P,te=!1,ne=!1,re=!1,F;function ie(t,n){if(!So(t))return;let r=a.value.findLast(e=>!e.ephemeral),i=t.serverMessageId??t.id;if(!(r&&(r.serverMessageId??r.id)!==i)){if(P&&te&&!a.value.some(e=>e.role===`user`&&!e.ephemeral))F={replyId:i,activityAt:n};else return xo(a.value,t,e,o.current.strings.newConversation,n)}}function ae(e,t,n){let r=ie(e,n);if(!r)return;let i=`${e.serverMessageId??e.id}:${t}:${r.preview??``}`;i!==M&&(M=i,s.publishConversation({...r,hasUnread:!0},!0))}let I;function oe(){I&&(clearTimeout(I.timer),I=void 0)}function se(){let e=I;if(!e)return;clearTimeout(e.timer),I=void 0;let t=a.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&ae(t,e.generation,e.activityAt)}function ce(e,t,n){oe(),I={replyId:e.serverMessageId??e.id,generation:t,activityAt:n,timer:setTimeout(se,120)}}function le(e,t,n=Date.now(),r=!0){oe();let i=ie(e,n);if(!i)return;let a=`${e.serverMessageId??e.id}:${t}`;a!==ee&&(ee=a,p(i),r&&P&&!te&&(ne=!0))}function ue(e,t){(e||!v.localSendRef.current)&&v.settle(t)}function L(e,t=[],n=!1,r,i=j,s=Date.now(),c=!0){let l=o.current;if(e.canceled){le(e,i,s,c),ue(n,r);return}let u=!0,d=e.status===`error`;switch(Yo(e,d)){case`drop`:a.value=a.value.filter(t=>t!==e),u=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(y.play(`messageReceived`),Gs(b,l,`assistant`,bo(e)));break;case`error`:if(e.status=`error`,n){y.play(`error`);let e=/* @__PURE__ */ Error(d?`stream error chunk`:`empty reply`);b.emit(`error`,e),l.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(y.play(`messageReceived`),Gs(b,l,`assistant`,bo(e))),f(e,t)}u&&le(e,i,s,c),ue(n,r)}function de(t){if(u.signal.aborted||i.value!==e)return;if(l(t),d?.(t),t.type===`start`){se();let n=t.messageId===void 0?void 0:a.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);k=n!==void 0&&n.status!==`streaming`;let r=A?.senderRole===`visitor`?A.messageId:void 0;A={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},j+=1,N=Date.now(),M=void 0,E=t.messageMetadata?.senderRole===void 0,D=!1,O=E?t.messageMetadata?.runId:void 0;let i=E?t.messageMetadata?.senderMessageId:void 0;function o(e){return e.role===`assistant`&&e.retryAction?.kind===`resend-user`&&e.retryAction.messageId===i}if(i&&a.value.some(o)&&(a.value=a.value.filter(e=>!o(e))),E){let n=t.messageId!==void 0&&a.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),i=a.value.at(-1),o=t.messageId!==void 0&&(i?.serverMessageId===t.messageId||i?.id===t.messageId),s=v.localSendRef.current&&(!n||o)&&i?.role===`assistant`&&i.status===`streaming`&&(o||i.serverMessageId===void 0&&i.partsSig.value.length===0);D=v.captureStart(e,t,s,r)}}let n=E&&(t.type===`finish`||t.type===`error`||t.type===`abort`),r=n?O:void 0,s=n&&(D||v.ownsLocalRun(r)),c=j,f=k;n&&(E=!1,D=!1,O=void 0);let p=T.applyResume(t),m=A?.messageId,h=m===void 0?void 0:a.value.find(e=>e.serverMessageId===m||e.id===m);k&&A?.senderRole!==`visitor`&&(p!==null||h?.status===`streaming`)&&(k=!1,f=!1);let g=!k&&(h?.role===`assistant`||h?.role===`operator`);t.type===`text-delta`&&g&&ce(h,j,N),t.type===`text-end`&&(oe(),g&&ae(h,j,N)),p?p.role===`operator`?(f||(y.play(`messageReceived`),Gs(b,o.current,`operator`,bo(p))),le(p,c,N),k=!1,n&&(s||!v.localSendRef.current)&&v.settle(r)):p.role===`assistant`&&(L(p,[],s,r,c,N),k=!1):n&&(s||!v.localSendRef.current)&&v.settle(r)}async function R(t){let n=j,r=await s.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(u.signal.aborted||i.value!==e||!r)return!1;r.controlState&&l({type:`data-control-state`,data:r.controlState});let o=a.value.at(-1),c=n===j&&(t===void 0||o!==void 0&&(o.serverMessageId===t||o.id===t));if(r.messages.length===0)return!0;let d=a.value,p=t===void 0?d.at(-1):d.find(e=>e.serverMessageId===t||e.id===t),m=Bo(d,_o(r.messages)),h=Ro(r.messages),g=m.messages.filter(e=>!(e.role===`assistant`&&e.retryAction?.kind===`resend-user`&&h.has(e.retryAction.messageId)));if(!m.changed&&g.length===m.messages.length)return!0;a.value=g;let _=t===void 0?g.at(-1):g.find(e=>e.serverMessageId===t||e.id===t),y=p!==void 0&&_!==void 0&&(p.id===_.id||p.serverMessageId!==void 0&&p.serverMessageId===_.serverMessageId),b=_!==void 0&&_.status!==`streaming`&&(!y||p?.status===`streaming`),x=y&&p?.status===`streaming`?Date.now():_?.createdAt;return c&&b&&_.role===`assistant`?L(_,_.suggestions??[],v.localSendRef.current,void 0,n,x,!1):c&&b&&_.role===`operator`?le(_,n,x,!1):c&&_?.role===`assistant`&&_.status!==`streaming`&&f(_,_.suggestions??[]),!0}let fe=/* @__PURE__ */ new Set;m=({messageId:e})=>{if(fe.has(e)||!a.value.some(t=>t.serverMessageId===e||t.id===e))return;fe.add(e);function t(){return fe.delete(e)}R(e).then(t,t)};function z(){let e=F;F=void 0;let t=e&&a.value.find(t=>(t.serverMessageId??t.id)===e.replyId),n=t&&ie(t,e.activityAt);n&&p(n)}function pe(t=!1){if(u.signal.aborted||i.value!==e){ne=!1;return}if(P){ne=!0;return}let n=t?x(e):void 0,r=n??(!t||S()?R():void 0);if(!r)return;g(e),P=r,te=n!==void 0;function a(t=!1){P===r&&(P=void 0,T.replayTurn(),ne?(ne=!1,pe()):(z(),t&&_(e)))}r.then(a,()=>a(!1))}let me=h.subscribe(e=>{e<=w.current||(w.current=e,re&&pe())});return nh({signal:u.signal,now:()=>performance.now(),sleep:e=>Qo(e,u.signal),connect:e=>s.connectResumeStream({signal:u.signal,onChunk:de,onConnected:()=>{C.value=!1,e()}}),onDropped:()=>{C.value=!0},onInitialBoundaryReady:()=>{re=!0,pe(!0)},backfill:()=>pe()}),()=>{u.abort(),C.value=!1,oe(),me(),T.detach()}},[t,n,r,i,i.value,c,s,l,d,f,p,h,g,_,v,a,b,y,x,S,C])}function ih(e){let{transport:t,setStreaming:n}=e,r=m(void 0),i=m(void 0),a=m(!1),o=m(void 0),s=m(!1),c=m(/* @__PURE__ */ new Map),u=m(/* @__PURE__ */ new Set),d=l((e,n)=>{let r=`${e}:${n}`;o.current!==r&&(o.current=r,t.cancelTurn(e,n))},[t]),f=l(e=>{r.current=void 0,i.current=e,a.current=!1,o.current=void 0,s.current=!0,n(!0)},[n]),h=l((e,t)=>{c.current.set(e,{messageId:t})},[]),g=l(e=>{if(e!==void 0){u.current.add(e);let t=u.current.values().next().value;u.current.size>32&&t!==void 0&&u.current.delete(t)}(e===void 0||r.current?.runId===e)&&(r.current=void 0,i.current=void 0,a.current=!1,s.current=!1,n(!1))},[n]),_=l((e,t)=>i.current===e?(i.current=void 0,t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},n(!0),a.current&&d(t.conversationId,t.runId),!0):(g(),!0)):t.runId&&r.current?.runId===t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&d(t.conversationId,t.runId),!0):!1,[d,n,g]),v=l((e,t)=>{let l=c.current.get(e);return l?(c.current.delete(e),!t.runId||u.current.has(t.runId)?!0:l.runId===void 0?(s.current||i.current||(r.current={conversationId:t.conversationId,runId:t.runId},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0)),!0):(l.runId===t.runId&&r.current?.runId===t.runId&&(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&d(t.conversationId,t.runId)),!0)):!1},[d,n]),y=l(e=>i.current===e&&(g(),!0),[g]),b=l(e=>{let t=c.current.get(e);return t?(c.current.delete(e),t.runId===void 0):!1},[]),x=l((e,t,l,f)=>{let p=t.messageMetadata?.runId;if(t.messageMetadata?.senderRole!==void 0||typeof p!=`string`||!p||u.current.has(p))return!1;if(r.current?.runId===p)return s.current;if(s.current)return r.current||!l?!1:(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&d(e,p),!0);let m=[...c.current.values()].filter(e=>e.runId===void 0).find(e=>e.messageId===f);return m?(m.runId=p,r.current={conversationId:e,runId:p},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0),!0):(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&d(e,p),s.current)},[d,n]),S=l(e=>typeof e==`string`&&r.current?.runId===e&&s.current,[]),C=l(()=>{let e=r.current;if(e)return a.current=!0,d(e.conversationId,e.runId),!0;let t=i.current;return t?(a.current=!0,t.then(e=>{e.runId&&d(e.conversationId,e.runId)}).catch(()=>void 0),!0):!1},[d]);return p(()=>({localSendRef:s,begin:f,beginRouted:h,acceptAck:_,acceptRoutedAck:v,reject:y,rejectRouted:b,captureStart:x,ownsLocalRun:S,settle:g,stop:C}),[_,v,f,h,x,S,y,b,g,C])}const ah=V.scope(`send`);function oh(e,t,n,r,i){e.publishConversation({...xo(t,n,r,i),hasUnread:!1},!0)}function sh(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function ch(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||So(e)))}function lh(e,t,n,r,i){let a=ch(t);a?.role===`user`&&sh(a,n)&&oh(e,t,a,r,i)}function uh(e){return e instanceof ns&&e.status===404&&e.errorCode===`CONVERSATION_NOT_FOUND`}function dh(e){return!(e instanceof ns)||e.code===`network`||e.status===void 0||e.status===202||e.status===408||e.status===425||e.status===429||e.status>=500&&e.status<600}function fh(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:u,applyControlState:d,setTicket:f,settleSuggestions:p,runCancellation:m,onConversationNotFound:h}=e,g=l(()=>{let e=r.value??$t();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:l(async({continueExisting:e,turn:l,movedFromConversation:_=!1})=>{let v=g(),y=n.value.at(-1),b=l?[l]:vo(n.value,e),x=b[0];x?.role===`user`&&Jd.markSent(x.id);let S=b.map(yo),C=s.loadUserPrefs(),w=lf(i.tools).then(n=>t.sendTurn(ro({messages:S,conversationId:v,visitorId:c,userPrefs:C,clientTools:uf(n)}),{keepalive:e}));m.begin(w);try{let a=await w;if(r.value!==v||!m.acceptAck(w,a))return!1;if(u(a.conversationId),f({conversationId:a.conversationId,reference:a.ticketReference}),a.runId&&x?.role===`user`&&lh(t,n.value,x,a.conversationId,i.strings.newConversation),!a.runId){let o=await t.loadConversation(a.conversationId).catch(()=>null);if(r.value!==a.conversationId)return!0;if(o){o.controlState&&d(o.controlState);let r=_o(o.messages),{messages:s,changed:c}=Bo(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),u=ch(n.value);u&&l&&sh(u,l)&&oh(t,n.value,u,a.conversationId,i.strings.newConversation);let f=y?n.value.find(e=>e.id===y.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;f&&p(f,f.suggestions??[]),!e&&y?.role===`assistant`&&n.value.includes(y)&&y.serverMessageId===void 0&&!So(y)&&(n.value=n.value.filter(e=>e!==y))}else y?.role===`assistant`&&n.value.includes(y)&&(y.status=`error`,y.errorText=i.strings.errorGeneric,y.retryAction=e?{kind:`continue-assistant`,messageId:y.serverMessageId??y.id}:x?.role===`user`?{kind:`resend-user`,messageId:x.id}:null,n.value=[...n.value])}return!0}catch(c){if(r.value!==v)return!1;if(!m.reject(w))return x?.role===`user`&&lh(t,n.value,x,v,i.strings.newConversation),!0;if(!e&&!_&&x?.role===`user`&&uh(c))return h(x);if(!e&&x?.role===`user`&&c instanceof ns&&c.status===401){let e=y?.role===`assistant`&&y.serverMessageId===void 0?y:void 0;return n.value=n.value.filter(t=>t!==x&&t!==e),s.saveDraft(v,bo(x)),!1}let u=Zl(c,i.strings),f=dh(c),g=l?.role===`assistant`?l:n.value.at(-1);if(e&&g?.role===`assistant`&&c instanceof ns&&c.status===409){let e=g.serverMessageId??g.id,i=await t.loadConversation(v,{ids:[e]}).catch(()=>null);if(r.value!==v)return!1;if(i){i.controlState&&d(i.controlState);let t=_o(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Vo(g,r)){let{messages:r,changed:i}=Bo(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==g)return a.awaitingContinuation=!1,a.continuationStreaming=void 0,a.retryAction=null,n.value=r,a.status!==`streaming`&&p(a,a.suggestions??[]),!0}}if(!n.value.includes(g)||g.status!==`streaming`)return!1;g.continuationStreaming=!0}if(e&&g?.role===`assistant`)g.status=`error`,g.errorText=u,g.retryAction=f?{kind:`continue-assistant`,messageId:g.serverMessageId??g.id}:null,n.value=[...n.value];else if(y?.role===`assistant`&&n.value.includes(y)){y.status=`error`,y.errorText=u;let e=b[0];y.retryAction=f&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=so();e.status=`error`,e.errorText=u;let t=b[0];e.retryAction=f&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,c),i.onError?.(c),!1}},[t,n,i,a,o,s,c,u,d,f,p,g,m,h]),sendRoutedTurn:l(async e=>{let l=g();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),Jd.markSent(e.id);let d=[yo(e)],p=s.loadUserPrefs(),_=lf(i.tools).then(e=>t.sendTurn(ro({messages:d,conversationId:l,visitorId:c,userPrefs:p,clientTools:uf(e)})));m.beginRouted(_,e.id);try{let a=await _;return r.value===l?m.acceptRoutedAck(_,a)?(u(a.conversationId),f({conversationId:a.conversationId,reference:a.ticketReference}),lh(t,n.value,e,a.conversationId,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0):!1:(m.rejectRouted(_),!1)}catch(s){let c=m.rejectRouted(_);if(r.value!==l)return!1;if(!c)return lh(t,n.value,e,l,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0;if(e.status!==`pending`)return lh(t,n.value,e,l,i.strings.newConversation),!0;if(uh(s))return h(e);ah.debug(`operator-routed send failed`,{error:s});let u=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=Zl(s,i.strings),e.retryAction=dh(s)?{kind:`resend-user`,messageId:e.id}:null,n.value.includes(e)&&(n.value=[...n.value]),o.play(`error`),a.emit(`error`,u),i.onError?.(u),!1}},[t,n,i,a,o,s,c,u,f,g,m,h])}}const ph=V.scope(`unread`);function mh(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=c(!1),d=c(0),f=c(0),p=m([]),h=m(void 0),g=m(!1),_=m(!1),v=l(()=>{let e=r.value,t=i.current()&&h.current===e?e:void 0,n=p.current.filter(e=>e.hasUnread&&e.conversationId!==t).length;d.value=n,s.value=n>0},[r,s,d,i]),y=l(e=>{let t=r.value,n=p.current.find(e=>e.conversationId===t),i=ys(p.current,e),a=i.find(e=>e.conversationId===t),o=e.type===`snapshot`&&t!==void 0&&a?.hasUnread===!0&&h.current===t&&n!==void 0&&n.lastMessageAt!==a.lastMessageAt;o&&(h.current=void 0),p.current=i,v(),o&&(f.value+=1)},[r,v,f]),b=l(()=>{if(v(),!i.current())return;let e=r.value;if(!e||h.current!==e)return;let n=p.current.find(t=>t.conversationId===e);n?.hasUnread&&t.markRead(e,n.lastMessageAt)},[r,i,v,t]),x=l(e=>{r.value===e&&(h.current=void 0,v())},[r,v]),S=l(e=>{r.value===e&&(h.current=e,b())},[r,b]),C=l(e=>h.current===e,[]),w=l((e=!1)=>{if(!n.history.enabled||!n.modules.list.some(e=>e.layout===`chat`))return;function r(e){g.current?e&&(_.current=!0):(g.current=!0,t.listConversations({limit:50},e).then(t=>{e||y({type:`snapshot`,result:t,requestedRevision:0}),b()}).catch(e=>ph.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{g.current=!1,_.current&&(_.current=!1,r(!0))}))}r(e)},[y,b,n.history.enabled,n.modules,t]),T=l(e=>{let n=e.conversationId,a=i.current()&&r.value===n&&h.current===n,o=p.current.find(e=>e.conversationId===n),s=a&&(o?.lastMessageAt!==e.lastMessageAt||o.hasUnread);t.publishConversation({...e,hasUnread:!a},!0),s&&t.markRead(n,e.lastMessageAt)},[r,i,t]);u(()=>t.subscribeConversationChanges(y),[y,t]);let E=m(!1);return u(()=>{a&&o&&!E.current&&(E.current=!0,w())},[a,o,w]),u(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(b(),w(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,b,w]),{hasUnreadSig:s,unreadCountSig:d,transcriptRecoverySig:f,markVisibleConversationRead:b,beginConversationTranscript:x,commitConversationTranscript:S,isConversationTranscriptCommitted:C,recordConversationReply:T,refreshUnread:w}}const hh=V.scope(`settings`);function gh(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,d]=h(()=>s.locale??t.locale),[f,p]=h(s.themeMode),m=_t(t.themeMode,f),[g,_]=h(()=>s.textSize??t.textSize),v=l(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>hh.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);u(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),u(()=>{if(m!==`host`)a.dataset.theme=m;else return _n(e=>{a.dataset.theme=e})},[a,m,t]),u(()=>{a.dataset.textSize=g},[a,g,t]),u(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:v({soundMuted:t})})},[i,v]);let y=ct(c,t.availableLocales,t.defaultLocale);return u(()=>{r.setLocale(y)},[r,y]),u(()=>{a.dir=ee(y)?`rtl`:`ltr`},[a,y]),u(()=>{y!==c&&d(y)},[y,c]),{activeLocale:c,activeThemeMode:m,activeTextSize:g,setActiveLocale:d,setActiveThemeMode:p,setActiveTextSize:_,patchAndSync:v,handleLocaleChange:l(e=>{hh.info(`localeChange`,{locale:e}),d(e),v({locale:e}),o.emit(`localeChange`,e)},[v,o]),handleThemeChange:l(e=>{hh.info(`themeChange`,{mode:e}),p(e),a.dataset.theme=e,v({themeMode:e}),o.emit(`themeChange`,e)},[a,v,o]),handleTextSizeChange:l(e=>{hh.info(`textSizeChange`,{size:e}),_(e),a.dataset.textSize=e,v({textSize:e}),o.emit(`textSizeChange`,e)},[a,v,o]),handleSoundToggle:l(()=>{i.toggleMuted();let e=i.mutedSig.value;hh.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=V.scope(`app`),_h=P.cssPrefix,vh={home:`home`,chats:`chat`,help:`help`,news:`news`};function yh({options:e,hostElement:t,bus:n,recentHostEvents:i,loginRevision:o=0,onPersonChanged:d,onStartAsGuest:g}){let y=e.aiAgentDeploymentId;if(!y)throw Error(`aiAgentDeploymentId is required`);let[b]=h(()=>nn(e.widgetId,e.storage,e.aiAgentDeploymentId)),[x,S]=h(()=>b.getVisitorId()),C=b.loadUserPrefs(),w=c(b.loadConversationId()),T=m(w.value!==void 0),D=c(w.value??``),O=c([]),k=c(!1),[A,j]=h(!1),ee=m(void 0);function N(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=b.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function te(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function ne(){let t=te();return t?e.modules.list.length===1||F.sig.value.activeTab===t:!1}let re=m(void 0);if(!re.current){let t=e.modules.list.map(e=>e.id),n=b.loadActiveModule()??t[0]??``;re.current=Js(n,n?[...t,n]:t,e=>b.saveActiveModule(e))}let F=re.current,ie=s(()=>F.sig.value.activeTab).value,ae=s(()=>w.value).value,[I,oe]=h(!1),[se,ce]=h(!1),le=e.mode===`standalone`||e.mode===`inline`,ue=m(tc(e,nc(),b.loadPanelOpen(),b.loadPanelSize())),[L,de]=h(ue.current.panelOpen),[R,fe]=h(ue.current.panelOpen),z=m(void 0),pe=m(void 0),me=m(!1),he=m(void 0),B=m(e.strings),ge=m(void 0);u(()=>{L&&fe(!0)},[L]);let _e=m(!1),[ve,ye]=h(!1),be=m(null),xe=m(!1),{dismissed:Se,dismissCallout:Ce}=Om({callout:e.launcher.callout,persistence:b}),we=e.launcher.callout?.persistent??!0,Te=l(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),Ce()},[n,Ce]),[Ee,De]=h(ue.current.panelSize),Oe=m(!1),[ke,Ae]=h(`chat`),je=m(()=>!1);je.current=()=>L&&ke===`chat`&&!document.hidden&&ne();let[Me,Ne]=h(!1),Pe=m(Me);Pe.current=Me;let Fe=m(null),[Ie,Le]=h(!1),Re=c(/* @__PURE__ */ new Map),ze=l((e,t)=>{let n=new Map(Re.value);t?n.set(e,t):n.delete(e),Re.value=n},[Re]),[Be,Ve]=h(null),[He,Ue]=h(),[We,Ge]=h([]),Ke=m(e);Ke.current=e;let[qe,Je]=h(void 0),[Ye,Xe]=h(void 0),[V,Ze]=h(()=>b.loadSidebarCollapsed()??!1),[Qe,$e]=h({status:`anonymous`}),[et,tt]=h({}),[nt,rt]=h(),[H]=h(()=>new Es({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Mn({publicKey:e.publicKey,aiAgentDeploymentId:y,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:i,onLoginState:$e,continueLink:e.continueLink})),[it]=h(()=>new ar(e.sound,e.haptics)),at=ih({transport:H,setStreaming:Ne}),{activeLocale:ot,activeThemeMode:st,activeTextSize:ct,setActiveLocale:lt,setActiveThemeMode:ut,setActiveTextSize:dt,patchAndSync:ft,handleLocaleChange:pt,handleThemeChange:mt,handleTextSizeChange:ht,handleSoundToggle:gt}=gh({options:e,persistence:b,transport:H,feedback:it,hostElement:t,bus:n}),{controlModeSig:_t,assignedOperatorSig:yt,operatorAvailableSig:bt,applyControlState:xt,adoptControlStateChunk:St,requestOperator:Ct,cancelOperatorRequest:wt}=Nm({transport:H,conversationIdSig:w}),Tt=c(/* @__PURE__ */ new Map),Et=l(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=w.value;if(!t)return;let n=to(e.data);if(!n)return;let r=Tt.value.get(t);if(r&&(n.postFinishSequence<r.postFinishSequence||n.postFinishSequence===r.postFinishSequence&&(r.status===`ready`||r.status===n.status)))return;let i=new Map(Tt.value);i.set(t,n),Tt.value=i},[w,Tt]),{hasUnreadSig:Dt,unreadCountSig:Ot,transcriptRecoverySig:kt,markVisibleConversationRead:At,beginConversationTranscript:jt,commitConversationTranscript:Mt,isConversationTranscriptCommitted:Nt,recordConversationReply:Pt,refreshUnread:Ft}=mh({transport:H,options:e,conversationIdSig:w,isConversationVisibleRef:je,activated:R,conversationReady:I}),It=Mm({state:Qe,deployment:et,bus:n,persistence:b,conversationIdSig:w}),Lt=L&&e.modules.byId[ie]?.layout===`home`,Rt=Dm({transport:H,options:e,persistence:b,enabled:I&&Lt});u(()=>{At()},[ie,L,ke,ae,At]),u(()=>{it.update(e.sound,e.haptics)},[it,e.sound,e.haptics]),u(()=>()=>it.destroy(),[it]),u(()=>{!Oe.current&&e.size.initialSize&&(Oe.current=!0,b.loadPanelSize()||De(ec(e.mode,e.size,nc())))},[e.mode,e.size,b]),u(()=>{if(!I||_e.current)return;_e.current=!0;let t=tc(e,nc(),b.loadPanelOpen(),b.loadPanelSize());de(t.panelOpen),De(t.panelSize)},[I,e,b]);let zt=m(null);u(()=>{I&&F.reconcile(e.modules.list.map(e=>e.id),N())},[I,e.modules.list,F]);let Bt=l(e=>{e&&e.length!==0&&(O.value=e.map(e=>co({...e,text:M(B.current,e.text)})))},[O]),Vt=m(0),Ht=m(0),Ut=l(e=>{if(e===w.value)return;let t=w.value;Ht.current++,j(!1),t&&(b.saveDraft(e,b.loadDraft(t)),b.saveDraft(t,``),b.saveMessageQueue(e,b.loadMessageQueue(t)),b.saveMessageQueue(t,[])),w.value=e,b.saveConversationId(e),H.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,w,b,H]),Wt=l(e=>{let t=e.map(e=>e.createdAt).filter(e=>e!==void 0),n=(t.length?Math.min(...t):Date.now())-1;return[...(he.current?.messages??[]).map(e=>{let t=co({...e,text:M(B.current,e.text)});return t.createdAt=n,t}),...e]},[]),Gt=l(async e=>{let t=Ht.current;function r(){return t!==Ht.current||w.value!==e}pe.current===e&&(pe.current=void 0),j(!0);try{let t=await H.loadConversation(e);if(r())return!1;let n=_o(t.messages),i=Wt(zo(n,O.value));if(O.value=i,pe.current=i.some(e=>e.role===`user`)?void 0:e,n.length>0||t.controlState!==void 0){Ue({conversationId:e,reference:t.ticketReference}),t.controlState&&xt(t.controlState);let r=n.findLast(e=>e.role===`assistant`&&!e.ephemeral);Ge(r?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),Ke.current.onError?.(t)),!1}finally{r()||j(!1)}},[H,O,w,Wt,n]),Kt=l(e=>{if(z.current===e)return z.current=void 0,Gt(e)},[Gt]),qt=l(()=>{if(ee.current)return Promise.resolve(void 0);let t=w.value,r=O.value.find(e=>e.serverMessageId!==void 0),i=r?.serverMessageId,a=r?new Date(r.createdAt).toISOString():void 0;if(!t||!i||!a)return Promise.resolve(void 0);let o=Ht.current,s={};return ee.current=s,(async()=>{try{let e=await H.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(ee.current!==s||Ht.current!==o||w.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(fo),r=O.value,c=Mo(r,n);if(c!==r){let e=Math.min(...n.map(e=>e.createdAt??1/0));if(Number.isFinite(e))for(let t of r){if(!t.ephemeral)break;(t.createdAt??1/0)>=e&&(t.createdAt=e-1)}O.value=c}return!0}catch(r){if(ee.current!==s||Ht.current!==o||w.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{ee.current===s&&(ee.current=void 0)}})()},[n,w,O,e,H]),Jt=l(async({newConversation:t})=>{let i=++Vt.current;function a(){return i!==Vt.current}if(!t){let e=await H.userSub(),t=b.loadLastUserSub();if(a())return;if(t&&t!==e){d?.();return}e&&b.saveLastUserSub(e)}let o=w.value,s=t||!o?$t():o;s!==o&&(Ht.current++,j(!1),r(()=>{w.value=s,D.value=s}),b.saveConversationId(s)),H.primeIdentity(x,s);let c;try{c=await H.handshake({visitorId:x,conversationId:s,userPrefs:b.loadUserPrefs(),locale:ot})}catch(r){if(a())return;n.emit(`error`,r),e.onError?.(r);let i=r instanceof ns&&r.errorCode?xh[r.errorCode]:void 0;if(i){$.warn(`the widget is not shown: ${i}`),(le||e.mode===`page`)&&ce(!0);return}t||oe(!0);return}if(a())return;e.continueLink&&c.visitorId!==x&&S(c.visitorId),c.conversationId!==s&&Ut(c.conversationId),ge.current=c;let l=E(c,ot);Ve(l.agent),tt(lr(c.config?.login));let u=c.config?.maxMessageCharacters;rt(typeof u==`number`&&u>0?u:void 0),l.site&&sr(l.site)?Je(l.site):l.site&&$.warn(`invalid site config, using fallback`,{site:l.site}),l.blocks&&cr(l.blocks)?Xe(l.blocks):l.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:l.blocks});let f=on(c.userPrefs);if(Object.keys(f).length>0&&!t&&(b.saveUserPrefs(f),f.locale&&lt(f.locale),f.soundMuted!==void 0&&it.setMuted(f.soundMuted),f.themeMode&&ut(f.themeMode),f.textSize&&dt(f.textSize)),he.current=l.welcome,t||n.emit(`handshake`,c),l.welcome?.suggestions){let e=B.current;Ge(l.welcome.suggestions.map(t=>({...t,label:M(e,t.label),...t.text===void 0?{}:{text:M(e,t.text)}})))}let p=!t&&(c.conversationId===o||e.continueLink!==void 0);T.current=p,p?me.current||(z.current=c.conversationId):(pe.current=c.conversationId,Bt(l.welcome?.messages),Mt(c.conversationId)),t||oe(!0)},[H,x,b,e,n,w,D,it,Bt,ot,Ut,Mt,d]),Yt=JSON.stringify(e.userContext??null),Xt=JSON.stringify(e.pageContext??null);u(()=>{H.setContext(e.userContext,bh(e.pageContext))},[H,Yt,Xt]);let Zt=m(!1);u(()=>{H.setUserToken(e.userToken),Zt.current?Jt({newConversation:!1}).then(()=>{R&&Ft(!0)}):Zt.current=!0},[H,e.userToken,o]);let Qt=l((e,t=[])=>Ge(e.suggestions??t),[]);u(()=>(H.primeIdentity(x,w.value),Jt({newConversation:!1}),()=>{Vt.current++,Ht.current++}),[]),u(()=>{R&&I&&!me.current&&(me.current=!0,z.current===w.value&&j(!0))},[R,I]);let en=m(Yt);u(()=>{I&&en.current!==Yt&&(en.current=Yt,Jt({newConversation:!1}))},[Yt,I,Jt]);let tn=m(async()=>!1),{sendAiTurn:rn,sendRoutedTurn:an}=fh({onConversationNotFound:e=>tn.current(e),transport:H,messagesSig:O,conversationIdSig:w,options:e,bus:n,feedback:it,persistence:b,visitorId:x,adoptConversationId:Ut,applyControlState:xt,setTicket:Ue,settleSuggestions:Qt,runCancellation:at}),{toolInteraction:sn,pageToolsRunning:cn,stopPageTools:ln}=Tm({streaming:Me,controlModeSig:_t,messagesSig:O,sendAiTurn:rn,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),un=l((e,t)=>{let r=O.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),H.submitFeedback({messageId:e,value:t})},[n,O,H]),dn=l(()=>T.current||O.value.some(e=>!e.ephemeral&&e.role===`user`),[O]);rh({activated:R,conversationReady:I,paused:Qe.status===`pending`||Qe.status===`expired`,conversationIdSig:w,messagesSig:O,optionsRef:Ke,transport:H,visitorId:x,adoptControlStateChunk:St,adoptMemoryCompactionStateChunk:Et,settleSuggestions:Qt,recordConversationReply:Pt,transcriptRecoverySig:kt,beginConversationTranscript:jt,commitConversationTranscript:Mt,runCancellation:at,feedback:it,bus:n,loadInitialThread:Kt,shouldReconcileOnConnect:dn,reconnectingSig:k});let fn=l(async(t,r,i)=>{if(Fe.current||It.gate)return!1;let a=w.value,o=a?Tt.value.get(a):void 0,s=_t.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:Pe.current,routedToOperator:s}),Pe.current&&!s))return!1;let c=new AbortController,l={conversationId:a,controller:c};Fe.current=l,Le(!0);try{it.unlock(),Re.value=/* @__PURE__ */ new Map;let o=await wh(H,r,c.signal,ze,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||w.value!==a)return!1;let s=a?Tt.value.get(a):void 0,l=_t.value!==`ai-agent`;if(!l&&s?.status===`compacting`||Pe.current&&!l||!i&&o.length<r.length||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),We.length>0&&Ge([]),it.play(`messageSent`);let u=oo(t,o,i);return Gs(n,e,`user`,t),l?(O.value=[...O.value,u],i?await an(u):(an(u),!0)):(O.value=[...O.value,u,so()],i?await rn({continueExisting:!1}):(rn({continueExisting:!1}),!0))}finally{Fe.current===l&&(Fe.current=null,Le(!1))}},[H,n,e,We.length,O,w,Tt,rn,an,_t,Re,ze,It.gate]),pn=m(fn);pn.current=fn;let mn=w.value,hn=(mn?Tt.value.get(mn):void 0)?.status===`compacting`,gn=_t.value===`ai-agent`,_n=s(()=>{let e=O.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`))}),vn=s(()=>O.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));f(()=>{let e=w.value;return()=>{let t=Fe.current;t&&t.conversationId===e&&(Fe.current=null,Le(!1),t.controller.abort())}},[w.value]);let yn=l(()=>{if(Fe.current){$.info(`stop uploads`),Fe.current.controller.abort();return}if(cn){$.info(`stop page tools`),n.emit(`stop`,void 0),ln();return}if(!at.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=O.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,O.value=[...O.value])},[at,n,O,cn,ln]),bn=l(e=>{$.info(`card action`,{text:e}),pn.current(e,[])},[]),xn=l(e=>{if(Me)return;let t=O.value,n=qo(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(_t.value!==`ai-agent`||e.role!==`assistant`||(e.serverMessageId??e.id)!==n.messageId)return;e.status=`streaming`,e.errorText=void 0,e.retryAction=void 0,e.awaitingContinuation=!0,O.value=[...t],rn({continueExisting:!0,turn:e});return;case`resend-user`:{let r=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!r)return;let i=e=>{e&&zt.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,_t.value!==`ai-agent`){O.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],an(r).then(i);return}let a=so();O.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],rn({continueExisting:!1,turn:r}).then(i);return}case`repeat-user`:{let e=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!e)return;let r=oo(bo(e),e.attachments?.map(e=>({...e}))??[]),i=new Set(r.attachments?.flatMap(e=>e.url?[e.url]:[])??[]),a=e.partsSig.value.flatMap(e=>e.kind===`file`&&!i.has(e.url)?[{...e}]:[]);if(a.length>0&&(r.partsSig.value=[...r.partsSig.value,...a]),_t.value!==`ai-agent`){O.value=[...t,r],an(r);return}O.value=[...t,r,so()],rn({continueExisting:!1,turn:r});return}default:return n}},[Me,O,_t,rn,an]),Sn=l(()=>{Ws(e.mode,Ee)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),De(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),xe.current=t.contains(t.ownerDocument.activeElement),de(!1),b.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,b,Ee,t]);Lm({hostElement:t,mode:e.mode,panelSize:Ee,isOpen:L,surfaceReady:I,onClose:Sn}),u(()=>{!L&&xe.current&&(xe.current=!1,be.current?.focus())},[L]);let Cn=l(()=>{$.info(`open`,{mode:e.mode}),it.unlock(),ye(!0),de(!0),b.savePanelOpen(!0),!Se&&!we&&Te(),setTimeout(()=>ye(!1),Sh),n.emit(`open`,void 0),e.onOpen?.()},[n,e,it,b,Se,we,Te]),wn=l(()=>{let e=O.value.some(e=>e.role===`user`);if(pe.current===w.value&&!e&&w.value)$.info(`clear → reusing empty conversation`,{conversationId:w.value}),O.value.length===0&&Bt(he.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:Me}),n.emit(`clear`,void 0),at.settle(),T.current=!1,z.current=void 0,pe.current=void 0,r(()=>{O.value=[],w.value=void 0,xt({controlMode:`ai-agent`,controlRevision:0})}),b.clearConversation(),Ge([]),Jt({newConversation:!0})},[Me,O,w,b,Jt,n,Bt,at,xt]);tn.current=async e=>($.info(`conversation not found → new conversation`,{messageId:e.id}),await wn(),e.status=`complete`,e.errorText=void 0,e.retryAction=void 0,O.value=[...O.value,e,so()],rn({continueExisting:!1,turn:e,movedFromConversation:!0}));let Tn=l(()=>{let t=wn();Ae(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&F.switchTab(n),t},[wn,F,e]),En=l(async e=>{await Tn(),await pn.current(e,[])||zt.current?.fill(e)},[Tn]),Dn=l(()=>{let e=Ee===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:Ee,expanded:e===`expanded`}),De(e),b.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,Ee,b]),On=l(()=>{let e=Ee===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:Ee,fullscreen:e===`fullscreen`}),De(e),b.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,Ee,b]),kn=l(()=>{Ae(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),An=l(()=>{Ze(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),b.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[b,n]),jn=l(e=>{$.info(`resize`,e),ft({widgetSize:e}),n.emit(`resize`,e)},[ft,n]),Nn=l(async t=>{let i=t.conversationId;if(i===w.value&&Nt(i)){$.info(`selectConversation`,{conversationId:i,cached:!0}),n.emit(`selectConversation`,{conversationId:i}),H.publishConversation(t),Ae(`chat`);let e=te();e&&F.switchTab(e),Mt(i);return}let a=++Vt.current;Ht.current++,j(!1);function o(){return a!==Vt.current}$.info(`selectConversation`,{conversationId:i,wasStreaming:Me}),n.emit(`selectConversation`,{conversationId:i}),H.publishConversation(t);try{let e=await H.loadConversation(i);if(o())return;at.settle(),T.current=!0,z.current=void 0;let t=_o(e.messages),n=e.conversationId!==w.value,a=n?t:zo(t,O.value);pe.current=a.some(e=>e.role===`user`)?void 0:e.conversationId,r(()=>{O.value=Wt(a),n&&(D.value=e.conversationId),w.value=e.conversationId}),b.saveConversationId(e.conversationId),H.primeIdentity(x,e.conversationId),Ue({conversationId:e.conversationId,reference:e.ticketReference}),e.controlState&&xt(e.controlState);let s=a.findLast(e=>e.role===`assistant`&&!e.ephemeral);Ge(s?.suggestions??[]),n?jt(e.conversationId):Mt(e.conversationId),Ae(`chat`);let c=te();c&&F.switchTab(c)}catch(t){if(o())return;n.emit(`error`,t),e.onError?.(t)}},[H,O,w,D,n,e,b,Wt,Me,x,at,jt,Mt,Nt,F]),Rn=m(void 0),Vn=l(t=>{let n=e.modules.list.find(e=>e.layout===vh[t.to]);if(!n){$.warn(`open: the widget has no such tab`,{to:t.to});return}let r=t.id&&(n.layout===`help`||n.layout===`news`)?{kind:`content`,id:t.id,title:``}:void 0;F.open(n.id,r)},[e.modules,F]),Un=l(e=>{L||Cn(),e!=null&&(Pn(e)?I?Vn(e):Rn.current=e:$.warn(`open: unknown target`,{detail:e}))},[L,Cn,I,Vn]);u(()=>{I&&Rn.current&&(Vn(Rn.current),Rn.current=void 0)},[I,Vn]);let Wn=I&&!A&&(!gn||!vn.value),[Gn,U]=h(),Kn=l(e=>{let t=Ln(e);t?(L||Cn(),U(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[L,Cn]),Jn=L&&I&&!A,Yn=Jn&&Wn&&!Ie&&!(gn&&(Me||hn));u(()=>{if(Gn===void 0||!(Gn.send?Yn:Jn))return;let e=te();e?ke!==`chat`||!ne()?(Ae(`chat`),F.switchTab(e)):(U(void 0),Gn.send?fn(Gn.text,[]).then(e=>{e||zt.current?.fill(Gn.text)}):zt.current?.fill(Gn.text)):($.warn(`ask: the widget has no chat`),U(void 0))},[Gn,Jn,Yn,ke,ie,e.modules,F,fn]),u(()=>{if(e.widgetId!=="default")return;let n=`data-${P.cssPrefix}-`,r=[`ask`,`open`,`close`].map(e=>n+e);function i(e){let i=e.composedPath().find(e=>e instanceof Element&&r.some(t=>e.hasAttribute(t)));if(!(i instanceof Element))return;e.preventDefault();let a=i.getAttribute(`${n}ask`),o=i.getAttribute(`${n}open`);a===null?o===null?zn(t,`close`):zn(t,`open`,Fn(o)):zn(t,`ask`,In(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,i),()=>document.removeEventListener(`click`,i)},[e.widgetId,t]),u(()=>{if(e.widgetId!=="default")return;let n=Hn(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?zn(t,`ask`,In(n.ask)):zn(t,`open`,n.target))},[e.widgetId,t]);let Xn=m(qn),Zn=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;u(()=>a(()=>{let e=w.value,t={open:Zn||L,ready:I,unread:Ot.value,...e?{conversationId:e}:{}},r=Xn.current;(t.open!==r.open||t.ready!==r.ready||t.unread!==r.unread||t.conversationId!==r.conversationId)&&(Xn.current=t,n.emit(`state`,t),t.unread!==r.unread&&n.emit(`unread`,t.unread))}),[n,Zn,L,I,Ot,w]);let Qn=m({handleOpenCommand:Un,handleClose:Sn,handleExpand:Dn,handleFullscreen:On,handleAskCommand:Kn});Qn.current={handleOpenCommand:Un,handleClose:Sn,handleExpand:Dn,handleFullscreen:On,handleAskCommand:Kn},f(()=>Bn(t,{open:e=>Qn.current.handleOpenCommand(e),close:()=>Qn.current.handleClose(),expand:()=>Qn.current.handleExpand(),fullscreen:()=>Qn.current.handleFullscreen(),ask:e=>Qn.current.handleAskCommand(e)}),[t]);let W=p(()=>vt(e,ot,st,ct),[e,ot,st,ct]);B.current=W.strings,u(()=>{let e=ge.current;if(!e?.translations?.length)return;let t=E(e,ot);Ve(t.agent),t.site&&sr(t.site)&&Je(t.site),t.blocks&&cr(t.blocks)&&Xe(t.blocks)},[ot]);function $n(e){Nn(e)}let er={options:W,transport:H,feedback:it,bus:n,persistence:b,conversationId:w.value??``,composerKey:D.value,composerApiRef:zt,view:ke,isStreaming:Me,pageToolRunning:cn,isMemoryCompacting:hn,canReleaseQueuedMessages:Wn,queueManualMessages:gn&&vn.value,replyAwaitsCard:gn&&_n.value,sendPreparing:Ie,attachmentUploadsSig:Re,composerActive:W.mode===`page`||W.mode===`inline`||W.mode===`standalone`||L,controlMode:_t.value,assignedOperator:yt.value,operatorAvailable:bt.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:Ct,onCancelOperatorRequest:wt,loadingMessages:A,onLoadPreviousMessages:qt,messagesSig:O,reconnectingSig:k,agent:Be,ticketReference:He?.conversationId===w.value?He?.reference:void 0,login:It,onStartAsGuest:g,maxMessageCharacters:nt,suggestions:We,initialWidgetSize:C.widgetSize??null,onClear:wn,onExpand:Dn,onFullscreen:On,onSoundToggle:gt,onToggleHistory:kn,onSelectHistoryConversation:$n,onNewConversation:Tn,onLocaleChange:pt,onThemeChange:mt,onTextSizeChange:ht,onWidgetSizeChange:jn,onSend:fn,onStop:yn,onSuggestion:t=>{if(Fe.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?fn(r,[]):zt.current?.fill(r)},tool:sn,onRetry:xn,onMessageFeedback:un,onCardAction:bn};if(se)return/* @__PURE__ */ _(`div`,{class:`${_h}-anchor`,children:/* @__PURE__ */ _(bm,{strings:W.strings,text:W.strings.chatUnavailable})});if(!I)return null;let tr=W.modules.list;function nr(e){let t=Hs(`close`,W.mode,e)?Sn:void 0;return tr.length===0?/* @__PURE__ */ _(bm,{strings:W.strings,text:W.strings.modulesEmpty,onClose:t}):tr.length===1&&tr[0]?.layout===`chat`?/* @__PURE__ */ _($p,{...er,panelSize:e,onClose:t}):/* @__PURE__ */ _(dm,{panelProps:{...er,panelSize:e,onClose:t},enabledModules:tr,nav:F,bus:n,hasUnread:Dt.value,latestNews:Rt,onSelectConversation:$n,onStartNewConversation:En,onSetPanelSize:De})}if(e.mode===`page`){let t=e.history.enabled&&tr.some(e=>e.layout===`chat`);return/* @__PURE__ */ _(`div`,{class:`${_h}-anchor`,children:/* @__PURE__ */ _(vm,{site:qe,blocks:Ye,transport:H,strings:W.strings,locale:W.locale,persistence:b,showConversations:t,onSelectConversation:$n,onNewConversation:Tn,sidebarCollapsed:V,onToggleSidebarCollapsed:An,children:nr(`fullscreen`)})})}if(le){let t=e.mode===`standalone`?`fullscreen`:Ee;return/* @__PURE__ */ _(`div`,{class:`${_h}-anchor`,children:nr(t)})}let rr=e.mode===`drawer`,ir=e.mode!==`modal`&&!e.launcher.hidden&&(!L||ve),or=ir&&!ve&&!Se&&!rr?W.launcher.callout:null;return/* @__PURE__ */ v(`div`,{class:`${_h}-anchor`,"data-launcher-size":W.launcher.size,children:[L||R?/* @__PURE__ */ _(`div`,{class:`${_h}-surface`,hidden:!L,children:nr(Ee)}):null,ir?/* @__PURE__ */ _(ul,{buttonRef:be,onToggle:Cn,launcher:W.launcher,strings:W.strings,leaving:ve,edgeTab:rr}):null,or?/* @__PURE__ */ _(hl,{callout:or,launcherPosition:W.position,strings:W.strings,closeLabel:W.strings.close,onDismiss:Te}):null]})}function bh(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const xh={AI_AGENT_PUBLIC_ACCESS_NOT_FOUND:`the deployment was not found or is turned off`,AI_AGENT_PUBLIC_ORIGIN_NOT_ALLOWED:`this website is not in the deployment's allowed origins`},Sh=120,Ch=/* @__PURE__ */ new WeakMap;async function wh(e,t,n,r,i){return(await Promise.all(t.map(async t=>{try{r(t.id,{status:`uploading`});let i=Ch.get(t)??await e.uploadFile(t.file,n,e=>r(t.id,{status:`uploading`,fraction:e}));return Ch.set(t,i),r(t.id,{status:`done`}),{id:i.id,name:i.originalName,mediaType:i.mimeType,size:i.fileSize,url:i.url}}catch(e){r(t.id,n.aborted?void 0:{status:`error`,refusal:e instanceof ns&&e.status===400?e.errorCode:void 0}),i(e);return}}))).filter(e=>e!==void 0)}const Th=V.scope(`error-boundary`);var Eh=class extends e{constructor(...e){super(...e),U(this,`state`,{crashed:!(`toSorted`in Array.prototype)})}componentDidCatch(e,t){Th.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}};function Dh(e){let{bus:r,host:i,appRoot:a,persistence:o,reportError:s}=e,c=e.initialRaw,l,u,d=at(c),f=o.loadUserPrefs().locale??d.locale,p=!0,m=0,h=0,g=Qt(r);function _(){let e=l&&E({config:l,translations:u},f).config;d=at(e?xt(c,e):c)}function v(){xn(i,Sn(d.mode)),jn(i,{...d,themeMode:_t(d.themeMode,o.loadUserPrefs().themeMode)}),p&&(An(i,Oh(d)),p=!1)}function y(){v(),n(t(Eh,{onError:s},t(yh,{key:m,bus:r,hostElement:i,options:d,recentHostEvents:g,loginRevision:h,onPersonChanged:S,onStartAsGuest:C})),a)}r.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&o.rememberStorageVersion(e.config.storageVersion),l=e.config,u=e.translations,_(),y())}),r.on(`localeChange`,e=>{f=e,u?.length&&(_(),y())});let b=fn(r,{getOptions:()=>d,getVisitorId:()=>o.getVisitorId(),getConversationId:()=>o.loadConversationId()});function x(){let e=o.takeLoginReturn();return e?(o.saveConversationId(e.conversationId),o.saveDraft(e.conversationId,e.draft),o.savePanelOpen(!0),!0):!1}c.userToken&&x();function S(){o.reset(),g.length=0,m+=1,p=!0,_(),y()}function C(){c={...c,userContext:void 0,userToken:void 0},S()}function w(e){`userToken`in e&&e.userToken&&!c.userToken&&x()&&(m+=1),c={...c,...e},_(),y()}return{getOptions:()=>d,getUserOptions:()=>c,render:y,setUserOptions:e=>{c=e,_(),y()},patchUserOptions:w,login:e=>{h+=1,w({userToken:e})},reset:()=>C(),destroy:()=>b()}}function Oh(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=nn(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=tc(e,nc(),t.loadPanelOpen(),t.loadPanelSize());return $s(e.mode,r,n)}var kh=class extends HTMLElement{constructor(...e){super(...e),U(this,`bus`,new Jn),U(this,`widgetState`,qn),U(this,`userToken`,void 0),U(this,`pageTools`,[]),U(this,`markReady`,()=>{}),U(this,`ready`,new Promise(e=>{this.markReady=e})),U(this,`mountResult`,null),U(this,`runtime`,null)}static get observedAttributes(){return Gt}connectedCallback(){if(Object.hasOwn(this,`tools`)){let e=Reflect.get(this,`tools`);Reflect.deleteProperty(this,`tools`),this.pageTools=Array.isArray(e)?e:[]}this.boot()}disconnectedCallback(){this.mountResult&&(this.runtime?.destroy(),this.runtime=null,n(null,this.mountResult.appRoot),this.bus.clear(),this.widgetState=qn)}attributeChangedCallback(){this.isConnected&&this.boot()}open(e){zn(this,`open`,e)}close(){zn(this,`close`)}expand(){zn(this,`expand`)}ask(e,t){zn(this,`ask`,In(e,t))}get state(){return this.widgetState}reset(){this.userToken=void 0,this.runtime?.reset()}login(e){this.userToken=e,this.runtime?.login(e)}track(e,t){let n=Zt(e,t);n&&this.bus.emit(`hostEvent`,n)}get tools(){return this.pageTools}set tools(e){this.pageTools=e,this.runtime?.patchUserOptions({tools:e})}registerTool(e,t){rf(e,t)}on(e,t){return this.bus.on(e,t)}boot(){let e={...Kt(e=>this.getAttribute(e)),...this.userToken?{userToken:this.userToken}:{},tools:this.pageTools};if(!e.aiAgentDeploymentId)throw Error(`ai-agent-deployment-id is required`);if(this.runtime){this.runtime.setUserOptions(e);return}let t=at(e);this.mountResult??(this.mountResult=Cn({existingHost:this,position:Sn(t.mode)}));let n=nn(t.widgetId,t.storage,t.aiAgentDeploymentId);this.bus.on(`state`,e=>{this.widgetState=e,e.ready&&this.markReady()}),this.runtime=Dh({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 Ah=!1;function jh(){if(Ah||typeof customElements>`u`)return;let e=P.tagName;customElements.get(e)||customElements.define(e,kh),Ah=!0}typeof customElements<`u`&&jh();export{jh as registerWebComponent};
43
+ `).trim(),F=!j&&t!==`error`&&!C.value&&re.length>0,ie=e.canceled===!0||t===`error`;function ae(n){return u&&t===`complete`&&Mo(e,n)}let I=/* @__PURE__ */ new Map;for(let[t,n]of S.entries()){if(n.kind!==`tool`)continue;let i=pf(n.toolMetadata),a=Ee(jf(n),{turn:{live:A||i&&!d,cutOff:ie,superseded:d,submitted:e.continuationStreaming===!0&&n.approvalSig.value?.approved===void 0,canAct:ae(t),interrupted:i&&yf(n.errorSig.value)},reader:{decides:!0},display:c,strings:r});I.set(n.toolCallId,a.placement===`card`&&!f?.humanInLoop?{...a,placement:`hidden`}:a)}function oe(e){let t=I.get(e.toolCallId);if(!t)throw Error(`no step view for ${e.toolCallId}`);return t}let se=hp(S,{showReasoning:s,showSources:l,viewOf:oe}),ce=vp(S),le=e.canceled===!0&&!O&&D.value&&T.value,ue=se.at(-1),L=ue?.kind===`steps`?ue.indices.at(-1):ue?.index;function de(t,n){return/* @__PURE__ */ _(Ip,{part:t,generativeUi:e.role===`assistant`,onCardAction:x,current:A&&n===L,reasoningMs:e.stepTimings?.[ce[n]??-1]?.reasoningMs,strings:r,locale:a,showReasoning:s,showSources:l,view:t.kind===`tool`?I.get(t.toolCallId):void 0,canAct:ae(n),superseded:d,continuationStreaming:e.continuationStreaming===!0,tool:f},`${zp(t)}#${n}`)}let R=ne||F;return/* @__PURE__ */ _(`div`,{class:`${jp}-bubble-row`,"data-role":e.role,"aria-busy":A?`true`:void 0,"data-testid":ul(J.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ v(`div`,{class:`${jp}-bubble-col`,children:[/* @__PURE__ */ v(`div`,{class:`${jp}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ _(`span`,{class:`${jp}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ v(`div`,{class:`${jp}-bubble-body`,children:[M?/* @__PURE__ */ _(Vp,{label:r.loading}):se.flatMap((t,n)=>t.kind===`part`?[de(t.part,t.index)]:t.rows.some(e=>e.kind===`tool`)?[/* @__PURE__ */ _(Cp,{rows:t.rows,steps:t.indices.map(e=>ce[e]??-1),stepTimings:e.stepTimings,timed:!ie,strings:r,running:A&&n===se.length-1,runStartedAt:e.runStartedAt,renderCard:(e,t)=>t.card===`questions`&&f?/* @__PURE__ */ _(op,{part:e,strings:r,active:!1,superseded:t.status===`replaced`,folded:!0,onDecision:f.onDecision,onEdit:f.onEdit}):void 0},`steps#${t.indices[0]}`)]:t.rows.map((e,n)=>de(e.part,t.indices[n]??n))),le?/* @__PURE__ */ v(`div`,{class:`${jp}-steps-row`,"data-status":`stopped`,"data-testid":J.replyStopped,children:[/* @__PURE__ */ _(`span`,{class:`${jp}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(pc,{})}),/* @__PURE__ */ _(`div`,{class:`${jp}-steps-row-main`,children:/* @__PURE__ */ _(`span`,{class:`${jp}-steps-stopped-label`,children:r.statusStopped})})]}):null,N&&!y?/* @__PURE__ */ _(Bp,{}):null,t===`error`||C.value?/* @__PURE__ */ _(ju,{text:Rp(e,t,r),retryLabel:r.errorRetry,onRetry:m?()=>m(e):void 0,retryTestId:J.messageRetry}):null,y&&A?/* @__PURE__ */ _(ju,{text:r.errorReconnecting,retryTestId:J.messageRetry}):null]})]}),P||R?/* @__PURE__ */ v(`div`,{class:`${jp}-bubble-meta`,children:[P?/* @__PURE__ */ _(`time`,{class:`${jp}-bubble-time`,dateTime:P.iso,title:P.full,children:P.short}):null,R?/* @__PURE__ */ v(`div`,{class:`${jp}-bubble-actions`,children:[ne&&e.serverMessageId?/* @__PURE__ */ _(Cf,{messageId:e.serverMessageId,initial:e.feedback??null,strings:r,onFeedback:g}):null,F?/* @__PURE__ */ _(Pp,{text:re,strings:r}):null]}):null]}):null]})})}function Pp({text:e,strings:t}){let[n,r]=h(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}let a=n?t.copied:t.copy;return/* @__PURE__ */ _(`button`,{type:`button`,class:`${jp}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":J.messageCopy,children:_(n?Dc:el,{})})}function Fp(e,t){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let n=new Date(e);return{short:n.toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),full:n.toLocaleString(t,{dateStyle:`full`,timeStyle:`short`}),iso:n.toISOString()}}catch{return null}}function Ip({part:e,generativeUi:t,onCardAction:n,current:r,reasoningMs:i,strings:a,locale:o,showReasoning:s,showSources:c,view:l,canAct:u,superseded:d,continuationStreaming:f,tool:p}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ _(wl,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:a,onCardAction:n});case`reasoning`:return s?/* @__PURE__ */ _(Ap,{part:e,current:r,reasoningMs:i,strings:a,standalone:!0}):null;case`tool`:return l?.placement!==`card`||!p?null:l.card===`questions`?/* @__PURE__ */ _(op,{part:e,strings:a,active:u,superseded:d,continuationStreaming:f,onDecision:p.onDecision,onEdit:p.onEdit}):/* @__PURE__ */ _(Bf,{part:e,view:l,strings:a,locale:o,canAct:u,onDecision:p.onDecision,onEdit:p.onEdit,preview:p.preview});case`file`:return/* @__PURE__ */ _(Lp,{part:e,strings:a});case`source`:return c?/* @__PURE__ */ _(kf,{part:e,strings:a}):null}}function Lp({part:e,strings:t}){let n=e.filename??t.file;if(e.mediaType.startsWith(`image/`))return/* @__PURE__ */ _(`a`,{class:`${jp}-file-image`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":J.messageFile,children:/* @__PURE__ */ _(`img`,{src:e.url,alt:n,loading:`lazy`})});let r=(n.includes(`.`)?n.split(`.`).pop():e.mediaType.split(`/`).pop())?.toUpperCase(),i=e.fileSize===void 0?void 0:pu(e.fileSize);return/* @__PURE__ */ v(`a`,{class:`${jp}-file-chip`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":J.messageFile,children:[/* @__PURE__ */ _(`span`,{class:`${jp}-file-chip-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Pc,{})}),/* @__PURE__ */ v(`span`,{class:`${jp}-file-chip-text`,children:[/* @__PURE__ */ _(`span`,{class:`${jp}-file-chip-name`,children:n}),/* @__PURE__ */ _(`span`,{class:`${jp}-file-chip-meta`,children:[r,i].filter(Boolean).join(` · `)})]})]})}function Rp(e,t,n){return e.errorText?e.errorText:t===`error`&&e.role===`assistant`?n.errorServer:n.errorGeneric}function zp(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 Bp(){return/* @__PURE__ */ v(`span`,{class:`${jp}-typing`,"data-testid":J.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`span`,{}),/* @__PURE__ */ _(`span`,{}),/* @__PURE__ */ _(`span`,{})]})}function Vp({label:e}){return/* @__PURE__ */ v(`span`,{class:`${jp}-loading`,role:`status`,children:[/* @__PURE__ */ _(`span`,{class:`${jp}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ _(`span`,{class:`${jp}-loading-label`,children:e})]})}const Hp=P.cssPrefix;function Up({messagesSig:e,reconnectingSig:t,pageToolRunning:n,strings:r,notice:i,locale:a,responseMode:o,showReasoning:c,stepDisplay:l,showSources:d,enableMessageFeedback:p,onFeedback:g,loading:y,onLoadPreviousMessages:b,idle:x,controlMode:S=`ai-agent`,tool:C,onRetry:w,onCardAction:T}){let E=m(null),D=s(()=>e.value),O=Wp(a),[k,A]=h(!1),[j,ee]=h(!1),M=m(!1),N=m(!1),[P,te]=h(),ne=m(!1),re=m(!1),F=m(!1),ie=m(0);function ae(){return F.current||performance.now()-ie.current<350}let I=m(0);function oe(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`}function se(e){return A(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function ce(e){I.current=performance.now(),e.scrollTop=e.scrollHeight,oe(e)}function le(e,t){ce(e);let n=t,r=0;function i(){re.current||ae()||(ce(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function ue(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(re.current||ae()||a>=0&&e.scrollTop<a-4)return o();ce(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}let L=D.value[0]?.id;f(()=>{let e=E.current;if(e&&D.value.length!==0&&!N.current&&(ne.current=!0,D.value.some(e=>e.role===`user`)))return ue(e,300)},[L]);let de=m(0);u(()=>{let e=E.current,t=D.value,n=de.current;if(de.current=t.length,e&&ne.current&&!N.current){if(t.slice(n).some(e=>e.role===`user`))return re.current=!1,le(e,3);t.some(e=>e.role===`user`)&&(re.current||ae()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&ce(e))}},[D.value.length]);let R=m(null);u(()=>{let e=E.current,t=D.value.at(-1),n=R.current;if(R.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&ne.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return re.current=!1,le(e,3)},[D.value]),u(()=>{let e=E.current;if(!e)return;let t=D.value.at(-1);if(!t||t.status!==`streaming`&&!D.value.some(e=>e.role===`user`))return;let n=()=>{re.current||ae()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&ce(e)};if(t.status!==`streaming`)return ue(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[D.value]),u(()=>{let e=E.current;if(!e)return;let t=()=>{se(e),oe(e),performance.now()-I.current>150&&(re.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){re.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,F.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){F.current=!1,ie.current=performance.now()}function c(){F.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}),se(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)}},[]),u(()=>{let e=E.current;if(!e)return;let t=e.clientHeight,n=new ResizeObserver(()=>{if(e.clientHeight===t)return;let n=e.scrollHeight-e.scrollTop-t<=120;t=e.clientHeight,n&&!N.current&&D.value.some(e=>e.role===`user`)&&(re.current=!1,ce(e))});return n.observe(e),()=>n.disconnect()},[]);function fe(){let e=E.current;e&&(re.current=!1,ce(e))}let z=D.value.filter(e=>!e.ephemeral),pe=z[0],me=pe?.serverMessageId??pe?.id,he=!!(b&&z.length>=50&&me!==P);async function B(){if(!b||M.current)return;let e=E.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;M.current=!0,N.current=!0,ee(!0);try{let r=await b();r===!1&&me&&te(me),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,oe(e),se(e))}finally{N.current=!1,M.current=!1,ee(!1)}}let ge=[],_e=``,ve=D.value.at(-1)?.id,ye=t?.value===!0,be=n===!0;for(let e of D.value){if(e.role===`assistant`&&e.id!==ve&&Jo(e))continue;let t=Gp(e.createdAt);t&&t!==_e&&(ge.push(/* @__PURE__ */ _(`div`,{class:`${Hp}-date-divider`,children:/* @__PURE__ */ _(`span`,{class:`${Hp}-date-pill`,title:Kp(e.createdAt,O),children:qp(e.createdAt,r,O)})},`day:${t}`)),_e=t);let n=e.retryAction!==void 0||e.role===`assistant`&&e.id===ve?Yo(D.value,e):void 0,i=n!==void 0&&(n.kind!==`continue-assistant`||S===`ai-agent`);ge.push(/* @__PURE__ */ _(Mp,{message:e,status:e.status,createdAt:e.createdAt,strings:r,locale:O,responseMode:o,showReasoning:c,stepDisplay:l,showSources:d,interactive:!!x&&S===`ai-agent`&&e.id===ve,superseded:e.id!==ve,tool:C,onRetry:x&&i&&(e.role===`user`||e.id===ve)?w:void 0,enableMessageFeedback:p,onFeedback:g,reconnecting:ye&&e.id===ve,clientToolRunning:be&&e.id===ve&&e.role===`assistant`,onCardAction:T},e.id))}return/* @__PURE__ */ v(`div`,{class:`${Hp}-list-wrap`,children:[/* @__PURE__ */ v(`div`,{ref:E,class:`${Hp}-list ${Hp}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[y&&D.value.length===0?/* @__PURE__ */ _(`div`,{class:`${Hp}-list-loading`,role:`status`,children:r.conversationLoading}):null,i&&!he?/* @__PURE__ */ _(`div`,{class:`${Hp}-chat-notice`,role:`note`,"data-testid":J.chatNotice,children:/* @__PURE__ */ _(Tl,{text:i})}):null,he?/* @__PURE__ */ _(`div`,{class:`${Hp}-load-previous`,children:/* @__PURE__ */ _(`button`,{type:`button`,onClick:B,disabled:j,"aria-busy":j,"data-testid":J.loadPreviousMessages,children:r.loadPreviousMessages})}):null,ge]}),k?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Hp}-jump`,onClick:fe,"aria-label":r.scrollToBottom,title:r.scrollToBottom,"data-testid":J.scrollToBottom,children:/* @__PURE__ */ _(Nc,{})}):null]})}function Wp(e){try{return Intl.getCanonicalLocales(e)[0]}catch{return}}function Gp(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Kp(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(t,{dateStyle:`full`})}catch{return``}}function qp(e,t,n){let r=new Date(e);function i(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let a=Math.round((i(/* @__PURE__ */ new Date)-i(r))/864e5);return a<=0?t.dateToday:a===1?t.dateYesterday:a<7?r.toLocaleDateString(n,{weekday:`long`}):r.toLocaleDateString(n,{month:`long`,day:`numeric`,year:`numeric`})}function Jp({panelEl:e,resize:t,position:n,edge:r,initialSize:i,onSizeChange:a,onResizeStart:o,strings:s}){let c=P.cssPrefix,l=m(null),[d,f]=h(null),p=i?.width,g=i?.height;if(u(()=>{if(!e)return;let n=e.style;n.setProperty(`--${c}-resize-min-w`,t.minWidth??`320px`),n.setProperty(`--${c}-resize-min-h`,t.minHeight??`400px`),t.maxWidth&&n.setProperty(`--${c}-resize-max-w`,t.maxWidth),t.maxHeight&&n.setProperty(`--${c}-resize-max-h`,t.maxHeight),p!==void 0&&g!==void 0&&(n.setProperty(`--${c}-widget-w`,`${p}px`),n.setProperty(`--${c}-widget-h`,`${g}px`)),f(Math.round(e.getBoundingClientRect().width/window.innerWidth*100))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,c,p,g]),!e)return null;let v=n.startsWith(`top-`),y=n.endsWith(`-right`),b=y?-1:1,x=v?1:-1,S=`${c}-resize-grip--${r?`edge`:`${v?`bottom`:`top`}-${y?`left`:`right`}`}`;function C(e){e.setAttribute(`data-resizing`,``),o?.()}function w(e,t,n){e.style.setProperty(`--${c}-widget-w`,`${t}px`),r||e.style.setProperty(`--${c}-widget-h`,`${n}px`)}function T(e){let t=e.getBoundingClientRect(),n={width:Math.round(t.width),height:Math.round(t.height)};e.style.setProperty(`--${c}-widget-w`,`${n.width}px`),r||e.style.setProperty(`--${c}-widget-h`,`${n.height}px`),f(Math.round(n.width/window.innerWidth*100)),a(n)}function E(t){if(!e)return;let n=e.getBoundingClientRect();l.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:n.width,startH:n.height,moved:!1},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault()}function D(t){let n=l.current;if(!n||t.pointerId!==n.pointerId||!e)return;let i=(t.clientX-n.startX)*b,a=r?0:(t.clientY-n.startY)*x;(n.moved||i!==0||a!==0)&&(n.moved||C(e),n.moved=!0,w(e,n.startW+i,n.startH+a))}function O(t){let n=l.current;n&&t.pointerId===n.pointerId&&e&&(t.currentTarget.releasePointerCapture(t.pointerId),l.current=null,n.moved&&(e.removeAttribute(`data-resizing`),T(e)))}function k(e){return e===`ArrowLeft`?[-1,0]:e===`ArrowRight`?[1,0]:r?null:e===`ArrowUp`?[0,-1]:e===`ArrowDown`?[0,1]:null}function A(t){let n=k(t.key);if(!n||!e)return;t.preventDefault();let r=t.shiftKey?64:16;t.repeat||C(e);let i=e.getBoundingClientRect();w(e,i.width+n[0]*r*b,i.height+n[1]*r*x)}function j(t){k(t.key)&&e&&(e.removeAttribute(`data-resizing`),T(e))}return/* @__PURE__ */ _(`div`,{class:`${c}-resize-grip ${S}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":s.resizeHandle,"aria-valuenow":d??void 0,tabIndex:0,title:s.resizeHandle,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerCancel:O,onKeyDown:A,onKeyUp:j,"data-testid":J.resizeGrip,children:r?null:/* @__PURE__ */ _(Sc,{})})}const Yp=P.cssPrefix;function Xp({suggestions:e,strings:t,onPick:n,disabled:r=!1}){let i=m(null),[a,o]=h({start:!1,end:!1});return u(()=>{let e=i.current;if(!e)return;function t(){if(!e)return;let t=Math.abs(e.scrollLeft),n=t>1,r=t<e.scrollWidth-e.clientWidth-1;o(e=>e.start===n&&e.end===r?e:{start:n,end:r})}t(),e.addEventListener(`scroll`,t,{passive:!0});let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);return n?.observe(e),()=>{e.removeEventListener(`scroll`,t),n?.disconnect()}},[e]),e.length===0?null:/* @__PURE__ */ _(`div`,{ref:i,class:`${Yp}-suggestions`,role:`group`,"aria-label":t.suggestedReplies,"data-cut-start":a.start?`true`:void 0,"data-cut-end":a.end?`true`:void 0,children:e.map((e,t)=>/* @__PURE__ */ _(`button`,{type:`button`,class:`${Yp}-suggestion`,onClick:()=>n(e),disabled:r,"data-testid":ul(J.suggestion,t),children:e.label},e.id))})}const Zp=P.cssPrefix,Qp=`.${Zp}-header, .${Zp}-back-header, .${Zp}-home-hero`;function $p(e,t){u(()=>{if(!t||!e)return;function n(e){return Number.parseFloat(e)||0}function r(e,t){return Math.min(t,Math.max(-t,e))}let i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(Qp)||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(`--${Zp}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Zp}-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(`--${Zp}-modal-dx`,`${n}px`),e.style.setProperty(`--${Zp}-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 em({containerRef:e,onDrop:t,accept:n,disabled:r=!1}){let[i,a]=h();return u(()=>{if(r){a(void 0);return}let i=e.current;if(!i)return;let o=0;function s(e){o+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),a([...e.dataTransfer.items].every(e=>e.kind!==`file`||mu(e.type,n))?`accept`:`reject`))}function c(){--o,o>0||(o=0,a(void 0))}function l(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function u(e){o=0,a(void 0),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return i.addEventListener(`dragenter`,s),i.addEventListener(`dragleave`,c),i.addEventListener(`dragover`,l),i.addEventListener(`drop`,u),()=>{i.removeEventListener(`dragenter`,s),i.removeEventListener(`dragleave`,c),i.removeEventListener(`dragover`,l),i.removeEventListener(`drop`,u)}},[n,e,r,t]),r?void 0:i}const Q=P.cssPrefix;function tm(e){let{options:t,onClose:n}=e,r=t.strings,i=m(null);u(()=>{let e=i.current;if(!e||!n)return;let t=bl(e);function r(e){e.key===`Escape`&&n?.()}return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let a=e.composerApiRef,o=e.composerActive&&e.view===`chat`&&!e.sendPreparing&&e.options.features.fileUpload,s=em({containerRef:i,onDrop:l(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),accept:e.options.attachments.accept,disabled:!o});return $p(i.current,t.mode===`modal`),/* @__PURE__ */ v(`div`,{ref:i,class:`${Q}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":J.panel,children:[/* @__PURE__ */ _(nm,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ _(um,{poweredBy:e.options.poweredBy,strings:e.options.strings})]})}function nm(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:c,panelSize:l,view:u,isStreaming:d,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,replyAwaitsCard:y,sendPreparing:b,attachmentUploadsSig:x,controlMode:S,assignedOperator:C,operatorAvailable:w,operatorRequestEnabled:T,onRequestOperator:E,onCancelOperatorRequest:D,loadingMessages:O,onLoadPreviousMessages:k,messagesSig:A,reconnectingSig:j,agent:ee,ticketReference:N,login:P,onStartAsGuest:te,suggestions:ne,initialWidgetSize:re,onClose:F,onBack:ie,onExpand:ae,onToggleHistory:I,onSelectHistoryConversation:oe,onNewConversation:se,onWidgetSizeChange:ce,onSend:le,onStop:ue,onSuggestion:L,tool:de,onRetry:R,onMessageFeedback:fe,onCardAction:z,containerEl:pe,dragOver:me,composerApiRef:he}=e,B=t.strings,ge=S===`operator`?C:void 0,_e=ge?{name:ge.name??ge.initials,avatar:ge.avatar,title:B.operatorBadgeTitle,status:`online`}:ee,ve=t.header.showNotice?M(B,t.header.notice||`chatNotice`):void 0,ye=s(()=>A.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,be=s(()=>A.value.length>0).value,[xe,Se]=h(),Ce=xe===o,we=t.features.emailTranscript&&ye?()=>Se(o):void 0,Te=P.gate?/* @__PURE__ */ _(lm,{login:{...P,gate:P.gate},alone:!be,onStartAsGuest:te,strings:B}):/* @__PURE__ */ v(g,{children:[S&&S!==`ai-agent`?/* @__PURE__ */ _(im,{controlMode:S,operatorName:C?.name??C?.initials,operatorAvailable:w,onCancelOperatorRequest:D,strings:B}):null,f&&S===`ai-agent`?/* @__PURE__ */ v(`div`,{class:`${Q}-loading ${Q}-compaction-status`,role:`status`,"data-testid":J.compactionStatus,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-loading-spinner`,"aria-hidden":`true`}),B.compactingContext]}):null,!d&&!f&&S===`ai-agent`&&/* @__PURE__ */ _(Xp,{suggestions:ne,strings:B,onPick:L,disabled:b}),/* @__PURE__ */ _(Ku,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,maxMessageCharacters:e.maxMessageCharacters,isStreaming:d,pageToolRunning:e.pageToolRunning,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,replyAwaitsCard:y,active:e.composerActive&&u===`chat`,isPreparing:b,attachmentUploadsSig:x,operatorRequestEnabled:T,canRequestOperator:ye,controlMode:S,onRequestOperator:E,onSend:le,onStop:ue,apiRef:he},c)]});return/* @__PURE__ */ v(g,{children:[u===`history`?/* @__PURE__ */ _(rm,{strings:B,onBack:I,onClose:F,showClose:Gs(t.mode,l,t.actions)}):/* @__PURE__ */ v(`header`,{class:`${Q}-header`,part:`header`,"data-variant":t.header.variant,"data-testid":J.panelHeader,children:[ie?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:ie,"aria-label":B.moduleBack,title:B.moduleBack,children:/* @__PURE__ */ _(Ac,{})}):null,_e?/* @__PURE__ */ _(dd,{agent:_e,strings:B,ticketReference:N,person:!!ge}):/* @__PURE__ */ _(`h1`,{children:B.panelTitle}),/* @__PURE__ */ _(Zl,{panelProps:P.gate?{...e,options:{...t,actions:t.actions.filter(e=>e!==`history`)}}:e,variant:`chat`,onEmailTranscript:we,onLogIn:P.menuLogIn})]}),u===`history`?/* @__PURE__ */ _(xd,{transport:n,strings:B,locale:t.locale,persistence:a,onSelect:oe,onNewConversation:se}):/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(Cd,{state:me,strings:B}),P.strip?/* @__PURE__ */ _(sm,{strip:P.strip,onLogIn:P.onLogIn,onHide:P.onHidePrompt,strings:B}):null,P.gate&&!be?null:/* @__PURE__ */ _(Up,{messagesSig:A,reconnectingSig:j,pageToolRunning:e.pageToolRunning,strings:B,notice:ve,locale:t.locale,responseMode:t.responseMode,showReasoning:t.showReasoning,stepDisplay:t.stepDisplay,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:fe,loading:O,onLoadPreviousMessages:k,idle:!d&&!b,controlMode:S,tool:de,onRetry:R,onCardAction:z}),Te,/* @__PURE__ */ _(om,{disclaimer:t.composerDisclaimer}),Ce?/* @__PURE__ */ _(Md,{transport:n,strings:B,knownEmail:kd({tokenEmail:P.email,userContext:t.userContext}),onClose:()=>Se(void 0)}):null]}),t.size.resize?.enabled?/* @__PURE__ */ _(Jp,{panelEl:pe,resize:t.size.resize,position:t.position,edge:t.mode===`drawer`,initialSize:re,onSizeChange:ce,onResizeStart:t.mode===`floating`&&l===`expanded`?ae:void 0,strings:B}):null]})}function rm({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ v(`header`,{class:`${Q}-header`,part:`header`,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ _(Ac,{})}),/* @__PURE__ */ _(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ _(sc,{})}):null]})}function im({controlMode:e,operatorName:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let[a,o]=h(!1),s=am(e,t,n,i);function c(){r&&(o(!0),r().finally(()=>o(!1)))}return/* @__PURE__ */ v(`div`,{class:`${Q}-operator-banner`,"data-mode":e,"data-available":n===!1?`false`:void 0,"data-testid":J.operatorBanner,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ _(`span`,{class:`${Q}-operator-label`,role:`status`,children:s}),e===`awaiting-operator`&&r?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn ${Q}-operator-dismiss`,onClick:c,disabled:a,"aria-label":i.cancelOperatorRequest,title:i.cancelOperatorRequest,"data-testid":J.cancelOperatorRequest,children:/* @__PURE__ */ _(sc,{})}):null]})}function am(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function om({disclaimer:e}){return e?/* @__PURE__ */ _(`div`,{class:`${Q}-composer-footer`,children:/* @__PURE__ */ _(`div`,{class:`${Q}-disclaimer`,children:e})}):null}function sm({strip:e,onLogIn:t,onHide:n,strings:r}){let i=e.kind===`user`;return/* @__PURE__ */ v(`div`,{class:`${Q}-login-bar`,"data-kind":e.kind,role:i?`status`:`note`,"data-testid":i?J.loggedIn:J.loginBar,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-login-bar-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(gc,{})}),i?/* @__PURE__ */ _(`span`,{class:`${Q}-login-bar-text`,children:e.who?r.loggedInAs.replace(`{name}`,e.who):r.loggedIn}):/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{class:`${Q}-login-bar-text`,children:r.loginPrompt}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-login-bar-action`,onClick:t,"data-testid":J.loginBarAction,children:r.loginAction}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-icon-btn ${Q}-login-bar-hide`,onClick:n,"aria-label":r.dismissLoginPrompt,title:r.dismissLoginPrompt,"data-testid":J.loginBarHide,children:/* @__PURE__ */ _(sc,{})})]})]})}function cm(e,t){return e.gate===`required`?t.loginRequired:e.canStartAsGuest?t.loginExpiredGuest:t.loginExpired}function lm({login:e,alone:t,onStartAsGuest:n,strings:r}){return/* @__PURE__ */ v(`div`,{class:`${Q}-login-gate`,"data-gate":e.gate,"data-alone":t?``:void 0,"data-testid":J.loginGate,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-login-gate-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(gc,{})}),/* @__PURE__ */ _(`p`,{class:`${Q}-login-gate-title`,role:`status`,children:cm(e,r)}),e.canLogIn||e.canStartAsGuest?/* @__PURE__ */ v(`div`,{class:`${Q}-form-actions ${Q}-login-gate-actions`,children:[e.canStartAsGuest?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-form-skip`,onClick:n,"data-testid":J.loginGateGuest,children:r.startAsGuest}):null,e.canLogIn?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-form-submit`,onClick:e.onLogIn,"data-testid":J.loginGateAction,children:r.loginAction}):null]}):null]})}function um({poweredBy:e,strings:t}){return e?/* @__PURE__ */ _(`div`,{class:`${Q}-poweredby-bar`,children:/* @__PURE__ */ _(dm,{logoUrl:e.logoUrl,text:e.text??t.poweredBy.replace(`{name}`,P.displayName),href:e.href})}):null}function dm({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ v(g,{children:[e?/* @__PURE__ */ _(`img`,{class:`${Q}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ _(`span`,{children:t}):null]});return n?/* @__PURE__ */ _(`a`,{class:`${Q}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ _(`span`,{class:`${Q}-poweredby`,children:r})}const fm=P.cssPrefix;function pm({panelProps:e,enabledModules:t,nav:n,bus:r,hasUnread:i,latestNews:a,onSelectConversation:o,onStartNewConversation:c,onSetPanelSize:d}){let f=e.options,p=f.strings,h=m(null),g=m(/* @__PURE__ */ new Set);u(()=>{let t=h.current;if(!t||!e.onClose)return;let n=bl(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let y=s(()=>n.sig.value).value,b=Qs(y),x=f.modules.byId[y.activeTab],S=e.composerActive&&x?.layout===`chat`&&b===void 0,C=e.composerApiRef,w=S&&e.view===`chat`&&!e.sendPreparing&&e.options.features.fileUpload,T=em({containerRef:h,onDrop:l(e=>{w&&C.current?.attachFromDrop(e)},[C,w]),accept:e.options.attachments.accept,disabled:!w});$p(h.current,f.mode===`modal`);let E=b?.kind===`content`,D=t.length>1&&$s(y),O=m(null);u(()=>{if(E&&O.current===null)O.current=e.panelSize,e.panelSize===`normal`&&d(`expanded`);else if(!E&&O.current!==null){let e=O.current;O.current=null,d(e)}},[E]);let k={push:e=>n.push(e),pop:()=>n.pop(),switchTab:e=>n.switchTab(e),switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:o,startNewConversation:c};function A(t){return{options:f,transport:e.transport,strings:p,config:t,nav:k,bus:r,panelProps:e,latestNews:a}}let j=/* @__PURE__ */ _(Zl,{panelProps:e,variant:`plain`});x&&g.current.add(x.id);let ee=t.filter(e=>g.current.has(e.id));function M(t){if(t.layout===`chat`)return/* @__PURE__ */ _(nm,{...e,composerActive:S,containerEl:h.current,dragOver:T});let n=sd[t.layout].Root;return n?/* @__PURE__ */ _(n,{...A(t)}):null}function N(){return b?.kind===`content`?/* @__PURE__ */ _(Hl,{id:b.id,title:b.title,transport:e.transport,strings:p,bus:r,onBack:()=>n.pop(),actions:j}):null}return/* @__PURE__ */ v(`div`,{ref:h,class:`${fm}-panel ${fm}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p.panelTitle,style:{position:`relative`},"data-testid":J.messengerHome,children:[/* @__PURE__ */ v(`div`,{class:`${fm}-messenger-body`,children:[ee.map(e=>/* @__PURE__ */ _(`div`,{class:`${fm}-messenger-pane`,hidden:E||e.id!==x?.id,children:M(e)},e.id)),N()]}),D?/* @__PURE__ */ _(ld,{modules:t,activeTab:y.activeTab,strings:p,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ _(um,{poweredBy:f.poweredBy,strings:f.strings}),f.size.resize?.enabled&&(x?.layout!==`chat`||b)?/* @__PURE__ */ _(Jp,{panelEl:h.current,resize:f.size.resize,position:f.position,edge:f.mode===`drawer`,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,onResizeStart:f.mode===`floating`&&e.panelSize===`expanded`?e.onExpand:void 0,strings:p}):null]})}function mm(e){let t=P.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return/* @__PURE__ */ v(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":J.sidebar,children:[/* @__PURE__ */ v(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ _(hm,{site:n}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":J.sidebarToggle,children:/* @__PURE__ */ _(gm,{collapsed:a})})]}),a?null:/* @__PURE__ */ v(g,{children:[o.length>0?/* @__PURE__ */ _(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ _(_m,{items:o})}):null,s.length>0?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ _(vm,{items:s})}):null,e.showConversations?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ _(xd,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function hm({site:e}){let t=P.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return/* @__PURE__ */ v(`picture`,{children:[e.logoDark?.url?/* @__PURE__ */ _(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,/* @__PURE__ */ _(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-title`,children:e?.title??P.name})}function gm({collapsed:e}){return/* @__PURE__ */ _(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?/* @__PURE__ */ _(`polyline`,{points:`9 6 15 12 9 18`}):/* @__PURE__ */ _(`polyline`,{points:`15 6 9 12 15 18`})})}function _m({items:e}){let t=P.cssPrefix;return/* @__PURE__ */ _(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>/* @__PURE__ */ _(`li`,{children:/* @__PURE__ */ v(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?/* @__PURE__ */ _(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function vm({items:e}){let t=P.cssPrefix;return/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>/* @__PURE__ */ v(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const ym=P.cssPrefix;function bm(e){return/* @__PURE__ */ v(`main`,{class:`${ym}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ _(mm,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),/* @__PURE__ */ _(`section`,{class:`${ym}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const xm=P.cssPrefix;function Sm({strings:e,text:t,onClose:n}){return/* @__PURE__ */ v(`div`,{class:`${xm}-panel ${xm}-panel-notice`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":J.panelNotice,children:[n?/* @__PURE__ */ _(`button`,{type:`button`,class:`${xm}-icon-btn ${xm}-panel-notice-close`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ _(sc,{})}):null,/* @__PURE__ */ _(`p`,{class:`${xm}-panel-notice-text`,children:t})]})}const Cm=V.scope(`hitl`);function wm(e){return e.kind===`tool`&&pf(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function Tm(e,t){t.errorSig.value=bf(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function Em(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&Xd.sentHere(n.id)}function Dm(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:c}=e,d=m(t);d.current=t;let f=m(c);f.current=c;let h=m(/* @__PURE__ */ new Map),g=s(()=>{let e=r.value,t=e.at(-1);return n.value!==`ai-agent`||t?.role!==`assistant`||t.status!==`complete`?!1:t.partsSig.value.some(e=>wm(e)&&Xd.get(e.toolCallId)?.state!==`stopped`)&&Em(e,t)}).value,_=l((e,t,a)=>{if(d.current||n.value!==`ai-agent`)return!1;let o=r.value.at(-1),s=o?.partsSig.value.findIndex(t=>t.kind===`tool`&&t.toolCallId===e)??-1,c=o?.partsSig.value[s];if(!o||c?.kind!==`tool`)return Cm.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Mo(o,s)||!t(c))return!1;if(a(c),o.partsSig.value=[...o.partsSig.value],!Ao(o)||o.partsSig.value.some(wm))return!0;o.status=`streaming`,o.retryAction={kind:`continue-assistant`,messageId:o.serverMessageId??o.id},o.awaitingContinuation=!0,r.value=[...r.value];let l=o.partsSig.value.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]);return i({continueExisting:!0}).then(e=>e&&Xd.clear(l)),!0},[n,r,i]),v=l((e,t)=>{let{toolCallId:n,toolName:r}=t;h.current.has(n)||(h.current.set(n,e),vf({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:f.current??[],onSettled:(e,t)=>{Cm.info(`toolResult`,{toolCallId:n,status:e}),a.emit(`toolResult`,{toolCallId:n,name:mf(r),status:e,durationMs:t})}}).then(e=>{h.current.delete(n)&&_(n,wm,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state})}))},[a,_]),y=l(()=>{let e=r.value;for(let[t,n]of h.current){let r=e.findIndex(e=>e.id===n);r<0||r===e.length-1||(h.current.delete(t),xf(t))}let t=e.at(-1);if(d.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(wm);if(n.length!==0&&Em(e,t))for(let e of n)Xd.get(e.toolCallId)?.state===`stopped`?Tm(t,e):v(t.id,e)},[r,v]);u(()=>y(),[t,y]),u(()=>r.subscribe(()=>y()),[r,y]);let b=l((e,t,n)=>{let i=!1,o;if(!_(e,e=>e.stateSig.value===`approval-requested`,r=>{pf(r.toolMetadata)&&(o=r),i=r.toolMetadata?.card===`questions`;let a=r.approvalSig.value?.id??e;r.approvalSig.value={id:a,approved:t,reason:n},r.stateSig.value=`approval-responded`}))return;let s=r.value.at(-1);o&&t&&s&&v(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:mf(o.toolName),status:`declined`,durationMs:0}),i?(Cm.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(Cm.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,_,r,v]),x=l(e=>{_(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!wm(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[_]);return{toolInteraction:p(()=>({humanInLoop:o,onDecision:b,onEdit:x,preview:(e,t)=>gf({toolName:e,input:t,optionTools:f.current??[]})}),[o,b,x]),pageToolsRunning:g,stopPageTools:l(()=>{let e=r.value.at(-1);for(let t of h.current.keys()){let n=e?.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);e&&n?Tm(e,n):bf(t),Cm.info(`toolResult`,{toolCallId:t,status:`stopped`}),a.emit(`toolResult`,{toolCallId:t,name:n?mf(n.toolName):void 0,status:`stopped`,durationMs:0})}h.current.clear()},[a,r])}}const Om=V.scope(`latest-news`);function km({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=h(),[c,d]=h(()=>n.loadSeenNewsId());u(()=>{if(!r||!i?.length)return;let t=!1;return e.listContent({contentCollectionIds:i,sortBy:`publishedAt`,sortOrder:`desc`,limit:1}).then(e=>{t||s(e.items[0])}).catch(e=>Om.debug(`listContent (latest news) failed (non-fatal)`,{err:e})),()=>{t=!0}},[e,r,a]);let f=l(e=>{n.saveSeenNewsId(e),d(e)},[n]);return{item:o,unseen:o!==void 0&&o.id!==c,markSeen:f}}function Am({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=h(()=>!r&&t.loadCalloutDismissed(n));return u(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:l(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}const jm=V.scope(`login`);function Mm(e,t){switch(e.status){case`required`:return`required`;case`expired`:return`expired`;case`anonymous`:return t?`required`:void 0;case`pending`:case`loggedIn`:return;default:return e}}function Nm(e,t,n){if(e.status===`loggedIn`)return t.hideUser?void 0:{kind:`user`,who:e.name??e.email};if(!(e.status!==`anonymous`||!t.url||t.hidePrompt||n))return{kind:`prompt`}}function Pm(e){let{state:t,deployment:n,bus:r,persistence:i,conversationIdSig:a}=e,[o,c]=h(()=>i.loadLoginPromptDismissedIn()),u=s(()=>a.value).value,d=o!==void 0&&o===u,f=(t.status===`required`?t.loginUrl:void 0)??n.url,p=Mm(t,n.required),m=l(()=>{let e=hr(),t=r.listensTo(`loginRequested`);if(jm.info(`loginRequested`,{pageLogsIn:t}),r.emit(`loginRequested`,{returnTo:e}),t||!f)return;let n=a.value;n&&i.saveLoginReturn({conversationId:n,draft:i.loadDraft(n)}),i.savePanelOpen(!1),gr(ur(f,e))},[r,a,f,i]),g=l(()=>{let e=a.value;e&&(i.dismissLoginPromptIn(e),c(e))},[a,i]),_=!!f||r.listensTo(`loginRequested`);return{strip:Nm(t,n,!!p||d),gate:p,canStartAsGuest:p===`expired`&&!n.required,email:t.status===`loggedIn`?t.email:void 0,canLogIn:_,onLogIn:m,menuLogIn:t.status===`anonymous`&&!p&&_?m:void 0,onHidePrompt:g}}function Fm(e){let{transport:t,conversationIdSig:n}=e,r=c(`ai-agent`),i=c(void 0),a=c(void 0),o=m(void 0),s=l(e=>{let t=e.controlRevision,s=o.current;if(s&&s.conversationId===n.value&&t<s.revision)return;o.current={conversationId:n.value,revision:t},r.value=e.controlMode;let c=e.assignedOperatorInitials;i.value=c?{initials:c,name:e.assignedOperatorName,avatar:e.assignedOperatorAvatar}:void 0,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0},[n,r,i,a]);return{controlModeSig:r,assignedOperatorSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:l(e=>{if(e.type!==`data-control-state`)return;let t=no(e.data);t&&s(t)},[s]),requestOperator:l(async()=>{let e=n.value,r=await t.requestOperator();r&&n.value===e&&s(r)},[t,n,s]),cancelOperatorRequest:l(async()=>{let e=n.value,r=await t.cancelOperatorRequest();r&&n.value===e&&s(r)},[t,n,s])}}const Im=P.cssPrefix,Lm=`--${Im}-visual-viewport-height`,Rm=`--${Im}-visual-viewport-top`;function zm(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,onClose:o}=e;f(()=>{An(t,tc(n,r,i))},[t,i,r,n]),f(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${Im}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(Lm,`${n.height}px`),r.style.setProperty(Rm,`${n.offsetTop}px`)},s=0,c=()=>{e.cancelAnimationFrame(s),s=e.requestAnimationFrame(()=>{s=e.requestAnimationFrame(o)})};return o(),n.addEventListener(`resize`,c),n.addEventListener(`scroll`,c),()=>{e.cancelAnimationFrame(s),n.removeEventListener(`resize`,c),n.removeEventListener(`scroll`,c),r.style.removeProperty(Lm),r.style.removeProperty(Rm)}},[t,i,a]),u(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${Im}-panel`))||o()}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),u(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&!e.composedPath().includes(t)&&o()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,i,n,o])}const Bm=V.scope(`reducer`);var Vm=class{constructor(e,t){this.messagesSig=e,this.onReconcileNeeded=t,U(this,`active`,null),U(this,`openTextParts`,/* @__PURE__ */ new Map),U(this,`partSeq`,0),U(this,`replay`,null),U(this,`turnChunks`,[]),U(this,`turnRow`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=lo();n.id=e.id;let r=Hm(e)||jo(e)&&(e.status!==`streaming`||Ao(e)),i=e.status===`streaming`&&Ao(e)&&ko(e);this.replay={baseline:e,shadow:n,chunks:[t],probeContinuation:r,continuationTailReplay:i,liveCatchUp:e.status===`streaming`&&!r},this.attach(n),this.apply(t)}refreshReplayBaseline(){let e=this.replay;if(!e)return null;let t=e.shadow.serverMessageId??e.baseline.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e.baseline||r?.id===e.baseline.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e.baseline)??n.find(n=>n.id===e.baseline.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e.baseline)return e;let a=e.baseline;return e.baseline=i,Um(a,i),e.liveCatchUp&&Hm(e.shadow)&&(i.status===`streaming`||jo(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=Hm(i)||jo(i)&&(i.status!==`streaming`||Ao(i)),e.continuationTailReplay=i.status===`streaming`&&Ao(i)&&ko(i),e.liveCatchUp=i.status===`streaming`&&!e.probeContinuation,e)}refreshActive(){let e=this.active;if(!e)return null;let t=e.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e||r?.id===e.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e)??n.find(n=>n.id===e.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e)return e;Um(e,i);let a=Hm(e)&&jo(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replayTurn(),this.replay?this.replay.shadow:this.active)}replayTurn(){let[e,...t]=this.turnChunks;if(e?.type!==`start`)return;let n=this.messagesSig.value.find(t=>t.serverMessageId===e.messageId);if(n!==void 0&&n!==this.turnRow){this.detach();for(let n of[e,...t])this.applyResume(n)}}promoteReplay(e){let{baseline:t,shadow:n}=e;return r(()=>{t.role=n.role,t.serverMessageId=n.serverMessageId,t.operatorInitials=n.operatorInitials,t.status=n.status,n.canceled&&(t.canceled=!0),t.finishReason=n.finishReason,t.errorText=n.errorText,t.suggestions=n.suggestions??t.suggestions,t.runStartedAt=n.runStartedAt??t.runStartedAt,t.stepTimings=n.stepTimings??t.stepTimings,t.partsSig.value=n.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=t,t}promoteContinuation(e){let{baseline:t,chunks:n}=e,i=No(t);return this.replay=null,r(()=>{t.partsSig.value=t.partsSig.value.slice(0,Wm(t,n)+1),t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t);for(let e of n)this.apply(e);t.continuationStreaming=i||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}settleOwnedContinuation(e,t){let{baseline:n}=e,i=No(n);return this.replay=null,r(()=>{n.awaitingContinuation=!1,n.status=`streaming`,n.finishReason=void 0,n.errorText=void 0,n.suggestions=void 0,this.attach(n),this.apply(t),n.continuationStreaming=i||void 0,this.messagesSig.value=[...this.messagesSig.value]}),n}applyResume(e){e.type===`start`&&(this.turnChunks=[]);let t=this.applyTurnChunk(e);return this.turnChunks.push(e),this.turnRow=t??this.replay?.baseline??this.active??this.turnRow,t}applyTurnChunk(e){if(e.type===`start`){let t=(this.replay?.baseline??this.active)?.serverMessageId;t!==void 0&&e.messageId!==void 0&&t!==e.messageId&&this.onReconcileNeeded?.({messageId:t}),this.detach();let n=e.messageId,r=n===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===n||e.id===n);if(r!==void 0)return e.messageMetadata?.senderRole===`visitor`&&r.role===`user`&&(r.status===`pending`||r.status===`error`)&&(r.serverMessageId=n,r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,this.messagesSig.value=[...this.messagesSig.value]),this.beginReplay(r,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&&!wo(a))return this.attach(a),this.apply(e),null;let o=lo();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.replay){let t=this.refreshReplayBaseline();if(!t)return null;t.chunks.push(e),e.type===`data-control-state`&&(t.baseline.operatorRoutedTurn=e.data.controlMode!==`ai-agent`),this.apply(e);let{baseline:n,shadow:r,probeContinuation:i,continuationTailReplay:a,liveCatchUp:o}=t,s=e.type===`finish`||e.type===`error`||e.type===`abort`;if(i){if(!Jm(n,r,e)){if(s){if(n.status===`streaming`&&n.awaitingContinuation!==!0){let n=this.settleOwnedContinuation(t,e);return this.detach(),n}Qm(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()}return null}let i=Hm(n)&&s?this.settleOwnedContinuation(t,e):this.promoteContinuation(t);return s?(i.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:i.serverMessageId??i.id}):i.continuationStreaming=!1),this.detach(),i):null}if(a&&Km(n,r)){let e=this.promoteContinuation(t);return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!wo(n)&&wo(r)){let e=this.promoteReplay(t);return this.detach(),e}if(!Gm(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay(t);return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyTurnChunk(e);if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let n=t;return n.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}):n.continuationStreaming=!1),this.detach(),n}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:o(``),doneSig:o(!1)};return this.openTextParts.set(r,a),eh(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?.runStartedAt&&(t.runStartedAt=n.runStartedAt),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`:eh(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`message-metadata`:t.stepTimings=ho(e.messageMetadata?.steps)??t.stepTimings;return;case`finish`:Bm.debug(`finish`,{reason:e.finishReason}),t.stepTimings=ho(e.messageMetadata?.steps)??t.stepTimings,t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:Bm.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=void 0,this.bumpDone(t);return;case`abort`:Bm.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,t.retryAction=void 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-input-error`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:case`tool-approval-response`:nh(t,e);return;case`file`:eh(t,{kind:`file`,url:e.url,mediaType:e.mediaType,filename:e.filename,fileId:e.fileId,fileSize:e.fileSize});return;case`source-url`:th(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:th(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=io(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){r(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};function Hm(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function Um(e,t){e.canceled&&(t.canceled=!0),Hm(e)&&(t.status===`streaming`||jo(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function Wm(e,t){let n=e.partsSig.value,r=t.findIndex(e=>e.type===`start-step`),i=new Set(t.slice(0,r<0?t.length:r).flatMap(e=>`toolCallId`in e&&e.type.startsWith(`tool-output`)?[e.toolCallId]:[])),a=n.findLastIndex(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`||i.has(e.toolCallId)));if(a>=0)return a;let o=new Set(t.flatMap(e=>e.type===`tool-input-start`||e.type===`tool-input-available`?[e.toolCallId]:[]));return n.some(e=>e.kind===`tool`&&o.has(e.toolCallId))?-1:n.findLastIndex(e=>e.kind===`tool`)}function Gm(e,t){let n=e.partsSig.value,r=t.partsSig.value;return e.role!==t.role||r.length<n.length?!1:n.every((e,t)=>qm(e,r[t]))}function Km(e,t){let n=e.partsSig.value,r=n.findLastIndex(e=>e.kind===`tool`),i=new Set(n.slice(0,r+1).flatMap(e=>e.kind===`tool`?[e.toolCallId]:[])),a=t.partsSig.value.filter(e=>e.kind!==`tool`||!i.has(e.toolCallId)),o=n.slice(r+1);return a.length<o.length?!1:o.every((e,t)=>qm(e,a[t]))}function qm(e,t){switch(e.kind){case`text`:case`reasoning`:return t?.kind===e.kind&&t.textSig.value.startsWith(e.textSig.value);case`step-start`:return t?.kind===`step-start`;case`tool`:{if(t?.kind!==`tool`||t.toolCallId!==e.toolCallId||!Go(t.toolName,e.toolName)||Ko[t.stateSig.value]<Ko[e.stateSig.value])return!1;let n=e.approvalSig.value?.approved;return n===void 0||t.approvalSig.value?.approved===n}case`file`:return t?.kind===`file`&&t.url===e.url&&t.mediaType===e.mediaType;case`source`:return t?.kind===`source`&&t.sourceId===e.sourceId&&t.url===e.url&&t.title===e.title&&t.filename===e.filename&&t.mediaType===e.mediaType;default:return e}}function Jm(e,t,n){return Ym(e,n)||!Xm(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:ko(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function Ym(e,t){if(t.type!==`tool-output-available`&&t.type!==`tool-output-error`&&t.type!==`tool-output-denied`)return!1;let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t.toolCallId);return n!==void 0&&Ko[n.stateSig.value]<4}function Xm(e,t){let n=t.partsSig.value;if(n.length===0)return!0;let r=e.partsSig.value;return r.some((e,t)=>n.every((e,n)=>Zm(r[t+n],e)))}function Zm(e,t){switch(t.kind){case`text`:case`reasoning`:return e?.kind===t.kind&&e.textSig.value.startsWith(t.textSig.value);case`step-start`:return e?.kind===`step-start`;case`tool`:return e?.kind===`tool`&&e.toolCallId===t.toolCallId&&(t.toolName===`tool`||Go(e.toolName,t.toolName));case`file`:return e?.kind===`file`&&e.url===t.url&&e.mediaType===t.mediaType;case`source`:return e?.kind===`source`&&e.sourceId===t.sourceId&&e.url===t.url&&e.title===t.title&&e.filename===t.filename&&e.mediaType===t.mediaType;default:return t}}function Qm(e,t){if(Hm(e)||!jo(e))return!1;let n=new Set(e.partsSig.value.filter(e=>e.kind===`tool`).map(e=>e.toolCallId));return!t.partsSig.value.some(e=>e.kind===`tool`&&n.has(e.toolCallId))}function $m(e,t,n={}){let r=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(r)return n.dynamic&&(r.dynamic=!0),r.toolMetadata??(r.toolMetadata=n.toolMetadata),r.title=n.title??r.title,r;let i={kind:`tool`,toolCallId:t,toolName:n.toolName??`tool`,title:n.title,dynamic:n.dynamic?!0:void 0,toolMetadata:n.toolMetadata,inputPartialSig:o(``),inputSig:o(void 0),outputSig:o(void 0),errorSig:o(void 0),stateSig:o(`input-streaming`),approvalSig:o(void 0)};return eh(e,i),i}function eh(e,t){e.partsSig.value=[...e.partsSig.value,t]}function th(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||eh(e,t)}function nh(e,t){switch(t.type){case`tool-input-start`:$m(e,t.toolCallId,t);return;case`tool-input-delta`:{let n=$m(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=$m(e,t.toolCallId,t);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=$m(e,t.toolCallId,t);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=$m(e,t.toolCallId,t);if(t.isAutomatic){n.approvalSig.value={id:t.approvalId,isAutomatic:!0};return}n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-approval-response`:{let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.approvalSig.value?.id===t.approvalId);n?.approvalSig.value&&(n.approvalSig.value={...n.approvalSig.value,approved:t.approved,reason:t.reason});return}case`tool-output-available`:{let n=$m(e,t.toolCallId,t);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=$m(e,t.toolCallId,t);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=$m(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const rh=1e3;async function ih(e){let t=rh,n=!1,r=!1,i=!1;function a(){i||e.signal.aborted||(i=!0,e.onInitialBoundaryReady())}for(;!e.signal.aborted;){let o,s=`held`;try{s=await e.connect(()=>{if(e.signal.aborted)return;o=e.now();let t=n||r;n=!0,r=!1,i?t&&e.backfill():a()})}catch{}if(e.signal.aborted||(!n&&o===void 0&&(r=!0,a()),s===`unavailable`))return;e.onDropped?.(),o!==void 0&&e.now()-o>=1e3&&(t=rh),await e.sleep(t),t=Math.min(t*2,15e3)}}function ah(e){let{activated:t,conversationReady:n,paused:r,conversationIdSig:i,messagesSig:a,optionsRef:o,transport:s,visitorId:c,adoptControlStateChunk:l,adoptMemoryCompactionStateChunk:d,settleSuggestions:f,recordConversationReply:p,transcriptRecoverySig:h,beginConversationTranscript:g,commitConversationTranscript:_,runCancellation:v,feedback:y,bus:b,loadInitialThread:x,shouldReconcileOnConnect:S,reconnectingSig:C}=e,w=m(0);u(()=>{if(!t||!n||r||!i.value)return;let e=i.value,u=new AbortController,m=e=>{},T=new Vm(a,e=>m(e));s.primeIdentity(c,e);let E=!1,D=!1,O,k=!1,A,j=0,ee,M,N=Date.now(),P,te=!1,ne=!1,re=!1,F;function ie(t,n){if(!wo(t))return;let r=a.value.findLast(e=>!e.ephemeral),i=t.serverMessageId??t.id;if(!(r&&(r.serverMessageId??r.id)!==i)){if(P&&te&&!a.value.some(e=>e.role===`user`&&!e.ephemeral))F={replyId:i,activityAt:n};else return Co(a.value,t,e,o.current.strings.newConversation,n)}}function ae(e,t,n){let r=ie(e,n);if(!r)return;let i=`${e.serverMessageId??e.id}:${t}:${r.preview??``}`;i!==M&&(M=i,s.publishConversation({...r,hasUnread:!0},!0))}let I;function oe(){I&&(clearTimeout(I.timer),I=void 0)}function se(){let e=I;if(!e)return;clearTimeout(e.timer),I=void 0;let t=a.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&ae(t,e.generation,e.activityAt)}function ce(e,t,n){oe(),I={replyId:e.serverMessageId??e.id,generation:t,activityAt:n,timer:setTimeout(se,120)}}function le(e,t,n=Date.now(),r=!0){oe();let i=ie(e,n);if(!i)return;let a=`${e.serverMessageId??e.id}:${t}`;a!==ee&&(ee=a,p(i),r&&P&&!te&&(ne=!0))}function ue(e,t){(e||!v.localSendRef.current)&&v.settle(t)}function L(e,t=[],n=!1,r,i=j,s=Date.now(),c=!0){let l=o.current;if(e.canceled){le(e,i,s,c),ue(n,r);return}let u=!0,d=e.status===`error`;switch(Zo(e,d)){case`drop`:a.value=a.value.filter(t=>t!==e),u=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(y.play(`messageReceived`),qs(b,l,`assistant`,So(e)));break;case`error`:if(e.status=`error`,n){y.play(`error`);let e=/* @__PURE__ */ Error(d?`stream error chunk`:`empty reply`);b.emit(`error`,e),l.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(y.play(`messageReceived`),qs(b,l,`assistant`,So(e))),f(e,t)}u&&le(e,i,s,c),ue(n,r)}function de(t){if(u.signal.aborted||i.value!==e)return;if(l(t),d?.(t),t.type===`start`){se();let n=t.messageId===void 0?void 0:a.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);k=n!==void 0&&n.status!==`streaming`;let r=A?.senderRole===`visitor`?A.messageId:void 0;A={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},j+=1,N=Date.now(),M=void 0,E=t.messageMetadata?.senderRole===void 0,D=!1,O=E?t.messageMetadata?.runId:void 0;let i=E?t.messageMetadata?.senderMessageId:void 0;function o(e){return e.role===`assistant`&&e.retryAction?.kind===`resend-user`&&e.retryAction.messageId===i}if(i&&a.value.some(o)&&(a.value=a.value.filter(e=>!o(e))),E){let n=t.messageId!==void 0&&a.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),i=a.value.at(-1),o=t.messageId!==void 0&&(i?.serverMessageId===t.messageId||i?.id===t.messageId),s=v.localSendRef.current&&(!n||o)&&i?.role===`assistant`&&i.status===`streaming`&&(o||i.serverMessageId===void 0&&i.partsSig.value.length===0);D=v.captureStart(e,t,s,r)}}let n=E&&(t.type===`finish`||t.type===`error`||t.type===`abort`),r=n?O:void 0,s=n&&(D||v.ownsLocalRun(r)),c=j,f=k;n&&(E=!1,D=!1,O=void 0);let p=T.applyResume(t),m=A?.messageId,h=m===void 0?void 0:a.value.find(e=>e.serverMessageId===m||e.id===m);k&&A?.senderRole!==`visitor`&&(p!==null||h?.status===`streaming`)&&(k=!1,f=!1);let g=!k&&(h?.role===`assistant`||h?.role===`operator`);t.type===`text-delta`&&g&&ce(h,j,N),t.type===`text-end`&&(oe(),g&&ae(h,j,N)),p?p.role===`operator`?(f||(y.play(`messageReceived`),qs(b,o.current,`operator`,So(p))),le(p,c,N),k=!1,n&&(s||!v.localSendRef.current)&&v.settle(r)):p.role===`assistant`&&(L(p,[],s,r,c,N),k=!1):n&&(s||!v.localSendRef.current)&&v.settle(r)}async function R(t){let n=j,r=await s.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(u.signal.aborted||i.value!==e||!r)return!1;r.controlState&&l({type:`data-control-state`,data:r.controlState});let o=a.value.at(-1),c=n===j&&(t===void 0||o!==void 0&&(o.serverMessageId===t||o.id===t));if(r.messages.length===0)return!0;let d=a.value,p=t===void 0?d.at(-1):d.find(e=>e.serverMessageId===t||e.id===t),m=Ho(d,yo(r.messages)),h=Bo(r.messages),g=m.messages.filter(e=>!(e.role===`assistant`&&e.retryAction?.kind===`resend-user`&&h.has(e.retryAction.messageId)));if(!m.changed&&g.length===m.messages.length)return!0;a.value=g;let _=t===void 0?g.at(-1):g.find(e=>e.serverMessageId===t||e.id===t),y=p!==void 0&&_!==void 0&&(p.id===_.id||p.serverMessageId!==void 0&&p.serverMessageId===_.serverMessageId),b=_!==void 0&&_.status!==`streaming`&&(!y||p?.status===`streaming`),x=y&&p?.status===`streaming`?Date.now():_?.createdAt;return c&&b&&_.role===`assistant`?L(_,_.suggestions??[],v.localSendRef.current,void 0,n,x,!1):c&&b&&_.role===`operator`?le(_,n,x,!1):c&&_?.role===`assistant`&&_.status!==`streaming`&&f(_,_.suggestions??[]),!0}let fe=/* @__PURE__ */ new Set;m=({messageId:e})=>{if(fe.has(e)||!a.value.some(t=>t.serverMessageId===e||t.id===e))return;fe.add(e);function t(){return fe.delete(e)}R(e).then(t,t)};function z(){let e=F;F=void 0;let t=e&&a.value.find(t=>(t.serverMessageId??t.id)===e.replyId),n=t&&ie(t,e.activityAt);n&&p(n)}function pe(t=!1){if(u.signal.aborted||i.value!==e){ne=!1;return}if(P){ne=!0;return}let n=t?x(e):void 0,r=n??(!t||S()?R():void 0);if(!r)return;g(e),P=r,te=n!==void 0;function a(t=!1){P===r&&(P=void 0,T.replayTurn(),ne?(ne=!1,pe()):(z(),t&&_(e)))}r.then(a,()=>a(!1))}let me=h.subscribe(e=>{e<=w.current||(w.current=e,re&&pe())});return ih({signal:u.signal,now:()=>performance.now(),sleep:e=>es(e,u.signal),connect:e=>s.connectResumeStream({signal:u.signal,onChunk:de,onConnected:()=>{C.value=!1,e()}}),onDropped:()=>{C.value=!0},onInitialBoundaryReady:()=>{re=!0,pe(!0)},backfill:()=>pe()}),()=>{u.abort(),C.value=!1,oe(),me(),T.detach()}},[t,n,r,i,i.value,c,s,l,d,f,p,h,g,_,v,a,b,y,x,S,C])}function oh(e){let{transport:t,setStreaming:n}=e,r=m(void 0),i=m(void 0),a=m(!1),o=m(void 0),s=m(!1),c=m(/* @__PURE__ */ new Map),u=m(/* @__PURE__ */ new Set),d=l((e,n)=>{let r=`${e}:${n}`;o.current!==r&&(o.current=r,t.cancelTurn(e,n))},[t]),f=l(e=>{r.current=void 0,i.current=e,a.current=!1,o.current=void 0,s.current=!0,n(!0)},[n]),h=l((e,t)=>{c.current.set(e,{messageId:t})},[]),g=l(e=>{if(e!==void 0){u.current.add(e);let t=u.current.values().next().value;u.current.size>32&&t!==void 0&&u.current.delete(t)}(e===void 0||r.current?.runId===e)&&(r.current=void 0,i.current=void 0,a.current=!1,s.current=!1,n(!1))},[n]),_=l((e,t)=>i.current===e?(i.current=void 0,t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},n(!0),a.current&&d(t.conversationId,t.runId),!0):(g(),!0)):t.runId&&r.current?.runId===t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&d(t.conversationId,t.runId),!0):!1,[d,n,g]),v=l((e,t)=>{let l=c.current.get(e);return l?(c.current.delete(e),!t.runId||u.current.has(t.runId)?!0:l.runId===void 0?(s.current||i.current||(r.current={conversationId:t.conversationId,runId:t.runId},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0)),!0):(l.runId===t.runId&&r.current?.runId===t.runId&&(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&d(t.conversationId,t.runId)),!0)):!1},[d,n]),y=l(e=>i.current===e&&(g(),!0),[g]),b=l(e=>{let t=c.current.get(e);return t?(c.current.delete(e),t.runId===void 0):!1},[]),x=l((e,t,l,f)=>{let p=t.messageMetadata?.runId;if(t.messageMetadata?.senderRole!==void 0||typeof p!=`string`||!p||u.current.has(p))return!1;if(r.current?.runId===p)return s.current;if(s.current)return r.current||!l?!1:(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&d(e,p),!0);let m=[...c.current.values()].filter(e=>e.runId===void 0).find(e=>e.messageId===f);return m?(m.runId=p,r.current={conversationId:e,runId:p},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0),!0):(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&d(e,p),s.current)},[d,n]),S=l(e=>typeof e==`string`&&r.current?.runId===e&&s.current,[]),C=l(()=>{let e=r.current;if(e)return a.current=!0,d(e.conversationId,e.runId),!0;let t=i.current;return t?(a.current=!0,t.then(e=>{e.runId&&d(e.conversationId,e.runId)}).catch(()=>void 0),!0):!1},[d]);return p(()=>({localSendRef:s,begin:f,beginRouted:h,acceptAck:_,acceptRoutedAck:v,reject:y,rejectRouted:b,captureStart:x,ownsLocalRun:S,settle:g,stop:C}),[_,v,f,h,x,S,y,b,g,C])}const sh=V.scope(`send`);function ch(e,t,n,r,i){e.publishConversation({...Co(t,n,r,i),hasUnread:!1},!0)}function lh(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function uh(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||wo(e)))}function dh(e,t,n,r,i){let a=uh(t);a?.role===`user`&&lh(a,n)&&ch(e,t,a,r,i)}function fh(e){return e instanceof is&&e.status===404&&e.errorCode===`CONVERSATION_NOT_FOUND`}function ph(e){return!(e instanceof is)||e.code===`network`||e.status===void 0||e.status===202||e.status===408||e.status===425||e.status===429||e.status>=500&&e.status<600}function mh(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:u,applyControlState:d,setTicket:f,settleSuggestions:p,runCancellation:m,onConversationNotFound:h}=e,g=l(()=>{let e=r.value??$t();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:l(async({continueExisting:e,turn:l,movedFromConversation:_=!1})=>{let v=g(),y=n.value.at(-1),b=l?[l]:bo(n.value,e),x=b[0];x?.role===`user`&&Xd.markSent(x.id);let S=b.map(xo),C=s.loadUserPrefs(),w=df(i.tools).then(n=>t.sendTurn(ao({messages:S,conversationId:v,visitorId:c,userPrefs:C,clientTools:ff(n)}),{keepalive:e}));m.begin(w);try{let a=await w;if(r.value!==v||!m.acceptAck(w,a))return!1;if(u(a.conversationId),f({conversationId:a.conversationId,reference:a.ticketReference}),a.runId&&x?.role===`user`&&dh(t,n.value,x,a.conversationId,i.strings.newConversation),!a.runId){let o=await t.loadConversation(a.conversationId).catch(()=>null);if(r.value!==a.conversationId)return!0;if(o){o.controlState&&d(o.controlState);let r=yo(o.messages),{messages:s,changed:c}=Ho(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),u=uh(n.value);u&&l&&lh(u,l)&&ch(t,n.value,u,a.conversationId,i.strings.newConversation);let f=y?n.value.find(e=>e.id===y.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;f&&p(f,f.suggestions??[]),!e&&y?.role===`assistant`&&n.value.includes(y)&&y.serverMessageId===void 0&&!wo(y)&&(n.value=n.value.filter(e=>e!==y))}else y?.role===`assistant`&&n.value.includes(y)&&(y.status=`error`,y.errorText=i.strings.errorGeneric,y.retryAction=e?{kind:`continue-assistant`,messageId:y.serverMessageId??y.id}:x?.role===`user`?{kind:`resend-user`,messageId:x.id}:null,n.value=[...n.value])}return!0}catch(c){if(r.value!==v)return!1;if(!m.reject(w))return x?.role===`user`&&dh(t,n.value,x,v,i.strings.newConversation),!0;if(!e&&!_&&x?.role===`user`&&fh(c))return h(x);if(!e&&x?.role===`user`&&c instanceof is&&c.status===401){let e=y?.role===`assistant`&&y.serverMessageId===void 0?y:void 0;return n.value=n.value.filter(t=>t!==x&&t!==e),s.saveDraft(v,So(x)),!1}let u=$l(c,i.strings),f=ph(c),g=l?.role===`assistant`?l:n.value.at(-1);if(e&&g?.role===`assistant`&&c instanceof is&&c.status===409){let e=g.serverMessageId??g.id,i=await t.loadConversation(v,{ids:[e]}).catch(()=>null);if(r.value!==v)return!1;if(i){i.controlState&&d(i.controlState);let t=yo(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Uo(g,r)){let{messages:r,changed:i}=Ho(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==g)return a.awaitingContinuation=!1,a.continuationStreaming=void 0,a.retryAction=null,n.value=r,a.status!==`streaming`&&p(a,a.suggestions??[]),!0}}if(!n.value.includes(g)||g.status!==`streaming`)return!1;g.continuationStreaming=!0}if(e&&g?.role===`assistant`)g.status=`error`,g.errorText=u,g.retryAction=f?{kind:`continue-assistant`,messageId:g.serverMessageId??g.id}:null,n.value=[...n.value];else if(y?.role===`assistant`&&n.value.includes(y)){y.status=`error`,y.errorText=u;let e=b[0];y.retryAction=f&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=lo();e.status=`error`,e.errorText=u;let t=b[0];e.retryAction=f&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,c),i.onError?.(c),!1}},[t,n,i,a,o,s,c,u,d,f,p,g,m,h]),sendRoutedTurn:l(async e=>{let l=g();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),Xd.markSent(e.id);let d=[xo(e)],p=s.loadUserPrefs(),_=df(i.tools).then(e=>t.sendTurn(ao({messages:d,conversationId:l,visitorId:c,userPrefs:p,clientTools:ff(e)})));m.beginRouted(_,e.id);try{let a=await _;return r.value===l?m.acceptRoutedAck(_,a)?(u(a.conversationId),f({conversationId:a.conversationId,reference:a.ticketReference}),dh(t,n.value,e,a.conversationId,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0):!1:(m.rejectRouted(_),!1)}catch(s){let c=m.rejectRouted(_);if(r.value!==l)return!1;if(!c)return dh(t,n.value,e,l,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0;if(e.status!==`pending`)return dh(t,n.value,e,l,i.strings.newConversation),!0;if(fh(s))return h(e);sh.debug(`operator-routed send failed`,{error:s});let u=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=$l(s,i.strings),e.retryAction=ph(s)?{kind:`resend-user`,messageId:e.id}:null,n.value.includes(e)&&(n.value=[...n.value]),o.play(`error`),a.emit(`error`,u),i.onError?.(u),!1}},[t,n,i,a,o,s,c,u,f,g,m,h])}}const hh=V.scope(`unread`);function gh(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=c(!1),d=c(0),f=c(0),p=m([]),h=m(void 0),g=m(!1),_=m(!1),v=l(()=>{let e=r.value,t=i.current()&&h.current===e?e:void 0,n=p.current.filter(e=>e.hasUnread&&e.conversationId!==t).length;d.value=n,s.value=n>0},[r,s,d,i]),y=l(e=>{let t=r.value,n=p.current.find(e=>e.conversationId===t),i=xs(p.current,e),a=i.find(e=>e.conversationId===t),o=e.type===`snapshot`&&t!==void 0&&a?.hasUnread===!0&&h.current===t&&n!==void 0&&n.lastMessageAt!==a.lastMessageAt;o&&(h.current=void 0),p.current=i,v(),o&&(f.value+=1)},[r,v,f]),b=l(()=>{if(v(),!i.current())return;let e=r.value;if(!e||h.current!==e)return;let n=p.current.find(t=>t.conversationId===e);n?.hasUnread&&t.markRead(e,n.lastMessageAt)},[r,i,v,t]),x=l(e=>{r.value===e&&(h.current=void 0,v())},[r,v]),S=l(e=>{r.value===e&&(h.current=e,b())},[r,b]),C=l(e=>h.current===e,[]),w=l((e=!1)=>{if(!n.history.enabled||!n.modules.list.some(e=>e.layout===`chat`))return;function r(e){g.current?e&&(_.current=!0):(g.current=!0,t.listConversations({limit:50},e).then(t=>{e||y({type:`snapshot`,result:t,requestedRevision:0}),b()}).catch(e=>hh.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{g.current=!1,_.current&&(_.current=!1,r(!0))}))}r(e)},[y,b,n.history.enabled,n.modules,t]),T=l(e=>{let n=e.conversationId,a=i.current()&&r.value===n&&h.current===n,o=p.current.find(e=>e.conversationId===n),s=a&&(o?.lastMessageAt!==e.lastMessageAt||o.hasUnread);t.publishConversation({...e,hasUnread:!a},!0),s&&t.markRead(n,e.lastMessageAt)},[r,i,t]);u(()=>t.subscribeConversationChanges(y),[y,t]);let E=m(!1);return u(()=>{a&&o&&!E.current&&(E.current=!0,w())},[a,o,w]),u(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(b(),w(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,b,w]),{hasUnreadSig:s,unreadCountSig:d,transcriptRecoverySig:f,markVisibleConversationRead:b,beginConversationTranscript:x,commitConversationTranscript:S,isConversationTranscriptCommitted:C,recordConversationReply:T,refreshUnread:w}}const _h=V.scope(`settings`);function vh(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,d]=h(()=>s.locale??t.locale),[f,p]=h(s.themeMode),m=_t(t.themeMode,f),[g,_]=h(()=>s.textSize??t.textSize),v=l(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>_h.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);u(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),u(()=>{if(m!==`host`)a.dataset.theme=m;else return _n(e=>{a.dataset.theme=e})},[a,m,t]),u(()=>{a.dataset.textSize=g},[a,g,t]),u(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:v({soundMuted:t})})},[i,v]);let y=ct(c,t.availableLocales,t.defaultLocale);return u(()=>{r.setLocale(y)},[r,y]),u(()=>{a.dir=ee(y)?`rtl`:`ltr`},[a,y]),u(()=>{y!==c&&d(y)},[y,c]),{activeLocale:c,activeThemeMode:m,activeTextSize:g,setActiveLocale:d,setActiveThemeMode:p,setActiveTextSize:_,patchAndSync:v,handleLocaleChange:l(e=>{_h.info(`localeChange`,{locale:e}),d(e),v({locale:e}),o.emit(`localeChange`,e)},[v,o]),handleThemeChange:l(e=>{_h.info(`themeChange`,{mode:e}),p(e),a.dataset.theme=e,v({themeMode:e}),o.emit(`themeChange`,e)},[a,v,o]),handleTextSizeChange:l(e=>{_h.info(`textSizeChange`,{size:e}),_(e),a.dataset.textSize=e,v({textSize:e}),o.emit(`textSizeChange`,e)},[a,v,o]),handleSoundToggle:l(()=>{i.toggleMuted();let e=i.mutedSig.value;_h.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=V.scope(`app`),yh=P.cssPrefix,bh={home:`home`,chats:`chat`,help:`help`,news:`news`};function xh({options:e,hostElement:t,bus:n,recentHostEvents:i,loginRevision:o=0,onPersonChanged:d,onStartAsGuest:g}){let y=e.aiAgentDeploymentId;if(!y)throw Error(`aiAgentDeploymentId is required`);let[b]=h(()=>nn(e.widgetId,e.storage,e.aiAgentDeploymentId)),[x,S]=h(()=>b.getVisitorId()),C=b.loadUserPrefs(),w=c(b.loadConversationId()),T=m(w.value!==void 0),D=c(w.value??``),O=c([]),k=c(!1),[A,j]=h(!1),ee=m(void 0);function N(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=b.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function te(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function ne(){let t=te();return t?e.modules.list.length===1||F.sig.value.activeTab===t:!1}let re=m(void 0);if(!re.current){let t=e.modules.list.map(e=>e.id),n=b.loadActiveModule()??t[0]??``;re.current=Xs(n,n?[...t,n]:t,e=>b.saveActiveModule(e))}let F=re.current,ie=s(()=>F.sig.value.activeTab).value,ae=s(()=>w.value).value,[I,oe]=h(!1),[se,ce]=h(!1),le=e.mode===`standalone`||e.mode===`inline`,ue=m(rc(e,ic(),b.loadPanelOpen(),b.loadPanelSize())),[L,de]=h(ue.current.panelOpen),[R,fe]=h(ue.current.panelOpen),z=m(void 0),pe=m(void 0),me=m(!1),he=m(void 0),B=m(e.strings),ge=m(void 0);u(()=>{L&&fe(!0)},[L]);let _e=m(!1),[ve,ye]=h(!1),be=m(null),xe=m(!1),{dismissed:Se,dismissCallout:Ce}=Am({callout:e.launcher.callout,persistence:b}),we=e.launcher.callout?.persistent??!0,Te=l(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),Ce()},[n,Ce]),[Ee,De]=h(ue.current.panelSize),Oe=m(!1),[ke,Ae]=h(`chat`),je=m(()=>!1);je.current=()=>L&&ke===`chat`&&!document.hidden&&ne();let[Me,Ne]=h(!1),Pe=m(Me);Pe.current=Me;let Fe=m(null),[Ie,Le]=h(!1),Re=c(/* @__PURE__ */ new Map),ze=l((e,t)=>{let n=new Map(Re.value);t?n.set(e,t):n.delete(e),Re.value=n},[Re]),[Be,Ve]=h(null),[He,Ue]=h(),[We,Ge]=h([]),Ke=m(e);Ke.current=e;let[qe,Je]=h(void 0),[Ye,Xe]=h(void 0),[V,Ze]=h(()=>b.loadSidebarCollapsed()??!1),[Qe,$e]=h({status:`anonymous`}),[et,tt]=h({}),[nt,rt]=h(),[H]=h(()=>new Os({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Mn({publicKey:e.publicKey,aiAgentDeploymentId:y,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:i,onLoginState:$e,continueLink:e.continueLink})),[it]=h(()=>new ar(e.sound,e.haptics)),at=oh({transport:H,setStreaming:Ne}),{activeLocale:ot,activeThemeMode:st,activeTextSize:ct,setActiveLocale:lt,setActiveThemeMode:ut,setActiveTextSize:dt,patchAndSync:ft,handleLocaleChange:pt,handleThemeChange:mt,handleTextSizeChange:ht,handleSoundToggle:gt}=vh({options:e,persistence:b,transport:H,feedback:it,hostElement:t,bus:n}),{controlModeSig:_t,assignedOperatorSig:yt,operatorAvailableSig:bt,applyControlState:xt,adoptControlStateChunk:St,requestOperator:Ct,cancelOperatorRequest:wt}=Fm({transport:H,conversationIdSig:w}),Tt=c(/* @__PURE__ */ new Map),Et=l(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=w.value;if(!t)return;let n=ro(e.data);if(!n)return;let r=Tt.value.get(t);if(r&&(n.postFinishSequence<r.postFinishSequence||n.postFinishSequence===r.postFinishSequence&&(r.status===`ready`||r.status===n.status)))return;let i=new Map(Tt.value);i.set(t,n),Tt.value=i},[w,Tt]),{hasUnreadSig:Dt,unreadCountSig:Ot,transcriptRecoverySig:kt,markVisibleConversationRead:At,beginConversationTranscript:jt,commitConversationTranscript:Mt,isConversationTranscriptCommitted:Nt,recordConversationReply:Pt,refreshUnread:Ft}=gh({transport:H,options:e,conversationIdSig:w,isConversationVisibleRef:je,activated:R,conversationReady:I}),It=Pm({state:Qe,deployment:et,bus:n,persistence:b,conversationIdSig:w}),Lt=L&&e.modules.byId[ie]?.layout===`home`,Rt=km({transport:H,options:e,persistence:b,enabled:I&&Lt});u(()=>{At()},[ie,L,ke,ae,At]),u(()=>{it.update(e.sound,e.haptics)},[it,e.sound,e.haptics]),u(()=>()=>it.destroy(),[it]),u(()=>{!Oe.current&&e.size.initialSize&&(Oe.current=!0,b.loadPanelSize()||De(nc(e.mode,e.size,ic())))},[e.mode,e.size,b]),u(()=>{if(!I||_e.current)return;_e.current=!0;let t=rc(e,ic(),b.loadPanelOpen(),b.loadPanelSize());de(t.panelOpen),De(t.panelSize)},[I,e,b]);let zt=m(null);u(()=>{I&&F.reconcile(e.modules.list.map(e=>e.id),N())},[I,e.modules.list,F]);let Bt=l(e=>{e&&e.length!==0&&(O.value=e.map(e=>uo({...e,text:M(B.current,e.text)})))},[O]),Vt=m(0),Ht=m(0),Ut=l(e=>{if(e===w.value)return;let t=w.value;Ht.current++,j(!1),t&&(b.saveDraft(e,b.loadDraft(t)),b.saveDraft(t,``),b.saveMessageQueue(e,b.loadMessageQueue(t)),b.saveMessageQueue(t,[])),w.value=e,b.saveConversationId(e),H.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,w,b,H]),Wt=l(e=>{let t=e.map(e=>e.createdAt).filter(e=>e!==void 0),n=(t.length?Math.min(...t):Date.now())-1;return[...(he.current?.messages??[]).map(e=>{let t=uo({...e,text:M(B.current,e.text)});return t.createdAt=n,t}),...e]},[]),Gt=l(async e=>{let t=Ht.current;function r(){return t!==Ht.current||w.value!==e}pe.current===e&&(pe.current=void 0),j(!0);try{let t=await H.loadConversation(e);if(r())return!1;let n=yo(t.messages),i=Wt(Vo(n,O.value));if(O.value=i,pe.current=i.some(e=>e.role===`user`)?void 0:e,n.length>0||t.controlState!==void 0){Ue({conversationId:e,reference:t.ticketReference}),t.controlState&&xt(t.controlState);let r=n.findLast(e=>e.role===`assistant`&&!e.ephemeral);Ge(r?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),Ke.current.onError?.(t)),!1}finally{r()||j(!1)}},[H,O,w,Wt,n]),Kt=l(e=>{if(z.current===e)return z.current=void 0,Gt(e)},[Gt]),qt=l(()=>{if(ee.current)return Promise.resolve(void 0);let t=w.value,r=O.value.find(e=>e.serverMessageId!==void 0),i=r?.serverMessageId,a=r?new Date(r.createdAt).toISOString():void 0;if(!t||!i||!a)return Promise.resolve(void 0);let o=Ht.current,s={};return ee.current=s,(async()=>{try{let e=await H.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(ee.current!==s||Ht.current!==o||w.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(mo),r=O.value,c=Po(r,n);if(c!==r){let e=Math.min(...n.map(e=>e.createdAt??1/0));if(Number.isFinite(e))for(let t of r){if(!t.ephemeral)break;(t.createdAt??1/0)>=e&&(t.createdAt=e-1)}O.value=c}return!0}catch(r){if(ee.current!==s||Ht.current!==o||w.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{ee.current===s&&(ee.current=void 0)}})()},[n,w,O,e,H]),Jt=l(async({newConversation:t})=>{let i=++Vt.current;function a(){return i!==Vt.current}if(!t){let e=await H.userSub(),t=b.loadLastUserSub();if(a())return;if(t&&t!==e){d?.();return}e&&b.saveLastUserSub(e)}let o=w.value,s=t||!o?$t():o;s!==o&&(Ht.current++,j(!1),r(()=>{w.value=s,D.value=s}),b.saveConversationId(s)),H.primeIdentity(x,s);let c;try{c=await H.handshake({visitorId:x,conversationId:s,userPrefs:b.loadUserPrefs(),locale:ot})}catch(r){if(a())return;n.emit(`error`,r),e.onError?.(r);let i=r instanceof is&&r.errorCode?Ch[r.errorCode]:void 0;if(i){$.warn(`the widget is not shown: ${i}`),(le||e.mode===`page`)&&ce(!0);return}t||oe(!0);return}if(a())return;e.continueLink&&c.visitorId!==x&&S(c.visitorId),c.conversationId!==s&&Ut(c.conversationId),ge.current=c;let l=E(c,ot);Ve(l.agent),tt(lr(c.config?.login));let u=c.config?.maxMessageCharacters;rt(typeof u==`number`&&u>0?u:void 0),l.site&&sr(l.site)?Je(l.site):l.site&&$.warn(`invalid site config, using fallback`,{site:l.site}),l.blocks&&cr(l.blocks)?Xe(l.blocks):l.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:l.blocks});let f=on(c.userPrefs);if(Object.keys(f).length>0&&!t&&(b.saveUserPrefs(f),f.locale&&lt(f.locale),f.soundMuted!==void 0&&it.setMuted(f.soundMuted),f.themeMode&&ut(f.themeMode),f.textSize&&dt(f.textSize)),he.current=l.welcome,t||n.emit(`handshake`,c),l.welcome?.suggestions){let e=B.current;Ge(l.welcome.suggestions.map(t=>({...t,label:M(e,t.label),...t.text===void 0?{}:{text:M(e,t.text)}})))}let p=!t&&(c.conversationId===o||e.continueLink!==void 0);T.current=p,p?me.current||(z.current=c.conversationId):(pe.current=c.conversationId,Bt(l.welcome?.messages),Mt(c.conversationId)),t||oe(!0)},[H,x,b,e,n,w,D,it,Bt,ot,Ut,Mt,d]),Yt=JSON.stringify(e.userContext??null),Xt=JSON.stringify(e.pageContext??null);u(()=>{H.setContext(e.userContext,Sh(e.pageContext))},[H,Yt,Xt]);let Zt=m(!1);u(()=>{H.setUserToken(e.userToken),Zt.current?Jt({newConversation:!1}).then(()=>{R&&Ft(!0)}):Zt.current=!0},[H,e.userToken,o]);let Qt=l((e,t=[])=>Ge(e.suggestions??t),[]);u(()=>(H.primeIdentity(x,w.value),Jt({newConversation:!1}),()=>{Vt.current++,Ht.current++}),[]),u(()=>{R&&I&&!me.current&&(me.current=!0,z.current===w.value&&j(!0))},[R,I]);let en=m(Yt);u(()=>{I&&en.current!==Yt&&(en.current=Yt,Jt({newConversation:!1}))},[Yt,I,Jt]);let tn=m(async()=>!1),{sendAiTurn:rn,sendRoutedTurn:an}=mh({onConversationNotFound:e=>tn.current(e),transport:H,messagesSig:O,conversationIdSig:w,options:e,bus:n,feedback:it,persistence:b,visitorId:x,adoptConversationId:Ut,applyControlState:xt,setTicket:Ue,settleSuggestions:Qt,runCancellation:at}),{toolInteraction:sn,pageToolsRunning:cn,stopPageTools:ln}=Dm({streaming:Me,controlModeSig:_t,messagesSig:O,sendAiTurn:rn,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),un=l((e,t)=>{let r=O.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),H.submitFeedback({messageId:e,value:t})},[n,O,H]),dn=l(()=>T.current||O.value.some(e=>!e.ephemeral&&e.role===`user`),[O]);ah({activated:R,conversationReady:I,paused:Qe.status===`pending`||Qe.status===`expired`,conversationIdSig:w,messagesSig:O,optionsRef:Ke,transport:H,visitorId:x,adoptControlStateChunk:St,adoptMemoryCompactionStateChunk:Et,settleSuggestions:Qt,recordConversationReply:Pt,transcriptRecoverySig:kt,beginConversationTranscript:jt,commitConversationTranscript:Mt,runCancellation:at,feedback:it,bus:n,loadInitialThread:Kt,shouldReconcileOnConnect:dn,reconnectingSig:k});let fn=l(async(t,r,i)=>{if(Fe.current||It.gate)return!1;let a=w.value,o=a?Tt.value.get(a):void 0,s=_t.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:Pe.current,routedToOperator:s}),Pe.current&&!s))return!1;let c=new AbortController,l={conversationId:a,controller:c};Fe.current=l,Le(!0);try{it.unlock(),Re.value=/* @__PURE__ */ new Map;let o=await Eh(H,r,c.signal,ze,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||w.value!==a)return!1;let s=a?Tt.value.get(a):void 0,l=_t.value!==`ai-agent`;if(!l&&s?.status===`compacting`||Pe.current&&!l||!i&&o.length<r.length||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),We.length>0&&Ge([]),it.play(`messageSent`);let u=co(t,o,i);return qs(n,e,`user`,t),l?(O.value=[...O.value,u],i?await an(u):(an(u),!0)):(O.value=[...O.value,u,lo()],i?await rn({continueExisting:!1}):(rn({continueExisting:!1}),!0))}finally{Fe.current===l&&(Fe.current=null,Le(!1))}},[H,n,e,We.length,O,w,Tt,rn,an,_t,Re,ze,It.gate]),pn=m(fn);pn.current=fn;let mn=w.value,hn=(mn?Tt.value.get(mn):void 0)?.status===`compacting`,gn=_t.value===`ai-agent`,_n=s(()=>{let e=O.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`))}),vn=s(()=>O.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));f(()=>{let e=w.value;return()=>{let t=Fe.current;t&&t.conversationId===e&&(Fe.current=null,Le(!1),t.controller.abort())}},[w.value]);let yn=l(()=>{if(Fe.current){$.info(`stop uploads`),Fe.current.controller.abort();return}if(cn){$.info(`stop page tools`),n.emit(`stop`,void 0),ln();return}if(!at.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=O.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,O.value=[...O.value])},[at,n,O,cn,ln]),bn=l(e=>{$.info(`card action`,{text:e}),pn.current(e,[])},[]),xn=l(e=>{if(Me)return;let t=O.value,n=Yo(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(_t.value!==`ai-agent`||e.role!==`assistant`||(e.serverMessageId??e.id)!==n.messageId)return;e.status=`streaming`,e.errorText=void 0,e.retryAction=void 0,e.awaitingContinuation=!0,O.value=[...t],rn({continueExisting:!0,turn:e});return;case`resend-user`:{let r=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!r)return;let i=e=>{e&&zt.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,_t.value!==`ai-agent`){O.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],an(r).then(i);return}let a=lo();O.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],rn({continueExisting:!1,turn:r}).then(i);return}case`repeat-user`:{let e=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!e)return;let r=co(So(e),e.attachments?.map(e=>({...e}))??[]),i=new Set(r.attachments?.flatMap(e=>e.url?[e.url]:[])??[]),a=e.partsSig.value.flatMap(e=>e.kind===`file`&&!i.has(e.url)?[{...e}]:[]);if(a.length>0&&(r.partsSig.value=[...r.partsSig.value,...a]),_t.value!==`ai-agent`){O.value=[...t,r],an(r);return}O.value=[...t,r,lo()],rn({continueExisting:!1,turn:r});return}default:return n}},[Me,O,_t,rn,an]),Sn=l(()=>{Ks(e.mode,Ee)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),De(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),xe.current=t.contains(t.ownerDocument.activeElement),de(!1),b.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,b,Ee,t]);zm({hostElement:t,mode:e.mode,panelSize:Ee,isOpen:L,surfaceReady:I,onClose:Sn}),u(()=>{!L&&xe.current&&(xe.current=!1,be.current?.focus())},[L]);let Cn=l(()=>{$.info(`open`,{mode:e.mode}),it.unlock(),ye(!0),de(!0),b.savePanelOpen(!0),!Se&&!we&&Te(),setTimeout(()=>ye(!1),wh),n.emit(`open`,void 0),e.onOpen?.()},[n,e,it,b,Se,we,Te]),wn=l(()=>{let e=O.value.some(e=>e.role===`user`);if(pe.current===w.value&&!e&&w.value)$.info(`clear → reusing empty conversation`,{conversationId:w.value}),O.value.length===0&&Bt(he.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:Me}),n.emit(`clear`,void 0),at.settle(),T.current=!1,z.current=void 0,pe.current=void 0,r(()=>{O.value=[],w.value=void 0,xt({controlMode:`ai-agent`,controlRevision:0})}),b.clearConversation(),Ge([]),Jt({newConversation:!0})},[Me,O,w,b,Jt,n,Bt,at,xt]);tn.current=async e=>($.info(`conversation not found → new conversation`,{messageId:e.id}),await wn(),e.status=`complete`,e.errorText=void 0,e.retryAction=void 0,O.value=[...O.value,e,lo()],rn({continueExisting:!1,turn:e,movedFromConversation:!0}));let Tn=l(()=>{let t=wn();Ae(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&F.switchTab(n),t},[wn,F,e]),En=l(async e=>{await Tn(),await pn.current(e,[])||zt.current?.fill(e)},[Tn]),Dn=l(()=>{let e=Ee===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:Ee,expanded:e===`expanded`}),De(e),b.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,Ee,b]),On=l(()=>{let e=Ee===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:Ee,fullscreen:e===`fullscreen`}),De(e),b.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,Ee,b]),kn=l(()=>{Ae(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),An=l(()=>{Ze(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),b.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[b,n]),jn=l(e=>{$.info(`resize`,e),ft({widgetSize:e}),n.emit(`resize`,e)},[ft,n]),Nn=l(async t=>{let i=t.conversationId;if(i===w.value&&Nt(i)){$.info(`selectConversation`,{conversationId:i,cached:!0}),n.emit(`selectConversation`,{conversationId:i}),H.publishConversation(t),Ae(`chat`);let e=te();e&&F.switchTab(e),Mt(i);return}let a=++Vt.current;Ht.current++,j(!1);function o(){return a!==Vt.current}$.info(`selectConversation`,{conversationId:i,wasStreaming:Me}),n.emit(`selectConversation`,{conversationId:i}),H.publishConversation(t);try{let e=await H.loadConversation(i);if(o())return;at.settle(),T.current=!0,z.current=void 0;let t=yo(e.messages),n=e.conversationId!==w.value,a=n?t:Vo(t,O.value);pe.current=a.some(e=>e.role===`user`)?void 0:e.conversationId,r(()=>{O.value=Wt(a),n&&(D.value=e.conversationId),w.value=e.conversationId}),b.saveConversationId(e.conversationId),H.primeIdentity(x,e.conversationId),Ue({conversationId:e.conversationId,reference:e.ticketReference}),e.controlState&&xt(e.controlState);let s=a.findLast(e=>e.role===`assistant`&&!e.ephemeral);Ge(s?.suggestions??[]),n?jt(e.conversationId):Mt(e.conversationId),Ae(`chat`);let c=te();c&&F.switchTab(c)}catch(t){if(o())return;n.emit(`error`,t),e.onError?.(t)}},[H,O,w,D,n,e,b,Wt,Me,x,at,jt,Mt,Nt,F]),Rn=m(void 0),Vn=l(t=>{let n=e.modules.list.find(e=>e.layout===bh[t.to]);if(!n){$.warn(`open: the widget has no such tab`,{to:t.to});return}let r=t.id&&(n.layout===`help`||n.layout===`news`)?{kind:`content`,id:t.id,title:``}:void 0;F.open(n.id,r)},[e.modules,F]),Un=l(e=>{L||Cn(),e!=null&&(Pn(e)?I?Vn(e):Rn.current=e:$.warn(`open: unknown target`,{detail:e}))},[L,Cn,I,Vn]);u(()=>{I&&Rn.current&&(Vn(Rn.current),Rn.current=void 0)},[I,Vn]);let Wn=I&&!A&&(!gn||!vn.value),[Gn,U]=h(),Kn=l(e=>{let t=Ln(e);t?(L||Cn(),U(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[L,Cn]),Jn=L&&I&&!A,Yn=Jn&&Wn&&!Ie&&!(gn&&(Me||hn));u(()=>{if(Gn===void 0||!(Gn.send?Yn:Jn))return;let e=te();e?ke!==`chat`||!ne()?(Ae(`chat`),F.switchTab(e)):(U(void 0),Gn.send?fn(Gn.text,[]).then(e=>{e||zt.current?.fill(Gn.text)}):zt.current?.fill(Gn.text)):($.warn(`ask: the widget has no chat`),U(void 0))},[Gn,Jn,Yn,ke,ie,e.modules,F,fn]),u(()=>{if(e.widgetId!=="default")return;let n=`data-${P.cssPrefix}-`,r=[`ask`,`open`,`close`].map(e=>n+e);function i(e){let i=e.composedPath().find(e=>e instanceof Element&&r.some(t=>e.hasAttribute(t)));if(!(i instanceof Element))return;e.preventDefault();let a=i.getAttribute(`${n}ask`),o=i.getAttribute(`${n}open`);a===null?o===null?zn(t,`close`):zn(t,`open`,Fn(o)):zn(t,`ask`,In(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,i),()=>document.removeEventListener(`click`,i)},[e.widgetId,t]),u(()=>{if(e.widgetId!=="default")return;let n=Hn(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?zn(t,`ask`,In(n.ask)):zn(t,`open`,n.target))},[e.widgetId,t]);let Xn=m(qn),Zn=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;u(()=>a(()=>{let e=w.value,t={open:Zn||L,ready:I,unread:Ot.value,...e?{conversationId:e}:{}},r=Xn.current;(t.open!==r.open||t.ready!==r.ready||t.unread!==r.unread||t.conversationId!==r.conversationId)&&(Xn.current=t,n.emit(`state`,t),t.unread!==r.unread&&n.emit(`unread`,t.unread))}),[n,Zn,L,I,Ot,w]);let Qn=m({handleOpenCommand:Un,handleClose:Sn,handleExpand:Dn,handleFullscreen:On,handleAskCommand:Kn});Qn.current={handleOpenCommand:Un,handleClose:Sn,handleExpand:Dn,handleFullscreen:On,handleAskCommand:Kn},f(()=>Bn(t,{open:e=>Qn.current.handleOpenCommand(e),close:()=>Qn.current.handleClose(),expand:()=>Qn.current.handleExpand(),fullscreen:()=>Qn.current.handleFullscreen(),ask:e=>Qn.current.handleAskCommand(e)}),[t]);let W=p(()=>vt(e,ot,st,ct),[e,ot,st,ct]);B.current=W.strings,u(()=>{let e=ge.current;if(!e?.translations?.length)return;let t=E(e,ot);Ve(t.agent),t.site&&sr(t.site)&&Je(t.site),t.blocks&&cr(t.blocks)&&Xe(t.blocks)},[ot]);function $n(e){Nn(e)}let er={options:W,transport:H,feedback:it,bus:n,persistence:b,conversationId:w.value??``,composerKey:D.value,composerApiRef:zt,view:ke,isStreaming:Me,pageToolRunning:cn,isMemoryCompacting:hn,canReleaseQueuedMessages:Wn,queueManualMessages:gn&&vn.value,replyAwaitsCard:gn&&_n.value,sendPreparing:Ie,attachmentUploadsSig:Re,composerActive:W.mode===`page`||W.mode===`inline`||W.mode===`standalone`||L,controlMode:_t.value,assignedOperator:yt.value,operatorAvailable:bt.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:Ct,onCancelOperatorRequest:wt,loadingMessages:A,onLoadPreviousMessages:qt,messagesSig:O,reconnectingSig:k,agent:Be,ticketReference:He?.conversationId===w.value?He?.reference:void 0,login:It,onStartAsGuest:g,maxMessageCharacters:nt,suggestions:We,initialWidgetSize:C.widgetSize??null,onClear:wn,onExpand:Dn,onFullscreen:On,onSoundToggle:gt,onToggleHistory:kn,onSelectHistoryConversation:$n,onNewConversation:Tn,onLocaleChange:pt,onThemeChange:mt,onTextSizeChange:ht,onWidgetSizeChange:jn,onSend:fn,onStop:yn,onSuggestion:t=>{if(Fe.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?fn(r,[]):zt.current?.fill(r)},tool:sn,onRetry:xn,onMessageFeedback:un,onCardAction:bn};if(se)return/* @__PURE__ */ _(`div`,{class:`${yh}-anchor`,children:/* @__PURE__ */ _(Sm,{strings:W.strings,text:W.strings.chatUnavailable})});if(!I)return null;let tr=W.modules.list;function nr(e){let t=Ws(`close`,W.mode,e)?Sn:void 0;return tr.length===0?/* @__PURE__ */ _(Sm,{strings:W.strings,text:W.strings.modulesEmpty,onClose:t}):tr.length===1&&tr[0]?.layout===`chat`?/* @__PURE__ */ _(tm,{...er,panelSize:e,onClose:t}):/* @__PURE__ */ _(pm,{panelProps:{...er,panelSize:e,onClose:t},enabledModules:tr,nav:F,bus:n,hasUnread:Dt.value,latestNews:Rt,onSelectConversation:$n,onStartNewConversation:En,onSetPanelSize:De})}if(e.mode===`page`){let t=e.history.enabled&&tr.some(e=>e.layout===`chat`);return/* @__PURE__ */ _(`div`,{class:`${yh}-anchor`,children:/* @__PURE__ */ _(bm,{site:qe,blocks:Ye,transport:H,strings:W.strings,locale:W.locale,persistence:b,showConversations:t,onSelectConversation:$n,onNewConversation:Tn,sidebarCollapsed:V,onToggleSidebarCollapsed:An,children:nr(`fullscreen`)})})}if(le){let t=e.mode===`standalone`?`fullscreen`:Ee;return/* @__PURE__ */ _(`div`,{class:`${yh}-anchor`,children:nr(t)})}let rr=e.mode===`drawer`,ir=e.mode!==`modal`&&!e.launcher.hidden&&(!L||ve),or=ir&&!ve&&!Se&&!rr?W.launcher.callout:null;return/* @__PURE__ */ v(`div`,{class:`${yh}-anchor`,"data-launcher-size":W.launcher.size,children:[L||R?/* @__PURE__ */ _(`div`,{class:`${yh}-surface`,hidden:!L,children:nr(Ee)}):null,ir?/* @__PURE__ */ _(fl,{buttonRef:be,onToggle:Cn,launcher:W.launcher,strings:W.strings,leaving:ve,edgeTab:rr}):null,or?/* @__PURE__ */ _(_l,{callout:or,launcherPosition:W.position,strings:W.strings,closeLabel:W.strings.close,onDismiss:Te}):null]})}function Sh(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const Ch={AI_AGENT_PUBLIC_ACCESS_NOT_FOUND:`the deployment was not found or is turned off`,AI_AGENT_PUBLIC_ORIGIN_NOT_ALLOWED:`this website is not in the deployment's allowed origins`},wh=120,Th=/* @__PURE__ */ new WeakMap;async function Eh(e,t,n,r,i){return(await Promise.all(t.map(async t=>{try{r(t.id,{status:`uploading`});let i=Th.get(t)??await e.uploadFile(t.file,n,e=>r(t.id,{status:`uploading`,fraction:e}));return Th.set(t,i),r(t.id,{status:`done`}),{id:i.id,name:i.originalName,mediaType:i.mimeType,size:i.fileSize,url:i.url}}catch(e){r(t.id,n.aborted?void 0:{status:`error`,refusal:e instanceof is&&e.status===400?e.errorCode:void 0}),i(e);return}}))).filter(e=>e!==void 0)}const Dh=V.scope(`error-boundary`);var Oh=class extends e{constructor(...e){super(...e),U(this,`state`,{crashed:!(`toSorted`in Array.prototype)})}componentDidCatch(e,t){Dh.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}};function kh(e){let{bus:r,host:i,appRoot:a,persistence:o,reportError:s}=e,c=e.initialRaw,l,u,d=at(c),f=o.loadUserPrefs().locale??d.locale,p=!0,m=0,h=0,g=Qt(r);function _(){let e=l&&E({config:l,translations:u},f).config;d=at(e?xt(c,e):c)}function v(){xn(i,Sn(d.mode)),jn(i,{...d,themeMode:_t(d.themeMode,o.loadUserPrefs().themeMode)}),p&&(An(i,Ah(d)),p=!1)}function y(){v(),n(t(Oh,{onError:s},t(xh,{key:m,bus:r,hostElement:i,options:d,recentHostEvents:g,loginRevision:h,onPersonChanged:S,onStartAsGuest:C})),a)}r.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&o.rememberStorageVersion(e.config.storageVersion),l=e.config,u=e.translations,_(),y())}),r.on(`localeChange`,e=>{f=e,u?.length&&(_(),y())});let b=fn(r,{getOptions:()=>d,getVisitorId:()=>o.getVisitorId(),getConversationId:()=>o.loadConversationId()});function x(){let e=o.takeLoginReturn();return e?(o.saveConversationId(e.conversationId),o.saveDraft(e.conversationId,e.draft),o.savePanelOpen(!0),!0):!1}c.userToken&&x();function S(){o.reset(),g.length=0,m+=1,p=!0,_(),y()}function C(){c={...c,userContext:void 0,userToken:void 0},S()}function w(e){`userToken`in e&&e.userToken&&!c.userToken&&x()&&(m+=1),c={...c,...e},_(),y()}return{getOptions:()=>d,getUserOptions:()=>c,render:y,setUserOptions:e=>{c=e,_(),y()},patchUserOptions:w,login:e=>{h+=1,w({userToken:e})},reset:()=>C(),destroy:()=>b()}}function Ah(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=nn(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=rc(e,ic(),t.loadPanelOpen(),t.loadPanelSize());return tc(e.mode,r,n)}var jh=class extends HTMLElement{constructor(...e){super(...e),U(this,`bus`,new Jn),U(this,`widgetState`,qn),U(this,`userToken`,void 0),U(this,`pageTools`,[]),U(this,`markReady`,()=>{}),U(this,`ready`,new Promise(e=>{this.markReady=e})),U(this,`mountResult`,null),U(this,`runtime`,null)}static get observedAttributes(){return Gt}connectedCallback(){if(Object.hasOwn(this,`tools`)){let e=Reflect.get(this,`tools`);Reflect.deleteProperty(this,`tools`),this.pageTools=Array.isArray(e)?e:[]}this.boot()}disconnectedCallback(){this.mountResult&&(this.runtime?.destroy(),this.runtime=null,n(null,this.mountResult.appRoot),this.bus.clear(),this.widgetState=qn)}attributeChangedCallback(){this.isConnected&&this.boot()}open(e){zn(this,`open`,e)}close(){zn(this,`close`)}expand(){zn(this,`expand`)}ask(e,t){zn(this,`ask`,In(e,t))}get state(){return this.widgetState}reset(){this.userToken=void 0,this.runtime?.reset()}login(e){this.userToken=e,this.runtime?.login(e)}track(e,t){let n=Zt(e,t);n&&this.bus.emit(`hostEvent`,n)}get tools(){return this.pageTools}set tools(e){this.pageTools=e,this.runtime?.patchUserOptions({tools:e})}registerTool(e,t){of(e,t)}on(e,t){return this.bus.on(e,t)}boot(){let e={...Kt(e=>this.getAttribute(e)),...this.userToken?{userToken:this.userToken}:{},tools:this.pageTools};if(!e.aiAgentDeploymentId)throw Error(`ai-agent-deployment-id is required`);if(this.runtime){this.runtime.setUserOptions(e);return}let t=at(e);this.mountResult??(this.mountResult=Cn({existingHost:this,position:Sn(t.mode)}));let n=nn(t.widgetId,t.storage,t.aiAgentDeploymentId);this.bus.on(`state`,e=>{this.widgetState=e,e.ready&&this.markReady()}),this.runtime=kh({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 Mh=!1;function Nh(){if(Mh||typeof customElements>`u`)return;let e=P.tagName;customElements.get(e)||customElements.define(e,jh),Mh=!0}typeof customElements<`u`&&Nh();export{Nh as registerWebComponent};
44
44
  //# sourceMappingURL=web-component.mjs.map