@mediquo/elements 0.9.1 → 0.9.3

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.
Files changed (99) hide show
  1. package/dist/chunks/api-chat-client-fYDIH220.js +1 -0
  2. package/dist/chunks/{apple-pay-outcomes-B2Y333xu.js → apple-pay-outcomes-DbuQ2LI3.js} +1 -1
  3. package/dist/chunks/ca_ES-OHfUU0MP.js +1 -0
  4. package/dist/chunks/{chunk-Y4EKUX25-QqMl3eiq.js → chunk-Y4EKUX25-CWAZgcgw.js} +1 -1
  5. package/dist/chunks/{chunk-YTQUGGS3-DmCGIoFy.js → chunk-YTQUGGS3-DJR1Yoyy.js} +1 -1
  6. package/dist/chunks/de_DE-BTPGM932.js +1 -0
  7. package/dist/chunks/documentation-view-DywQ1MfS.js +1 -0
  8. package/dist/chunks/en_US-C2zY9QiH.js +1 -0
  9. package/dist/chunks/{external-CJj32K_p.js → external-BXLaKy9c.js} +1 -1
  10. package/dist/chunks/index-2xVO6z8H.js +1 -0
  11. package/dist/chunks/index-BLxNeTVi.js +1 -0
  12. package/dist/chunks/{mq-layout-TG2K4zRv.d.ts → index-CFlNQLy2.d.ts} +0 -18
  13. package/dist/chunks/{index-CZOI1VRs.js → index-ClLOggjQ.js} +1 -1
  14. package/dist/chunks/mq-layout-BiE8gq23.js +1 -0
  15. package/dist/chunks/mq-layout-D8Mak16a.d.ts +21 -0
  16. package/dist/chunks/mq-next-appointments-5tvQaSba.js +1 -0
  17. package/dist/chunks/mq-recent-documents-DzsyvBjW.js +1 -0
  18. package/dist/chunks/{next-appointment-card-Bc65OZ1_.d.ts → next-appointment-card-DBXsY3Sp.d.ts} +50 -2
  19. package/dist/chunks/next-appointment-card-DQE7dNXw.js +1 -0
  20. package/dist/chunks/pt_PT-DUs_Ox73.js +1 -0
  21. package/dist/chunks/{telemetry-client-BdPx4SXu.js → telemetry-client-DEIuDZfA.js} +1 -1
  22. package/dist/env.js +1 -1
  23. package/dist/i18n.js +1 -1
  24. package/dist/mq-api-client-provider.js +1 -1
  25. package/dist/mq-apple-pay-checkout.js +1 -1
  26. package/dist/mq-appointment-checkout.js +1 -1
  27. package/dist/mq-appointment-documentation.d.ts +2 -1
  28. package/dist/mq-appointment-documentation.js +1 -1
  29. package/dist/mq-chat-room.js +1 -1
  30. package/dist/mq-checkout.js +1 -1
  31. package/dist/mq-dashboard.d.ts +12 -51
  32. package/dist/mq-dashboard.js +1 -1
  33. package/dist/mq-documents.js +1 -1
  34. package/dist/mq-google-pay-checkout.js +1 -1
  35. package/dist/mq-immediate-videocall-checkout.js +1 -1
  36. package/dist/mq-my-appointments.d.ts +91 -13
  37. package/dist/mq-my-appointments.js +1 -1
  38. package/dist/mq-next-appointments.d.ts +2 -3
  39. package/dist/mq-next-appointments.js +1 -1
  40. package/dist/mq-payment-poller.js +1 -1
  41. package/dist/mq-professional-presence-sync.js +1 -1
  42. package/dist/mq-recent-documents.js +1 -1
  43. package/dist/mq-schedule-success.js +2 -2
  44. package/dist/mq-schedule.d.ts +2 -0
  45. package/dist/mq-schedule.js +1 -1
  46. package/dist/mq-socket-provider.js +1 -1
  47. package/dist/mq-support-chat.js +1 -1
  48. package/dist/mq-terms-and-conditions.js +1 -1
  49. package/dist/mq-unread-count-sync.js +1 -1
  50. package/dist/mq-videocall.d.ts +2 -1
  51. package/dist/mq-videocall.js +1 -1
  52. package/dist/react/mq-api-client-provider.js +1 -1
  53. package/dist/react/mq-apple-pay-checkout.js +1 -1
  54. package/dist/react/mq-appointment-checkout.js +1 -1
  55. package/dist/react/mq-appointment-documentation.d.ts +2 -1
  56. package/dist/react/mq-appointment-documentation.js +1 -1
  57. package/dist/react/mq-chat-room.js +1 -1
  58. package/dist/react/mq-checkout.js +1 -1
  59. package/dist/react/mq-dashboard.d.ts +13 -11
  60. package/dist/react/mq-dashboard.js +1 -1
  61. package/dist/react/mq-documents-page.js +1 -1
  62. package/dist/react/mq-documents.js +1 -1
  63. package/dist/react/mq-google-pay-checkout.js +1 -1
  64. package/dist/react/mq-immediate-videocall-checkout.js +1 -1
  65. package/dist/react/mq-my-appointments.d.ts +5 -7
  66. package/dist/react/mq-my-appointments.js +1 -1
  67. package/dist/react/mq-next-appointments.d.ts +2 -3
  68. package/dist/react/mq-next-appointments.js +1 -1
  69. package/dist/react/mq-payment-poller.js +1 -1
  70. package/dist/react/mq-professional-presence-sync.js +1 -1
  71. package/dist/react/mq-recent-documents.js +1 -1
  72. package/dist/react/mq-schedule-success.js +1 -1
  73. package/dist/react/mq-schedule.d.ts +1 -0
  74. package/dist/react/mq-schedule.js +1 -1
  75. package/dist/react/mq-socket-provider.js +1 -1
  76. package/dist/react/mq-support-chat.js +1 -1
  77. package/dist/react/mq-terms-and-conditions.js +1 -1
  78. package/dist/react/mq-unread-count-sync.js +1 -1
  79. package/dist/react/mq-videocall.d.ts +2 -1
  80. package/dist/react/mq-videocall.js +1 -1
  81. package/dist/ui/mq-badge.d.ts +18 -0
  82. package/dist/ui/mq-badge.js +4 -0
  83. package/dist/ui/mq-time-slot-picker.js +1 -1
  84. package/package.json +1 -1
  85. package/dist/chunks/action-unavailable-message-BIgsXk9u.js +0 -1
  86. package/dist/chunks/api-chat-client-DLpFzml6.js +0 -1
  87. package/dist/chunks/appointment-action-unavailable-dialog-CTiL4nMo.d.ts +0 -54
  88. package/dist/chunks/appointment-card-skeleton-C2Sim4nR.d.ts +0 -93
  89. package/dist/chunks/appointment-card-skeleton-hIRGcKmO.js +0 -1
  90. package/dist/chunks/ca_ES-Cvua2ilS.js +0 -1
  91. package/dist/chunks/de_DE-B3TduWuH.js +0 -1
  92. package/dist/chunks/documentation-view-DjNSPW_K.js +0 -1
  93. package/dist/chunks/en_US-f0buppez.js +0 -1
  94. package/dist/chunks/get-patient-documents-query-NC9xCa_N.js +0 -1
  95. package/dist/chunks/index-B7uU0VJH.js +0 -1
  96. package/dist/chunks/index-m6lXVNW0.js +0 -1
  97. package/dist/chunks/mq-layout-CVfDDjsX.js +0 -1
  98. package/dist/chunks/next-appointment-card-DDzJ1hMB.js +0 -1
  99. package/dist/chunks/pt_PT-DQenaZN8.js +0 -1
@@ -0,0 +1 @@
1
+ import{s as a}from"./runtime-Bg1WXVCx.js";const e={s0043fc30b467bc43:"Ocultar detalhes",s00c8bf60a179e056:"O Google Pay não está disponível. Tente com cartão ou outro método de pagamento.",s035706a468d0c40b:"Viernes",s0520ac0a7da193d4:"Não foi possível validar o código. Tente novamente.",s071bd6bbf6c08f34:"Carregando",s08404262212123ef:"Como posso ajudar-te?",s08fe5307b5987c42:"De",s08fe5907b5988674:"Do",s09165307b5ad0e23:"Mi",s09165b07b5ad1bbb:"Ma",s09195307b5af43fa:"Lu",s092e4f07b5c19938:"Ju",s093b3307b5cbf400:"Vi",s09462f07b5d5f4b9:"Sa",s09528d5c26b62213:"Jueves",s0aaec824f7c6b501:"Enviar mensagem",s0b0085a15991b134:"Reconectando...",s0b0955208f737a86:"O arquivo excede o tamanho máximo permitido",s0df1cead9c1f2a72:"Ver toda a documentação",s0eb69642cbc19745:"Esta consulta já passou, pelo que não pode ser modificada.",s0fc7c4bfd185800d:"Aqui vai ver as suas receitas e relatórios médicos.",s0fcbdef9dc977231:"Ocorreu um erro ao carregar a página. Por favor, tente novamente ou contacte o suporte.",s11605fc03de64e14:"Escreve aqui...",s12f171594a5379d2:"Tem certeza que deseja cancelar esta consulta?",s132e84f499a23985:"Não há horários disponíveis atualmente",s13317a76a9ed776e:"Repetir",s142eba34d93fe59e:"Descrição",s1513f3687bfcac96:"Domingo",s1a0efa6ac51e8a85:"Página anterior",s1a874fc38d0fcef0:"Ordem médica",s1d318e9d0ccba86b:"Chat",s1ee6d7e6d04932a4:"O email não é válido",s1fe8bb7f6ae07f9b:"Não tens consultas no histórico",s219b833c5ca095b3:"Aqui você verá todas as consultas que você teve. Pode acessar os documentos de cada consulta e reagendar uma consulta se necessário.",s22cf91a84fba4c4e:"Quando você agenda uma consulta, aparecerá aqui para que você possa consultá-la, modificá-la ou cancelá-la.",s255bf4de23c83482:"Condições de reserva:",s256189bafbcd2e34:"O telefone não é válido",s27e462e9f48eb3a6:"Documentação",s2a1d212b3cb5c1a1:"Pode chatear com o profissional até 48 horas após a sua consulta",s2aa2c19d07591438:"Vai receber um lembrete 15 minutos antes da consulta",s2aab27b26a86469f:"Motivo da consulta",s2b9fde9a5739d2a0:"Nome",s2bb20b2162a18938:"Por que precisa da consulta?",s2d6183fa992e10e9:"Este profissional não tem horários disponíveis",s2ebd846b5a30f9d1:"Lamentamos, não foi possível repetir a sua consulta. Por favor, contacte o suporte.",s30c9095a2e07d929:"Sala de espera",s31219c9bdeb7bc3e:"Continuar",s337e34cd11150eb6:"Ver as minhas consultas",s346d488070fe4cc8:"Pedir consulta",s3944638e633d719a:"Consulta",s3b77baf6a4864231:"Erro desconhecido",s3bd87e3e21b07900:"Espere enquanto a conexão é restabelecida",s3dc6584e403858df:"Não conseguimos carregar a sua documentação",s3f55bc3bfec41a5d:"Anexar arquivos",s4177fe7f5d70fd33:"Voltar",s41826ac201c3cd85:"Não foi possível abrir o chat com suporte",s4364d4be7641e15f:"Confirmar consulta",s43e5edcc8801e9a4:"Perfil de profesional",s4813ee5d305442e5:"Parece que não encontramos-te na hora da sua consulta. Pode programar outra consulta para resolver as suas dúvidas.",s49683919cdaeca83:"Hoje",s4a061033615c8016:"Documentos",s4a8494821c987a17:"Relatório",s4a8f1fcd3f5e5952:"Ainda não é hora!",s4d20157b5a655e70:"Este horário não está disponível. Por favor, selecione outro.",s4de424f531892818:"Ir para videoconferência",s51c461d40f9fb865:"Seleciona o seu especialista",s536a0b4d3d4a5d9f:"Não conseguimos carregar a sua próxima consulta",s53d957dda6cc200b:"Serviço e plataforma prestados por",s53e2497bf900c7fd:"Não tens consultas próximas",s5558a2e389d04223:"Modificar",s55c5126e99bae190:"Buscar disponibilidade",s563dcbfd432eb18f:"Cancelar consulta",s57e65113a89160cf:"Modalidade da consulta",s59612eaa6993aa7e:a`${0} minutos`,s5eef402d73eecbdc:"Anexar arquivo",s5f7956aacb5c6ca2:"A verificar Google Pay…",s5f817b8841b188d2:"Mais opções",s60cc7f0f9b185dee:"Documentação mais recente",s631f73a10d156b22:"Consulta expirada",s63f7af84683dd7c3:"Esta consulta já não pode ser modificada ou cancelada: o tempo mínimo requerido antes do início já passou.",s643155d1b6ee1684:"Tente novamente dentro de alguns minutos.",s6431bc5f3d97fa7b:"Aqui você verá suas prescrições e relatórios médicos. Consulte seu profissional de saúde para receber documentação.",s64b78a5026d4ce8d:"Não há horários disponíveis",s65bedc0e516977d9:"Sábado",s679be6312356a21c:"Agende uma consulta médica quando você precisar. Aqui você verá todos os detalhes e poderá gerenciar as suas consultas próximas.",s67f30f9f4ea881f3:"Este código não é válido.",s6a50fd7f52263b04:"Não foi possível voltar à sala de espera",s6ab6fcd87fdbf217:"Olá",s6b1c4fb634461e7c:"Mês anterior",s6b6fa877ec1e6968:"Chatear com o profissional",s6c81d42670932f93:"Atualizar",s6e2423db05f36856:"Pedido de consulta",s6ecdc22accc55af7:"Videochamada",s70258a0040dd9e19:"Voltar à sala de espera",s718177442a7447b2:"Consulta com um especialista em menos de 72 horas",s733b3bf647b7b0fa:"Aceita os permissões de câmara e microfone",s73cad78d8a3c39c2:"Prescrição",s74d7a739b6ab651d:"Histórico",s757fef148e0c94c6:"Disponibilidade",s77320b73fdd9cc40:"Sair",s775370fdb0af1546:"Data de nascimento",s77c2b712a9813175:"Pedir uma nova consulta",s77f8e4bee88d44aa:a`${0} de ${1}`,s7907902da8916212:"O profissional vai te ligar no número que indicas neste campo.",s7aa3cd94d51825fc:"Não há profissionais disponíveis para a especialidade selecionada. Por favor, tente novamente em outro momento ou selecione outra especialidade.",s7af26e861bb6f905:"Falta o identificador de gateway do Google Pay",s7fd8da9511b66dd4:"Pode anexar imagens ou documentação adicional (análises, resultados de testes, etc.) para que o médico avalie",s83c6ce869a2bbaa7:"(1 é muito mau, 5 é excelente)",s8447efe79d058943:"Valor pago",s8581adc786786298:"Formato de arquivo não suportado",s862ca980b16911d0:"Chatear com o profissional",s8c18dbf02590a72e:"Código promocional aplicado",s8cce15c931017937:"Voltar ao início",s8e7a6119525dc7c9:a`Lamentamos, como faltam menos de ${0} minutos para a sua consulta não a podemos modificar.`,s9005845c358db9da:"Não conseguimos descarregar o documento.",s92f34d487d1d0355:"Promoção",s94626d2ffd70f075:"Código promocional validado com sucesso",s9536695467bcf9c4:"Esta consulta já passou, pelo que não pode ser cancelada.",s96474eac63a69381:"Ir para o chat",s96ceb408923a7ab1:a`Nº COL. ${0}`,s979ee14368bf1505:"Fala comigo",s9802dd10b2c2f760:"Enviar",s99898f495319cd49:"Este mensagem foi eliminado",s9c309154722f8e06:"Carregando portal de pagamento",s9cabdaf42f04afee:"Introduza o código",s9cbf16425cadadb1:"Por favor, tente novamente mais tarde.",s9d22fa67943fdc4c:"Consulta telefónica",sa00e726e1e7e46a9:"Adicionar código promocional",sa27f38ad9db3bc4f:"Assistente comercial",sa2fe3f3b565f15f4:"Cancelar",sa4186d5e26cab4bb:"Página não encontrada",sa497ebaaeb251035:"Repetir consulta",sa7de4334479674c6:"Modificar consulta",sa82bc40dafbe3256:a`Consulta agendada de ${0}`,sa83d79734eb60ee3:"Aplicar",sa86d729f62b39f99:"Entrar na videochamada",sa87d2c48a52b2617:"Você não tem documentação",sab964c37a0934399:"Não foi possível carregar o Google Pay. Verifique a configuração do site e tente novamente.",sac2728ace11e5f4b:"Especialidade*",sadc5ede25dd6e126:"O profissional vai te enviar uma mensagem para que possamos协调ar a consulta. Certifique-se de ter boa cobertura e poder atender no horário escolhido.",sae8f7ac5552b2af1:"Quando faltarem 10 minutos para a sua consulta, poderás aceder à videoconferência",saf63dc4c8601ec8c:"a",safe333e385f371ff:"Verificando seu pagamento...",saff3019e8a8c5f98:"Lunes",sb01184796ad3832e:"Como correu a tua consulta?",sb410a3509b92a90c:"Tens algum comentário sobre a consulta?",sb49dc4c5edae9d4e:"Avaliação da consulta",sb5387e21dc21422b:"Consulta modificada",sb621415007181c43:"Mês seguinte",sb73394814d122852:"Se o seu médico gerou alguma documentação, poderás ver e descarregar aqui, na secção de documentação, o seu e-mail ou o chat.",sb882f28c9b20052e:"Consulta confirmada",sba98cf8b2a7dfca4:"Ontem",sbbee712c4900abc2:"Não conseguimos iniciar o pagamento",sbc0be90393c87447:a`Resumo da consulta para ${0}`,sbcf081de432a2172:"Ver detalhes",sbcfc05bdb868b383:"Prescrição",sbd07d1f779e482ae:"Não conseguimos confirmar seu pagamento",sbd9803cceb34513a:"Iniciar chat com assistente comercial",sbda1cf7b293e17d2:"Carregar arquivo",sc27e7c4850fc5a34:a`Lamentamos, como faltam menos de ${0} horas para a sua consulta não a podemos cancelar.`,sc3bb7ea72886e4d0:"Documentos recentes",sc3c7734c15d2a045:"Conta-nos como foi o atendimento ou se tiveste algum problema com a videochamada…",sc43929cc6582a185:"Ver agenda completa",sc4edf6a4e0157d4e:"Consultas próximas",sc7cf2be40c8614fa:a`Lamentamos, como faltam menos de ${0} minutos para a sua consulta não a podemos cancelar.`,sca0e87aae6bde276:"Ocorreu algum problema?",sca4bd395e3148194:"Confirmar cancelação",sca90bc30758f9082:"A página que estás a procurar foi removida, renomeada ou pode não existir.",scbe4c6673872bda5:"Telefone",sce29e337ebd75277:"Chat com suporte",scf469737e1670fd4:"Página seguinte",scfc7f5c5f41936dc:"Meus consultas",sd1f44f1a8bc20e67:"Email",sd24922a2783f286e:"Miércoles",sd2a8fc66c53c1a27:"Saltar",sd3f7579076c6611c:"Parece que rejeitou os permissões necessárias para entrar na videoconferência. Edita os permissões no seu navegador para entrar. Uma vez concedidos, deves atualizar esta tela.",sd4beaeb9a1b1fed5:"Datas anteriores",sd812eb30f385776d:"Completa o seu perfil",sd853d3bcf5341b59:"Ver mais",sda962b28e9110c82:"Realiza a busca no seu perfil médico digital",sdb7004e477873574:"Consulta cancelada com sucesso",sdd963b1b2ce9a1f5:a`O profissional vai te ligar no ${0} no horário selecionado. Certifique-se de ter boa cobertura e poder atender no horário escolhido.`,sde993da26c048f19:"Traumatologia, ginecologia, endocrinologia, digestivo ou psiquiatria",sdee32ae81ca0d6d8:"Adicionar ao calendário",se00b081edccfae39:"Datas seguintes",se07ea9607704c5ad:"Alterar código",se090f7226b372a4a:"Se a consulta não pôde ser realizada, podes",se0c7cc77f86aa8a0:"Apelidos",se17f2b402ecea2e1:"Valor a devolver",se18fa3ef98e155de:"A preparar Google Pay…",se1cce5af3e9bb6ee:"Ocorreu um erro ao enviar o arquivo",se1cf783f86c53031:"Martes",se45e6f6f3428ad50:a`Link para a consulta: ${0}`,se5a09223256f98db:"Este campo é obrigatório",se5f9264155b99909:"Ocorreu um problema ao verificar o estado do seu pagamento. Por favor, contate o suporte se o pagamento foi realizado.",se92e438da4e7099f:a`Lamentamos, como faltam menos de ${0} horas para a sua consulta não a podemos modificar.`,sea11fd8a12559bc5:"Consulta prévia:",seb6739450e8d9c8d:"Tem certeza que deseja cancelar esta consulta? Você receberá o valor pago em um prazo de 5-10 dias úteis.",seb850e89f9ff58e8:"Próxima consulta",sed750da423170d47:"Resultados para:",sed836a96c3b5d523:"Portal de pagamento",sed8ec5e3c64fa25d:"Total",sed97e90642983578:"Continuar ao pagamento",sedb2092dda465ea1:"DNI/NIE",sedbca9676f07a51f:"Modalidade da consulta*",see7c0a7b5b6ebbc5:"Utiliza o chat para enviar o motivo da consulta, documentos ou imagens",sefc0dd68776c9466:"Questionário pré-consulta",sf0638d3fc50964d2:"Escolhe outra data",sf0695a0a125ae748:"Confirmar",sf09d5e51b63f2b7d:"Pagar com Google Pay",sf199b210440b7c5f:"Consulta finalizada",sf3457daf057bff15:"voltar à sala de espera.",sf484a0e20a7829ac:"Nós enviaremos um e-mail para o e-mail indicado quando for a hora de conectar-se à videoconferência. Certifique-se de ter uma boa conexão com a internet e um dispositivo com câmara e microfone.",sf48d12e7ae207023:"Especialidade",sf5258cfb2fa10bdc:"Aguarde ser atendido sem sair desta tela",sf63a72ff4116c6a9:"Descarregar documento",sf9705e1c4e82c017:"Não foi possível enviar o questionário",sfa6bc28a7faedc92:"Nova consulta de especialidades digitais",sfac5734d03595135:"Ver todas",sfc63af0362cfb78b:"Falta o identificador de comerciante do Google Pay",sfd51ca4e1b145054:"Não foi possível reservar este horário. Por favor, selecione outro.",sff337500b69abf7f:"O médico está a terminar a sua consulta. Atualiza em alguns minutos para ver se tem documentação.",sffbc330c8a19f838:"Ver menos",sc6a6d42245892254:"Falta el identificador de comercio de Apple Pay",s3da77e69fe62cb2a:"No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.",se1dd5d211b5b00e4:"Apple Pay no está disponible",s7e8b7a5acbdf83ed:"Preparando Apple Pay…",sc8271ba819299b59:"Comprobando Apple Pay…",s57e95bc3afddfeb0:"Para pagar con Apple Pay, escanea el código QR con tu iPhone (iOS 18 o posterior) y confirma el pago.",sf32cd04f9a848ee2:"Pagar con Apple Pay",s6a796114fe45025d:a`${0}, ${1} h${2}`,s35d601992fe66fed:"Confirmando tu pago",s5370521b92483bf3:"No cierres, vuelvas atrás ni actualices la ventana; esto puede tardar unos momentos.",s77bf41039c589159:"Tu pago no se ha completado",s589cd89559bc046b:"El pago ha sido rechazado y no hemos creado la cita. No se te ha cobrado nada: vuelve a intentarlo con otro método de pago.",sf9e6fbadcce256d0:"Ha ocurrido un error",sa24acad3b1338788:"No hemos podido confirmar tu pago. Por favor, inténtalo de nuevo más tarde.",s8bbbd679ddb50d3b:"Si se te ha cobrado sin una cita confirmada, contacta con nuestro equipo en",s44d3670b18cefe17:"Reintentar verificación",s67ebdb57fc6ed724:"Confirmar y pagar",sf75ec3d5bb6b65ab:"Método de pago",s0ef2d611972d04af:"Selecciona un método para realizar el pago de la cita",s0569fb3d65e68486:"Tarjeta",sa8771906f4c82494:"Google pay",se2570afbd791e071:"Apple pay",s3a392bf1aa5a8813:"No se puede iniciar Google Pay",sc9c8fbf418b784ac:"No se puede iniciar Apple Pay",s55e29f17a7ab0b80:"Esperando confirmación de Google Pay",s8ff9b86afd460a55:"Esperando confirmación de Apple Pay",s5b8873ddba610f68:"Abrir Google Pay",s9506fb9bc66942ed:"Abrir Apple Pay",s6db69fd67f48404c:"Abrir ventana de Google Pay",s6911c9ad386cc8b9:"Abrir ventana de Apple Pay",s4a9be42496525265:"Volver a abrir Google Pay",s3356a53ef97dcfba:"Volver a abrir Apple Pay",s9ca719e1a40e96e3:"Faltan credenciales de pago. Vuelve atrás e inténtalo de nuevo, o paga con tarjeta.",s0f6deacf5441e291:"Elegir otro método",s275336b3d23d6d9c:"No cierres esta página.",s1dec877628213eef:"Tus citas",se0c593aac5e172e6:"Accede, modifica o anula tus citas.",s230b0bee447e61a5:"Ver mis citas"};export{e as templates};
@@ -1 +1 @@
1
- import{s as t}from"./chunk-6CCJWPGL-TiaqZaPV.js";function e(e,n){return{queryKey:t(e,"organization-specialties"),queryFn:()=>e.organizations.getOrganizationSpecialties(),...n}}function n(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function i(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function a(t,e){return{action_type:"event",event_type:"modify appoinment button click",patient_hash:t,id_appointment:e}}function o(t,e){return{action_type:"event",event_type:"cancel appoinment button click",patient_hash:t,id_appointment:e}}function p(t,e){return{action_type:"event",event_type:"view appointment document list button click",patient_hash:t,id_appointment:e}}function s(t,e){return{action_type:"event",event_type:"repeat appointment button click",patient_hash:t,id_appointment:e}}function c(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function _(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function r(t,e){return{action_type:"event",event_type:"add to calendar button click",patient_hash:t,id_appointment:e}}function l(t,e){return{action_type:"pageview",event_type:"appointment success page view",patient_hash:t,id_appointment:e}}function u(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function d(t,e){return{action_type:"event",event_type:"update documentation",patient_hash:t,id_appointment:e}}function y(t,e){return{action_type:"pageview",event_type:"documentation page view",patient_hash:t,id_appointment:e}}function h(t){return{action_type:"event",event_type:"view documentation list button click",patient_hash:t}}function v(t,e){return{action_type:"event",event_type:"download document button click",patient_hash:t,id_document:e}}function g(t){return{action_type:"event",event_type:"make an appointment button click",patient_hash:t}}function m(t){return{action_type:"event",event_type:"view appointment list button click",patient_hash:t}}function f(t){return{action_type:"pageview",event_type:"home page view",patient_hash:t}}function E(t,e,n){return{action_type:"event",event_type:"find availability button click",patient_hash:t,speciality_id:e,service_id:n}}function S(t,e,n,i,a,o,p){return{action_type:"debug",event_type:"find availability result",patient_hash:t,speciality_id:e,service_id:n,first_slot_date:i,first_slot_professional_hash:a,total_professionals:o,total_slots:p}}function k(t,e,n,i,a){return{action_type:"event",event_type:"professional schedule slot button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function b(t,e,n,i){return{action_type:"event",event_type:"professional availability button click",patient_hash:t,professional_hash:e,speciality_id:n,service_id:i}}function T(t,e,n,i,a){return{action_type:"event",event_type:"confirm appointment button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function w(t){return{action_type:"pageview",event_type:"select professional step page view",patient_hash:t}}function P(t,e){return{action_type:"pageview",event_type:"not time yet pageview",patient_hash:t,id_appointment:e}}function C(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function D(t,e){return{action_type:"pageview",event_type:"waiting room pageview",patient_hash:t,id_appointment:e}}function q(t,e){return{action_type:"pageview",event_type:"videocall pageview",patient_hash:t,id_appointment:e}}var K={digestive_system:{de_DE:"Verdauungssystem",en_US:"Digestive System",es_ES:"Aparato Digestivo",ca_ES:"Aparell Digestiu",pt_PT:"Aparelho Digestivo"},orthopedic_surgery_traumatology:{de_DE:"Traumatologie und Orthopädische Chirurgie",en_US:"Traumatology and Orthopedic Surgery",es_ES:"Traumatología y Cirugía Ortopédica",ca_ES:"Traumatologia i Cirurgia Ortopèdica",pt_PT:"Traumatologia e Cirurgia Ortopédica"},gynecology:{de_DE:"Gynäkologie",en_US:"Gynecology",es_ES:"Ginecología",ca_ES:"Ginecologia",pt_PT:"Ginecologia"},endocrinology:{de_DE:"Endokrinologie",en_US:"Endocrinology",es_ES:"Endocrinología",ca_ES:"Endocrinologia",pt_PT:"Endocrinologia"},psychiatry:{de_DE:"Psychiatrie",en_US:"Psychiatry",es_ES:"Psiquiatría",ca_ES:"Psiquiatria",pt_PT:"Psiquiatria"}},O={videocall:{de_DE:"Videosprechstunde",en_US:"Videocall",es_ES:"Videoconsulta",ca_ES:"Videoconsulta",pt_PT:"Videoconsulta"},phonecall:{de_DE:"Telefonische Behandlung",en_US:"Phone consultation",es_ES:"Consulta telefónica",ca_ES:"Consulta telefònica",pt_PT:"Consulta telefónica"}},U={de_DE:"Konsultationspreis",en_US:"Consultation price",es_ES:"Precio de consulta",ca_ES:"Preu de consulta",pt_PT:"Preço da consulta"},G={videocall:"videocall",phonecall:"phonecall",adeslas_videocall:"videocall",adeslas_prod_videocall:"videocall",adeslas_phonecall:"phonecall",adeslas_prod_phonecall:"phonecall"};function A(t,e,n){if(!t)return n??"";const i=G[t];return i?O[i][e]:n??U[e]}var V={consulta_telefonica:"phonecall",videoconsulta:"videocall"},x={"aparato-digestivo":"digestive_system","cirugia-ortopedica-y-traumatologia":"orthopedic_surgery_traumatology",ginecologia:"gynecology",endocrinologia:"endocrinology",psiquiatria:"psychiatry"};function z(t,e,n){const i=n?.trim();if(i)return i;const a=K[t]?.[e];return void 0!==a?a:t}class HttpTransport{endpoint;apiKey;constructor(t,e){this.endpoint=t,this.apiKey=e}send(t){fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(t)}).catch(()=>{})}}class MediquoTelemetryClient{_apiKey=null;_transport=null;setApiKey(t){this._apiKey=t,this._buildTransport()}track(t){null!==this._transport&&this._transport.send(t)}_buildTransport(){null!==this._apiKey&&(this._transport=new HttpTransport("https://tracking.____.mediquo.com/sdk",this._apiKey))}}const j=new class AppTelemetryClient extends MediquoTelemetryClient{track(t){}};export{k as A,b as B,S as C,w as D,P as E,C as F,D as G,q as H,V as S,n as a,i as b,a as c,o as d,z as e,v as f,e as g,y as h,d as i,u as j,s as k,p as l,l as m,r as n,c as o,_ as p,g as q,h as r,f as s,j as t,x as u,m as v,A as w,T as x,E as y,K as z};
1
+ import{s as t}from"./chunk-6CCJWPGL-TiaqZaPV.js";function e(e,n){return{queryKey:t(e,"organization-specialties"),queryFn:()=>e.organizations.getOrganizationSpecialties(),...n}}function n(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function i(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function a(t,e){return{action_type:"event",event_type:"modify appoinment button click",patient_hash:t,id_appointment:e}}function o(t,e){return{action_type:"event",event_type:"cancel appoinment button click",patient_hash:t,id_appointment:e}}function p(t,e){return{action_type:"event",event_type:"view appointment document list button click",patient_hash:t,id_appointment:e}}function s(t,e){return{action_type:"event",event_type:"repeat appointment button click",patient_hash:t,id_appointment:e}}function c(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function _(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function r(t,e){return{action_type:"event",event_type:"add to calendar button click",patient_hash:t,id_appointment:e}}function l(t,e){return{action_type:"pageview",event_type:"appointment success page view",patient_hash:t,id_appointment:e}}function u(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function d(t,e){return{action_type:"event",event_type:"update documentation",patient_hash:t,id_appointment:e}}function y(t,e){return{action_type:"pageview",event_type:"documentation page view",patient_hash:t,id_appointment:e}}function h(t){return{action_type:"event",event_type:"view documentation list button click",patient_hash:t}}function v(t,e){return{action_type:"event",event_type:"download document button click",patient_hash:t,id_document:e}}function g(t){return{action_type:"event",event_type:"make an appointment button click",patient_hash:t}}function m(t){return{action_type:"event",event_type:"view appointment list button click",patient_hash:t}}function f(t){return{action_type:"pageview",event_type:"home page view",patient_hash:t}}function E(t,e,n){return{action_type:"event",event_type:"find availability button click",patient_hash:t,speciality_id:e,service_id:n}}function S(t,e,n,i,a,o,p){return{action_type:"debug",event_type:"find availability result",patient_hash:t,speciality_id:e,service_id:n,first_slot_date:i,first_slot_professional_hash:a,total_professionals:o,total_slots:p}}function k(t,e,n,i,a){return{action_type:"event",event_type:"professional schedule slot button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function b(t,e,n,i){return{action_type:"event",event_type:"professional availability button click",patient_hash:t,professional_hash:e,speciality_id:n,service_id:i}}function T(t,e,n,i,a){return{action_type:"event",event_type:"confirm appointment button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function w(t){return{action_type:"pageview",event_type:"select professional step page view",patient_hash:t}}function P(t,e){return{action_type:"pageview",event_type:"not time yet pageview",patient_hash:t,id_appointment:e}}function C(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function D(t,e){return{action_type:"pageview",event_type:"waiting room pageview",patient_hash:t,id_appointment:e}}function q(t,e){return{action_type:"pageview",event_type:"videocall pageview",patient_hash:t,id_appointment:e}}var K={digestive_system:{de_DE:"Verdauungssystem",en_US:"Digestive System",es_ES:"Aparato Digestivo",ca_ES:"Aparell Digestiu",pt_PT:"Aparelho Digestivo"},orthopedic_surgery_traumatology:{de_DE:"Traumatologie und Orthopädische Chirurgie",en_US:"Traumatology and Orthopedic Surgery",es_ES:"Traumatología y Cirugía Ortopédica",ca_ES:"Traumatologia i Cirurgia Ortopèdica",pt_PT:"Traumatologia e Cirurgia Ortopédica"},gynecology:{de_DE:"Gynäkologie",en_US:"Gynecology",es_ES:"Ginecología",ca_ES:"Ginecologia",pt_PT:"Ginecologia"},endocrinology:{de_DE:"Endokrinologie",en_US:"Endocrinology",es_ES:"Endocrinología",ca_ES:"Endocrinologia",pt_PT:"Endocrinologia"},psychiatry:{de_DE:"Psychiatrie",en_US:"Psychiatry",es_ES:"Psiquiatría",ca_ES:"Psiquiatria",pt_PT:"Psiquiatria"}},O={videocall:{de_DE:"Videosprechstunde",en_US:"Videocall",es_ES:"Videoconsulta",ca_ES:"Videoconsulta",pt_PT:"Videoconsulta"},phonecall:{de_DE:"Telefonische Behandlung",en_US:"Phone consultation",es_ES:"Consulta telefónica",ca_ES:"Consulta telefònica",pt_PT:"Consulta telefónica"}},U={de_DE:"Konsultationspreis",en_US:"Consultation price",es_ES:"Precio de consulta",ca_ES:"Preu de consulta",pt_PT:"Preço da consulta"},G={videocall:"videocall",phonecall:"phonecall",adeslas_videocall:"videocall",adeslas_prod_videocall:"videocall",adeslas_phonecall:"phonecall",adeslas_prod_phonecall:"phonecall"};function A(t,e,n){if(!t)return n??"";const i=G[t];return i?O[i][e]:n??U[e]}var V={consulta_telefonica:"phonecall",videoconsulta:"videocall"},x={"aparato-digestivo":"digestive_system","cirugia-ortopedica-y-traumatologia":"orthopedic_surgery_traumatology",ginecologia:"gynecology",endocrinologia:"endocrinology",psiquiatria:"psychiatry"};function z(t,e,n){const i=n?.trim();if(i)return i;const a=K[t]?.[e];return void 0!==a?a:t}class HttpTransport{endpoint;apiKey;constructor(t,e){this.endpoint=t,this.apiKey=e}send(t){fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(t)}).catch(()=>{})}}class MediquoTelemetryClient{_apiKey=null;_transport=null;setApiKey(t){this._apiKey=t,this._buildTransport()}track(t){null!==this._transport&&this._transport.send(t)}_buildTransport(){null!==this._apiKey&&(this._transport=new HttpTransport("https://tracking.____.mediquo.com/sdk",this._apiKey))}}const j=new class AppTelemetryClient extends MediquoTelemetryClient{track(t){}};export{k as A,b as B,S as C,w as D,P as E,C as F,D as G,q as H,V as S,z as a,y as b,d as c,v as d,u as e,n as f,e as g,f as h,i,a as j,o as k,l,g as m,r as n,c as o,_ as p,s as q,h as r,p as s,j as t,x as u,m as v,A as w,T as x,E as y,K as z};
package/dist/env.js CHANGED
@@ -1 +1 @@
1
- const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.9.1",n={development:{MODE:"development",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"47836441",ASSETS_BASE_URL:E},production:{MODE:"production",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"46655102",ASSETS_BASE_URL:E}};let t=o;const _=new Proxy({},{get:(E,o)=>n[t??"production"][o]});function S(E){t=E}export{E as ASSETS_BASE_URL,_ as env,S as setEnv};
1
+ const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.9.3",n={development:{MODE:"development",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"47836441",ASSETS_BASE_URL:E},production:{MODE:"production",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"46655102",ASSETS_BASE_URL:E}};let t=o;const _=new Proxy({},{get:(E,o)=>n[t??"production"][o]});function S(E){t=E}export{E as ASSETS_BASE_URL,_ as env,S as setEnv};
package/dist/i18n.js CHANGED
@@ -1 +1 @@
1
- import{c as e}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{z as t}from"./chunks/external-CJj32K_p.js";const c=["ca_ES","de_DE","en_US","pt_PT"],s=t.enum(["en_US","pt_PT","de_DE","es_ES","ca_ES"]);function a(e){return s.safeParse(e).success}const o="__mqElementsLocalization__";function i(){const e=globalThis;return e[o]||(e[o]={initialized:!1}),e[o]}function r(){const t=i();if(!t.initialized){t.initialized=!0;try{const{setLocale:n,getLocale:s}=e({sourceLocale:"es_ES",targetLocales:c,loadLocale:async e=>{switch(e){case"en_US":default:return import("./chunks/en_US-f0buppez.js");case"pt_PT":return import("./chunks/pt_PT-DQenaZN8.js");case"de_DE":return import("./chunks/de_DE-B3TduWuH.js");case"ca_ES":return import("./chunks/ca_ES-Cvua2ilS.js")}}});t.setLocale=n,t.getLocale=s}catch(e){n.warn("Localization was already configured on this page.",e)}}}const u="Localization not initialized yet.";async function l(e){const{setLocale:t}=i();if(t)return t(e);n.warn(u)}function _(){const{getLocale:e}=i();return e?e():(n.warn(u),"es_ES")}export{_ as getLocale,r as initLocalization,a as isValidLocale,l as setLocale};
1
+ import{c as e}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{z as t}from"./chunks/external-BXLaKy9c.js";const c=["ca_ES","de_DE","en_US","pt_PT"],s=t.enum(["en_US","pt_PT","de_DE","es_ES","ca_ES"]);function a(e){return s.safeParse(e).success}const o="__mqElementsLocalization__";function i(){const e=globalThis;return e[o]||(e[o]={initialized:!1}),e[o]}function r(){const t=i();if(!t.initialized){t.initialized=!0;try{const{setLocale:n,getLocale:s}=e({sourceLocale:"es_ES",targetLocales:c,loadLocale:async e=>{switch(e){case"en_US":default:return import("./chunks/en_US-C2zY9QiH.js");case"pt_PT":return import("./chunks/pt_PT-DUs_Ox73.js");case"de_DE":return import("./chunks/de_DE-BTPGM932.js");case"ca_ES":return import("./chunks/ca_ES-OHfUU0MP.js")}}});t.setLocale=n,t.getLocale=s}catch(e){n.warn("Localization was already configured on this page.",e)}}}const u="Localization not initialized yet.";async function l(e){const{setLocale:t}=i();if(t)return t(e);n.warn(u)}function _(){const{getLocale:e}=i();return e?e():(n.warn(u),"es_ES")}export{_ as getLocale,r as initLocalization,a as isValidLocale,l as setLocale};
@@ -1 +1 @@
1
- import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{e as o}from"./chunks/provide-BwI4DDGF.js";import{A as i}from"./chunks/api-client-context-V1UAGtKW.js";import{a as r,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n}from"./chunks/property-scuRaFcM.js";import{r as p}from"./chunks/state-LQivXIgA.js";import{setEnv as c}from"./env.js";import{c as a,n as m}from"./chunks/api-chat-client-DLpFzml6.js";import{e as h}from"./chunks/ensure-context-root-DbdqwnKB.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";h();let u=class MqApiClientProvider extends r{constructor(){super(...arguments),this.apiClient=a()}willUpdate(t){t.has("env")&&this.env&&c(this.env);const e=m(t,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale});e&&(this.apiClient=e)}render(){return s`<slot></slot>`}};t([n({type:String,attribute:"api-key"})],u.prototype,"apiKey",void 0),t([n({type:String,attribute:"token"})],u.prototype,"token",void 0),t([n({type:String,attribute:"locale"})],u.prototype,"locale",void 0),t([n({type:String,attribute:"env"})],u.prototype,"env",void 0),t([o({context:i}),p()],u.prototype,"apiClient",void 0),u=t([e("mq-api-client-provider")],u);export{u as MqApiClientProvider};
1
+ import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{e as o}from"./chunks/provide-BwI4DDGF.js";import{A as i}from"./chunks/api-client-context-V1UAGtKW.js";import{a as r,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n}from"./chunks/property-scuRaFcM.js";import{r as p}from"./chunks/state-LQivXIgA.js";import{setEnv as c}from"./env.js";import{c as a,n as m}from"./chunks/api-chat-client-fYDIH220.js";import{e as h}from"./chunks/ensure-context-root-DbdqwnKB.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-BXLaKy9c.js";import"./chunks/isBefore-CPpTogxo.js";h();let u=class MqApiClientProvider extends r{constructor(){super(...arguments),this.apiClient=a()}willUpdate(t){t.has("env")&&this.env&&c(this.env);const e=m(t,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale});e&&(this.apiClient=e)}render(){return s`<slot></slot>`}};t([n({type:String,attribute:"api-key"})],u.prototype,"apiKey",void 0),t([n({type:String,attribute:"token"})],u.prototype,"token",void 0),t([n({type:String,attribute:"locale"})],u.prototype,"locale",void 0),t([n({type:String,attribute:"env"})],u.prototype,"env",void 0),t([o({context:i}),p()],u.prototype,"apiClient",void 0),u=t([e("mq-api-client-provider")],u);export{u as MqApiClientProvider};
@@ -1 +1 @@
1
- import{_ as e,c as t}from"./chunks/custom-element-D2ziPxYE.js";import{e as a}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{m as s}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{A as o}from"./chunks/api-client-context-V1UAGtKW.js";import{L as r}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as l,a as c,x as h}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as y}from"./chunks/state-LQivXIgA.js";import{setEnv as d}from"./env.js";import{initLocalization as m,setLocale as v,isValidLocale as k}from"./i18n.js";import{c as b,n as f}from"./chunks/api-chat-client-DLpFzml6.js";import{u as P,s as _,r as E}from"./chunks/apple-pay-outcomes-B2Y333xu.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/external-CJj32K_p.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";function g(){if("undefined"==typeof navigator)return!1;const e=navigator.userAgent;return/Safari/i.test(e)&&!/Chrome|Chromium|Edg|OPR|Firefox|FxiOS/i.test(e)}async function S(e){if("undefined"==typeof window||!window.isSecureContext)return{available:!1,reason:"unsupported"};if(!function(){if("undefined"==typeof window)return!1;const e="undefined"!=typeof ApplePaySession&&"function"==typeof ApplePaySession.canMakePayments,t="undefined"!=typeof customElements&&void 0!==customElements.get("apple-pay-button");return e&&t}())return{available:!1,reason:"sdk-missing"};if(!e.trim())return{available:!1,reason:"merchant-id-missing"};const t=ApplePaySession;if(function(e){return"function"==typeof e.applePayCapabilities}(t))try{return function(e){switch(e){case"applePayUnsupported":return{available:!1,reason:"unsupported"};case"paymentCredentialsUnavailable":case"paymentCredentialsAvailable":case"paymentCredentialStatusUnknown":return{available:!0,usesQrFlow:!g()}}}((await t.applePayCapabilities(e)).paymentCredentialStatus)}catch{return t.canMakePayments()?{available:!0,usesQrFlow:!g()}:{available:!1,reason:"unsupported"}}return t.canMakePayments()?{available:!0,usesQrFlow:!g()}:{available:!1,reason:"unsupported"}}const A={es_ES:"es-ES",en_US:"en-US",pt_PT:"pt-PT",de_DE:"de-DE",ca_ES:"ca-ES"};try{m()}catch{}const C=["visa","masterCard","amex"],w=["supports3DS"],x=l`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.helper{margin:0;text-align:center;font-family:system-ui,sans-serif;font-size:13px;line-height:1.4;color:#6e6e73}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:48px;--apple-pay-button-border-radius:10px;--apple-pay-button-padding:0;display:block;width:100%;min-height:48px;cursor:pointer}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class ApplePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ApplePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(ApplePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(ApplePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}function j(e,t){p.warn(e,{error:t instanceof Error?t.message:String(t)})}let T=class MqApplePayCheckout extends c{constructor(){super(...arguments),this._availabilityPhase="checking",this._showQrHelper=!1,this._paying=!1,this._suppressCancelEvent=!1,this._availabilityGeneration=0,this.apiClient=b(),this._loginTokenTask=new r(this,()=>this.apiClient,{args:()=>[this.apiKey,this.token],onComplete:e=>{this._sessionToken=e.access_token,this.apiClient.setAuthToken(e.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{if(this._paying||"ready"!==this._availabilityPhase)return;let e;try{e=new ApplePaySession(3,this._buildPaymentRequest())}catch(e){return j("mq-apple-pay-checkout: failed to create ApplePaySession",e),void this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}this._paying=!0,this._suppressCancelEvent=!1,e.onvalidatemerchant=async t=>{try{const a=await this.apiClient.payments.validateApplePayMerchant({order_id:this.sessionId,validation_url:t.validationURL});e.completeMerchantValidation(P(a))}catch(t){j("mq-apple-pay-checkout: validate-merchant failed",t),this._suppressCancelEvent=!0,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"merchant"})),e.abort(),this._paying=!1}},e.onpaymentauthorized=async t=>{try{const a=await this.apiClient.payments.authorizeApplePay({order_id:this.sessionId,token:_(t.payment.token)}),{status:i,consultation_id:s}=a.data,n=E(i,s,this.sessionId);switch(n.kind){case"success":e.completePayment(ApplePaySession.STATUS_SUCCESS),this.dispatchEvent(new ApplePayCheckoutSuccessEvent({sessionId:n.sessionId,reference:n.reference}));break;case"denied":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutDeniedEvent({sessionId:n.sessionId}));break;case"error":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:n.reason}))}}catch(t){j("mq-apple-pay-checkout: authorize failed",t),e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"authorize"}))}finally{this._paying=!1}},e.oncancel=()=>{this._paying=!1,this._suppressCancelEvent?this._suppressCancelEvent=!1:this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"cancelled"}))};try{e.begin()}catch(e){j("mq-apple-pay-checkout: session.begin() failed",e),this._paying=!1,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}}}static{this.styles=x}willUpdate(e){e.has("env")&&this.env&&d(this.env),e.has("locale")&&v(k(this.locale)?this.locale:"es_ES");const t=f(e,{env:this.env,apiKey:this.apiKey,token:this._sessionToken,locale:k(this.locale)?this.locale:"es_ES"},this.inheritedApiClient);t&&(this.apiClient=t),e.has("merchantId")&&this._loginTokenTask.value&&this._refreshAvailability()}async _refreshAvailability(){const e=++this._availabilityGeneration;this._availabilityPhase="checking",this._showQrHelper=!1;const t=await S(this.merchantId??"");e===this._availabilityGeneration&&(t.available?(this._availabilityPhase="ready",this._showQrHelper=t.usesQrFlow):this._availabilityPhase="unavailable")}get _resolvedLocale(){return k(this.locale)?this.locale:"es_ES"}_buildPaymentRequest(){return{countryCode:this.country,currencyCode:this.currency,supportedNetworks:[...C],merchantCapabilities:[...w],total:{label:this.label,amount:this.amount}}}_renderUnavailable(){return this.merchantId?.trim()?"undefined"==typeof ApplePaySession?h`<p class="state">${s("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:h`<p class="state">${s("Apple Pay no está disponible")}</p>`:h`<p class="state">${s("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>h`<p class="state">${s("Preparando Apple Pay…")}</p>`,error:()=>h`<p class="state">${s("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?h`<p class="state">${s("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():h`${this._showQrHelper?h`<p class="helper">${s("Para pagar con Apple Pay, escanea el código QR con tu iPhone (iOS 18 o posterior) y confirma el pago.")}</p>`:null}<div class="pay-row ${this._paying?"pay-row--paying":""}"><apple-pay-button buttonstyle="black" type="pay" locale="${e=this._resolvedLocale,A[e]??"es-ES"}" aria-label="${s("Pagar con Apple Pay")}" @click="${this._onPayClick}"></apple-pay-button></div>`;var e}})}};e([u({type:String,attribute:"env"})],T.prototype,"env",void 0),e([u({type:String,attribute:"api-key"})],T.prototype,"apiKey",void 0),e([u({type:String,attribute:"token"})],T.prototype,"token",void 0),e([u({type:String,attribute:"locale",reflect:!0})],T.prototype,"locale",void 0),e([u({type:String,attribute:"merchant-id"})],T.prototype,"merchantId",void 0),e([u({type:String,attribute:"session-id"})],T.prototype,"sessionId",void 0),e([u({type:String,attribute:"amount"})],T.prototype,"amount",void 0),e([u({type:String,attribute:"currency"})],T.prototype,"currency",void 0),e([u({type:String,attribute:"country"})],T.prototype,"country",void 0),e([u({type:String,attribute:"label"})],T.prototype,"label",void 0),e([y()],T.prototype,"_availabilityPhase",void 0),e([y()],T.prototype,"_showQrHelper",void 0),e([y()],T.prototype,"_paying",void 0),e([i({context:o,subscribe:!0}),y()],T.prototype,"inheritedApiClient",void 0),e([a({context:o}),y()],T.prototype,"apiClient",void 0),T=e([n(),t("mq-apple-pay-checkout")],T);export{ApplePayCheckoutDeniedEvent,ApplePayCheckoutErrorEvent,ApplePayCheckoutSuccessEvent,T as MqApplePayCheckout};
1
+ import{_ as e,c as t}from"./chunks/custom-element-D2ziPxYE.js";import{e as a}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{m as s}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{A as o}from"./chunks/api-client-context-V1UAGtKW.js";import{L as r}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as l,a as c,x as h}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as y}from"./chunks/state-LQivXIgA.js";import{setEnv as d}from"./env.js";import{initLocalization as m,setLocale as v,isValidLocale as k}from"./i18n.js";import{c as b,n as f}from"./chunks/api-chat-client-fYDIH220.js";import{u as P,s as _,r as E}from"./chunks/apple-pay-outcomes-DbuQ2LI3.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/external-BXLaKy9c.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";function g(){if("undefined"==typeof navigator)return!1;const e=navigator.userAgent;return/Safari/i.test(e)&&!/Chrome|Chromium|Edg|OPR|Firefox|FxiOS/i.test(e)}async function S(e){if("undefined"==typeof window||!window.isSecureContext)return{available:!1,reason:"unsupported"};if(!function(){if("undefined"==typeof window)return!1;const e="undefined"!=typeof ApplePaySession&&"function"==typeof ApplePaySession.canMakePayments,t="undefined"!=typeof customElements&&void 0!==customElements.get("apple-pay-button");return e&&t}())return{available:!1,reason:"sdk-missing"};if(!e.trim())return{available:!1,reason:"merchant-id-missing"};const t=ApplePaySession;if(function(e){return"function"==typeof e.applePayCapabilities}(t))try{return function(e){switch(e){case"applePayUnsupported":return{available:!1,reason:"unsupported"};case"paymentCredentialsUnavailable":case"paymentCredentialsAvailable":case"paymentCredentialStatusUnknown":return{available:!0,usesQrFlow:!g()}}}((await t.applePayCapabilities(e)).paymentCredentialStatus)}catch{return t.canMakePayments()?{available:!0,usesQrFlow:!g()}:{available:!1,reason:"unsupported"}}return t.canMakePayments()?{available:!0,usesQrFlow:!g()}:{available:!1,reason:"unsupported"}}const A={es_ES:"es-ES",en_US:"en-US",pt_PT:"pt-PT",de_DE:"de-DE",ca_ES:"ca-ES"};try{m()}catch{}const C=["visa","masterCard","amex"],w=["supports3DS"],x=l`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.helper{margin:0;text-align:center;font-family:system-ui,sans-serif;font-size:13px;line-height:1.4;color:#6e6e73}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:48px;--apple-pay-button-border-radius:10px;--apple-pay-button-padding:0;display:block;width:100%;min-height:48px;cursor:pointer}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class ApplePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ApplePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(ApplePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(ApplePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}function j(e,t){p.warn(e,{error:t instanceof Error?t.message:String(t)})}let T=class MqApplePayCheckout extends c{constructor(){super(...arguments),this._availabilityPhase="checking",this._showQrHelper=!1,this._paying=!1,this._suppressCancelEvent=!1,this._availabilityGeneration=0,this.apiClient=b(),this._loginTokenTask=new r(this,()=>this.apiClient,{args:()=>[this.apiKey,this.token],onComplete:e=>{this._sessionToken=e.access_token,this.apiClient.setAuthToken(e.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{if(this._paying||"ready"!==this._availabilityPhase)return;let e;try{e=new ApplePaySession(3,this._buildPaymentRequest())}catch(e){return j("mq-apple-pay-checkout: failed to create ApplePaySession",e),void this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}this._paying=!0,this._suppressCancelEvent=!1,e.onvalidatemerchant=async t=>{try{const a=await this.apiClient.payments.validateApplePayMerchant({order_id:this.sessionId,validation_url:t.validationURL});e.completeMerchantValidation(P(a))}catch(t){j("mq-apple-pay-checkout: validate-merchant failed",t),this._suppressCancelEvent=!0,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"merchant"})),e.abort(),this._paying=!1}},e.onpaymentauthorized=async t=>{try{const a=await this.apiClient.payments.authorizeApplePay({order_id:this.sessionId,token:_(t.payment.token)}),{status:i,consultation_id:s}=a.data,n=E(i,s,this.sessionId);switch(n.kind){case"success":e.completePayment(ApplePaySession.STATUS_SUCCESS),this.dispatchEvent(new ApplePayCheckoutSuccessEvent({sessionId:n.sessionId,reference:n.reference}));break;case"denied":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutDeniedEvent({sessionId:n.sessionId}));break;case"error":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:n.reason}))}}catch(t){j("mq-apple-pay-checkout: authorize failed",t),e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"authorize"}))}finally{this._paying=!1}},e.oncancel=()=>{this._paying=!1,this._suppressCancelEvent?this._suppressCancelEvent=!1:this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"cancelled"}))};try{e.begin()}catch(e){j("mq-apple-pay-checkout: session.begin() failed",e),this._paying=!1,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}}}static{this.styles=x}willUpdate(e){e.has("env")&&this.env&&d(this.env),e.has("locale")&&v(k(this.locale)?this.locale:"es_ES");const t=f(e,{env:this.env,apiKey:this.apiKey,token:this._sessionToken,locale:k(this.locale)?this.locale:"es_ES"},this.inheritedApiClient);t&&(this.apiClient=t),e.has("merchantId")&&this._loginTokenTask.value&&this._refreshAvailability()}async _refreshAvailability(){const e=++this._availabilityGeneration;this._availabilityPhase="checking",this._showQrHelper=!1;const t=await S(this.merchantId??"");e===this._availabilityGeneration&&(t.available?(this._availabilityPhase="ready",this._showQrHelper=t.usesQrFlow):this._availabilityPhase="unavailable")}get _resolvedLocale(){return k(this.locale)?this.locale:"es_ES"}_buildPaymentRequest(){return{countryCode:this.country,currencyCode:this.currency,supportedNetworks:[...C],merchantCapabilities:[...w],total:{label:this.label,amount:this.amount}}}_renderUnavailable(){return this.merchantId?.trim()?"undefined"==typeof ApplePaySession?h`<p class="state">${s("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:h`<p class="state">${s("Apple Pay no está disponible")}</p>`:h`<p class="state">${s("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>h`<p class="state">${s("Preparando Apple Pay…")}</p>`,error:()=>h`<p class="state">${s("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?h`<p class="state">${s("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():h`${this._showQrHelper?h`<p class="helper">${s("Para pagar con Apple Pay, escanea el código QR con tu iPhone (iOS 18 o posterior) y confirma el pago.")}</p>`:null}<div class="pay-row ${this._paying?"pay-row--paying":""}"><apple-pay-button buttonstyle="black" type="pay" locale="${e=this._resolvedLocale,A[e]??"es-ES"}" aria-label="${s("Pagar con Apple Pay")}" @click="${this._onPayClick}"></apple-pay-button></div>`;var e}})}};e([u({type:String,attribute:"env"})],T.prototype,"env",void 0),e([u({type:String,attribute:"api-key"})],T.prototype,"apiKey",void 0),e([u({type:String,attribute:"token"})],T.prototype,"token",void 0),e([u({type:String,attribute:"locale",reflect:!0})],T.prototype,"locale",void 0),e([u({type:String,attribute:"merchant-id"})],T.prototype,"merchantId",void 0),e([u({type:String,attribute:"session-id"})],T.prototype,"sessionId",void 0),e([u({type:String,attribute:"amount"})],T.prototype,"amount",void 0),e([u({type:String,attribute:"currency"})],T.prototype,"currency",void 0),e([u({type:String,attribute:"country"})],T.prototype,"country",void 0),e([u({type:String,attribute:"label"})],T.prototype,"label",void 0),e([y()],T.prototype,"_availabilityPhase",void 0),e([y()],T.prototype,"_showQrHelper",void 0),e([y()],T.prototype,"_paying",void 0),e([i({context:o,subscribe:!0}),y()],T.prototype,"inheritedApiClient",void 0),e([a({context:o}),y()],T.prototype,"apiClient",void 0),T=e([n(),t("mq-apple-pay-checkout")],T);export{ApplePayCheckoutDeniedEvent,ApplePayCheckoutErrorEvent,ApplePayCheckoutSuccessEvent,T as MqApplePayCheckout};
@@ -1 +1 @@
1
- import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{a as o,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n as i}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import"./mq-checkout.js";import"./chunks/provide-BwI4DDGF.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/consume-CovVqBjI.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/api-chat-client-DLpFzml6.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";import"./chunks/api-client-context-V1UAGtKW.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/login-token-task-Yib__6a9.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class AppointmentPaidEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(AppointmentPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let r=class MqAppointmentCheckout extends o{constructor(){super(...arguments),this._provideSession=async t=>{const e=await t.payments.createPaymentLink({slot_id:this.slotId,service_id:this.serviceId,specialty_id:this.specialtyId,consultation_reason:this.consultationReason,discount_code:this.discountCode,preconsultation_documents:this.preconsultationDocuments});return{sessionId:e.session_id,paymentUrl:e.payment_link}},this._onSuccess=t=>{t.stopPropagation(),this.dispatchEvent(new AppointmentPaidEvent({appointmentId:t.detail.reference}))}}render(){return s`<mq-checkout env="${n(this.env)}" api-key="${this.apiKey}" token="${this.token}" locale="${this.locale}" .provideSession="${this._provideSession}" @payment-success="${this._onSuccess}"></mq-checkout>`}};t([i({type:String,attribute:"env"})],r.prototype,"env",void 0),t([i({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),t([i({type:String,attribute:"token"})],r.prototype,"token",void 0),t([i({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),t([i({type:String,attribute:"slot-id"})],r.prototype,"slotId",void 0),t([i({type:String,attribute:"service-id"})],r.prototype,"serviceId",void 0),t([i({type:String,attribute:"specialty-id"})],r.prototype,"specialtyId",void 0),t([i({type:String,attribute:"consultation-reason"})],r.prototype,"consultationReason",void 0),t([i({type:String,attribute:"discount-code"})],r.prototype,"discountCode",void 0),t([i({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
1
+ import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{a as o,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n as i}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import"./mq-checkout.js";import"./chunks/provide-BwI4DDGF.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/consume-CovVqBjI.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/api-chat-client-fYDIH220.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-BXLaKy9c.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";import"./chunks/api-client-context-V1UAGtKW.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/login-token-task-Yib__6a9.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class AppointmentPaidEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(AppointmentPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let r=class MqAppointmentCheckout extends o{constructor(){super(...arguments),this._provideSession=async t=>{const e=await t.payments.createPaymentLink({slot_id:this.slotId,service_id:this.serviceId,specialty_id:this.specialtyId,consultation_reason:this.consultationReason,discount_code:this.discountCode,preconsultation_documents:this.preconsultationDocuments});return{sessionId:e.session_id,paymentUrl:e.payment_link}},this._onSuccess=t=>{t.stopPropagation(),this.dispatchEvent(new AppointmentPaidEvent({appointmentId:t.detail.reference}))}}render(){return s`<mq-checkout env="${n(this.env)}" api-key="${this.apiKey}" token="${this.token}" locale="${this.locale}" .provideSession="${this._provideSession}" @payment-success="${this._onSuccess}"></mq-checkout>`}};t([i({type:String,attribute:"env"})],r.prototype,"env",void 0),t([i({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),t([i({type:String,attribute:"token"})],r.prototype,"token",void 0),t([i({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),t([i({type:String,attribute:"slot-id"})],r.prototype,"slotId",void 0),t([i({type:String,attribute:"service-id"})],r.prototype,"serviceId",void 0),t([i({type:String,attribute:"specialty-id"})],r.prototype,"specialtyId",void 0),t([i({type:String,attribute:"consultation-reason"})],r.prototype,"consultationReason",void 0),t([i({type:String,attribute:"discount-code"})],r.prototype,"discountCode",void 0),t([i({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
@@ -8,7 +8,8 @@ import './ui/mq-floating-bubble.js';
8
8
  import './ui/mq-card.js';
9
9
  import './ui/mq-unread-badge.js';
10
10
  import './ui/mq-page-title.js';
11
- import './chunks/mq-layout-TG2K4zRv.js';
11
+ import './chunks/index-CFlNQLy2.js';
12
+ import './chunks/mq-layout-D8Mak16a.js';
12
13
  import 'axios';
13
14
  import 'zod';
14
15
  import './chunks/schemas.d-b6_AekBb.js';
@@ -1 +1 @@
1
- import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as s,c as o}from"./chunks/custom-element-D2ziPxYE.js";import{e as r}from"./chunks/provide-BwI4DDGF.js";import{c as n}from"./chunks/consume-CovVqBjI.js";import{Q as a}from"./chunks/query-controller-BlO1Ax65.js";import{A as c}from"./chunks/api-client-context-V1UAGtKW.js";import{g as p}from"./chunks/get-appointment-query-C-gTTuiQ.js";import{a as d,i as m,x as l}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as k}from"./chunks/state-LQivXIgA.js";import{setEnv as h}from"./env.js";import{c as v,n as j}from"./chunks/api-chat-client-DLpFzml6.js";import"./chunks/documentation-view-DjNSPW_K.js";import"./ui/mq-card.js";import"./chunks/mq-layout-CVfDDjsX.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-CJj32K_p.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/addSeconds-ofMnxlgT.js";import"./ui/icons/calendar-icon.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/icons/types.js";import"./ui/icons/clock-icon.js";import"./ui/icons/info-circle-outine-icon.js";import"./ui/mq-button.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import"./ui/icons/message-bubble-icon.js";import"./mq-chat-room.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./chunks/chunk-Y4EKUX25-QqMl3eiq.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import"./chunks/mutation-controller-CR2qcqhH.js";import"./ui/mq-floating-bubble.js";import"./ui/mq-unread-badge.js";import"./ui/mq-page-title.js";import"./ui/icons/arrow-narrow-left-icon.js";import"./chunks/telemetry-client-BdPx4SXu.js";import"./ui/icons/download-icon.js";import"./chunks/blob-to-base64-CUL1trde.js";let b=class DocumentationViewSkeleton extends d{static{this.styles=m`.skeleton{border-radius:var(--border-radius-md);background-color:#f0f0f0;animation:skeleton-pulse 1.5s infinite}.page-title-skeleton{display:flex;align-items:center;gap:var(--sp-3);margin-bottom:var(--size-3)}.back-button-skeleton{width:var(--size-10);height:var(--size-10);border-radius:var(--border-radius-full);flex-shrink:0}.title-bar-skeleton{width:120px;height:24px;border-radius:var(--border-radius-sm)}@media (min-width:768px){.page-title-skeleton{gap:var(--sp-6)}.title-bar-skeleton{width:200px;height:32px}}.description-skeleton{width:100%;height:16px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-2)}.description-skeleton:last-of-type{width:70%;margin-bottom:var(--size-5)}.professional-card{padding:var(--size-4);margin-bottom:var(--size-4)}.professional-name-skeleton{width:180px;height:24px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-1)}.professional-speciality-skeleton{width:140px;height:16px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-4)}.description-list{display:flex;flex-direction:column;gap:var(--size-4)}.description-list-item{display:flex;flex-direction:row;align-items:center;gap:var(--size-2);font-family:var(--font-body)}.icon-skeleton{width:20px;height:20px;border-radius:var(--border-radius-sm)}.text-skeleton{width:120px;height:16px;border-radius:var(--border-radius-sm)}.documents-card{padding:var(--size-4);margin-bottom:var(--size-6)}.documents-card .skeleton{background-color:var(--color-muted)}.documents-card-title-skeleton{width:150px;height:24px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-4)}.button-skeleton{width:100%;height:44px;border-radius:var(--border-radius-md);margin-top:var(--size-4)}@keyframes skeleton-pulse{0%{opacity:1}50%{opacity:.6}100%{opacity:1}}`}render(){return l`<div class="page-title-skeleton"><div class="skeleton back-button-skeleton"></div><div class="skeleton title-bar-skeleton"></div></div><div class="skeleton description-skeleton"></div><div class="skeleton description-skeleton"></div><mq-card class="professional-card" roundness="md"><div><div class="skeleton professional-name-skeleton"></div><div class="skeleton professional-speciality-skeleton"></div></div><dl class="description-list"><div class="description-list-item"><div class="skeleton icon-skeleton"></div><div class="skeleton text-skeleton"></div></div><div class="description-list-item"><div class="skeleton icon-skeleton"></div><div class="skeleton text-skeleton"></div></div></dl></mq-card><mq-card class="documents-card" roundness="md"><div class="skeleton documents-card-title-skeleton"></div><div class="skeleton button-skeleton"></div></mq-card>`}};b=s([o("documentation-view-skeleton")],b);let g=class MqAppointmentDocumentation extends d{constructor(){super(...arguments),this.getAppointmentQuery=new a(this,()=>p(this.apiClient,{id:this.appointmentId})),this.apiClient=v()}willUpdate(i){i.has("env")&&this.env&&h(this.env),i.has("locale")&&this.locale&&t(this.locale)&&e(this.locale);const s=j(i,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);s&&(this.apiClient=s)}render(){return l`<mq-layout background="transparent">${this.getAppointmentQuery.render({complete:t=>l`<documentation-view .token="${this.token}" .appointment="${t}"></documentation-view>`,error:()=>l``,pending:()=>l`<documentation-view-skeleton></documentation-view-skeleton>`})}</mq-layout>`}};s([u({type:String,attribute:"appointment-id"})],g.prototype,"appointmentId",void 0),s([u({type:String,attribute:"token"})],g.prototype,"token",void 0),s([u({type:String,attribute:"api-key"})],g.prototype,"apiKey",void 0),s([u({type:String,attribute:"locale"})],g.prototype,"locale",void 0),s([u({type:String,attribute:"env"})],g.prototype,"env",void 0),s([n({context:c,subscribe:!0}),k()],g.prototype,"inheritedApiClient",void 0),s([r({context:c}),k()],g.prototype,"apiClient",void 0),g=s([o("mq-appointment-documentation")],g),i();export{g as MqAppointmentDocumentation};
1
+ import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as s,c as o}from"./chunks/custom-element-D2ziPxYE.js";import{e as r}from"./chunks/provide-BwI4DDGF.js";import{c as n}from"./chunks/consume-CovVqBjI.js";import{Q as a}from"./chunks/query-controller-BlO1Ax65.js";import{A as c}from"./chunks/api-client-context-V1UAGtKW.js";import{g as p}from"./chunks/get-appointment-query-C-gTTuiQ.js";import{a as d,i as m,x as l}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as k}from"./chunks/state-LQivXIgA.js";import{setEnv as h}from"./env.js";import{c as v,n as j}from"./chunks/api-chat-client-fYDIH220.js";import"./chunks/documentation-view-DywQ1MfS.js";import"./ui/mq-card.js";import"./chunks/mq-layout-BiE8gq23.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-BXLaKy9c.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/addSeconds-ofMnxlgT.js";import"./ui/icons/calendar-icon.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/icons/types.js";import"./ui/icons/clock-icon.js";import"./ui/icons/info-circle-outine-icon.js";import"./ui/mq-button.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import"./ui/icons/message-bubble-icon.js";import"./mq-chat-room.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./chunks/chunk-Y4EKUX25-CWAZgcgw.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-DJR1Yoyy.js";import"./chunks/mutation-controller-CR2qcqhH.js";import"./ui/mq-floating-bubble.js";import"./ui/mq-unread-badge.js";import"./ui/mq-page-title.js";import"./ui/icons/arrow-narrow-left-icon.js";import"./ui/icons/download-icon.js";import"./chunks/blob-to-base64-CUL1trde.js";import"./chunks/telemetry-client-DEIuDZfA.js";let b=class DocumentationViewSkeleton extends d{static{this.styles=m`.skeleton{border-radius:var(--border-radius-md);background-color:#f0f0f0;animation:skeleton-pulse 1.5s infinite}.page-title-skeleton{display:flex;align-items:center;gap:var(--sp-3);margin-bottom:var(--size-3)}.back-button-skeleton{width:var(--size-10);height:var(--size-10);border-radius:var(--border-radius-full);flex-shrink:0}.title-bar-skeleton{width:120px;height:24px;border-radius:var(--border-radius-sm)}@media (min-width:768px){.page-title-skeleton{gap:var(--sp-6)}.title-bar-skeleton{width:200px;height:32px}}.description-skeleton{width:100%;height:16px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-2)}.description-skeleton:last-of-type{width:70%;margin-bottom:var(--size-5)}.professional-card{padding:var(--size-4);margin-bottom:var(--size-4)}.professional-name-skeleton{width:180px;height:24px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-1)}.professional-speciality-skeleton{width:140px;height:16px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-4)}.description-list{display:flex;flex-direction:column;gap:var(--size-4)}.description-list-item{display:flex;flex-direction:row;align-items:center;gap:var(--size-2);font-family:var(--font-body)}.icon-skeleton{width:20px;height:20px;border-radius:var(--border-radius-sm)}.text-skeleton{width:120px;height:16px;border-radius:var(--border-radius-sm)}.documents-card{padding:var(--size-4);margin-bottom:var(--size-6)}.documents-card .skeleton{background-color:var(--color-muted)}.documents-card-title-skeleton{width:150px;height:24px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-4)}.button-skeleton{width:100%;height:44px;border-radius:var(--border-radius-md);margin-top:var(--size-4)}@keyframes skeleton-pulse{0%{opacity:1}50%{opacity:.6}100%{opacity:1}}`}render(){return l`<div class="page-title-skeleton"><div class="skeleton back-button-skeleton"></div><div class="skeleton title-bar-skeleton"></div></div><div class="skeleton description-skeleton"></div><div class="skeleton description-skeleton"></div><mq-card class="professional-card" roundness="md"><div><div class="skeleton professional-name-skeleton"></div><div class="skeleton professional-speciality-skeleton"></div></div><dl class="description-list"><div class="description-list-item"><div class="skeleton icon-skeleton"></div><div class="skeleton text-skeleton"></div></div><div class="description-list-item"><div class="skeleton icon-skeleton"></div><div class="skeleton text-skeleton"></div></div></dl></mq-card><mq-card class="documents-card" roundness="md"><div class="skeleton documents-card-title-skeleton"></div><div class="skeleton button-skeleton"></div></mq-card>`}};b=s([o("documentation-view-skeleton")],b);let g=class MqAppointmentDocumentation extends d{constructor(){super(...arguments),this.getAppointmentQuery=new a(this,()=>p(this.apiClient,{id:this.appointmentId})),this.apiClient=v()}willUpdate(i){i.has("env")&&this.env&&h(this.env),i.has("locale")&&this.locale&&t(this.locale)&&e(this.locale);const s=j(i,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);s&&(this.apiClient=s)}render(){return l`<mq-layout background="transparent">${this.getAppointmentQuery.render({complete:t=>l`<documentation-view .token="${this.token}" .appointment="${t}"></documentation-view>`,error:()=>l``,pending:()=>l`<documentation-view-skeleton></documentation-view-skeleton>`})}</mq-layout>`}};s([u({type:String,attribute:"appointment-id"})],g.prototype,"appointmentId",void 0),s([u({type:String,attribute:"token"})],g.prototype,"token",void 0),s([u({type:String,attribute:"api-key"})],g.prototype,"apiKey",void 0),s([u({type:String,attribute:"locale"})],g.prototype,"locale",void 0),s([u({type:String,attribute:"env"})],g.prototype,"env",void 0),s([n({context:c,subscribe:!0}),k()],g.prototype,"inheritedApiClient",void 0),s([r({context:c}),k()],g.prototype,"apiClient",void 0),g=s([o("mq-appointment-documentation")],g),i();export{g as MqAppointmentDocumentation};
@@ -1 +1 @@
1
- import{_ as e,c as t}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{l as o}from"./chunks/localized-decorator-BlOuLhym.js";import{m as a,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{A as n}from"./chunks/api-client-context-V1UAGtKW.js";import{i as l,a as d,x as c,E as h}from"./chunks/lit-element-DiWJYFwC.js";import{n as m}from"./chunks/property-scuRaFcM.js";import{r as p}from"./chunks/state-LQivXIgA.js";import{n as g}from"./chunks/create-context-DqP79qjF.js";import{tokens as u}from"./theme.js";import{xIcon as v}from"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-button.js";import"./ui/mq-skeleton.js";import{Q as b}from"./chunks/query-controller-BlO1Ax65.js";import{g as y}from"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import{o as f}from"./chunks/if-defined-BYeVdwgd.js";import{chevronLeftIcon as w}from"./ui/icons/chevron-left-icon.js";import{e as k}from"./chunks/query-CeeutdfT.js";import{l as x}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{DownloadFileEvent as C}from"./events.js";import{M as $,c as I,n as z}from"./chunks/api-chat-client-DLpFzml6.js";import{S as T,g as D}from"./chunks/chunk-Y4EKUX25-QqMl3eiq.js";import{checkDoubleIcon as M}from"./ui/icons/check-double-icon.js";import{checkIcon as j}from"./ui/icons/check-icon.js";import{getLocale as q}from"./i18n.js";import{S,a as P}from"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import{s as A}from"./chunks/context-consumer-ESdICVAb.js";import{s as _}from"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import{Q as E}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{e as R}from"./chunks/class-map-Co76I6aw.js";import{M as U}from"./chunks/mutation-controller-CR2qcqhH.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./ui/icons/types.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";const B=g("apiKey"),N=g("token"),H=g("professionalHash"),L=g("roomId"),K=g("consultationId"),F=g("consultationType");class MqChatRoomCloseEvent extends Event{static{this.eventName="mq-chat-room-close"}constructor(){super(MqChatRoomCloseEvent.eventName,{bubbles:!0,composed:!0})}}class MqChatRoomProfileEvent extends Event{static{this.eventName="mq-chat-room-profile"}constructor(){super(MqChatRoomProfileEvent.eventName,{bubbles:!0,composed:!0})}}const O=l`header{padding:var(--size-3) var(--size-4);background-color:var(--color-background-primary);display:flex;justify-content:space-between;gap:var(--size-1)}.left-side{display:flex;flex:1;min-width:0;align-items:center;gap:var(--size-3)}.left-side mq-avatar{flex-shrink:0}.info{min-width:0}.ghost-btn{text-align:left;background:0 0;border:none;padding:0;cursor:pointer}.right-side{display:flex;align-items:center}.name{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-bold);margin:0;color:var(--color-background);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.specialty{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0;color:var(--color-white);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.name-skeleton{margin-bottom:var(--size-1)}.profile-title{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);margin:0;color:var(--color-white)}`;let Q=class ChatRoomHeader extends d{constructor(){super(...arguments),this.hideCloseButton=!1,this.getProfessionalQuery=new b(this,()=>y(this.apiClient,{hash:this.professionalHash}))}static{this.styles=O}handleClose(){this.dispatchEvent(new MqChatRoomCloseEvent)}handleClickProfile(){this.dispatchEvent(new MqChatRoomProfileEvent)}renderProfile(){return c`<div class="left-side"><mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${()=>{this.dispatchEvent(new CustomEvent("goto-chat",{bubbles:!0,composed:!0}))}}">${w({size:24})}</mq-button><p class="profile-title">${a("Perfil de profesional")}</p></div>`}renderChat(){return c`${this.getProfessionalQuery.render({complete:e=>c`<button type="button" class="left-side ghost-btn" @click="${this.handleClickProfile}"><mq-avatar src="${f(e.avatar??void 0)}" alt="User Avatar" fallback="John Doe" size="sm"></mq-avatar><div class="info"><p class="name">${e.name}</p><p class="specialty">${e.title}</p></div></button>`,pending:()=>c`<div class="left-side"><mq-skeleton width="45px" height="45px" border-radius="full"></mq-skeleton><div><mq-skeleton class="name-skeleton" height="14px" width="120px"></mq-skeleton><mq-skeleton height="14px" width="100px"></mq-skeleton></div></div>`})}`}render(){return c`<header>${"profile"===this.view?this.renderProfile():this.renderChat()}<div class="right-side">${this.hideCloseButton?h:c`<mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${this.handleClose}">${v({size:24})}</mq-button>`}</div></header>`}};e([i({context:n,subscribe:!0})],Q.prototype,"apiClient",void 0),e([m({type:String})],Q.prototype,"professionalHash",void 0),e([m({type:Boolean})],Q.prototype,"hideCloseButton",void 0),e([m({type:String})],Q.prototype,"view",void 0),Q=e([o(),t("chat-room-header")],Q);const V=/(https?:\/\/[^\s,;:!)\]}\]]+|www\.[^\s,;:!)\]}\]]+|[a-zA-Z0-9][-a-zA-Z0-9]*(?:\.[a-zA-Z0-9][-a-zA-Z0-9]*)+(?:\/[^\s,;:!)\]}\]]*|(?:\?|#|&)[^\s,;:!)\]}\]]*)?)/gi;function J(e){return e.split(V).map((e,t)=>{if(t%2==1){const t=e.startsWith("http")?e:`https://${e}`;return c`<a href="${t}" target="_blank" rel="noopener noreferrer" class="message-link">${e}</a>`}return e})}let Y=class TextMessageBubble extends d{static{this.styles=[l`:host{display:block}.message-bubble{padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal)}.message-bubble.received{background-color:var(--chat-received-message-background);color:var(--chat-received-message-foreground);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);color:var(--chat-sent-message-foreground);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}.message-bubble.received .message-content a.message-link,.message-bubble.sent .message-content a.message-link{color:var(--color-primary-link-default);text-decoration:underline}.message-bubble.received .message-content a.message-link:hover,.message-bubble.sent .message-content a.message-link:hover{opacity:.8}`]}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return c`<div class="message-content">${J(e)}</div>`;const s=t.map(e=>c`<div class="message-paragraph">${J(e.trim())}</div>`);return c`<div class="message-content">${s}</div>`}render(){return c`<div class="message-bubble ${this.kind}">${this.formatMessageContent(this.message.string)}</div>`}};e([m({type:Object})],Y.prototype,"message",void 0),e([m({type:String})],Y.prototype,"kind",void 0),Y=e([t("text-message-bubble")],Y);const Z=l`:host{display:block}.message-bubble{padding:var(--size-2);border-radius:var(--border-radius-lg);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);overflow:hidden}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.image-content{display:block;width:229px;height:229px;object-fit:cover;border-radius:var(--border-radius-md)}.image-placeholder{display:flex;align-items:center;justify-content:center;width:100%;max-width:300px;height:200px;background-color:var(--color-gray-light);border-radius:var(--border-radius-md);color:var(--chat-sent-message-foreground);font-size:var(--text-sm)}.image-content{cursor:pointer;transition:opacity .2s ease}.image-content:hover{opacity:.9}.preview-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:var(--dialog-underlay);display:flex;align-items:center;justify-content:center;z-index:1000;cursor:pointer;opacity:0;transition:opacity var(--dialog-transition-duration) ease}.preview-overlay.open{opacity:1}.preview-image{position:fixed;z-index:1000;inset:var(--mq-safe-top,0) var(--mq-safe-right,0) var(--mq-safe-bottom,0) var(--mq-safe-left,0);max-width:calc(100% - var(--mq-safe-left,4px) - var(--mq-safe-right,4px));max-height:calc(100% - var(--mq-safe-top,4px) - var(--mq-safe-bottom,4px));margin:auto;object-fit:contain;cursor:default;box-shadow:var(--dialog-shadow);transform:scale(.95);transition:transform var(--dialog-transition-duration) ease}.preview-overlay.open .preview-image{transform:scale(1)}.preview-close{z-index:1001;display:inline-flex;align-items:center;justify-content:center;height:var(--size-10);width:var(--size-10);position:absolute;top:var(--mq-safe-top,4px);right:var(--mq-safe-right,4px);background:rgba(255,255,255,.3);border:none;color:var(--color-neutrals-text-default);font-size:var(--text-xl);padding:var(--size-2) var(--size-3);border-radius:var(--border-radius-md);cursor:pointer;transition:background var(--dialog-transition-duration) ease}.preview-close:hover{background:var(--dialog-close-hover-bg)}`;let G=class ImageMessageBubble extends d{constructor(){super(...arguments),this.showPreview=!1,this.isPreviewRendered=!1,this.isPreviewActive=!1,this.closeTimer=null}static{this.styles=Z}handleImageError(e){const t=e.target;t.style.display="none";const s=t.nextElementSibling;s&&(s.style.display="flex")}handleImageLoad(e){const t=e.target.nextElementSibling;t&&(t.style.display="none")}handleImageClick(){this.showPreview=!0,this.isPreviewRendered=!0,this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.isPreviewActive=!0})})}handleImageKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleImageClick())}handleClosePreview(e){e&&e.stopPropagation(),this.isPreviewActive=!1,this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=window.setTimeout(()=>{this.isPreviewRendered=!1,this.showPreview=!1,this.closeTimer=null},200)}handleOverlayClick(e){e.target===e.currentTarget&&this.handleClosePreview()}handleOverlayKeyDown(e){"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),this.handleClosePreview())}handleKeyDown(e){"Escape"===e.key&&this.showPreview&&(e.preventDefault(),this.handleClosePreview())}handlePreviewImageKeyDown(e){e.stopPropagation()}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown.bind(this)),this.closeTimer&&(window.clearTimeout(this.closeTimer),this.closeTimer=null)}render(){const e=this.message.attachment.signed_url??this.message.attachment.url;return c`<div class="message-bubble ${this.kind}"><img class="image-content" src="${e}" width="229" height="229" alt="Shared attachment" @error="${this.handleImageError}" @load="${this.handleImageLoad}" @click="${this.handleImageClick}" @keydown="${this.handleImageKeyDown}" tabindex="0"><div class="image-placeholder" style="display:none">Image unavailable</div></div>${this.showPreview&&this.isPreviewRendered?c`<div class="preview-overlay ${this.isPreviewActive?"open":""}" @click="${this.handleOverlayClick}" @keydown="${this.handleOverlayKeyDown}" tabindex="0"><button class="preview-close" @click="${this.handleClosePreview}" aria-label="Close preview">${v({size:24})}</button> <img class="preview-image" src="${e}" alt="Shared attachment preview" @click="${e=>e.stopPropagation()}" @keydown="${this.handlePreviewImageKeyDown}" tabindex="0"></div>`:""}`}};e([m({type:Object})],G.prototype,"message",void 0),e([m({type:String})],G.prototype,"kind",void 0),e([i({context:N})],G.prototype,"token",void 0),e([p()],G.prototype,"showPreview",void 0),e([p()],G.prototype,"isPreviewRendered",void 0),e([p()],G.prototype,"isPreviewActive",void 0),G=e([t("image-message-bubble")],G);const W=l`:host{background-color:var(--chat-system-message-background);color:var(--chat-system-message-foreground);display:block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal)}a.message-link{color:var(--color-primary-link-default);text-decoration:underline}a.message-link:hover{opacity:.8}`;let X=class SystemMessageBubble extends d{static{this.styles=W}render(){return c`<div class="system-message-bubble">${J(this.message.string)}</div>`}};e([m({type:Object})],X.prototype,"message",void 0),X=e([t("system-message-bubble")],X);const ee=l`:host{display:block}.message-bubble{display:inline-block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);text-decoration:underline;color:var(--color-primary-link-default);border:none;cursor:pointer;text-align:left}.message-bubble:hover:not(:disabled){opacity:.8}.message-bubble:disabled{opacity:.5;cursor:not-allowed}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}`;let te=class FileMessageBubble extends d{constructor(){super(...arguments),this.isDownloading=!1}static{this.styles=ee}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return c`<div class="message-content">${e}</div>`;const s=t.map(e=>c`<div class="message-paragraph">${e.trim()}</div>`);return c`<div class="message-content">${s}</div>`}async handleDownload(){if(this.isDownloading)return;const e=this.message.attachment.url;try{this.isDownloading=!0;const t=await fetch(e,{headers:{Authorization:`Bearer ${this.token}`}});if(!t.ok)throw new Error(`Failed to fetch file: ${t.statusText}`);const s=await t.blob(),i=new FileReader;i.onloadend=()=>{const e=i.result,t=new C({url:e,filename:this.message.attachment.file_name});this.dispatchEvent(t),this.isDownloading=!1},i.onerror=()=>{x.error("Error reading file as data URL"),this.isDownloading=!1},i.readAsDataURL(s)}catch(e){x.error("Error downloading file:",e),this.isDownloading=!1}}render(){return c`<button type="button" @click="${this.handleDownload}" class="message-bubble ${this.kind}" ?disabled="${this.isDownloading}">${this.formatMessageContent(this.message.attachment.file_name)}</button>`}};e([m({type:Object})],te.prototype,"message",void 0),e([m({type:String})],te.prototype,"kind",void 0),e([i({context:N})],te.prototype,"token",void 0),e([p()],te.prototype,"isDownloading",void 0),te=e([t("file-message-bubble")],te);let se=class MessageBubble extends d{constructor(){super(...arguments),this.showTimestamp=!0}static{this.styles=[l`:host{display:block}.timestamp{font-family:var(--font-body);font-size:var(--text-xs);color:var(--color-gray-medium);font-weight:var(--font-weight-normal);text-align:left;display:flex;align-items:center;gap:var(--size-1)}.timestamp.sent{text-align:right;justify-content:flex-end}.status-icon{width:12px;height:12px}.status-icon.read{color:var(--color-primary)}`]}formatTimestamp(e){if(!e)return"";try{const t=new Date(e);return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}catch{return e}}renderStatusIcon(){switch(this.message.status){case $.Sent:return j({size:12,color:"currentColor"});case $.Received:return M({size:12,color:"currentColor"});case $.Read:return M({size:12,color:"currentColor",className:"read"});default:return null}}renderBubbleContent(){switch(this.message.type){case"image":return c`<image-message-bubble .message="${this.message}" .kind="${this.kind}"></image-message-bubble>`;case"file":return c`<file-message-bubble .message="${this.message}" .kind="${this.kind}"></file-message-bubble>`;default:return c`<text-message-bubble .message="${this.message}" .kind="${this.kind}"></text-message-bubble>`}}render(){if(this.message.senderType===T.system)return c`<system-message-bubble .message="${this.message}"></system-message-bubble>`;const e=this.message.createdAt?new Date(this.message.createdAt):this.message.time?new Date(this.message.time):null;return c`${this.renderBubbleContent()} ${this.showTimestamp&&e?c`<div class="timestamp ${this.kind}">${this.formatTimestamp(e.toISOString())} ${"sent"===this.kind?c`<span class="status-icon ${this.message.status===$.Read?"read":""}">${this.renderStatusIcon()}</span>`:""}</div>`:""}`}};e([m({type:String})],se.prototype,"kind",void 0),e([m({type:Object})],se.prototype,"message",void 0),e([m({type:Boolean})],se.prototype,"showTimestamp",void 0),se=e([t("message-bubble")],se);let ie=class DateBanner extends d{constructor(){super(...arguments),this.date=""}static{this.styles=[u,l`:host{display:block;margin-bottom:var(--size-2)}.date-banner{display:flex;align-items:center;justify-content:center;position:relative}.date-text{background-color:var(--color-gray-light);color:var(--color-gray-darker);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);padding:var(--size-1) var(--size-2);border-radius:var(--border-radius-2xl);white-space:nowrap}`]}formatDate(e){const t=q().replace("_","-"),s=new Date(e),i=new Date,o=new Date(i);o.setDate(o.getDate()-1);const r=new Date(s.getFullYear(),s.getMonth(),s.getDate()),n=new Date(i.getFullYear(),i.getMonth(),i.getDate()),l=new Date(o.getFullYear(),o.getMonth(),o.getDate());return r.getTime()===n.getTime()?a("Hoy"):r.getTime()===l.getTime()?a("Ayer"):s.toLocaleDateString(t,{dateStyle:"medium"})}render(){return c`<div class="date-banner"><span class="date-text">${this.formatDate(this.date)}</span></div>`}};function oe(e){return e.createdAt?new Date(e.createdAt):e.time?new Date(e.time):new Date}e([m({type:String})],ie.prototype,"date",void 0),ie=e([o(),t("date-banner")],ie);let ae=class MessagesList extends d{constructor(){super(...arguments),this.messages=[]}static{this.styles=[u,l`:host{display:block;width:100%;height:100%;overflow-y:auto;overflow-x:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-1);background-color:var(--color-white);padding-bottom:var(--size-4)}.message-wrapper{display:flex;width:100%}.message-wrapper.received{justify-content:flex-start}.message-wrapper.sent{justify-content:flex-end}.message-wrapper.system{justify-content:center}message-bubble{max-width:70%}`]}scrollToBottom(){requestAnimationFrame(()=>{const e=this.messagesContainerEnd;e&&e.scrollIntoView({behavior:"instant",block:"end"})})}shouldShowMessageTimestamp(e,t){if(e.senderType===T.system)return!1;if(!t)return!0;if(t.senderType!==e.senderType)return!0;if(t.senderType===T.ordinary&&e.senderType===T.ordinary&&t.fromUserHash!==e.fromUserHash)return!0;return(oe(t).getTime()-oe(e).getTime())/6e4>1}groupMessagesByDate(e){const t=[];let s=null;return e.forEach((i,o)=>{const a=oe(i),r=a?.toDateString();r!==s&&(t.push({type:"date",data:a.toDateString()}),s=r??null);const n=e[o+1],l=this.shouldShowMessageTimestamp(i,n);t.push({type:"message",data:i,showTimestamp:l})}),t}firstUpdated(){this.scrollToBottom()}willUpdate(e){e.has("messages")&&this.scrollToBottom()}render(){const e=this.groupMessagesByDate(this.messages),t=e.map((t,s)=>{if("date"===t.type)return c`<date-banner .date="${t.data}"></date-banner>`;const i=this.professionalHash!==t.data.fromUserHash,o=t.data.senderType===T.system?"system":i?"sent":"received";return c`<div class="message-wrapper ${o}"><message-bubble .message="${t.data}" .kind="${o}" .showTimestamp="${t.showTimestamp||"date"===e[s+1]?.type}"></message-bubble></div>`});return c`<div class="messages-container">${t}<div class="messages-container-end"></div></div>`}};e([m({type:Array})],ae.prototype,"messages",void 0),e([m({type:String})],ae.prototype,"professionalHash",void 0),e([k(".messages-container-end")],ae.prototype,"messagesContainerEnd",void 0),ae=e([t("messages-list")],ae);let re=class MessageBubbleSkeleton extends d{constructor(){super(...arguments),this.variant="patient",this.height="md",this.showTimestamp=!0}static{this.styles=[l`:host{display:block}.message-bubble{padding:var(--size-4);border-radius:var(--border-radius-lg);margin-bottom:var(--size-1);position:relative;overflow:hidden}.message-bubble.doctor{background-color:var(--color-gray-light);border-bottom-left-radius:0}.message-bubble.patient{background-color:var(--color-background-primary-light);border-bottom-right-radius:0}:host([height=sm]) .message-bubble{height:var(--size-8)}:host([height=md]) .message-bubble{height:var(--size-12)}`]}render(){return c`<div class="message-bubble ${this.variant}"></div>${this.showTimestamp?c`<div class="timestamp-skeleton ${this.variant}"></div>`:""}`}};e([m({type:String})],re.prototype,"variant",void 0),e([m({type:String})],re.prototype,"height",void 0),e([m({type:Boolean})],re.prototype,"showTimestamp",void 0),re=e([t("message-bubble-skeleton")],re);let ne=class MessagesSkeleton extends d{constructor(){super(...arguments),this.messageCount=6}static{this.styles=[u,l`:host{display:block;width:100%;height:100%;overflow:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-3);max-width:100%;height:100%;background-color:var(--color-white)}.message-wrapper{display:flex;width:100%}.message-wrapper.doctor{justify-content:flex-start}.message-wrapper.patient{justify-content:flex-end}message-bubble-skeleton{max-width:85%;min-width:60%;width:100%}`]}getSkeletonHeight(e){const t=["sm","md","sm","md","sm","md"];return t[e%t.length]}getSkeletonVariant(e){const t=["doctor","patient","doctor","doctor","patient","doctor","patient"];return t[e%t.length]}renderSkeletonMessages(){return Array.from({length:this.messageCount},(e,t)=>{const s=this.getSkeletonVariant(t),i=this.getSkeletonHeight(t);return c`<div class="message-wrapper ${s}"><message-bubble-skeleton variant="${s}" height="${i}" ?showTimestamp="${t===this.messageCount-1||Math.random()>.7}"></message-bubble-skeleton></div>`})}render(){return c`<div class="messages-container">${this.renderSkeletonMessages()}</div>`}};e([m({type:Number})],ne.prototype,"messageCount",void 0),ne=e([t("messages-skeleton")],ne);var le=class{constructor(e,t){this.host=e,this.listeners=[],this.host.addController(this),this.socketContext=new A(this.host,{context:S,subscribe:!0,callback:e=>{if(e&&(this.socket=e,t?.listeners)){this.listeners=t.listeners;for(const e of this.listeners)this.socket?.on(e.eventName,e.callback)}}})}hostConnected(){}hostDisconnected(){for(const e of this.listeners)this.socket?.off(e.eventName,e.callback)}};function de(e,t){return{queryKey:_(e,"rooms",t.roomId),queryFn:()=>e.rooms.getRoomMessages(t),staleTime:0}}class OptimisticUpdatesController{constructor(e){this.host=e,this.apiClientContext=new A(this.host,{context:n,subscribe:!0,callback:e=>{this.apiClient=e}}),this.queryClientContext=new A(this.host,{context:E,subscribe:!0,callback:e=>{e&&(this.queryClient=e)}}),this.host.addController(this)}hostConnected(){}appendMessageToRoom(e,t){if(!this.apiClient)return;const s=de(this.apiClient,{roomId:t}).queryKey;this.queryClient?.setQueriesData({queryKey:s,exact:!0},t=>[...t??[],e])}deleteMessage(e,t){if(!this.queryClient||!this.apiClient)return;const s=de(this.apiClient,{roomId:t}).queryKey;this.queryClient.setQueryData(s,t=>(t??[]).map(t=>t.messageId===e?{...t,deletedAt:(new Date).toISOString(),string:a("Este mensaje fue eliminado")}:t))}updateMessageStatus({messageId:e,status:t,roomId:s}){if(!this.queryClient||!this.apiClient)return;const i=de(this.apiClient,{roomId:s}).queryKey;this.queryClient.setQueryData(i,s=>(s??[]).map(s=>s.messageId===e?{...s,status:t}:s))}}let ce=class ChatRoomMessages extends d{constructor(){super(...arguments),this.getRoomMessagesQuery=new b(this,()=>de(this.apiClient,{roomId:this.roomId})),this.optimisticUpdatesController=new OptimisticUpdatesController(this),this.onMessageReceived=e=>{if(e.roomId!==this.roomId)return;const t=function(e){const t={roomId:"string"==typeof e.roomId?Number.parseInt(e.roomId,10):e.roomId,messageId:e.messageId,status:e.status,senderType:e.senderType,fromUserHash:e.fromUserHash,time:e.time,createdAt:e.time?new Date(e.time).toISOString():null,deletedAt:null};switch(e.type){case"string":return{...t,type:"string",string:e.string,auto:e.auto?1:0,attachment:null};case"image":return{...t,type:"image",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.imageUrl,type:"uncategorized",meta:{duration:0},signed_url:e.imageUrl}};case"file":return{...t,type:"file",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.fileUrl,type:"uncategorized",meta:{duration:0},signed_url:e.fileUrl}};default:return{...t,type:"string",string:"",auto:0,attachment:null}}}(e);this.optimisticUpdatesController.appendMessageToRoom(t,t.roomId),t.roomId===this.roomId&&e.fromUserHash===this.professionalHash&&this._socketController.socket?.emit(P.messageStatus,e.messageId,this.roomId,$.Read)},this.onMessageDeleted=e=>{e.room_id===this.roomId&&this.optimisticUpdatesController.deleteMessage(e.message_id,e.room_id)},this.onMessageStatusUpdated=e=>{e.roomId===this.roomId&&this.optimisticUpdatesController.updateMessageStatus({messageId:e.messageId,status:e.status,roomId:e.roomId})},this._socketController=new le(this,{listeners:[{eventName:P.message,callback:this.onMessageReceived},{eventName:P.message_deleted,callback:this.onMessageDeleted},{eventName:P.messageStatus,callback:this.onMessageStatusUpdated}]})}static{this.styles=[u,l`:host{display:block;width:100%;height:100%}`]}render(){return this.getRoomMessagesQuery.render({pending:()=>c`<messages-skeleton messageCount="8"></messages-skeleton>`,complete:e=>c`<messages-list .messages="${e}" .professionalHash="${this.professionalHash}"></messages-list>`})}};e([i({context:n,subscribe:!0})],ce.prototype,"apiClient",void 0),e([m({type:Number})],ce.prototype,"roomId",void 0),e([m({type:String})],ce.prototype,"professionalHash",void 0),ce=e([t("chat-room-messages")],ce);var he=class{constructor(e){this.string=e.string,this.roomId=e.roomId,this.messageId=e.messageId,this.type=e.type,this.fileName=e.fileName,this.autoMessage=e.autoMessage,this.senderType=e.senderType,this.attachmentType=e.attachmentType,this.consultationId=e.consultationId,this.consultationType=e.consultationType}toSocketMessage(){return[P.message,this.string,this.roomId,this.messageId,this.type,this.fileName,this.autoMessage,this.senderType,this.attachmentType,this.consultationId,this.consultationType]}},me=class extends he{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.string,type:"string",fileName:null,autoMessage:!1,senderType:T.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}},pe=class extends he{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.base64Attachment,fileName:e.fileName,type:e.type,autoMessage:!1,senderType:T.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}};async function ge(e){return await Promise.all(e.map(async e=>{const t=await function(e){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>{const o=i.result.split(",")[1];o?t(o):s(new Error(`Invalid data URL format for file: ${e.name}`))},i.onerror=()=>{s(new Error(`Failed to read file: ${e.name}`))},i.readAsDataURL(e)})}(e);return{name:e.name,size:e.size,type:e.type,base64:t}}))}const ue=l`:host{display:block;position:absolute;bottom:0;padding:var(--size-2) var(--size-2);background:#fff}.footer-container{display:flex;align-items:center;gap:var(--size-1);max-width:100%}.input-container{flex:1;position:relative;display:flex;align-items:center;border:1px solid var(--color-neutrals-border-disabled);border-radius:var(--border-radius-2xl);padding:0 var(--size-1);overflow:hidden}.input-container:focus-within{border-color:var(--color-primary)}.message-input{flex:1;border:none;outline:0;background:0 0;font-family:var(--font-body);font-size:var(--text-base);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);padding-left:var(--sp-2)}.message-input::placeholder{color:var(--color-neutrals-text-medium)}.attachment-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.send-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.send-button{color:var(--color-neutrals-link-disabled);background:0 0;border:none;padding:var(--size-2);border-radius:var(--border-radius-md);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .2s ease}.send-button:hover:not(.disabled){background:var(--color-primary-light)}.send-button:active:not(.disabled){background-color:var(--color-neutrals-background-active)}.send-button.disabled{cursor:not-allowed;opacity:.4}.send-button.disabled .send-icon{color:var(--color-neutrals-text-disabled)}`;let ve=class ChatRoomFooter extends d{constructor(){super(...arguments),this.isTyping=!1,this.typingTimeoutId=null,this.inputValue="",this.socketController=new le(this)}static{this.styles=[ue]}handleInputChange(e){const t=e.target;this.inputValue=t.value,this.isTyping||(this.socketController.socket?.emit(P.typing,this.roomId),this.isTyping=!0),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId),this.typingTimeoutId=setTimeout(()=>{this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.isTyping=!1)},1500)}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())}async handleAttachment(e){const t=e.target.files;if(!t||0===t.length)return;const s=t.item(0);if(s)try{const e=(await ge([s]))[0];if(!e)return void x.error("Error converting file to base64");const t=e?.type.includes("image")?"image":"file",i=crypto.randomUUID(),o=s.name,a=new pe({type:t,base64Attachment:e.base64,fileName:o,roomId:this.roomId,messageId:i,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...a.toSocketMessage())}catch(e){x.error("Error converting files to base64:",e)}}handleAttachmentClick(){this.attachmentInput.click()}handleSendMessage(){const e=this.inputValue.trim();if(!e)return;const t=crypto.randomUUID();this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.isTyping=!1,this.typingTimeoutId&&clearTimeout(this.typingTimeoutId));const s=new me({messageId:t,string:e,roomId:this.roomId,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...s.toSocketMessage()),this.inputValue=""}disconnectedCallback(){this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId))}render(){const e=this.inputValue.trim().length>0;return c`<div class="footer-container"><div class="input-container"><input class="message-input" type="text" placeholder="${a("Escribe aquí...")}" .value="${this.inputValue}" @input="${this.handleInputChange}" @keydown="${this.handleKeyDown}"><div><input class="attachment-input sr-only" type="file" accept="image/jpeg,image/jpg,image/png,image/gif,image/bmp,image/tiff,application/pdf,text/*,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,audio/*,video/*" @change="${this.handleAttachment}"><mq-button variant="ghost" size="icon-sm" @click="${this.handleAttachmentClick}" title="${a("Adjuntar archivo")}">${c`<svg class="attachment-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`}</mq-button></div></div><button class="send-button ${e?"":"disabled"}" @click="${this.handleSendMessage}" ?disabled="${!e}" title="${a("Enviar mensaje")}">${c`<svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 2L11 13"/><path d="M22 2L15 22L11 13L2 9L22 2z"/></svg>`}</button></div>`}};e([i({context:K})],ve.prototype,"consultationId",void 0),e([i({context:F})],ve.prototype,"consultationType",void 0),e([m({type:Number})],ve.prototype,"roomId",void 0),e([p()],ve.prototype,"inputValue",void 0),e([k(".attachment-input")],ve.prototype,"attachmentInput",void 0),ve=e([t("chat-room-footer")],ve);const be=e=>({all_week:!0,monday:1===e,tuesday:2===e,wednesday:3===e,thursday:4===e,friday:5===e,saturday:6===e,sunday:7===e,working_week:e>=1&&e<=5,weekend:0===e||6===e});function ye(e,t){const s=be(6===e?0:e+1);return t.some(e=>{const t=e.days_of_week;return!0===s[t]})}let fe=class AvailabilitySection extends d{constructor(){super(...arguments),this.gaps=[],this.selectedDay=function(){const e=(new Date).getDay();return 0===e?6:e-1}()}static{this.styles=l`:host{display:flex;flex-direction:column;gap:var(--size-3)}.availability-header{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-normal);color:var(--color-primary);text-align:center;margin:0;margin-bottom:var(--size-4) 0}.availability-days{display:flex;flex-direction:row;justify-content:center;gap:var(--size-1);overflow-x:auto;padding-bottom:var(--size-4)}.availability-button{outline:0;border:1px solid var(--color-gray-medium);background:0 0;color:var(--color-gray-medium);cursor:pointer;height:var(--size-9);width:var(--size-10);border-radius:var(--border-radius-sm);text-transform:capitalize;font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium)}.availability-button:hover{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button:focus{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button.active{background:var(--color-primary);color:var(--color-white);border:none}.availability-button:disabled{opacity:.5;cursor:not-allowed;background-color:var(--color-gray-light)}.time-title{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-gray-dark);margin:0;margin-bottom:var(--size-1)}.time-entries{display:flex;flex-direction:column;gap:var(--size-1);margin-bottom:var(--size-6)}.time-entry{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal);color:var(--color-gray-medium);margin:0}`}updated(e){e.has("gaps")&&(void 0===this.selectedDay||ye(this.selectedDay,this.gaps)||(this.selectedDay=void 0))}render(){const e=[{shortLabel:a("Lu"),label:a("Lunes"),key:"monday",disabled:!ye(0,this.gaps)},{shortLabel:a("Ma"),label:a("Martes"),key:"tuesday",disabled:!ye(1,this.gaps)},{shortLabel:a("Mi"),label:a("Miércoles"),key:"wednesday",disabled:!ye(2,this.gaps)},{shortLabel:a("Ju"),label:a("Jueves"),key:"thursday",disabled:!ye(3,this.gaps)},{shortLabel:a("Vi"),label:a("Viernes"),key:"friday",disabled:!ye(4,this.gaps)},{shortLabel:a("Sa"),label:a("Sábado"),key:"saturday",disabled:!ye(5,this.gaps)},{shortLabel:a("Do"),label:a("Domingo"),key:"sunday",disabled:!ye(6,this.gaps)}];return c`<h2 class="availability-header">${a("Disponibilidad")}</h2><div class="availability-days">${e.map((e,t)=>c`<button type="button" class="availability-button ${R({active:this.selectedDay===t&&!e.disabled})}" ?disabled="${e.disabled}" @click="${()=>{e.disabled||(this.selectedDay=t)}}">${e.shortLabel}</button>`)}</div>${void 0===this.selectedDay||e[this.selectedDay]?.disabled?"":(()=>{const t=function(e,t){const s=be(6===e?0:e+1);return t.filter(e=>{const t=e.days_of_week;return!0===s[t]}).map(e=>({from_time:e.from_time,to_time:e.to_time}))}(this.selectedDay,this.gaps);return c`<div class="availability-time"><p class="time-title">${e[this.selectedDay]?.label}</p><div class="time-entries">${t.length>0?t.map(e=>c`<p class="time-entry">${a("De")} ${e.from_time} ${a("a")} ${e.to_time}</p>`):c`<p class="time-entry">${a("No hay horarios disponibles")}</p>`}</div></div>`})()}`}};e([m({type:Array})],fe.prototype,"gaps",void 0),e([p()],fe.prototype,"selectedDay",void 0),fe=e([o(),t("availability-section")],fe);const we=l`:host{display:flex;flex-direction:column;height:100%;overflow-y:auto;background-color:var(--color-white)}.profile-container{padding:var(--size-6);display:flex;flex-direction:column}.profile-header{display:flex;flex-direction:column;align-items:center;text-align:center;padding-bottom:var(--size-6);border-bottom:1px solid var(--color-gray-medium);margin-bottom:var(--size-6)}.profile-avatar{margin-bottom:var(--size-2)}.profile-name{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-primary);margin:var(--size-4) 0}.profile-specialty{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-icons--secondary);margin:0;margin-bottom:var(--size-2);text-transform:uppercase}.profile-collegiate{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);color:var(--color-gray-medium);text-transform:uppercase;margin:0}.description-header{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);color:var(--color-primary);margin:0;margin-bottom:var(--size-3)}.description-text{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-foreground);margin:0}`;let ke=class ChatRoomProfile extends d{constructor(){super(...arguments),this.getProfessionalQuery=new b(this,()=>y(this.apiClient,{hash:this.professionalHash}))}static{this.styles=[u,we]}renderProfile(e){return c`<div class="profile-container"><div class="profile-header"><mq-avatar class="profile-avatar" src="${e.avatar||""}" fallback="${e.name}" alt="${e.name}'s profile picture" size="xl"></mq-avatar><div><h1 class="profile-name">${e.name}</h1>${e.title?c`<p class="profile-specialty">${e.title}</p>`:""} ${e.collegiate_number?c`<p class="profile-collegiate">${a(r`Nº COL. ${e.collegiate_number}`)}</p>`:""}</div></div>${e.chat_schedule&&e.chat_schedule.gaps.length>0?c`<availability-section .gaps="${e.chat_schedule.gaps}"></availability-section>`:h} ${e.description||e.overview?c`<div><h2 class="description-header">${a("Descripción")}</h2><p class="description-text">${e.description||e.overview}</p></div>`:""}</div>`}render(){return this.getProfessionalQuery.render({pending:()=>c``,complete:e=>this.renderProfile(e)})}};e([i({context:n,subscribe:!0})],ke.prototype,"apiClient",void 0),e([m({type:String})],ke.prototype,"professionalHash",void 0),ke=e([o(),t("chat-room-profile")],ke);const xe=l`.root{display:flex;flex-direction:column;height:100%;overflow:hidden}chat-room-header{flex-shrink:0}chat-room-messages{flex:1;overflow-y:auto;overflow-x:hidden}chat-room-footer{position:sticky;bottom:0;left:0;right:0;flex-shrink:0}`;let Ce=class MqChatRoom extends d{constructor(){super(...arguments),this.consultationId=void 0,this.consultationType=void 0,this.readonly=!1,this.hideCloseButton=!1,this.view="chat",this.socketController=new le(this),this.readAllMessagesMutation=new U(this,{mutationFn:()=>this.apiClient.professionals.readAllMessages({roomId:this.roomId}),onSuccess:()=>{this.queryClientContext?.invalidateQueries({queryKey:D(this.apiClient,{roomId:this.roomId}).queryKey})}}),this.apiClient=I()}static{this.styles=[u,xe]}willUpdate(e){const t=z(e,{apiKey:this.apiKey,token:this.token},this.inheritedApiClient);t&&(this.apiClient=t),e.has("roomId")&&(this.socketController.socket?.emit(P.joinRoom,this.roomId),this.readAllMessagesMutation.run(void 0))}render(){return c`<div class="root"><chat-room-header .professionalHash="${this.professionalHash}" .view="${this.view}" .hideCloseButton="${this.hideCloseButton}" @mq-chat-room-profile="${()=>{this.view="profile"}}" @goto-chat="${()=>{this.view="chat"}}"></chat-room-header>${"chat"===this.view?c`<chat-room-messages .roomId="${this.roomId}" .professionalHash="${this.professionalHash}"></chat-room-messages>${this.readonly?h:c`<chat-room-footer .roomId="${this.roomId}"></chat-room-footer>`}`:c`<chat-room-profile .professionalHash="${this.professionalHash}" @mq-chat-room-chat="${()=>{this.view="chat"}}"></chat-room-profile>`}</div>`}};e([s({context:B}),m({type:String,attribute:"api-key"})],Ce.prototype,"apiKey",void 0),e([s({context:N}),m({type:String,attribute:"token"})],Ce.prototype,"token",void 0),e([s({context:H}),m({type:String,attribute:"professional-hash"})],Ce.prototype,"professionalHash",void 0),e([s({context:L}),m({type:Number,attribute:"room-id"})],Ce.prototype,"roomId",void 0),e([s({context:K}),m({type:String,attribute:"consultation-id"})],Ce.prototype,"consultationId",void 0),e([s({context:F}),m({type:String,attribute:"consultation-type"})],Ce.prototype,"consultationType",void 0),e([m({type:Boolean,reflect:!0})],Ce.prototype,"readonly",void 0),e([m({type:Boolean,attribute:"hide-close-button"})],Ce.prototype,"hideCloseButton",void 0),e([p()],Ce.prototype,"view",void 0),e([i({context:E,subscribe:!0})],Ce.prototype,"queryClientContext",void 0),e([i({context:n,subscribe:!0}),p()],Ce.prototype,"inheritedApiClient",void 0),e([s({context:n}),p()],Ce.prototype,"apiClient",void 0),Ce=e([o(),t("mq-chat-room")],Ce);export{Ce as MqChatRoom,MqChatRoomCloseEvent,MqChatRoomProfileEvent};
1
+ import{_ as e,c as t}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{l as o}from"./chunks/localized-decorator-BlOuLhym.js";import{m as a,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{A as n}from"./chunks/api-client-context-V1UAGtKW.js";import{i as l,a as d,x as c,E as h}from"./chunks/lit-element-DiWJYFwC.js";import{n as m}from"./chunks/property-scuRaFcM.js";import{r as p}from"./chunks/state-LQivXIgA.js";import{n as g}from"./chunks/create-context-DqP79qjF.js";import{tokens as u}from"./theme.js";import{xIcon as v}from"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-button.js";import"./ui/mq-skeleton.js";import{Q as b}from"./chunks/query-controller-BlO1Ax65.js";import{g as y}from"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import{o as f}from"./chunks/if-defined-BYeVdwgd.js";import{chevronLeftIcon as w}from"./ui/icons/chevron-left-icon.js";import{e as k}from"./chunks/query-CeeutdfT.js";import{l as x}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{DownloadFileEvent as C}from"./events.js";import{M as $,c as I,n as z}from"./chunks/api-chat-client-fYDIH220.js";import{S as T,g as D}from"./chunks/chunk-Y4EKUX25-CWAZgcgw.js";import{checkDoubleIcon as M}from"./ui/icons/check-double-icon.js";import{checkIcon as j}from"./ui/icons/check-icon.js";import{getLocale as q}from"./i18n.js";import{S,a as P}from"./chunks/chunk-YTQUGGS3-DJR1Yoyy.js";import{s as A}from"./chunks/context-consumer-ESdICVAb.js";import{s as _}from"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import{Q as E}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{e as R}from"./chunks/class-map-Co76I6aw.js";import{M as U}from"./chunks/mutation-controller-CR2qcqhH.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./ui/icons/types.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-BXLaKy9c.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";const B=g("apiKey"),N=g("token"),H=g("professionalHash"),L=g("roomId"),K=g("consultationId"),F=g("consultationType");class MqChatRoomCloseEvent extends Event{static{this.eventName="mq-chat-room-close"}constructor(){super(MqChatRoomCloseEvent.eventName,{bubbles:!0,composed:!0})}}class MqChatRoomProfileEvent extends Event{static{this.eventName="mq-chat-room-profile"}constructor(){super(MqChatRoomProfileEvent.eventName,{bubbles:!0,composed:!0})}}const O=l`header{padding:var(--size-3) var(--size-4);background-color:var(--color-background-primary);display:flex;justify-content:space-between;gap:var(--size-1)}.left-side{display:flex;flex:1;min-width:0;align-items:center;gap:var(--size-3)}.left-side mq-avatar{flex-shrink:0}.info{min-width:0}.ghost-btn{text-align:left;background:0 0;border:none;padding:0;cursor:pointer}.right-side{display:flex;align-items:center}.name{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-bold);margin:0;color:var(--color-background);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.specialty{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0;color:var(--color-white);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.name-skeleton{margin-bottom:var(--size-1)}.profile-title{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);margin:0;color:var(--color-white)}`;let Q=class ChatRoomHeader extends d{constructor(){super(...arguments),this.hideCloseButton=!1,this.getProfessionalQuery=new b(this,()=>y(this.apiClient,{hash:this.professionalHash}))}static{this.styles=O}handleClose(){this.dispatchEvent(new MqChatRoomCloseEvent)}handleClickProfile(){this.dispatchEvent(new MqChatRoomProfileEvent)}renderProfile(){return c`<div class="left-side"><mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${()=>{this.dispatchEvent(new CustomEvent("goto-chat",{bubbles:!0,composed:!0}))}}">${w({size:24})}</mq-button><p class="profile-title">${a("Perfil de profesional")}</p></div>`}renderChat(){return c`${this.getProfessionalQuery.render({complete:e=>c`<button type="button" class="left-side ghost-btn" @click="${this.handleClickProfile}"><mq-avatar src="${f(e.avatar??void 0)}" alt="User Avatar" fallback="John Doe" size="sm"></mq-avatar><div class="info"><p class="name">${e.name}</p><p class="specialty">${e.title}</p></div></button>`,pending:()=>c`<div class="left-side"><mq-skeleton width="45px" height="45px" border-radius="full"></mq-skeleton><div><mq-skeleton class="name-skeleton" height="14px" width="120px"></mq-skeleton><mq-skeleton height="14px" width="100px"></mq-skeleton></div></div>`})}`}render(){return c`<header>${"profile"===this.view?this.renderProfile():this.renderChat()}<div class="right-side">${this.hideCloseButton?h:c`<mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${this.handleClose}">${v({size:24})}</mq-button>`}</div></header>`}};e([i({context:n,subscribe:!0})],Q.prototype,"apiClient",void 0),e([m({type:String})],Q.prototype,"professionalHash",void 0),e([m({type:Boolean})],Q.prototype,"hideCloseButton",void 0),e([m({type:String})],Q.prototype,"view",void 0),Q=e([o(),t("chat-room-header")],Q);const V=/(https?:\/\/[^\s,;:!)\]}\]]+|www\.[^\s,;:!)\]}\]]+|[a-zA-Z0-9][-a-zA-Z0-9]*(?:\.[a-zA-Z0-9][-a-zA-Z0-9]*)+(?:\/[^\s,;:!)\]}\]]*|(?:\?|#|&)[^\s,;:!)\]}\]]*)?)/gi;function J(e){return e.split(V).map((e,t)=>{if(t%2==1){const t=e.startsWith("http")?e:`https://${e}`;return c`<a href="${t}" target="_blank" rel="noopener noreferrer" class="message-link">${e}</a>`}return e})}let Y=class TextMessageBubble extends d{static{this.styles=[l`:host{display:block}.message-bubble{padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal)}.message-bubble.received{background-color:var(--chat-received-message-background);color:var(--chat-received-message-foreground);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);color:var(--chat-sent-message-foreground);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}.message-bubble.received .message-content a.message-link,.message-bubble.sent .message-content a.message-link{color:var(--color-primary-link-default);text-decoration:underline}.message-bubble.received .message-content a.message-link:hover,.message-bubble.sent .message-content a.message-link:hover{opacity:.8}`]}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return c`<div class="message-content">${J(e)}</div>`;const s=t.map(e=>c`<div class="message-paragraph">${J(e.trim())}</div>`);return c`<div class="message-content">${s}</div>`}render(){return c`<div class="message-bubble ${this.kind}">${this.formatMessageContent(this.message.string)}</div>`}};e([m({type:Object})],Y.prototype,"message",void 0),e([m({type:String})],Y.prototype,"kind",void 0),Y=e([t("text-message-bubble")],Y);const Z=l`:host{display:block}.message-bubble{padding:var(--size-2);border-radius:var(--border-radius-lg);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);overflow:hidden}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.image-content{display:block;width:229px;height:229px;object-fit:cover;border-radius:var(--border-radius-md)}.image-placeholder{display:flex;align-items:center;justify-content:center;width:100%;max-width:300px;height:200px;background-color:var(--color-gray-light);border-radius:var(--border-radius-md);color:var(--chat-sent-message-foreground);font-size:var(--text-sm)}.image-content{cursor:pointer;transition:opacity .2s ease}.image-content:hover{opacity:.9}.preview-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:var(--dialog-underlay);display:flex;align-items:center;justify-content:center;z-index:1000;cursor:pointer;opacity:0;transition:opacity var(--dialog-transition-duration) ease}.preview-overlay.open{opacity:1}.preview-image{position:fixed;z-index:1000;inset:var(--mq-safe-top,0) var(--mq-safe-right,0) var(--mq-safe-bottom,0) var(--mq-safe-left,0);max-width:calc(100% - var(--mq-safe-left,4px) - var(--mq-safe-right,4px));max-height:calc(100% - var(--mq-safe-top,4px) - var(--mq-safe-bottom,4px));margin:auto;object-fit:contain;cursor:default;box-shadow:var(--dialog-shadow);transform:scale(.95);transition:transform var(--dialog-transition-duration) ease}.preview-overlay.open .preview-image{transform:scale(1)}.preview-close{z-index:1001;display:inline-flex;align-items:center;justify-content:center;height:var(--size-10);width:var(--size-10);position:absolute;top:var(--mq-safe-top,4px);right:var(--mq-safe-right,4px);background:rgba(255,255,255,.3);border:none;color:var(--color-neutrals-text-default);font-size:var(--text-xl);padding:var(--size-2) var(--size-3);border-radius:var(--border-radius-md);cursor:pointer;transition:background var(--dialog-transition-duration) ease}.preview-close:hover{background:var(--dialog-close-hover-bg)}`;let G=class ImageMessageBubble extends d{constructor(){super(...arguments),this.showPreview=!1,this.isPreviewRendered=!1,this.isPreviewActive=!1,this.closeTimer=null}static{this.styles=Z}handleImageError(e){const t=e.target;t.style.display="none";const s=t.nextElementSibling;s&&(s.style.display="flex")}handleImageLoad(e){const t=e.target.nextElementSibling;t&&(t.style.display="none")}handleImageClick(){this.showPreview=!0,this.isPreviewRendered=!0,this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.isPreviewActive=!0})})}handleImageKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleImageClick())}handleClosePreview(e){e&&e.stopPropagation(),this.isPreviewActive=!1,this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=window.setTimeout(()=>{this.isPreviewRendered=!1,this.showPreview=!1,this.closeTimer=null},200)}handleOverlayClick(e){e.target===e.currentTarget&&this.handleClosePreview()}handleOverlayKeyDown(e){"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),this.handleClosePreview())}handleKeyDown(e){"Escape"===e.key&&this.showPreview&&(e.preventDefault(),this.handleClosePreview())}handlePreviewImageKeyDown(e){e.stopPropagation()}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown.bind(this)),this.closeTimer&&(window.clearTimeout(this.closeTimer),this.closeTimer=null)}render(){const e=this.message.attachment.signed_url??this.message.attachment.url;return c`<div class="message-bubble ${this.kind}"><img class="image-content" src="${e}" width="229" height="229" alt="Shared attachment" @error="${this.handleImageError}" @load="${this.handleImageLoad}" @click="${this.handleImageClick}" @keydown="${this.handleImageKeyDown}" tabindex="0"><div class="image-placeholder" style="display:none">Image unavailable</div></div>${this.showPreview&&this.isPreviewRendered?c`<div class="preview-overlay ${this.isPreviewActive?"open":""}" @click="${this.handleOverlayClick}" @keydown="${this.handleOverlayKeyDown}" tabindex="0"><button class="preview-close" @click="${this.handleClosePreview}" aria-label="Close preview">${v({size:24})}</button> <img class="preview-image" src="${e}" alt="Shared attachment preview" @click="${e=>e.stopPropagation()}" @keydown="${this.handlePreviewImageKeyDown}" tabindex="0"></div>`:""}`}};e([m({type:Object})],G.prototype,"message",void 0),e([m({type:String})],G.prototype,"kind",void 0),e([i({context:N})],G.prototype,"token",void 0),e([p()],G.prototype,"showPreview",void 0),e([p()],G.prototype,"isPreviewRendered",void 0),e([p()],G.prototype,"isPreviewActive",void 0),G=e([t("image-message-bubble")],G);const W=l`:host{background-color:var(--chat-system-message-background);color:var(--chat-system-message-foreground);display:block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal)}a.message-link{color:var(--color-primary-link-default);text-decoration:underline}a.message-link:hover{opacity:.8}`;let X=class SystemMessageBubble extends d{static{this.styles=W}render(){return c`<div class="system-message-bubble">${J(this.message.string)}</div>`}};e([m({type:Object})],X.prototype,"message",void 0),X=e([t("system-message-bubble")],X);const ee=l`:host{display:block}.message-bubble{display:inline-block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);text-decoration:underline;color:var(--color-primary-link-default);border:none;cursor:pointer;text-align:left}.message-bubble:hover:not(:disabled){opacity:.8}.message-bubble:disabled{opacity:.5;cursor:not-allowed}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}`;let te=class FileMessageBubble extends d{constructor(){super(...arguments),this.isDownloading=!1}static{this.styles=ee}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return c`<div class="message-content">${e}</div>`;const s=t.map(e=>c`<div class="message-paragraph">${e.trim()}</div>`);return c`<div class="message-content">${s}</div>`}async handleDownload(){if(this.isDownloading)return;const e=this.message.attachment.url;try{this.isDownloading=!0;const t=await fetch(e,{headers:{Authorization:`Bearer ${this.token}`}});if(!t.ok)throw new Error(`Failed to fetch file: ${t.statusText}`);const s=await t.blob(),i=new FileReader;i.onloadend=()=>{const e=i.result,t=new C({url:e,filename:this.message.attachment.file_name});this.dispatchEvent(t),this.isDownloading=!1},i.onerror=()=>{x.error("Error reading file as data URL"),this.isDownloading=!1},i.readAsDataURL(s)}catch(e){x.error("Error downloading file:",e),this.isDownloading=!1}}render(){return c`<button type="button" @click="${this.handleDownload}" class="message-bubble ${this.kind}" ?disabled="${this.isDownloading}">${this.formatMessageContent(this.message.attachment.file_name)}</button>`}};e([m({type:Object})],te.prototype,"message",void 0),e([m({type:String})],te.prototype,"kind",void 0),e([i({context:N})],te.prototype,"token",void 0),e([p()],te.prototype,"isDownloading",void 0),te=e([t("file-message-bubble")],te);let se=class MessageBubble extends d{constructor(){super(...arguments),this.showTimestamp=!0}static{this.styles=[l`:host{display:block}.timestamp{font-family:var(--font-body);font-size:var(--text-xs);color:var(--color-gray-medium);font-weight:var(--font-weight-normal);text-align:left;display:flex;align-items:center;gap:var(--size-1)}.timestamp.sent{text-align:right;justify-content:flex-end}.status-icon{width:12px;height:12px}.status-icon.read{color:var(--color-primary)}`]}formatTimestamp(e){if(!e)return"";try{const t=new Date(e);return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}catch{return e}}renderStatusIcon(){switch(this.message.status){case $.Sent:return j({size:12,color:"currentColor"});case $.Received:return M({size:12,color:"currentColor"});case $.Read:return M({size:12,color:"currentColor",className:"read"});default:return null}}renderBubbleContent(){switch(this.message.type){case"image":return c`<image-message-bubble .message="${this.message}" .kind="${this.kind}"></image-message-bubble>`;case"file":return c`<file-message-bubble .message="${this.message}" .kind="${this.kind}"></file-message-bubble>`;default:return c`<text-message-bubble .message="${this.message}" .kind="${this.kind}"></text-message-bubble>`}}render(){if(this.message.senderType===T.system)return c`<system-message-bubble .message="${this.message}"></system-message-bubble>`;const e=this.message.createdAt?new Date(this.message.createdAt):this.message.time?new Date(this.message.time):null;return c`${this.renderBubbleContent()} ${this.showTimestamp&&e?c`<div class="timestamp ${this.kind}">${this.formatTimestamp(e.toISOString())} ${"sent"===this.kind?c`<span class="status-icon ${this.message.status===$.Read?"read":""}">${this.renderStatusIcon()}</span>`:""}</div>`:""}`}};e([m({type:String})],se.prototype,"kind",void 0),e([m({type:Object})],se.prototype,"message",void 0),e([m({type:Boolean})],se.prototype,"showTimestamp",void 0),se=e([t("message-bubble")],se);let ie=class DateBanner extends d{constructor(){super(...arguments),this.date=""}static{this.styles=[u,l`:host{display:block;margin-bottom:var(--size-2)}.date-banner{display:flex;align-items:center;justify-content:center;position:relative}.date-text{background-color:var(--color-gray-light);color:var(--color-gray-darker);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);padding:var(--size-1) var(--size-2);border-radius:var(--border-radius-2xl);white-space:nowrap}`]}formatDate(e){const t=q().replace("_","-"),s=new Date(e),i=new Date,o=new Date(i);o.setDate(o.getDate()-1);const r=new Date(s.getFullYear(),s.getMonth(),s.getDate()),n=new Date(i.getFullYear(),i.getMonth(),i.getDate()),l=new Date(o.getFullYear(),o.getMonth(),o.getDate());return r.getTime()===n.getTime()?a("Hoy"):r.getTime()===l.getTime()?a("Ayer"):s.toLocaleDateString(t,{dateStyle:"medium"})}render(){return c`<div class="date-banner"><span class="date-text">${this.formatDate(this.date)}</span></div>`}};function oe(e){return e.createdAt?new Date(e.createdAt):e.time?new Date(e.time):new Date}e([m({type:String})],ie.prototype,"date",void 0),ie=e([o(),t("date-banner")],ie);let ae=class MessagesList extends d{constructor(){super(...arguments),this.messages=[]}static{this.styles=[u,l`:host{display:block;width:100%;height:100%;overflow-y:auto;overflow-x:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-1);background-color:var(--color-white);padding-bottom:var(--size-4)}.message-wrapper{display:flex;width:100%}.message-wrapper.received{justify-content:flex-start}.message-wrapper.sent{justify-content:flex-end}.message-wrapper.system{justify-content:center}message-bubble{max-width:70%}`]}scrollToBottom(){requestAnimationFrame(()=>{const e=this.messagesContainerEnd;e&&e.scrollIntoView({behavior:"instant",block:"end"})})}shouldShowMessageTimestamp(e,t){if(e.senderType===T.system)return!1;if(!t)return!0;if(t.senderType!==e.senderType)return!0;if(t.senderType===T.ordinary&&e.senderType===T.ordinary&&t.fromUserHash!==e.fromUserHash)return!0;return(oe(t).getTime()-oe(e).getTime())/6e4>1}groupMessagesByDate(e){const t=[];let s=null;return e.forEach((i,o)=>{const a=oe(i),r=a?.toDateString();r!==s&&(t.push({type:"date",data:a.toDateString()}),s=r??null);const n=e[o+1],l=this.shouldShowMessageTimestamp(i,n);t.push({type:"message",data:i,showTimestamp:l})}),t}firstUpdated(){this.scrollToBottom()}willUpdate(e){e.has("messages")&&this.scrollToBottom()}render(){const e=this.groupMessagesByDate(this.messages),t=e.map((t,s)=>{if("date"===t.type)return c`<date-banner .date="${t.data}"></date-banner>`;const i=this.professionalHash!==t.data.fromUserHash,o=t.data.senderType===T.system?"system":i?"sent":"received";return c`<div class="message-wrapper ${o}"><message-bubble .message="${t.data}" .kind="${o}" .showTimestamp="${t.showTimestamp||"date"===e[s+1]?.type}"></message-bubble></div>`});return c`<div class="messages-container">${t}<div class="messages-container-end"></div></div>`}};e([m({type:Array})],ae.prototype,"messages",void 0),e([m({type:String})],ae.prototype,"professionalHash",void 0),e([k(".messages-container-end")],ae.prototype,"messagesContainerEnd",void 0),ae=e([t("messages-list")],ae);let re=class MessageBubbleSkeleton extends d{constructor(){super(...arguments),this.variant="patient",this.height="md",this.showTimestamp=!0}static{this.styles=[l`:host{display:block}.message-bubble{padding:var(--size-4);border-radius:var(--border-radius-lg);margin-bottom:var(--size-1);position:relative;overflow:hidden}.message-bubble.doctor{background-color:var(--color-gray-light);border-bottom-left-radius:0}.message-bubble.patient{background-color:var(--color-background-primary-light);border-bottom-right-radius:0}:host([height=sm]) .message-bubble{height:var(--size-8)}:host([height=md]) .message-bubble{height:var(--size-12)}`]}render(){return c`<div class="message-bubble ${this.variant}"></div>${this.showTimestamp?c`<div class="timestamp-skeleton ${this.variant}"></div>`:""}`}};e([m({type:String})],re.prototype,"variant",void 0),e([m({type:String})],re.prototype,"height",void 0),e([m({type:Boolean})],re.prototype,"showTimestamp",void 0),re=e([t("message-bubble-skeleton")],re);let ne=class MessagesSkeleton extends d{constructor(){super(...arguments),this.messageCount=6}static{this.styles=[u,l`:host{display:block;width:100%;height:100%;overflow:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-3);max-width:100%;height:100%;background-color:var(--color-white)}.message-wrapper{display:flex;width:100%}.message-wrapper.doctor{justify-content:flex-start}.message-wrapper.patient{justify-content:flex-end}message-bubble-skeleton{max-width:85%;min-width:60%;width:100%}`]}getSkeletonHeight(e){const t=["sm","md","sm","md","sm","md"];return t[e%t.length]}getSkeletonVariant(e){const t=["doctor","patient","doctor","doctor","patient","doctor","patient"];return t[e%t.length]}renderSkeletonMessages(){return Array.from({length:this.messageCount},(e,t)=>{const s=this.getSkeletonVariant(t),i=this.getSkeletonHeight(t);return c`<div class="message-wrapper ${s}"><message-bubble-skeleton variant="${s}" height="${i}" ?showTimestamp="${t===this.messageCount-1||Math.random()>.7}"></message-bubble-skeleton></div>`})}render(){return c`<div class="messages-container">${this.renderSkeletonMessages()}</div>`}};e([m({type:Number})],ne.prototype,"messageCount",void 0),ne=e([t("messages-skeleton")],ne);var le=class{constructor(e,t){this.host=e,this.listeners=[],this.host.addController(this),this.socketContext=new A(this.host,{context:S,subscribe:!0,callback:e=>{if(e&&(this.socket=e,t?.listeners)){this.listeners=t.listeners;for(const e of this.listeners)this.socket?.on(e.eventName,e.callback)}}})}hostConnected(){}hostDisconnected(){for(const e of this.listeners)this.socket?.off(e.eventName,e.callback)}};function de(e,t){return{queryKey:_(e,"rooms",t.roomId),queryFn:()=>e.rooms.getRoomMessages(t),staleTime:0}}class OptimisticUpdatesController{constructor(e){this.host=e,this.apiClientContext=new A(this.host,{context:n,subscribe:!0,callback:e=>{this.apiClient=e}}),this.queryClientContext=new A(this.host,{context:E,subscribe:!0,callback:e=>{e&&(this.queryClient=e)}}),this.host.addController(this)}hostConnected(){}appendMessageToRoom(e,t){if(!this.apiClient)return;const s=de(this.apiClient,{roomId:t}).queryKey;this.queryClient?.setQueriesData({queryKey:s,exact:!0},t=>[...t??[],e])}deleteMessage(e,t){if(!this.queryClient||!this.apiClient)return;const s=de(this.apiClient,{roomId:t}).queryKey;this.queryClient.setQueryData(s,t=>(t??[]).map(t=>t.messageId===e?{...t,deletedAt:(new Date).toISOString(),string:a("Este mensaje fue eliminado")}:t))}updateMessageStatus({messageId:e,status:t,roomId:s}){if(!this.queryClient||!this.apiClient)return;const i=de(this.apiClient,{roomId:s}).queryKey;this.queryClient.setQueryData(i,s=>(s??[]).map(s=>s.messageId===e?{...s,status:t}:s))}}let ce=class ChatRoomMessages extends d{constructor(){super(...arguments),this.getRoomMessagesQuery=new b(this,()=>de(this.apiClient,{roomId:this.roomId})),this.optimisticUpdatesController=new OptimisticUpdatesController(this),this.onMessageReceived=e=>{if(e.roomId!==this.roomId)return;const t=function(e){const t={roomId:"string"==typeof e.roomId?Number.parseInt(e.roomId,10):e.roomId,messageId:e.messageId,status:e.status,senderType:e.senderType,fromUserHash:e.fromUserHash,time:e.time,createdAt:e.time?new Date(e.time).toISOString():null,deletedAt:null};switch(e.type){case"string":return{...t,type:"string",string:e.string,auto:e.auto?1:0,attachment:null};case"image":return{...t,type:"image",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.imageUrl,type:"uncategorized",meta:{duration:0},signed_url:e.imageUrl}};case"file":return{...t,type:"file",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.fileUrl,type:"uncategorized",meta:{duration:0},signed_url:e.fileUrl}};default:return{...t,type:"string",string:"",auto:0,attachment:null}}}(e);this.optimisticUpdatesController.appendMessageToRoom(t,t.roomId),t.roomId===this.roomId&&e.fromUserHash===this.professionalHash&&this._socketController.socket?.emit(P.messageStatus,e.messageId,this.roomId,$.Read)},this.onMessageDeleted=e=>{e.room_id===this.roomId&&this.optimisticUpdatesController.deleteMessage(e.message_id,e.room_id)},this.onMessageStatusUpdated=e=>{e.roomId===this.roomId&&this.optimisticUpdatesController.updateMessageStatus({messageId:e.messageId,status:e.status,roomId:e.roomId})},this._socketController=new le(this,{listeners:[{eventName:P.message,callback:this.onMessageReceived},{eventName:P.message_deleted,callback:this.onMessageDeleted},{eventName:P.messageStatus,callback:this.onMessageStatusUpdated}]})}static{this.styles=[u,l`:host{display:block;width:100%;height:100%}`]}render(){return this.getRoomMessagesQuery.render({pending:()=>c`<messages-skeleton messageCount="8"></messages-skeleton>`,complete:e=>c`<messages-list .messages="${e}" .professionalHash="${this.professionalHash}"></messages-list>`})}};e([i({context:n,subscribe:!0})],ce.prototype,"apiClient",void 0),e([m({type:Number})],ce.prototype,"roomId",void 0),e([m({type:String})],ce.prototype,"professionalHash",void 0),ce=e([t("chat-room-messages")],ce);var he=class{constructor(e){this.string=e.string,this.roomId=e.roomId,this.messageId=e.messageId,this.type=e.type,this.fileName=e.fileName,this.autoMessage=e.autoMessage,this.senderType=e.senderType,this.attachmentType=e.attachmentType,this.consultationId=e.consultationId,this.consultationType=e.consultationType}toSocketMessage(){return[P.message,this.string,this.roomId,this.messageId,this.type,this.fileName,this.autoMessage,this.senderType,this.attachmentType,this.consultationId,this.consultationType]}},me=class extends he{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.string,type:"string",fileName:null,autoMessage:!1,senderType:T.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}},pe=class extends he{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.base64Attachment,fileName:e.fileName,type:e.type,autoMessage:!1,senderType:T.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}};async function ge(e){return await Promise.all(e.map(async e=>{const t=await function(e){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>{const o=i.result.split(",")[1];o?t(o):s(new Error(`Invalid data URL format for file: ${e.name}`))},i.onerror=()=>{s(new Error(`Failed to read file: ${e.name}`))},i.readAsDataURL(e)})}(e);return{name:e.name,size:e.size,type:e.type,base64:t}}))}const ue=l`:host{display:block;position:absolute;bottom:0;padding:var(--size-2) var(--size-2);background:#fff}.footer-container{display:flex;align-items:center;gap:var(--size-1);max-width:100%}.input-container{flex:1;position:relative;display:flex;align-items:center;border:1px solid var(--color-neutrals-border-disabled);border-radius:var(--border-radius-2xl);padding:0 var(--size-1);overflow:hidden}.input-container:focus-within{border-color:var(--color-primary)}.message-input{flex:1;border:none;outline:0;background:0 0;font-family:var(--font-body);font-size:var(--text-base);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);padding-left:var(--sp-2)}.message-input::placeholder{color:var(--color-neutrals-text-medium)}.attachment-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.send-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.send-button{color:var(--color-neutrals-link-disabled);background:0 0;border:none;padding:var(--size-2);border-radius:var(--border-radius-md);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .2s ease}.send-button:hover:not(.disabled){background:var(--color-primary-light)}.send-button:active:not(.disabled){background-color:var(--color-neutrals-background-active)}.send-button.disabled{cursor:not-allowed;opacity:.4}.send-button.disabled .send-icon{color:var(--color-neutrals-text-disabled)}`;let ve=class ChatRoomFooter extends d{constructor(){super(...arguments),this.isTyping=!1,this.typingTimeoutId=null,this.inputValue="",this.socketController=new le(this)}static{this.styles=[ue]}handleInputChange(e){const t=e.target;this.inputValue=t.value,this.isTyping||(this.socketController.socket?.emit(P.typing,this.roomId),this.isTyping=!0),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId),this.typingTimeoutId=setTimeout(()=>{this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.isTyping=!1)},1500)}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())}async handleAttachment(e){const t=e.target.files;if(!t||0===t.length)return;const s=t.item(0);if(s)try{const e=(await ge([s]))[0];if(!e)return void x.error("Error converting file to base64");const t=e?.type.includes("image")?"image":"file",i=crypto.randomUUID(),o=s.name,a=new pe({type:t,base64Attachment:e.base64,fileName:o,roomId:this.roomId,messageId:i,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...a.toSocketMessage())}catch(e){x.error("Error converting files to base64:",e)}}handleAttachmentClick(){this.attachmentInput.click()}handleSendMessage(){const e=this.inputValue.trim();if(!e)return;const t=crypto.randomUUID();this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.isTyping=!1,this.typingTimeoutId&&clearTimeout(this.typingTimeoutId));const s=new me({messageId:t,string:e,roomId:this.roomId,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...s.toSocketMessage()),this.inputValue=""}disconnectedCallback(){this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId))}render(){const e=this.inputValue.trim().length>0;return c`<div class="footer-container"><div class="input-container"><input class="message-input" type="text" placeholder="${a("Escribe aquí...")}" .value="${this.inputValue}" @input="${this.handleInputChange}" @keydown="${this.handleKeyDown}"><div><input class="attachment-input sr-only" type="file" accept="image/jpeg,image/jpg,image/png,image/gif,image/bmp,image/tiff,application/pdf,text/*,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,audio/*,video/*" @change="${this.handleAttachment}"><mq-button variant="ghost" size="icon-sm" @click="${this.handleAttachmentClick}" title="${a("Adjuntar archivo")}">${c`<svg class="attachment-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`}</mq-button></div></div><button class="send-button ${e?"":"disabled"}" @click="${this.handleSendMessage}" ?disabled="${!e}" title="${a("Enviar mensaje")}">${c`<svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 2L11 13"/><path d="M22 2L15 22L11 13L2 9L22 2z"/></svg>`}</button></div>`}};e([i({context:K})],ve.prototype,"consultationId",void 0),e([i({context:F})],ve.prototype,"consultationType",void 0),e([m({type:Number})],ve.prototype,"roomId",void 0),e([p()],ve.prototype,"inputValue",void 0),e([k(".attachment-input")],ve.prototype,"attachmentInput",void 0),ve=e([t("chat-room-footer")],ve);const be=e=>({all_week:!0,monday:1===e,tuesday:2===e,wednesday:3===e,thursday:4===e,friday:5===e,saturday:6===e,sunday:7===e,working_week:e>=1&&e<=5,weekend:0===e||6===e});function ye(e,t){const s=be(6===e?0:e+1);return t.some(e=>{const t=e.days_of_week;return!0===s[t]})}let fe=class AvailabilitySection extends d{constructor(){super(...arguments),this.gaps=[],this.selectedDay=function(){const e=(new Date).getDay();return 0===e?6:e-1}()}static{this.styles=l`:host{display:flex;flex-direction:column;gap:var(--size-3)}.availability-header{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-normal);color:var(--color-primary);text-align:center;margin:0;margin-bottom:var(--size-4) 0}.availability-days{display:flex;flex-direction:row;justify-content:center;gap:var(--size-1);overflow-x:auto;padding-bottom:var(--size-4)}.availability-button{outline:0;border:1px solid var(--color-gray-medium);background:0 0;color:var(--color-gray-medium);cursor:pointer;height:var(--size-9);width:var(--size-10);border-radius:var(--border-radius-sm);text-transform:capitalize;font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium)}.availability-button:hover{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button:focus{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button.active{background:var(--color-primary);color:var(--color-white);border:none}.availability-button:disabled{opacity:.5;cursor:not-allowed;background-color:var(--color-gray-light)}.time-title{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-gray-dark);margin:0;margin-bottom:var(--size-1)}.time-entries{display:flex;flex-direction:column;gap:var(--size-1);margin-bottom:var(--size-6)}.time-entry{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal);color:var(--color-gray-medium);margin:0}`}updated(e){e.has("gaps")&&(void 0===this.selectedDay||ye(this.selectedDay,this.gaps)||(this.selectedDay=void 0))}render(){const e=[{shortLabel:a("Lu"),label:a("Lunes"),key:"monday",disabled:!ye(0,this.gaps)},{shortLabel:a("Ma"),label:a("Martes"),key:"tuesday",disabled:!ye(1,this.gaps)},{shortLabel:a("Mi"),label:a("Miércoles"),key:"wednesday",disabled:!ye(2,this.gaps)},{shortLabel:a("Ju"),label:a("Jueves"),key:"thursday",disabled:!ye(3,this.gaps)},{shortLabel:a("Vi"),label:a("Viernes"),key:"friday",disabled:!ye(4,this.gaps)},{shortLabel:a("Sa"),label:a("Sábado"),key:"saturday",disabled:!ye(5,this.gaps)},{shortLabel:a("Do"),label:a("Domingo"),key:"sunday",disabled:!ye(6,this.gaps)}];return c`<h2 class="availability-header">${a("Disponibilidad")}</h2><div class="availability-days">${e.map((e,t)=>c`<button type="button" class="availability-button ${R({active:this.selectedDay===t&&!e.disabled})}" ?disabled="${e.disabled}" @click="${()=>{e.disabled||(this.selectedDay=t)}}">${e.shortLabel}</button>`)}</div>${void 0===this.selectedDay||e[this.selectedDay]?.disabled?"":(()=>{const t=function(e,t){const s=be(6===e?0:e+1);return t.filter(e=>{const t=e.days_of_week;return!0===s[t]}).map(e=>({from_time:e.from_time,to_time:e.to_time}))}(this.selectedDay,this.gaps);return c`<div class="availability-time"><p class="time-title">${e[this.selectedDay]?.label}</p><div class="time-entries">${t.length>0?t.map(e=>c`<p class="time-entry">${a("De")} ${e.from_time} ${a("a")} ${e.to_time}</p>`):c`<p class="time-entry">${a("No hay horarios disponibles")}</p>`}</div></div>`})()}`}};e([m({type:Array})],fe.prototype,"gaps",void 0),e([p()],fe.prototype,"selectedDay",void 0),fe=e([o(),t("availability-section")],fe);const we=l`:host{display:flex;flex-direction:column;height:100%;overflow-y:auto;background-color:var(--color-white)}.profile-container{padding:var(--size-6);display:flex;flex-direction:column}.profile-header{display:flex;flex-direction:column;align-items:center;text-align:center;padding-bottom:var(--size-6);border-bottom:1px solid var(--color-gray-medium);margin-bottom:var(--size-6)}.profile-avatar{margin-bottom:var(--size-2)}.profile-name{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-primary);margin:var(--size-4) 0}.profile-specialty{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-icons--secondary);margin:0;margin-bottom:var(--size-2);text-transform:uppercase}.profile-collegiate{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);color:var(--color-gray-medium);text-transform:uppercase;margin:0}.description-header{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);color:var(--color-primary);margin:0;margin-bottom:var(--size-3)}.description-text{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-foreground);margin:0}`;let ke=class ChatRoomProfile extends d{constructor(){super(...arguments),this.getProfessionalQuery=new b(this,()=>y(this.apiClient,{hash:this.professionalHash}))}static{this.styles=[u,we]}renderProfile(e){return c`<div class="profile-container"><div class="profile-header"><mq-avatar class="profile-avatar" src="${e.avatar||""}" fallback="${e.name}" alt="${e.name}'s profile picture" size="xl"></mq-avatar><div><h1 class="profile-name">${e.name}</h1>${e.title?c`<p class="profile-specialty">${e.title}</p>`:""} ${e.collegiate_number?c`<p class="profile-collegiate">${a(r`Nº COL. ${e.collegiate_number}`)}</p>`:""}</div></div>${e.chat_schedule&&e.chat_schedule.gaps.length>0?c`<availability-section .gaps="${e.chat_schedule.gaps}"></availability-section>`:h} ${e.description||e.overview?c`<div><h2 class="description-header">${a("Descripción")}</h2><p class="description-text">${e.description||e.overview}</p></div>`:""}</div>`}render(){return this.getProfessionalQuery.render({pending:()=>c``,complete:e=>this.renderProfile(e)})}};e([i({context:n,subscribe:!0})],ke.prototype,"apiClient",void 0),e([m({type:String})],ke.prototype,"professionalHash",void 0),ke=e([o(),t("chat-room-profile")],ke);const xe=l`.root{display:flex;flex-direction:column;height:100%;overflow:hidden}chat-room-header{flex-shrink:0}chat-room-messages{flex:1;overflow-y:auto;overflow-x:hidden}chat-room-footer{position:sticky;bottom:0;left:0;right:0;flex-shrink:0}`;let Ce=class MqChatRoom extends d{constructor(){super(...arguments),this.consultationId=void 0,this.consultationType=void 0,this.readonly=!1,this.hideCloseButton=!1,this.view="chat",this.socketController=new le(this),this.readAllMessagesMutation=new U(this,{mutationFn:()=>this.apiClient.professionals.readAllMessages({roomId:this.roomId}),onSuccess:()=>{this.queryClientContext?.invalidateQueries({queryKey:D(this.apiClient,{roomId:this.roomId}).queryKey})}}),this.apiClient=I()}static{this.styles=[u,xe]}willUpdate(e){const t=z(e,{apiKey:this.apiKey,token:this.token},this.inheritedApiClient);t&&(this.apiClient=t),e.has("roomId")&&(this.socketController.socket?.emit(P.joinRoom,this.roomId),this.readAllMessagesMutation.run(void 0))}render(){return c`<div class="root"><chat-room-header .professionalHash="${this.professionalHash}" .view="${this.view}" .hideCloseButton="${this.hideCloseButton}" @mq-chat-room-profile="${()=>{this.view="profile"}}" @goto-chat="${()=>{this.view="chat"}}"></chat-room-header>${"chat"===this.view?c`<chat-room-messages .roomId="${this.roomId}" .professionalHash="${this.professionalHash}"></chat-room-messages>${this.readonly?h:c`<chat-room-footer .roomId="${this.roomId}"></chat-room-footer>`}`:c`<chat-room-profile .professionalHash="${this.professionalHash}" @mq-chat-room-chat="${()=>{this.view="chat"}}"></chat-room-profile>`}</div>`}};e([s({context:B}),m({type:String,attribute:"api-key"})],Ce.prototype,"apiKey",void 0),e([s({context:N}),m({type:String,attribute:"token"})],Ce.prototype,"token",void 0),e([s({context:H}),m({type:String,attribute:"professional-hash"})],Ce.prototype,"professionalHash",void 0),e([s({context:L}),m({type:Number,attribute:"room-id"})],Ce.prototype,"roomId",void 0),e([s({context:K}),m({type:String,attribute:"consultation-id"})],Ce.prototype,"consultationId",void 0),e([s({context:F}),m({type:String,attribute:"consultation-type"})],Ce.prototype,"consultationType",void 0),e([m({type:Boolean,reflect:!0})],Ce.prototype,"readonly",void 0),e([m({type:Boolean,attribute:"hide-close-button"})],Ce.prototype,"hideCloseButton",void 0),e([p()],Ce.prototype,"view",void 0),e([i({context:E,subscribe:!0})],Ce.prototype,"queryClientContext",void 0),e([i({context:n,subscribe:!0}),p()],Ce.prototype,"inheritedApiClient",void 0),e([s({context:n}),p()],Ce.prototype,"apiClient",void 0),Ce=e([o(),t("mq-chat-room")],Ce);export{Ce as MqChatRoom,MqChatRoomCloseEvent,MqChatRoomProfileEvent};
@@ -1 +1 @@
1
- import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{m as o}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{h as r}from"./chunks/task-Bj8p7kJX.js";import{c as a,P as h,n as c}from"./chunks/api-chat-client-DLpFzml6.js";import{A as d}from"./chunks/api-client-context-V1UAGtKW.js";import{L as l}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as m,a as u,x as v}from"./chunks/lit-element-DiWJYFwC.js";import{n as _}from"./chunks/property-scuRaFcM.js";import{r as f}from"./chunks/state-LQivXIgA.js";import{setEnv as k}from"./env.js";import{tokens as y}from"./theme.js";import{initLocalization as g,setLocale as E,isValidLocale as C}from"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";var x=class{constructor(t,e){this.host=t,this.options=e,this._deadline=0,this._timedOut=!1,this.host.addController(this)}get timedOut(){return this._timedOut}hostConnected(){const t=this.options.intervalMs??1e3,e=void 0!==this.options.startDelayMs?this.options.startDelayMs:t;this._deadline=Date.now()+this.options.timeoutMs,this._timedOut=!1,this._startTimeoutId=setTimeout(()=>{this._startTimeoutId=void 0,this._poll(),this._intervalId=setInterval(()=>{this._poll()},t)},e)}hostDisconnected(){this._stop()}stop(){this._stop()}async _poll(){if(Date.now()>=this._deadline)return this._stop(),this._timedOut=!0,this.host.requestUpdate(),void this.options.onTimeout?.();try{const t=await this.options.refetchFn();this.options.shouldComplete(t)&&(this._stop(),this.options.onComplete?.(t))}catch{}}_stop(){void 0!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),void 0!==this._startTimeoutId&&(clearTimeout(this._startTimeoutId),this._startTimeoutId=void 0)}};try{g()}catch{}const b=m`:host{height:100%;min-height:0;display:flex;flex-direction:column;flex:1}.payment-frame{position:relative;width:100%;min-width:0;display:flex;flex-direction:column;flex:1;min-height:0}.payment-frame iframe:not(.loaded){position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;border:none}.payment-frame iframe.loaded{flex:none;display:block;width:100%;border:none;min-height:1050px}.state{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;gap:var(--sp-4);padding:var(--sp-8);text-align:center}.state-title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.state-message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default);margin:0}`,w="mediquo:payment:retry",j="mediquo:payment:resize";class CheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(CheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(t){super(CheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(t){super(CheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutRetryEvent extends Event{static{this.eventName="payment-retry"}constructor(){super(CheckoutRetryEvent.eventName,{bubbles:!0,composed:!0})}}let S=class MqCheckout extends u{constructor(){super(...arguments),this._iframeLoaded=!1,this._iframeHeight=null,this._sessionEpoch=0,this._currentSessionId=null,this._paymentOrigin=null,this.apiClient=a(),this._loginTokenTask=new l(this,()=>this.apiClient,{args:()=>[this.apiKey,this.token],onComplete:t=>{this._sessionToken=t.access_token,this.apiClient.setAuthToken(t.access_token),this._sessionTask.run()},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"auth"}))}}),this._sessionTask=new r(this,{task:async()=>{if("function"!=typeof this.provideSession)throw new Error("mq-checkout: `provideSession` property is required");return this.provideSession(this.apiClient)},args:()=>[this._sessionEpoch],autoRun:!1,onComplete:t=>{this._currentSessionId=t.sessionId,this._iframeLoaded=!1,this._iframeHeight=null;try{this._paymentOrigin=new URL(t.paymentUrl).origin}catch{this._paymentOrigin=null,p.warn(`mq-checkout: invalid paymentUrl "${t.paymentUrl}"`)}},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"session"}))}}),this._paymentPoll=new x(this,{startDelayMs:5e3,intervalMs:3e3,timeoutMs:6e5,refetchFn:async()=>{if(!this._currentSessionId)throw new Error("mq-checkout: session not ready");const t=await this.apiClient.payments.getPaymentSession(this._currentSessionId);return t.status===h.Denied&&(this._paymentPoll.stop(),this.dispatchEvent(new CheckoutDeniedEvent({sessionId:this._currentSessionId}))),t},shouldComplete:t=>t.status===h.Paid,onComplete:t=>{this.dispatchEvent(new CheckoutSuccessEvent({sessionId:this._currentSessionId??"",reference:t.consultation_id}))},onTimeout:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"timeout"}))}}),this._onMessage=t=>{if(!this._paymentOrigin||t.origin===this._paymentOrigin)switch(t.data?.type){case w:return this.dispatchEvent(new CheckoutRetryEvent),this._sessionEpoch+=1,void this._sessionTask.run();case j:return void("number"==typeof t.data.height&&(this._iframeHeight=t.data.height))}}}static{this.styles=[y,b]}get _timedOut(){return this._paymentPoll.timedOut}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),super.disconnectedCallback()}willUpdate(t){t.has("env")&&this.env&&k(this.env),t.has("locale")&&E(C(this.locale)?this.locale:"es_ES");const e=c(t,{env:this.env,apiKey:this.apiKey,token:this._sessionToken,locale:C(this.locale)?this.locale:"es_ES"},this.inheritedApiClient);e&&(this.apiClient=e)}_onIframeLoad(){this._iframeLoaded=!0}_renderState(t,e){return v`<div class="state"><p class="state-title">${t}</p>${e?v`<p class="state-message">${e}</p>`:null}</div>`}_renderLoading(){return v`<div class="payment-frame"><mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${o("Cargando portal de pago")}"></mq-skeleton></div>`}_renderFrame(t){return v`<div class="payment-frame">${this._iframeLoaded?null:this._renderLoading()}<iframe class="${this._iframeLoaded?"loaded":""}" src="${t}" title="${o("Portal de pago")}" style="${null!==this._iframeHeight?`min-height: ${this._iframeHeight}px; height: ${this._iframeHeight}px;`:""}" @load="${this._onIframeLoad}"></iframe></div>`}render(){return this._timedOut?this._renderState(o("No hemos podido confirmar tu pago"),o("Ha ocurrido un problema al verificar el estado de tu pago. Por favor, contacta con soporte si el cargo se ha realizado.")):this._loginTokenTask.render({pending:()=>this._renderLoading(),error:()=>this._renderState(o("No hemos podido iniciar el pago"),o("Por favor, inténtalo de nuevo más tarde.")),complete:()=>this._sessionTask.render({initial:()=>this._renderLoading(),pending:()=>this._renderLoading(),error:()=>this._renderState(o("No hemos podido iniciar el pago"),o("Por favor, inténtalo de nuevo más tarde.")),complete:t=>this._renderFrame(t.paymentUrl)})})}};t([_({type:String,attribute:"env"})],S.prototype,"env",void 0),t([_({type:String,attribute:"api-key"})],S.prototype,"apiKey",void 0),t([_({type:String,attribute:"token"})],S.prototype,"token",void 0),t([_({type:String,attribute:"locale",reflect:!0})],S.prototype,"locale",void 0),t([_({attribute:!1})],S.prototype,"provideSession",void 0),t([f()],S.prototype,"_iframeLoaded",void 0),t([f()],S.prototype,"_iframeHeight",void 0),t([f()],S.prototype,"_sessionEpoch",void 0),t([i({context:d,subscribe:!0}),f()],S.prototype,"inheritedApiClient",void 0),t([s({context:d}),f()],S.prototype,"apiClient",void 0),S=t([n(),e("mq-checkout")],S);export{CheckoutDeniedEvent,CheckoutErrorEvent,CheckoutRetryEvent,CheckoutSuccessEvent,S as MqCheckout};
1
+ import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{m as o}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{h as r}from"./chunks/task-Bj8p7kJX.js";import{c as a,P as h,n as c}from"./chunks/api-chat-client-fYDIH220.js";import{A as d}from"./chunks/api-client-context-V1UAGtKW.js";import{L as l}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as m,a as u,x as v}from"./chunks/lit-element-DiWJYFwC.js";import{n as _}from"./chunks/property-scuRaFcM.js";import{r as f}from"./chunks/state-LQivXIgA.js";import{setEnv as k}from"./env.js";import{tokens as y}from"./theme.js";import{initLocalization as g,setLocale as E,isValidLocale as C}from"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/chunk-2TKJJNS7-BGwxtEg7.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-BXLaKy9c.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";var x=class{constructor(t,e){this.host=t,this.options=e,this._deadline=0,this._timedOut=!1,this.host.addController(this)}get timedOut(){return this._timedOut}hostConnected(){const t=this.options.intervalMs??1e3,e=void 0!==this.options.startDelayMs?this.options.startDelayMs:t;this._deadline=Date.now()+this.options.timeoutMs,this._timedOut=!1,this._startTimeoutId=setTimeout(()=>{this._startTimeoutId=void 0,this._poll(),this._intervalId=setInterval(()=>{this._poll()},t)},e)}hostDisconnected(){this._stop()}stop(){this._stop()}async _poll(){if(Date.now()>=this._deadline)return this._stop(),this._timedOut=!0,this.host.requestUpdate(),void this.options.onTimeout?.();try{const t=await this.options.refetchFn();this.options.shouldComplete(t)&&(this._stop(),this.options.onComplete?.(t))}catch{}}_stop(){void 0!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),void 0!==this._startTimeoutId&&(clearTimeout(this._startTimeoutId),this._startTimeoutId=void 0)}};try{g()}catch{}const b=m`:host{height:100%;min-height:0;display:flex;flex-direction:column;flex:1}.payment-frame{position:relative;width:100%;min-width:0;display:flex;flex-direction:column;flex:1;min-height:0}.payment-frame iframe:not(.loaded){position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;border:none}.payment-frame iframe.loaded{flex:none;display:block;width:100%;border:none;min-height:1050px}.state{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;gap:var(--sp-4);padding:var(--sp-8);text-align:center}.state-title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.state-message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default);margin:0}`,w="mediquo:payment:retry",j="mediquo:payment:resize";class CheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(CheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(t){super(CheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(t){super(CheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutRetryEvent extends Event{static{this.eventName="payment-retry"}constructor(){super(CheckoutRetryEvent.eventName,{bubbles:!0,composed:!0})}}let S=class MqCheckout extends u{constructor(){super(...arguments),this._iframeLoaded=!1,this._iframeHeight=null,this._sessionEpoch=0,this._currentSessionId=null,this._paymentOrigin=null,this.apiClient=a(),this._loginTokenTask=new l(this,()=>this.apiClient,{args:()=>[this.apiKey,this.token],onComplete:t=>{this._sessionToken=t.access_token,this.apiClient.setAuthToken(t.access_token),this._sessionTask.run()},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"auth"}))}}),this._sessionTask=new r(this,{task:async()=>{if("function"!=typeof this.provideSession)throw new Error("mq-checkout: `provideSession` property is required");return this.provideSession(this.apiClient)},args:()=>[this._sessionEpoch],autoRun:!1,onComplete:t=>{this._currentSessionId=t.sessionId,this._iframeLoaded=!1,this._iframeHeight=null;try{this._paymentOrigin=new URL(t.paymentUrl).origin}catch{this._paymentOrigin=null,p.warn(`mq-checkout: invalid paymentUrl "${t.paymentUrl}"`)}},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"session"}))}}),this._paymentPoll=new x(this,{startDelayMs:5e3,intervalMs:3e3,timeoutMs:6e5,refetchFn:async()=>{if(!this._currentSessionId)throw new Error("mq-checkout: session not ready");const t=await this.apiClient.payments.getPaymentSession(this._currentSessionId);return t.status===h.Denied&&(this._paymentPoll.stop(),this.dispatchEvent(new CheckoutDeniedEvent({sessionId:this._currentSessionId}))),t},shouldComplete:t=>t.status===h.Paid,onComplete:t=>{this.dispatchEvent(new CheckoutSuccessEvent({sessionId:this._currentSessionId??"",reference:t.consultation_id}))},onTimeout:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"timeout"}))}}),this._onMessage=t=>{if(!this._paymentOrigin||t.origin===this._paymentOrigin)switch(t.data?.type){case w:return this.dispatchEvent(new CheckoutRetryEvent),this._sessionEpoch+=1,void this._sessionTask.run();case j:return void("number"==typeof t.data.height&&(this._iframeHeight=t.data.height))}}}static{this.styles=[y,b]}get _timedOut(){return this._paymentPoll.timedOut}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),super.disconnectedCallback()}willUpdate(t){t.has("env")&&this.env&&k(this.env),t.has("locale")&&E(C(this.locale)?this.locale:"es_ES");const e=c(t,{env:this.env,apiKey:this.apiKey,token:this._sessionToken,locale:C(this.locale)?this.locale:"es_ES"},this.inheritedApiClient);e&&(this.apiClient=e)}_onIframeLoad(){this._iframeLoaded=!0}_renderState(t,e){return v`<div class="state"><p class="state-title">${t}</p>${e?v`<p class="state-message">${e}</p>`:null}</div>`}_renderLoading(){return v`<div class="payment-frame"><mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${o("Cargando portal de pago")}"></mq-skeleton></div>`}_renderFrame(t){return v`<div class="payment-frame">${this._iframeLoaded?null:this._renderLoading()}<iframe class="${this._iframeLoaded?"loaded":""}" src="${t}" title="${o("Portal de pago")}" style="${null!==this._iframeHeight?`min-height: ${this._iframeHeight}px; height: ${this._iframeHeight}px;`:""}" @load="${this._onIframeLoad}"></iframe></div>`}render(){return this._timedOut?this._renderState(o("No hemos podido confirmar tu pago"),o("Ha ocurrido un problema al verificar el estado de tu pago. Por favor, contacta con soporte si el cargo se ha realizado.")):this._loginTokenTask.render({pending:()=>this._renderLoading(),error:()=>this._renderState(o("No hemos podido iniciar el pago"),o("Por favor, inténtalo de nuevo más tarde.")),complete:()=>this._sessionTask.render({initial:()=>this._renderLoading(),pending:()=>this._renderLoading(),error:()=>this._renderState(o("No hemos podido iniciar el pago"),o("Por favor, inténtalo de nuevo más tarde.")),complete:t=>this._renderFrame(t.paymentUrl)})})}};t([_({type:String,attribute:"env"})],S.prototype,"env",void 0),t([_({type:String,attribute:"api-key"})],S.prototype,"apiKey",void 0),t([_({type:String,attribute:"token"})],S.prototype,"token",void 0),t([_({type:String,attribute:"locale",reflect:!0})],S.prototype,"locale",void 0),t([_({attribute:!1})],S.prototype,"provideSession",void 0),t([f()],S.prototype,"_iframeLoaded",void 0),t([f()],S.prototype,"_iframeHeight",void 0),t([f()],S.prototype,"_sessionEpoch",void 0),t([i({context:d,subscribe:!0}),f()],S.prototype,"inheritedApiClient",void 0),t([s({context:d}),f()],S.prototype,"apiClient",void 0),S=t([n(),e("mq-checkout")],S);export{CheckoutDeniedEvent,CheckoutErrorEvent,CheckoutRetryEvent,CheckoutSuccessEvent,S as MqCheckout};