@mediquo/elements 0.10.4 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/chunks/api-chat-client-D5BosjTp.js +1 -0
- package/dist/chunks/{apple-pay-outcomes-tbZjXEYD.js → apple-pay-outcomes-DJDSt0US.js} +1 -1
- package/dist/chunks/{chunk-Y4EKUX25-Bix9r5ry.js → chunk-Y4EKUX25-Bdei04iw.js} +1 -1
- package/dist/chunks/{chunk-YTQUGGS3-DH0H7ld7.js → chunk-YTQUGGS3-sBILRfPo.js} +1 -1
- package/dist/chunks/{documentation-view-CSMoGBMk.js → documentation-view-BnKC8xEu.js} +1 -1
- package/dist/chunks/{external-JLtsAfi6.js → external-cM_kgYO_.js} +1 -1
- package/dist/chunks/{index-CV03omw_.js → index-D54b6IW6.js} +1 -1
- package/dist/chunks/{index-C8O_sOOh.js → index-DYDUC2Va.js} +1 -1
- package/dist/chunks/{mq-chat-room-3PU4Fsub.js → mq-chat-room-C7FB_wOo.js} +1 -1
- package/dist/chunks/{mq-next-appointments-DfszxI2l.js → mq-next-appointments-DMMeL0DC.js} +1 -1
- package/dist/chunks/{mq-recent-documents-B8-mnfxp.js → mq-recent-documents-DzxYuYy6.js} +1 -1
- package/dist/chunks/mq-schedule-JZyPjgBT.js +1 -0
- package/dist/chunks/{mq-support-chat-KBgsUQKV.js → mq-support-chat-HYSmf_ud.js} +1 -1
- package/dist/chunks/{mq-videocall-B3iq_BOi.js → mq-videocall-CgU0vUQJ.js} +1 -1
- package/dist/chunks/{next-appointment-card-Cj-3N8jg.js → next-appointment-card-BFBmWPYB.js} +1 -1
- package/dist/env.js +1 -1
- package/dist/i18n.js +1 -1
- package/dist/mq-api-client-provider.js +1 -1
- package/dist/mq-apple-pay-checkout.js +1 -1
- package/dist/mq-appointment-checkout.js +1 -1
- package/dist/mq-appointment-documentation.js +1 -1
- package/dist/mq-chat-room.js +1 -1
- package/dist/mq-checkout.js +1 -1
- package/dist/mq-dashboard.js +1 -1
- package/dist/mq-documents.js +1 -1
- package/dist/mq-google-pay-checkout.js +1 -1
- package/dist/mq-immediate-videocall-checkout.js +1 -1
- package/dist/mq-my-appointments.js +1 -1
- package/dist/mq-next-appointments.js +1 -1
- package/dist/mq-payment-poller.js +1 -1
- package/dist/mq-professional-presence-sync.js +1 -1
- package/dist/mq-recent-documents.js +1 -1
- package/dist/mq-schedule-success.js +1 -1
- package/dist/mq-schedule.d.ts +6 -0
- package/dist/mq-schedule.js +1 -1
- package/dist/mq-socket-provider.js +1 -1
- package/dist/mq-support-chat.js +1 -1
- package/dist/mq-terms-and-conditions.js +1 -1
- package/dist/mq-unread-count-sync.js +1 -1
- package/dist/mq-videocall.js +1 -1
- package/dist/react/mq-api-client-provider.js +1 -1
- package/dist/react/mq-apple-pay-checkout.js +1 -1
- package/dist/react/mq-appointment-checkout.js +1 -1
- package/dist/react/mq-appointment-documentation.js +1 -1
- package/dist/react/mq-chat-room.js +1 -1
- package/dist/react/mq-checkout.js +1 -1
- package/dist/react/mq-dashboard.js +1 -1
- package/dist/react/mq-documents-page.js +1 -1
- package/dist/react/mq-documents.js +1 -1
- package/dist/react/mq-google-pay-checkout.js +1 -1
- package/dist/react/mq-immediate-videocall-checkout.js +1 -1
- package/dist/react/mq-my-appointments.js +1 -1
- package/dist/react/mq-next-appointments.js +1 -1
- package/dist/react/mq-payment-poller.js +1 -1
- package/dist/react/mq-professional-presence-sync.js +1 -1
- package/dist/react/mq-recent-documents.js +1 -1
- package/dist/react/mq-schedule-success.js +1 -1
- package/dist/react/mq-schedule.d.ts +2 -0
- package/dist/react/mq-schedule.js +1 -1
- package/dist/react/mq-socket-provider.js +1 -1
- package/dist/react/mq-support-chat.js +1 -1
- package/dist/react/mq-terms-and-conditions.js +1 -1
- package/dist/react/mq-unread-count-sync.js +1 -1
- package/dist/react/mq-videocall.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/api-chat-client-3tgSK-oL.js +0 -1
- package/dist/chunks/mq-schedule-aoRvmsws.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as t,c as e}from"./custom-element-D2ziPxYE.js";import{a as i,i as o,E as s,x as n}from"./lit-element-DiWJYFwC.js";import{n as r}from"./property-scuRaFcM.js";import{spinnerIcon as a}from"../ui/icons/spinner-icon.js";import{e as l}from"./provide-BwI4DDGF.js";import{c as d}from"./consume-CovVqBjI.js";import{h as c}from"./task-Bj8p7kJX.js";import{A as p}from"./api-client-context-BXGqBAlO.js";import{f as h,A as m,C as u,c as v,n as g,i as b}from"./api-chat-client-3tgSK-oL.js";import{r as f}from"./state-LQivXIgA.js";import{n as y}from"./create-context-DqP79qjF.js";import{env as w}from"../env.js";import{m as x}from"./runtime-Bg1WXVCx.js";import{l as k}from"./localized-decorator-BlOuLhym.js";import{g as $,a as C}from"./chunk-2TKJJNS7-DzhxHWWb.js";import{a as E}from"./addSeconds-CXt0dUch.js";import{getLocale as _}from"../i18n.js";import{calendarIcon as S}from"../ui/icons/calendar-icon.js";import"../ui/mq-page-title.js";import"./professional-overview-B4E05rLd.js";import{MqViewAppointmentsEvent as z}from"../events.js";import{clockIcon as T}from"../ui/icons/clock-icon.js";import"./documentation-view-CSMoGBMk.js";import{l as O}from"./chunk-S5RWG6G2-CQJ38pW6.js";import{t as q,u as j,w as I,x as R,y as V}from"./telemetry-client-dwDzxn9N.js";import"./mq-chat-room-3PU4Fsub.js";import{chatbubbleIcon as A}from"../ui/icons/chat-bubble-icon.js";import{micIcon as N}from"../ui/icons/mic-icon.js";import{micOffIcon as U}from"../ui/icons/mic-off-icon.js";import{videoIcon as P}from"../ui/icons/video-icon.js";import{videoOffIcon as W}from"../ui/icons/video-off-icon.js";import"../ui/mq-unread-badge.js";import{Q as D}from"./query-controller-B1byDHlF.js";import{g as M}from"./chunk-Y4EKUX25-Bix9r5ry.js";import{l as K}from"./chunk-FUCSYDW7-Duj5hy8S.js";import"../ui/mq-floating-bubble.js";import{e as L}from"./query-CeeutdfT.js";import{M as F}from"./mutation-controller-CR2qcqhH.js";import{alertCircleIcon as B}from"../ui/icons/alert-circle-icon.js";import"../ui/mq-rating.js";import{toast as H}from"../ui/mq-toast.js";import{heartBeatIcon as Q}from"../ui/icons/heartbeat-icon.js";import{timeLeftIcon as G}from"../ui/icons/time-left-icon.js";import"./mq-layout-BndHxkbb.js";class PermissionController{constructor(t){this.state="prompt",this.host=t,t.addController(this)}async hostConnected(){await this.requestPermissions()}async requestPermissions(){try{const t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0});for(const e of t.getTracks())e.stop();this.state="granted"}catch{this.state="denied"}finally{this.host.requestUpdate()}}}class InvalidTokenError extends Error{}function J(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(t){return decodeURIComponent(atob(t).replace(/(.)/g,(t,e)=>{let i=e.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i}))}(e)}catch(t){return atob(e)}}InvalidTokenError.prototype.name="InvalidTokenError";const Y=y(Symbol("opentok-service")),Z=y(Symbol("params"));class OpenTokService{static{this.URL="https://static.opentok.com/v2/js/opentok.min.js"}_ensureLoaded(){if(!window.OT)throw new Error("OpenTok SDK is not loaded");return window.OT}load(){return new Promise((t,e)=>{if(window.OT)return void t();const i=document.createElement("script");i.src=OpenTokService.URL,i.onload=()=>{t()},i.onerror=e,document.head.appendChild(i)})}initSession(t,e){return this._ensureLoaded().initSession(t,e)}initPublisher(t,e,i){return this._ensureLoaded().initPublisher(t,e,i)}subscribe(t,e,i,o,s){return t.subscribe(e,i,o,s)}}const X="waiting-room",tt="videocall",et="documentation",it="not-time-yet",ot="review";class OpenTokController{constructor(t,e,i,o,s,n){this.isLoading=!0,this.isSessionReady=!1,this.isReconnecting=!1,this.errorMessage="",this.session=null,this.streams=[],this.destroyedStreamIds=new Set,this.openTokService=new OpenTokService,this.session_token=null,this.hasLeftWaitingRoom=!1,this.host=t,this.apiClient=e,t.addController(this),this.appointment=i,this.token=o,this.onCallStarted=s,this.onCallFinished=n,this._loadOpentok()}async _loadOpentok(){try{await this.openTokService.load(),this._initializeSession()}catch{this.isLoading=!1,this.errorMessage="Failed to load OpenTok script",this.host.requestUpdate()}}async _getSessionAndToken(){const t=await this.apiClient.flash.joinCall({callId:this.appointment.call_id});return this.session_token=t.session_token,[t.session_id,t.session_token]}async _initializeSession(){try{const[t,e]=await this._getSessionAndToken();this.session=this.openTokService.initSession(w.OPENTOK_API_KEY,t),this.session.on("sessionConnected",()=>{this.isLoading=!1,this.isSessionReady=!0,this.host.requestUpdate()}),this.session.on("sessionDisconnected",()=>{this.isSessionReady=!1,this._leaveWaitingRoom(),setTimeout(()=>{this.onCallFinished(),this.host.requestUpdate()},1e3),this.host.requestUpdate()}),this.session.on("sessionReconnecting",()=>{this.isReconnecting=!0,this.host.requestUpdate()}),this.session.on("sessionReconnected",()=>{this.isReconnecting=!1;const t=this.streams.filter(t=>!this.destroyedStreamIds.has(t.streamId));this.streams=[],this.host.requestUpdate(),requestAnimationFrame(()=>{this.streams=t.filter(t=>!this.destroyedStreamIds.has(t.streamId)),this.host.requestUpdate()})}),this.session.on("streamCreated",t=>{this.streams=[...this.streams,t.stream],this.onCallStarted(),this.host.requestUpdate()}),this.session.on("streamDestroyed",t=>{t.stream?.streamId&&this.destroyedStreamIds.add(t.stream.streamId),setTimeout(()=>{this.streams=this.streams.filter(e=>e.streamId!==t.stream?.streamId),this._leaveWaitingRoom(),this.onCallFinished(),this.host.requestUpdate()},1e3)}),this.session.connect(e,t=>{t&&(this.isLoading=!1,this.errorMessage=`Failed to connect to session: ${t.message}`,this.host.requestUpdate())}),this.apiClient.flash.setReady({professional_hash:this.appointment.from.hash,consultation_id:this.appointment.id,consultation_type:"appointment"})}catch(t){this.isLoading=!1,this.errorMessage=`Error initializing session: ${t instanceof Error?t.message:"Unknown error"}`,this.host.requestUpdate()}}_leaveWaitingRoom(){this.hasLeftWaitingRoom||(this.hasLeftWaitingRoom=!0,this.apiClient.flash.leaveWaitingRoom({professional_hash:this.appointment.from.hash,consultation_id:this.appointment.id,consultation_type:"appointment"}))}hostDisconnected(){this._leaveWaitingRoom(),this.session&&(this.session.disconnect(),this.session.off("streamCreated"),this.session.off("streamDestroyed"),this.session.off("sessionConnected"),this.session.off("sessionDisconnected"),this.session.off("sessionReconnecting"),this.session.off("sessionReconnected"))}}let st=class NotTimeYetView extends i{static{this.styles=[o`mq-page-title{margin-bottom:var(--size-3)}.description{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);font-weight:var(--font-weight-normal);margin:0;margin-bottom:var(--size-3)}.details-card{background-color:var(--color-background);border-radius:var(--border-radius-xl);padding:var(--size-6) var(--size-4);display:flex;min-width:0;flex-direction:column;gap:var(--size-6);margin-bottom:var(--size-6)}.details-card-title{padding:14px 0;font-size:var(--text-base);line-height:100%;font-weight:var(--font-weight-medium);color:var(--color-gray-darker);text-align:left}.details-rows{display:flex;flex-direction:column;gap:var(--size-3)}.details-row{display:flex;align-items:center;gap:var(--size-2);font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default);font-weight:var(--font-weight-semibold)}.details-row span::first-letter{text-transform:uppercase}@media (min-width:768px){.description{font-size:var(--text-base);line-height:var(--text-base--line-height);margin-bottom:var(--sp-6)}}`]}firstUpdated(){q.track(j(this.loginToken.patient.hash,this.appointment.id??""))}render(){const t=_()?.replace("_","-")??"es-ES",e=$(this.loginToken.patient.timezone),i=new Intl.DateTimeFormat(t,{dateStyle:"full",...e?{timeZone:e}:{}}),o=new Intl.DateTimeFormat(t,{timeStyle:"short",...e?{timeZone:e}:{}}),r=new Date(this.appointment.start_date),a=E(r,this.appointment.duration),l=e?C(e,r):"";return n`<mq-page-title .title="${x("¡Aún no es la hora!")}" back-label="${x("Salir")}" @mq-back="${t=>{t.stopPropagation(),this.dispatchEvent(new z({tab:"next"}))}}"></mq-page-title><p class="description">${x("Cuando falten 10 minutos para tu consulta, podrás acceder a la videoconsulta")}</p><div class="details-card"><professional-overview .name="${this.appointment.from.name??""}" .specialtyName="${this.appointment.from.speciality??""}" .collegiateNumber="${this.appointment.from.collegiate_number??void 0}" .description="${this.appointment.from.description??""}" .languages="${this.appointment.from.languages}" .avatar="${this.appointment.from.avatar??""}"></professional-overview><div class="details-rows"><div class="details-row">${S({size:24})} <span>${i.format(r)}</span></div><div class="details-row">${T({size:24})} <span>${o.format(r)} - ${o.format(a)}${l?` (${l})`:""}</span></div></div></div>${!0===this.appointment.has_chat_in_appointment?n`<chat-cta .consultationId="${this.appointment.id}" .roomId="${Number(this.appointment.room_id)}" .professionalHash="${this.appointment.from.hash}" .text="${x("Utiliza el chat para enviar el motivo de consulta, documentos o imágenes")}" .onOpenChat="${()=>{q.track(I(this.loginToken.patient.hash,this.appointment.id??""))}}"></chat-cta>`:s}`}};t([r({type:Object})],st.prototype,"appointment",void 0),t([d({context:O})],st.prototype,"loginToken",void 0),st=t([k(),e("not-time-yet-view")],st);let nt=class PermissionStatusBanner extends i{static{this.styles=o`:host{display:block;padding:var(--size-5) var(--size-6);background-color:#ebf9ff;border-radius:var(--border-radius-lg);text-align:center}span{color:var(--color-neutrals-text-default);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal)}`}render(){return n`<span>${x("Espera a ser atendido sin salir de esta pantalla")}</span>`}};nt=t([k(),e("permission-status-banner")],nt);let rt=class WaitingRoomLayout extends i{constructor(){super(...arguments),this.isWaitingRoom=!1}static{this.styles=o`.information-container{padding:var(--size-5) var(--size-4);background-color:var(--color-neutrals-background-disabled)}mq-page-title{margin-bottom:var(--size-4)}.content{max-width:560px;margin:0 auto}.information-container p{font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-neutrals-text-default);margin:0}.video-container{margin-left:auto;margin-right:auto;margin-bottom:var(--size-6);position:relative;max-height:301px;aspect-ratio:9/16;border-radius:16px;overflow:hidden}@media (min-width:768px){.information-container{background-color:transparent;padding:var(--size-6) 0}.video-container{max-height:454px;aspect-ratio:16/9}.information-container p{font-size:var(--text-base);line-height:var(--text-base--line-height)}}`}firstUpdated(){this.isWaitingRoom&&q.track(R(this.loginToken.patient.hash,this.appointment.id??""))}render(){if(!this.isWaitingRoom)return n`<slot></slot>`;const t=_()?.replace("_","-")??"es-ES",e=$(this.loginToken.patient.timezone),i=e?{timeZone:e}:{},o=new Intl.DateTimeFormat(t,{dateStyle:"short",...i}),r=new Intl.DateTimeFormat(t,{timeStyle:"short",...i}),a=new Date(this.appointment.start_date),l=E(a,this.appointment.duration),d=e?C(e,a):"",c=o.format(a),p=`${r.format(a)} - ${r.format(l)}${d?` (${d})`:""}`;return n`<permission-status-banner></permission-status-banner><div class="content"><div class="information-container"><mq-page-title .title="${x("Sala de espera")}" back-label="${x("Salir")}" @mq-back="${t=>{t.stopPropagation(),this.dispatchEvent(new z({tab:"next"}))}}"></mq-page-title><div class="doctor-info"><p>${this.appointment.from.name}</p><p>${c}</p><p>${p}</p></div></div><div class="video-container"><slot></slot></div>${!0===this.appointment.has_chat_in_appointment?n`<chat-cta .consultationId="${this.appointment.id}" .roomId="${Number(this.appointment.room_id)}" .professionalHash="${this.appointment.from.hash}" .text="${x("Utiliza el chat para enviar el motivo de consulta, documentos o imágenes")}" .onOpenChat="${()=>{q.track(I(this.loginToken.patient.hash,this.appointment.id??""))}}"></chat-cta>`:s}</div>`}};t([r({type:Object})],rt.prototype,"appointment",void 0),t([r({type:Boolean,attribute:"is-waiting-room"})],rt.prototype,"isWaitingRoom",void 0),t([d({context:O})],rt.prototype,"loginToken",void 0),rt=t([e("waiting-room-layout")],rt);class AppointmentCounterController{constructor(t,e){this.startsAtGetter=e,this.formattedTime="--:--",this.interval=null,this.host=t,t.addController(this)}async hostConnected(){this.interval=setInterval(()=>{const t=new Date,e=this.startsAtGetter(),i=t.getTime()-e.getTime(),o=Math.floor(i/1e3),s=Math.floor(o/60),n=o%60;this.formattedTime=`${s.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`,this.host.requestUpdate()},1e3)}hostDisconnected(){this.interval&&clearInterval(this.interval)}}class ToggleAudioEvent extends Event{static{this.eventName="toggle-audio"}constructor(t){super(ToggleAudioEvent.eventName,{bubbles:!0,composed:!0}),this.isAudioOn=t}}class ToggleVideoEvent extends Event{static{this.eventName="toggle-video"}constructor(t){super(ToggleVideoEvent.eventName,{bubbles:!0,composed:!0}),this.isVideoOn=t}}class ToggleChatEvent extends Event{static{this.eventName="toggle-chat"}constructor(t){super(ToggleChatEvent.eventName,{bubbles:!0,composed:!0}),this.isChatOpen=t}}class ViewDocumentationEvent extends Event{static{this.eventName="view-documentation"}constructor(){super(ViewDocumentationEvent.eventName,{bubbles:!0,composed:!0})}}class DownloadFileEvent extends Event{static{this.eventName="download-file"}constructor(t,e){super(DownloadFileEvent.eventName,{bubbles:!0,composed:!0}),this.url=t,this.filename=e}}let at=class PublisherControls extends i{constructor(){super(...arguments),this.isAudioOn=!1,this.isVideoOn=!0,this.isChatOpen=!1,this.chatEnabled=!1,this.isWaitingRoom=!1,this.unreadQuery=new D(this,()=>M(this.apiClient,{roomId:this.roomId}))}static{this.styles=o`:host{display:flex;justify-content:space-between;gap:var(--size-4)}:host([is-waiting-room]){justify-content:center}.left-controls{display:flex;gap:var(--size-4)}.control-button{border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;width:var(--size-10);height:var(--size-10);padding:var(--size-2);border-radius:12.5px;transition:all .2s ease-in-out}@media (min-width:768px){.control-button{width:var(--size-11);height:var(--size-11);padding:var(--size-2);border-radius:16px}}.control-button:hover{background-color:var(--color-gray-light)}.control-button:focus-visible{outline:0;box-shadow:0 0 0 2px var(--color-primary-light)}.control-button--on{background-color:var(--color-white);color:var(--color-primary)}.control-button--off{background-color:var(--color-white);color:var(--color-negative)}`}toggleAudio(){this.dispatchEvent(new ToggleAudioEvent(!this.isAudioOn))}toggleVideo(){this.dispatchEvent(new ToggleVideoEvent(!this.isVideoOn))}toggleChat(){this.dispatchEvent(new ToggleChatEvent(!this.isChatOpen))}render(){return n`<div class="left-controls">${this.isWaitingRoom||!this.chatEnabled?s:n`<button type="button" class="control-button control-button--on" @click="${this.toggleChat}">${A({size:20})} ${(this.unreadQuery.result?.data?.unread_count??0)>0?n`<mq-unread-badge></mq-unread-badge>`:s}</button>`} <button type="button" class="control-button ${this.isAudioOn?"control-button--on":"control-button--off"}" @click="${this.toggleAudio}">${this.isAudioOn?N({size:20}):U({size:20})}</button> <button type="button" class="control-button ${this.isVideoOn?"control-button--on":"control-button--off"}" @click="${this.toggleVideo}">${this.isVideoOn?P({size:20}):W({size:20})}</button></div>`}};t([d({context:p,subscribe:!0})],at.prototype,"apiClient",void 0),t([r({type:Boolean})],at.prototype,"isAudioOn",void 0),t([r({type:Boolean})],at.prototype,"isVideoOn",void 0),t([r({type:Boolean})],at.prototype,"isChatOpen",void 0),t([r({type:Boolean})],at.prototype,"chatEnabled",void 0),t([r({type:Boolean,reflect:!0,attribute:"is-waiting-room"})],at.prototype,"isWaitingRoom",void 0),t([r({type:Number})],at.prototype,"roomId",void 0),at=t([e("publisher-controls")],at);let lt=class VideoPublisher extends i{constructor(){super(...arguments),this.isWaitingRoom=!1,this.hasChatInAppointment=!1,this.appointmentCounterController=new AppointmentCounterController(this,()=>new Date(this.startsAt)),this.isAudioOn=!0,this.isVideoOn=!0,this.isChatOpen=!1,this._handleVisibilityChange=()=>{"visible"===document.visibilityState&&this.publisher&&(this.publisher.publishAudio(!1),this.publisher.publishVideo(!1),setTimeout(()=>{this.publisher?.publishAudio(this.isAudioOn),this.publisher?.publishVideo(this.isVideoOn)},500))}}static{this.styles=o`:host{width:100%;height:100%;display:block}.OT_video-element{width:100%;height:100%;background:var(--color-black)}.OT_mute{display:none}video{border-radius:var(--border-radius-lg)}#video-publisher{width:100%;height:100%;transition:width .5s ease-in-out,height .5s ease-in-out;border-radius:var(--border-radius-lg)}:host(:not([is-waiting-room])) #video-publisher{width:121px;height:200px;z-index:50;border-radius:12px;overflow:hidden}:host([is-waiting-room]) .top-items{position:absolute;inset:0}:host(:not([is-waiting-room])) .top-items{position:absolute;z-index:50;top:var(--size-4);left:var(--size-4);right:var(--size-4);display:flex;justify-content:space-between;gap:var(--size-1)}.meta-container{display:flex;align-items:flex-start;gap:var(--size-1);min-width:0}.meta-item{background-color:var(--color-neutrals-text-default);padding:var(--size-2) var(--size-3);color:var(--color-white);font-size:var(--text-xs);line-height:var(--text-xs--line-height);flex-shrink:0}.meta-item:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex-shrink:1;min-width:0}publisher-controls{position:absolute;z-index:50;bottom:var(--size-4);left:var(--size-4);right:var(--size-4)}mq-chat-room{height:100%}@media (min-width:768px){:host(:not([is-waiting-room])) #video-publisher{width:250px;height:auto;aspect-ratio:16/9}:host(:not([is-waiting-room])) .top-items{top:var(--size-6);left:var(--size-6);right:var(--size-6)}}`}firstUpdated(t){super.firstUpdated(t),this.publisher=this.openTokService.initPublisher(this.publisherEl,{fitMode:"contain",width:"100%",height:"100%",audioFallbackEnabled:!1,insertMode:"append",mirror:!1,publishAudio:this.isAudioOn,publishVideo:this.isVideoOn},t=>{t&&K.error("error initializing publisher",t),this.session.publish(this.publisher)}),document.addEventListener("visibilitychange",this._handleVisibilityChange)}disconnectedCallback(){document.removeEventListener("visibilitychange",this._handleVisibilityChange),super.disconnectedCallback(),this.publisher?.destroy()}async _handleToggleAudioEvent(t){this.isAudioOn=t.isAudioOn,this.publisher.publishAudio(t.isAudioOn)}async _handleToggleVideoEvent(t){this.isVideoOn=t.isVideoOn,this.publisher.publishVideo(t.isVideoOn)}async _handleToggleChatEvent(t){this.isChatOpen=t.isChatOpen}render(){return n`<div class="top-items">${this.isWaitingRoom?n`<div></div>`:n`<div class="meta-container"><span class="meta-item">${this.professionalName}</span> <span class="meta-item">${this.appointmentCounterController.formattedTime}</span></div>`}<div id="video-publisher"></div></div><publisher-controls .isAudioOn="${this.isAudioOn}" .isVideoOn="${this.isVideoOn}" .isChatOpen="${this.isChatOpen}" .chatEnabled="${this.hasChatInAppointment}" .roomId="${Number.parseInt(this.roomId,10)}" ?is-waiting-room="${this.isWaitingRoom}" @toggle-audio="${this._handleToggleAudioEvent}" @toggle-video="${this._handleToggleVideoEvent}" @toggle-chat="${this._handleToggleChatEvent}"></publisher-controls>${this.hasChatInAppointment?n`<mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" @mq-close="${()=>{this.isChatOpen=!1}}" hideCloseButton>${this.isChatOpen?n`<mq-chat-room slot="content" .consultationId="${this.consultationId}" .consultationType="${u.appointment}" token="${this.loginToken.access_token}" .roomId="${Number.parseInt(this.roomId,10)}" .professionalHash="${this.professionalHash}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room>`:s}</mq-floating-bubble>`:s}`}};t([r({type:String})],lt.prototype,"consultationId",void 0),t([r({type:String})],lt.prototype,"apiKey",void 0),t([r({type:String})],lt.prototype,"token",void 0),t([r({type:String})],lt.prototype,"roomId",void 0),t([r({type:String})],lt.prototype,"professionalHash",void 0),t([r({type:Object})],lt.prototype,"session",void 0),t([r({type:String})],lt.prototype,"professionalName",void 0),t([r({type:String})],lt.prototype,"startsAt",void 0),t([r({type:Boolean,reflect:!0,attribute:"is-waiting-room"})],lt.prototype,"isWaitingRoom",void 0),t([r({type:Boolean})],lt.prototype,"hasChatInAppointment",void 0),t([d({context:Y})],lt.prototype,"openTokService",void 0),t([d({context:O})],lt.prototype,"loginToken",void 0),t([L("#video-publisher")],lt.prototype,"publisherEl",void 0),t([f()],lt.prototype,"isAudioOn",void 0),t([f()],lt.prototype,"isVideoOn",void 0),t([f()],lt.prototype,"isChatOpen",void 0),lt=t([e("video-publisher")],lt);let dt=class VideoSubscriber extends i{constructor(){super(...arguments),this.isVideoOn=!0,this._subscriberProperties={fitMode:"contain",insertMode:"append",width:"100%",height:"100%"},this._handleVisibilityChange=()=>{"visible"===document.visibilityState&&this.subscriber&&(this.subscriber.subscribeToAudio(!1),this.subscriber.subscribeToVideo(!1),setTimeout(()=>{this.subscriber?.subscribeToAudio(!0),this.subscriber?.subscribeToVideo(!0)},500),setTimeout(()=>this._resubscribe(),600))}}static{this.styles=o`:host{position:absolute;inset:0}.OT_subscriber{width:100%;height:100%;position:absolute;inset:0;background:var(--color-neutrals-background-default)}video{width:100%;height:100%}.video-disabled{position:absolute;inset:0;background:var(--color-gray-dark)}.hidden{display:none}`}firstUpdated(){this._subscribe(),document.addEventListener("visibilitychange",this._handleVisibilityChange)}_subscribe(){this.subscriber=this.openTokService.subscribe(this.session,this.stream,this.subscriberEl,this._subscriberProperties,t=>{}),this._attachSubscriberEvents()}_attachSubscriberEvents(){this.subscriber.on("connected",t=>{this.isVideoOn=t.target.stream?.hasVideo??!0}),this.subscriber.on("videoDisabled",()=>{this.isVideoOn=!1}),this.subscriber.on("videoEnabled",()=>{this.isVideoOn=!0}),this.subscriber.on("disconnected",()=>{this.isVideoOn=!1})}_resubscribe(){if(this.subscriber&&this.session&&this.subscriberEl){try{this.session.unsubscribe(this.subscriber)}catch{}this.subscriberEl.innerHTML="",this._subscribe()}}disconnectedCallback(){if(document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.subscriber&&this.session)try{this.session.unsubscribe(this.subscriber)}catch{}super.disconnectedCallback()}render(){return n`<div id="video-subscriber" class="${this.isVideoOn?"":"hidden"}"></div>${this.isVideoOn?n``:n`<div class="video-disabled"></div>`}`}};t([r({type:Object})],dt.prototype,"session",void 0),t([r({type:Object})],dt.prototype,"stream",void 0),t([f()],dt.prototype,"isVideoOn",void 0),t([d({context:Y})],dt.prototype,"openTokService",void 0),t([L("#video-subscriber")],dt.prototype,"subscriberEl",void 0),dt=t([e("video-subscriber")],dt);let ct=class VideocallContent extends i{constructor(){super(...arguments),this.streams=[],this.isWaitingRoom=!1,this.isReconnecting=!1}static{this.styles=o`:host{display:block;position:relative;width:100%;height:100%;background:var(--color-gray-darkest);aspect-ratio:16/9}.reconnecting-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--size-3);background:rgba(0,0,0,.6);z-index:100}.reconnecting-overlay__text{color:var(--color-white);font-size:var(--text-sm);line-height:var(--text-sm--line-height)}.reconnecting-overlay__subtitle{color:var(--color-white);font-size:var(--text-xs);line-height:var(--text-xs--line-height);opacity:.85}`}firstUpdated(){this.isWaitingRoom||q.track(V(this.loginToken.patient.hash,this.appointment.id??""))}updated(t){t.has("isWaitingRoom")&&!0===t.get("isWaitingRoom")&&!this.isWaitingRoom&&q.track(V(this.loginToken.patient.hash,this.appointment.id??""))}render(){return n`<video-publisher .consultationId="${this.appointment.id}" .session="${this.session}" ?is-waiting-room="${this.isWaitingRoom}" .professionalName="${this.appointment.from.name??""}" .professionalHash="${this.appointment.from.hash}" .startsAt="${this.appointment.started_at??(new Date).toISOString()}" .apiKey="${this.apiKey}" .token="${this.token}" .roomId="${this.appointment.room_id}" .hasChatInAppointment="${!0===this.appointment.has_chat_in_appointment}"></video-publisher>${0===this.streams.length?n``:this.streams.map(t=>n`<video-subscriber .session="${this.session}" .stream="${t}"></video-subscriber>`)} ${this.isReconnecting?n`<div class="reconnecting-overlay">${a({color:"var(--color-white)"})} <span class="reconnecting-overlay__text">${x("Reconectando...")} </span><span class="reconnecting-overlay__subtitle">${x("Espere mientras se restablece la conexión")}</span></div>`:""}`}};t([r({type:Object})],ct.prototype,"session",void 0),t([r({type:Array})],ct.prototype,"streams",void 0),t([r({type:String})],ct.prototype,"apiKey",void 0),t([r({type:String})],ct.prototype,"token",void 0),t([r({type:Object})],ct.prototype,"appointment",void 0),t([r({type:Boolean,reflect:!0,attribute:"is-waiting-room"})],ct.prototype,"isWaitingRoom",void 0),t([r({type:Boolean,reflect:!0,attribute:"is-reconnecting"})],ct.prototype,"isReconnecting",void 0),t([d({context:O})],ct.prototype,"loginToken",void 0),ct=t([k(),e("mq-videocall-content")],ct);class ReviewSubmittedEvent extends Event{static{this.eventName="review-submitted"}constructor(){super(ReviewSubmittedEvent.eventName,{bubbles:!0,composed:!0})}}class ReviewSkippedEvent extends Event{static{this.eventName="review-skipped"}constructor(){super(ReviewSkippedEvent.eventName,{bubbles:!0,composed:!0})}}let pt=class ReviewView extends i{constructor(){super(...arguments),this.rating=0,this.comment="",this._reviewMutation=new F(this,{mutationFn:({rating:t,comment:e})=>this.apiClient.consultations.postReview({consultation_id:this.appointment.id??"",consultation_type:u.appointment,rating:t,comment:e.trim()?e.trim():null}),onSuccess:()=>{this.dispatchEvent(new ReviewSubmittedEvent)},onError:t=>{!function(t){const e=t,i=e?.response?.status;return 400===i&&/already exists/i.test(e?.response?.data?.message??"")}(t)?H.error(x("No se ha podido enviar el cuestionario")):this.dispatchEvent(new ReviewSubmittedEvent)}}),this._reconnectMutation=new F(this,{mutationFn:t=>this.apiClient.appointments.reconnectAppointment(t),onSuccess:()=>{this.dispatchEvent(new CustomEvent("review-reconnect",{bubbles:!0,composed:!0}))},onError:()=>{H.error(x("No se ha podido volver a la sala de espera"))}}),this.handleSkip=()=>{this.dispatchEvent(new ReviewSkippedEvent)},this.handleSubmit=()=>{this.rating<1||this.rating>5||this._reviewMutation.isPending||this._reviewMutation.run({rating:this.rating,comment:this.comment})}}static{this.styles=o`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100%;background-color:var(--color-background);box-sizing:border-box}.container{width:100%;max-width:500px;padding:var(--sp-6);display:flex;flex-direction:column;gap:var(--sp-5);box-sizing:border-box}.title{margin:0;padding:0 var(--sp-6);font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-normal);color:var(--color-primary);text-align:center}.rating{display:flex;flex-direction:column;align-items:center;gap:var(--sp-2);padding:var(--sp-1) var(--sp-6)}.subtitle{margin:0;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-text-icons--secondary);text-align:center}.comment-card{background-color:var(--color-white);border:var(--action-border-width) solid var(--color-border);border-radius:var(--border-radius-lg);box-shadow:0 4px 4px rgba(0,0,0,.05);padding:var(--sp-5);display:flex;flex-direction:column;gap:var(--sp-5)}.comment-header{display:flex;justify-content:space-between;align-items:flex-start;gap:var(--sp-3)}.comment-label{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm);font-weight:var(--font-weight-medium);color:var(--color-neutrals-text-default)}.comment-counter{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-text-icons--secondary);white-space:nowrap}.textarea{width:100%;box-sizing:border-box;height:var(--size-44);padding:var(--sp-3) var(--sp-4);background-color:var(--color-gray-lighter);border:var(--action-border-width) solid var(--color-border);border-radius:var(--border-radius-md);font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);resize:none}.textarea::placeholder{color:var(--color-text-icons--secondary);opacity:.6}.textarea:focus{outline:0;border-color:var(--color-primary)}.actions{display:flex;gap:var(--sp-4)}.btn{flex:1;height:var(--button-height-md);padding:var(--sp-2) var(--sp-4);border-radius:var(--border-radius-md);font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);cursor:pointer;transition:opacity .15s ease-in-out}.btn:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.btn:disabled{cursor:not-allowed}.btn-skip{background:var(--color-white);border:var(--action-border-width) solid var(--color-primary);color:var(--color-primary)}.btn-skip:hover:not(:disabled){background:var(--color-primary-background-extraWeak)}.btn-submit{background:var(--color-primary);border:var(--action-border-width) solid var(--color-primary);color:var(--color-white)}.btn-submit:hover:not(:disabled){background:var(--color-primary-dark)}.btn-submit:disabled{opacity:.5}.waiting-card{background-color:var(--color-background-primary-light);border-radius:var(--border-radius-lg);padding:var(--sp-4);display:flex;flex-direction:column;gap:var(--sp-2)}.waiting-header{display:flex;align-items:center;gap:var(--sp-2);color:var(--color-neutrals-text-default)}.waiting-title{font-family:var(--font-body);font-size:var(--text-xs);line-height:1;font-weight:var(--font-weight-medium);color:var(--color-neutrals-text-default)}.waiting-body{margin:0;font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);color:var(--color-text-icons--secondary)}.waiting-link{background:0 0;border:0;padding:0;cursor:pointer;color:#3c50ec;font:inherit;text-decoration:none}.waiting-link:hover{text-decoration:none}.waiting-link:disabled{cursor:not-allowed;opacity:.6}`}render(){return n`<div class="container"><h1 class="title">${x("¿Qué tal ha ido tu cita?")}</h1><div class="rating"><mq-rating .value="${this.rating}" .label="${x("Valoración de la consulta")}" @mq-rating-change="${t=>{this.rating=t.value}}"></mq-rating><p class="subtitle">${x("(1 es muy malo, 5 es excelente)")}</p></div><div class="comment-card"><div class="comment-header"><span class="comment-label">${x("¿Tienes comentarios sobre la consulta?")}</span> <span class="comment-counter">${this.comment.length}/${240}</span></div><textarea class="textarea" maxlength="${240}" placeholder="${x("Comparte cómo fue la atención o si tuviste algún problema con la videollamada…")}" .value="${this.comment}" @input="${t=>{this.comment=t.target.value}}"></textarea><div class="actions"><button type="button" class="btn btn-skip" ?disabled="${this._reviewMutation.isPending}" @click="${this.handleSkip}">${x("Omitir")}</button> <button type="button" class="btn btn-submit" ?disabled="${this.rating<1||this._reviewMutation.isPending}" @click="${this.handleSubmit}">${x("Enviar")}</button></div></div><div class="waiting-card"><div class="waiting-header">${B({color:"currentColor",size:18})} <span class="waiting-title">${x("¿Ocurrió algún problema?")}</span></div><p class="waiting-body">${x("Si la cita no se ha podido realizar, puedes")} <button type="button" class="waiting-link" ?disabled="${this._reconnectMutation.isPending}" @click="${()=>this._reconnectMutation.run({appointmentId:this.appointment.id})}">${x("volver a la sala de espera.")}</button></p></div></div>`}};t([d({context:p,subscribe:!0})],pt.prototype,"apiClient",void 0),t([r({type:Object})],pt.prototype,"appointment",void 0),t([f()],pt.prototype,"rating",void 0),t([f()],pt.prototype,"comment",void 0),pt=t([k(),e("review-view")],pt);let ht=class ErrorView extends i{static{this.styles=o`.container{display:grid;place-items:center;width:100%;max-width:447px;margin:0 auto}.card>:not(:first-child){margin-top:var(--size-8)}.title{font-family:var(--font-titles);color:var(--color-neutrals-text-default);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0;margin-bottom:var(--size-3)}.description{color:var(--color-neutrals-text-default);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:400}`}render(){return n`<div class="container"><div class="card"><slot name="icon"></slot><div class="content"><h1 class="title">${this.title}</h1><p class="description">${this.message}</p></div></div></div>`}};t([r({type:String})],ht.prototype,"title",void 0),t([r({type:String})],ht.prototype,"message",void 0),ht=t([e("error-view")],ht);let mt=class UnexpectedErrorView extends i{render(){return n`<error-view .title="${x("Error desconocido")}" .message="${x("Ha ocurrido un error al cargar la página. Por favor, intenta nuevamente o contacta al soporte.")}"><div slot="icon">${Q()}</div></error-view>`}};mt=t([k(),e("unexpected-error-view")],mt);let ut=class ExpiredAppointmentErrorView extends i{render(){return n`<error-view .title="${x("Consulta caducada")}" .message="${x("Parece que no te hemos encontrado a la hora de tu cita. Puedes programar otra consulta para resolver tus dudas.")}"><div slot="icon">${G()}</div></error-view>`}};ut=t([k(),e("expired-appointment-error-view")],ut);let vt=class NotFoundErrorView extends i{static{this.styles=o`div{display:flex;flex-direction:column;gap:2px}span{font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:400;color:var(--color-gray-medium)}`}render(){return n`<error-view .title="${x("Página no encontrada")}" .message="${x("La página que estás buscando fue removida, renombrada o puede que no exista.")}"><div slot="icon"><span>404</span> ${Q()}</div></error-view>`}};function gt(t){try{return function(t,e){if("string"!=typeof t)throw new InvalidTokenError("Invalid token specified: must be a string");e||(e={});const i=!0===e.header?0:1,o=t.split(".")[i];if("string"!=typeof o)throw new InvalidTokenError(`Invalid token specified: missing part #${i+1}`);let s;try{s=J(o)}catch(t){throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${i+1} (${t.message})`)}try{return JSON.parse(s)}catch(t){throw new InvalidTokenError(`Invalid token specified: invalid json for part #${i+1} (${t.message})`)}}(t)}catch{return null}}vt=t([k(),e("not-found-error-view")],vt);let bt=class MqVideocallProvider extends i{static{this.styles=o`*{box-sizing:border-box}:host{display:block;margin:0 auto;width:100%;height:100%}.centered{display:grid;place-items:center;height:100%;min-height:var(--mq-container-min-height)}documentation-view{display:block;padding:var(--sp-4)}`}constructor(){super(),this.apiClient=v(),this.opentokService=new OpenTokService,this.params={appointmentId:this.appointmentId,token:this.token,apiKey:this.apiKey},this.appointmentTask=new c(this,{task:async([t,,])=>{const[e,i,o]=await Promise.all([this.apiClient.flash.getAppointment({appointmentId:t}),this.apiClient.consultations.getReview(t).then(()=>!0).catch(()=>!1),this.apiClient.organizations.getOrganizationSetup().catch(()=>{})]);return{appointment:e,hasReview:i,hasNps:!0===o?.appointments?.has_nps}},args:()=>[this.appointmentId,this.apiKey,this.token]})}willUpdate(t){const e=g(t,{apiKey:this.apiKey,token:this.token},this.inheritedApiClient);if(e&&(this.apiClient=e),this.appointmentTask.value&&!this.opentokController){const{appointment:t,hasReview:e,hasNps:i}=this.appointmentTask.value,o=function(t,e){return h(t)?t.status===m.finished||t.status===m.reporting?e?ot:et:X:it}(t,i);this.screen=o===ot&&e?et:o,this.params={appointmentId:this.appointmentId,token:this.token,apiKey:this.apiKey},this.opentokController=new OpenTokController(this,this.apiClient,t,this.token,()=>{this.screen=tt},()=>{this.screen=!i||e?et:ot})}}render(){const t=n`<div class="centered">${a({color:"var(--color-primary)"})}</div>`,e=n`<mq-layout background="transparent"><not-found-error-view></not-found-error-view></mq-layout>`;return this.appointmentTask.render({pending:()=>t,error:t=>{const i=gt(this.token);return i?.exp&&i.exp<Date.now()/1e3?n`<mq-layout background="transparent"><expired-appointment-error-view></expired-appointment-error-view></mq-layout>`:b(t)&&t.response?.status&&t.response.status<500?e:n`<mq-layout background="transparent"><unexpected-error-view></unexpected-error-view></mq-layout>`},complete:({appointment:i,hasNps:o})=>{if(this.opentokController?.isLoading)return t;if(this.opentokController?.errorMessage||!this.opentokController)return e;if(this.screen===it)return n`<mq-layout background="transparent"><not-time-yet-view .appointment="${i}"></not-time-yet-view></mq-layout>`;if(this.screen===ot)return n`<mq-layout background="transparent"><review-view .appointment="${i}" @review-submitted="${()=>{this.screen=et}}" @review-skipped="${()=>{this.screen=et}}" @review-reconnect="${()=>{this.screen=X}}"></review-view></mq-layout>`;if(this.screen===et)return n`<mq-layout background="transparent"><documentation-view .appointment="${i}" .token="${this.token}" ?can-reconnect="${!o}" @reconnect="${()=>{this.screen=X}}"></documentation-view></mq-layout>`;if(this.screen===X||this.screen===tt){const e=this.opentokController.session;return e?n`<waiting-room-layout .appointment="${i}" ?is-waiting-room="${this.screen===X}"><mq-videocall-content .apiKey="${this.apiKey}" .token="${this.token}" .session="${e}" .streams="${this.opentokController?.streams??[]}" ?is-waiting-room="${this.screen===X}" ?is-reconnecting="${this.opentokController.isReconnecting}" .appointment="${i}"></mq-videocall-content></waiting-room-layout>`:t}return n`<mq-layout background="transparent"><unexpected-error-view></unexpected-error-view></mq-layout>`}})}};t([r({type:String,attribute:"appointment-id"})],bt.prototype,"appointmentId",void 0),t([r({type:String,attribute:"api-key"})],bt.prototype,"apiKey",void 0),t([r({type:String})],bt.prototype,"token",void 0),t([d({context:p,subscribe:!0}),f()],bt.prototype,"inheritedApiClient",void 0),t([l({context:p}),f()],bt.prototype,"apiClient",void 0),t([f()],bt.prototype,"screen",void 0),t([l({context:Y})],bt.prototype,"opentokService",void 0),t([l({context:Z})],bt.prototype,"params",void 0),bt=t([e("mq-videocall-provider")],bt);let ft=class PermissionsRequiredErrorView extends i{static{this.styles=o`.img-container{display:flex;justify-content:center}img{width:100%;height:auto;max-width:229px}`}render(){return n`<error-view .title="${x("Acepta los permisos de cámara y micrófono")}" .message="${x("Parece que has denegado los permisos necesarios para entrar a la videollamada. Edita los permisos en tu navegador para entrar. Una vez concedidos, debes refrescar esta pantalla.")}"><div class="img-container" slot="icon"><img src="${`${w.ASSETS_BASE_URL}/wc-videocall/Miccam_asset.png`}" alt="Miccam_asset" width="229" height="166.44"></div></error-view>`}};ft=t([k(),e("permissions-required-error-view")],ft);let yt=class MqVideocall extends i{constructor(){super(...arguments),this._permissionController=new PermissionController(this)}static{this.styles=o`:host{display:block;width:100%;height:100%}.loading-spinner-container{height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center}.permissions-required-error-view-container{height:100%;padding-left:var(--size-4);padding-right:var(--size-4);display:grid;place-items:center}`}render(){return"prompt"===this._permissionController.state?n`<div class="loading-spinner-container">${a({color:"var(--color-primary)"})}</div>`:"denied"===this._permissionController.state?n`<div class="permissions-required-error-view-container"><permissions-required-error-view></permissions-required-error-view></div>`:n`<mq-videocall-provider .appointmentId="${this.appointmentId}" .token="${this.token}" .apiKey="${this.apiKey}"></mq-videocall-provider>`}};t([r({type:String,attribute:"appointment-id"})],yt.prototype,"appointmentId",void 0),t([r({type:String,attribute:"api-key"})],yt.prototype,"apiKey",void 0),t([r({type:String})],yt.prototype,"token",void 0),yt=t([e("mq-videocall")],yt);export{DownloadFileEvent as D,yt as M,ReviewSkippedEvent as R,ToggleAudioEvent as T,ViewDocumentationEvent as V,ReviewSubmittedEvent as a,ToggleChatEvent as b,ToggleVideoEvent as c};
|
|
1
|
+
import{_ as t,c as e}from"./custom-element-D2ziPxYE.js";import{a as i,i as o,E as s,x as n}from"./lit-element-DiWJYFwC.js";import{n as r}from"./property-scuRaFcM.js";import{spinnerIcon as a}from"../ui/icons/spinner-icon.js";import{e as l}from"./provide-BwI4DDGF.js";import{c as d}from"./consume-CovVqBjI.js";import{h as c}from"./task-Bj8p7kJX.js";import{A as p}from"./api-client-context-BXGqBAlO.js";import{f as h,A as m,C as u,c as v,n as g,i as b}from"./api-chat-client-D5BosjTp.js";import{r as f}from"./state-LQivXIgA.js";import{n as y}from"./create-context-DqP79qjF.js";import{env as w}from"../env.js";import{m as x}from"./runtime-Bg1WXVCx.js";import{l as k}from"./localized-decorator-BlOuLhym.js";import{g as $,a as C}from"./chunk-2TKJJNS7-DzhxHWWb.js";import{a as E}from"./addSeconds-CXt0dUch.js";import{getLocale as _}from"../i18n.js";import{calendarIcon as S}from"../ui/icons/calendar-icon.js";import"../ui/mq-page-title.js";import"./professional-overview-B4E05rLd.js";import{MqViewAppointmentsEvent as z}from"../events.js";import{clockIcon as T}from"../ui/icons/clock-icon.js";import"./documentation-view-BnKC8xEu.js";import{l as O}from"./chunk-S5RWG6G2-CQJ38pW6.js";import{t as q,u as j,w as I,x as R,y as V}from"./telemetry-client-dwDzxn9N.js";import"./mq-chat-room-C7FB_wOo.js";import{chatbubbleIcon as A}from"../ui/icons/chat-bubble-icon.js";import{micIcon as N}from"../ui/icons/mic-icon.js";import{micOffIcon as U}from"../ui/icons/mic-off-icon.js";import{videoIcon as P}from"../ui/icons/video-icon.js";import{videoOffIcon as W}from"../ui/icons/video-off-icon.js";import"../ui/mq-unread-badge.js";import{Q as D}from"./query-controller-B1byDHlF.js";import{g as M}from"./chunk-Y4EKUX25-Bdei04iw.js";import{l as K}from"./chunk-FUCSYDW7-Duj5hy8S.js";import"../ui/mq-floating-bubble.js";import{e as L}from"./query-CeeutdfT.js";import{M as F}from"./mutation-controller-CR2qcqhH.js";import{alertCircleIcon as B}from"../ui/icons/alert-circle-icon.js";import"../ui/mq-rating.js";import{toast as H}from"../ui/mq-toast.js";import{heartBeatIcon as Q}from"../ui/icons/heartbeat-icon.js";import{timeLeftIcon as G}from"../ui/icons/time-left-icon.js";import"./mq-layout-BndHxkbb.js";class PermissionController{constructor(t){this.state="prompt",this.host=t,t.addController(this)}async hostConnected(){await this.requestPermissions()}async requestPermissions(){try{const t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0});for(const e of t.getTracks())e.stop();this.state="granted"}catch{this.state="denied"}finally{this.host.requestUpdate()}}}class InvalidTokenError extends Error{}function J(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(t){return decodeURIComponent(atob(t).replace(/(.)/g,(t,e)=>{let i=e.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i}))}(e)}catch(t){return atob(e)}}InvalidTokenError.prototype.name="InvalidTokenError";const Y=y(Symbol("opentok-service")),Z=y(Symbol("params"));class OpenTokService{static{this.URL="https://static.opentok.com/v2/js/opentok.min.js"}_ensureLoaded(){if(!window.OT)throw new Error("OpenTok SDK is not loaded");return window.OT}load(){return new Promise((t,e)=>{if(window.OT)return void t();const i=document.createElement("script");i.src=OpenTokService.URL,i.onload=()=>{t()},i.onerror=e,document.head.appendChild(i)})}initSession(t,e){return this._ensureLoaded().initSession(t,e)}initPublisher(t,e,i){return this._ensureLoaded().initPublisher(t,e,i)}subscribe(t,e,i,o,s){return t.subscribe(e,i,o,s)}}const X="waiting-room",tt="videocall",et="documentation",it="not-time-yet",ot="review";class OpenTokController{constructor(t,e,i,o,s,n){this.isLoading=!0,this.isSessionReady=!1,this.isReconnecting=!1,this.errorMessage="",this.session=null,this.streams=[],this.destroyedStreamIds=new Set,this.openTokService=new OpenTokService,this.session_token=null,this.hasLeftWaitingRoom=!1,this.host=t,this.apiClient=e,t.addController(this),this.appointment=i,this.token=o,this.onCallStarted=s,this.onCallFinished=n,this._loadOpentok()}async _loadOpentok(){try{await this.openTokService.load(),this._initializeSession()}catch{this.isLoading=!1,this.errorMessage="Failed to load OpenTok script",this.host.requestUpdate()}}async _getSessionAndToken(){const t=await this.apiClient.flash.joinCall({callId:this.appointment.call_id});return this.session_token=t.session_token,[t.session_id,t.session_token]}async _initializeSession(){try{const[t,e]=await this._getSessionAndToken();this.session=this.openTokService.initSession(w.OPENTOK_API_KEY,t),this.session.on("sessionConnected",()=>{this.isLoading=!1,this.isSessionReady=!0,this.host.requestUpdate()}),this.session.on("sessionDisconnected",()=>{this.isSessionReady=!1,this._leaveWaitingRoom(),setTimeout(()=>{this.onCallFinished(),this.host.requestUpdate()},1e3),this.host.requestUpdate()}),this.session.on("sessionReconnecting",()=>{this.isReconnecting=!0,this.host.requestUpdate()}),this.session.on("sessionReconnected",()=>{this.isReconnecting=!1;const t=this.streams.filter(t=>!this.destroyedStreamIds.has(t.streamId));this.streams=[],this.host.requestUpdate(),requestAnimationFrame(()=>{this.streams=t.filter(t=>!this.destroyedStreamIds.has(t.streamId)),this.host.requestUpdate()})}),this.session.on("streamCreated",t=>{this.streams=[...this.streams,t.stream],this.onCallStarted(),this.host.requestUpdate()}),this.session.on("streamDestroyed",t=>{t.stream?.streamId&&this.destroyedStreamIds.add(t.stream.streamId),setTimeout(()=>{this.streams=this.streams.filter(e=>e.streamId!==t.stream?.streamId),this._leaveWaitingRoom(),this.onCallFinished(),this.host.requestUpdate()},1e3)}),this.session.connect(e,t=>{t&&(this.isLoading=!1,this.errorMessage=`Failed to connect to session: ${t.message}`,this.host.requestUpdate())}),this.apiClient.flash.setReady({professional_hash:this.appointment.from.hash,consultation_id:this.appointment.id,consultation_type:"appointment"})}catch(t){this.isLoading=!1,this.errorMessage=`Error initializing session: ${t instanceof Error?t.message:"Unknown error"}`,this.host.requestUpdate()}}_leaveWaitingRoom(){this.hasLeftWaitingRoom||(this.hasLeftWaitingRoom=!0,this.apiClient.flash.leaveWaitingRoom({professional_hash:this.appointment.from.hash,consultation_id:this.appointment.id,consultation_type:"appointment"}))}hostDisconnected(){this._leaveWaitingRoom(),this.session&&(this.session.disconnect(),this.session.off("streamCreated"),this.session.off("streamDestroyed"),this.session.off("sessionConnected"),this.session.off("sessionDisconnected"),this.session.off("sessionReconnecting"),this.session.off("sessionReconnected"))}}let st=class NotTimeYetView extends i{static{this.styles=[o`mq-page-title{margin-bottom:var(--size-3)}.description{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);font-weight:var(--font-weight-normal);margin:0;margin-bottom:var(--size-3)}.details-card{background-color:var(--color-background);border-radius:var(--border-radius-xl);padding:var(--size-6) var(--size-4);display:flex;min-width:0;flex-direction:column;gap:var(--size-6);margin-bottom:var(--size-6)}.details-card-title{padding:14px 0;font-size:var(--text-base);line-height:100%;font-weight:var(--font-weight-medium);color:var(--color-gray-darker);text-align:left}.details-rows{display:flex;flex-direction:column;gap:var(--size-3)}.details-row{display:flex;align-items:center;gap:var(--size-2);font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default);font-weight:var(--font-weight-semibold)}.details-row span::first-letter{text-transform:uppercase}@media (min-width:768px){.description{font-size:var(--text-base);line-height:var(--text-base--line-height);margin-bottom:var(--sp-6)}}`]}firstUpdated(){q.track(j(this.loginToken.patient.hash,this.appointment.id??""))}render(){const t=_()?.replace("_","-")??"es-ES",e=$(this.loginToken.patient.timezone),i=new Intl.DateTimeFormat(t,{dateStyle:"full",...e?{timeZone:e}:{}}),o=new Intl.DateTimeFormat(t,{timeStyle:"short",...e?{timeZone:e}:{}}),r=new Date(this.appointment.start_date),a=E(r,this.appointment.duration),l=e?C(e,r):"";return n`<mq-page-title .title="${x("¡Aún no es la hora!")}" back-label="${x("Salir")}" @mq-back="${t=>{t.stopPropagation(),this.dispatchEvent(new z({tab:"next"}))}}"></mq-page-title><p class="description">${x("Cuando falten 10 minutos para tu consulta, podrás acceder a la videoconsulta")}</p><div class="details-card"><professional-overview .name="${this.appointment.from.name??""}" .specialtyName="${this.appointment.from.speciality??""}" .collegiateNumber="${this.appointment.from.collegiate_number??void 0}" .description="${this.appointment.from.description??""}" .languages="${this.appointment.from.languages}" .avatar="${this.appointment.from.avatar??""}"></professional-overview><div class="details-rows"><div class="details-row">${S({size:24})} <span>${i.format(r)}</span></div><div class="details-row">${T({size:24})} <span>${o.format(r)} - ${o.format(a)}${l?` (${l})`:""}</span></div></div></div>${!0===this.appointment.has_chat_in_appointment?n`<chat-cta .consultationId="${this.appointment.id}" .roomId="${Number(this.appointment.room_id)}" .professionalHash="${this.appointment.from.hash}" .text="${x("Utiliza el chat para enviar el motivo de consulta, documentos o imágenes")}" .onOpenChat="${()=>{q.track(I(this.loginToken.patient.hash,this.appointment.id??""))}}"></chat-cta>`:s}`}};t([r({type:Object})],st.prototype,"appointment",void 0),t([d({context:O})],st.prototype,"loginToken",void 0),st=t([k(),e("not-time-yet-view")],st);let nt=class PermissionStatusBanner extends i{static{this.styles=o`:host{display:block;padding:var(--size-5) var(--size-6);background-color:#ebf9ff;border-radius:var(--border-radius-lg);text-align:center}span{color:var(--color-neutrals-text-default);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal)}`}render(){return n`<span>${x("Espera a ser atendido sin salir de esta pantalla")}</span>`}};nt=t([k(),e("permission-status-banner")],nt);let rt=class WaitingRoomLayout extends i{constructor(){super(...arguments),this.isWaitingRoom=!1}static{this.styles=o`.information-container{padding:var(--size-5) var(--size-4);background-color:var(--color-neutrals-background-disabled)}mq-page-title{margin-bottom:var(--size-4)}.content{max-width:560px;margin:0 auto}.information-container p{font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-neutrals-text-default);margin:0}.video-container{margin-left:auto;margin-right:auto;margin-bottom:var(--size-6);position:relative;max-height:301px;aspect-ratio:9/16;border-radius:16px;overflow:hidden}@media (min-width:768px){.information-container{background-color:transparent;padding:var(--size-6) 0}.video-container{max-height:454px;aspect-ratio:16/9}.information-container p{font-size:var(--text-base);line-height:var(--text-base--line-height)}}`}firstUpdated(){this.isWaitingRoom&&q.track(R(this.loginToken.patient.hash,this.appointment.id??""))}render(){if(!this.isWaitingRoom)return n`<slot></slot>`;const t=_()?.replace("_","-")??"es-ES",e=$(this.loginToken.patient.timezone),i=e?{timeZone:e}:{},o=new Intl.DateTimeFormat(t,{dateStyle:"short",...i}),r=new Intl.DateTimeFormat(t,{timeStyle:"short",...i}),a=new Date(this.appointment.start_date),l=E(a,this.appointment.duration),d=e?C(e,a):"",c=o.format(a),p=`${r.format(a)} - ${r.format(l)}${d?` (${d})`:""}`;return n`<permission-status-banner></permission-status-banner><div class="content"><div class="information-container"><mq-page-title .title="${x("Sala de espera")}" back-label="${x("Salir")}" @mq-back="${t=>{t.stopPropagation(),this.dispatchEvent(new z({tab:"next"}))}}"></mq-page-title><div class="doctor-info"><p>${this.appointment.from.name}</p><p>${c}</p><p>${p}</p></div></div><div class="video-container"><slot></slot></div>${!0===this.appointment.has_chat_in_appointment?n`<chat-cta .consultationId="${this.appointment.id}" .roomId="${Number(this.appointment.room_id)}" .professionalHash="${this.appointment.from.hash}" .text="${x("Utiliza el chat para enviar el motivo de consulta, documentos o imágenes")}" .onOpenChat="${()=>{q.track(I(this.loginToken.patient.hash,this.appointment.id??""))}}"></chat-cta>`:s}</div>`}};t([r({type:Object})],rt.prototype,"appointment",void 0),t([r({type:Boolean,attribute:"is-waiting-room"})],rt.prototype,"isWaitingRoom",void 0),t([d({context:O})],rt.prototype,"loginToken",void 0),rt=t([e("waiting-room-layout")],rt);class AppointmentCounterController{constructor(t,e){this.startsAtGetter=e,this.formattedTime="--:--",this.interval=null,this.host=t,t.addController(this)}async hostConnected(){this.interval=setInterval(()=>{const t=new Date,e=this.startsAtGetter(),i=t.getTime()-e.getTime(),o=Math.floor(i/1e3),s=Math.floor(o/60),n=o%60;this.formattedTime=`${s.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`,this.host.requestUpdate()},1e3)}hostDisconnected(){this.interval&&clearInterval(this.interval)}}class ToggleAudioEvent extends Event{static{this.eventName="toggle-audio"}constructor(t){super(ToggleAudioEvent.eventName,{bubbles:!0,composed:!0}),this.isAudioOn=t}}class ToggleVideoEvent extends Event{static{this.eventName="toggle-video"}constructor(t){super(ToggleVideoEvent.eventName,{bubbles:!0,composed:!0}),this.isVideoOn=t}}class ToggleChatEvent extends Event{static{this.eventName="toggle-chat"}constructor(t){super(ToggleChatEvent.eventName,{bubbles:!0,composed:!0}),this.isChatOpen=t}}class ViewDocumentationEvent extends Event{static{this.eventName="view-documentation"}constructor(){super(ViewDocumentationEvent.eventName,{bubbles:!0,composed:!0})}}class DownloadFileEvent extends Event{static{this.eventName="download-file"}constructor(t,e){super(DownloadFileEvent.eventName,{bubbles:!0,composed:!0}),this.url=t,this.filename=e}}let at=class PublisherControls extends i{constructor(){super(...arguments),this.isAudioOn=!1,this.isVideoOn=!0,this.isChatOpen=!1,this.chatEnabled=!1,this.isWaitingRoom=!1,this.unreadQuery=new D(this,()=>M(this.apiClient,{roomId:this.roomId}))}static{this.styles=o`:host{display:flex;justify-content:space-between;gap:var(--size-4)}:host([is-waiting-room]){justify-content:center}.left-controls{display:flex;gap:var(--size-4)}.control-button{border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;width:var(--size-10);height:var(--size-10);padding:var(--size-2);border-radius:12.5px;transition:all .2s ease-in-out}@media (min-width:768px){.control-button{width:var(--size-11);height:var(--size-11);padding:var(--size-2);border-radius:16px}}.control-button:hover{background-color:var(--color-gray-light)}.control-button:focus-visible{outline:0;box-shadow:0 0 0 2px var(--color-primary-light)}.control-button--on{background-color:var(--color-white);color:var(--color-primary)}.control-button--off{background-color:var(--color-white);color:var(--color-negative)}`}toggleAudio(){this.dispatchEvent(new ToggleAudioEvent(!this.isAudioOn))}toggleVideo(){this.dispatchEvent(new ToggleVideoEvent(!this.isVideoOn))}toggleChat(){this.dispatchEvent(new ToggleChatEvent(!this.isChatOpen))}render(){return n`<div class="left-controls">${this.isWaitingRoom||!this.chatEnabled?s:n`<button type="button" class="control-button control-button--on" @click="${this.toggleChat}">${A({size:20})} ${(this.unreadQuery.result?.data?.unread_count??0)>0?n`<mq-unread-badge></mq-unread-badge>`:s}</button>`} <button type="button" class="control-button ${this.isAudioOn?"control-button--on":"control-button--off"}" @click="${this.toggleAudio}">${this.isAudioOn?N({size:20}):U({size:20})}</button> <button type="button" class="control-button ${this.isVideoOn?"control-button--on":"control-button--off"}" @click="${this.toggleVideo}">${this.isVideoOn?P({size:20}):W({size:20})}</button></div>`}};t([d({context:p,subscribe:!0})],at.prototype,"apiClient",void 0),t([r({type:Boolean})],at.prototype,"isAudioOn",void 0),t([r({type:Boolean})],at.prototype,"isVideoOn",void 0),t([r({type:Boolean})],at.prototype,"isChatOpen",void 0),t([r({type:Boolean})],at.prototype,"chatEnabled",void 0),t([r({type:Boolean,reflect:!0,attribute:"is-waiting-room"})],at.prototype,"isWaitingRoom",void 0),t([r({type:Number})],at.prototype,"roomId",void 0),at=t([e("publisher-controls")],at);let lt=class VideoPublisher extends i{constructor(){super(...arguments),this.isWaitingRoom=!1,this.hasChatInAppointment=!1,this.appointmentCounterController=new AppointmentCounterController(this,()=>new Date(this.startsAt)),this.isAudioOn=!0,this.isVideoOn=!0,this.isChatOpen=!1,this._handleVisibilityChange=()=>{"visible"===document.visibilityState&&this.publisher&&(this.publisher.publishAudio(!1),this.publisher.publishVideo(!1),setTimeout(()=>{this.publisher?.publishAudio(this.isAudioOn),this.publisher?.publishVideo(this.isVideoOn)},500))}}static{this.styles=o`:host{width:100%;height:100%;display:block}.OT_video-element{width:100%;height:100%;background:var(--color-black)}.OT_mute{display:none}video{border-radius:var(--border-radius-lg)}#video-publisher{width:100%;height:100%;transition:width .5s ease-in-out,height .5s ease-in-out;border-radius:var(--border-radius-lg)}:host(:not([is-waiting-room])) #video-publisher{width:121px;height:200px;z-index:50;border-radius:12px;overflow:hidden}:host([is-waiting-room]) .top-items{position:absolute;inset:0}:host(:not([is-waiting-room])) .top-items{position:absolute;z-index:50;top:var(--size-4);left:var(--size-4);right:var(--size-4);display:flex;justify-content:space-between;gap:var(--size-1)}.meta-container{display:flex;align-items:flex-start;gap:var(--size-1);min-width:0}.meta-item{background-color:var(--color-neutrals-text-default);padding:var(--size-2) var(--size-3);color:var(--color-white);font-size:var(--text-xs);line-height:var(--text-xs--line-height);flex-shrink:0}.meta-item:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex-shrink:1;min-width:0}publisher-controls{position:absolute;z-index:50;bottom:var(--size-4);left:var(--size-4);right:var(--size-4)}mq-chat-room{height:100%}@media (min-width:768px){:host(:not([is-waiting-room])) #video-publisher{width:250px;height:auto;aspect-ratio:16/9}:host(:not([is-waiting-room])) .top-items{top:var(--size-6);left:var(--size-6);right:var(--size-6)}}`}firstUpdated(t){super.firstUpdated(t),this.publisher=this.openTokService.initPublisher(this.publisherEl,{fitMode:"contain",width:"100%",height:"100%",audioFallbackEnabled:!1,insertMode:"append",mirror:!1,publishAudio:this.isAudioOn,publishVideo:this.isVideoOn},t=>{t&&K.error("error initializing publisher",t),this.session.publish(this.publisher)}),document.addEventListener("visibilitychange",this._handleVisibilityChange)}disconnectedCallback(){document.removeEventListener("visibilitychange",this._handleVisibilityChange),super.disconnectedCallback(),this.publisher?.destroy()}async _handleToggleAudioEvent(t){this.isAudioOn=t.isAudioOn,this.publisher.publishAudio(t.isAudioOn)}async _handleToggleVideoEvent(t){this.isVideoOn=t.isVideoOn,this.publisher.publishVideo(t.isVideoOn)}async _handleToggleChatEvent(t){this.isChatOpen=t.isChatOpen}render(){return n`<div class="top-items">${this.isWaitingRoom?n`<div></div>`:n`<div class="meta-container"><span class="meta-item">${this.professionalName}</span> <span class="meta-item">${this.appointmentCounterController.formattedTime}</span></div>`}<div id="video-publisher"></div></div><publisher-controls .isAudioOn="${this.isAudioOn}" .isVideoOn="${this.isVideoOn}" .isChatOpen="${this.isChatOpen}" .chatEnabled="${this.hasChatInAppointment}" .roomId="${Number.parseInt(this.roomId,10)}" ?is-waiting-room="${this.isWaitingRoom}" @toggle-audio="${this._handleToggleAudioEvent}" @toggle-video="${this._handleToggleVideoEvent}" @toggle-chat="${this._handleToggleChatEvent}"></publisher-controls>${this.hasChatInAppointment?n`<mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" @mq-close="${()=>{this.isChatOpen=!1}}" hideCloseButton>${this.isChatOpen?n`<mq-chat-room slot="content" .consultationId="${this.consultationId}" .consultationType="${u.appointment}" token="${this.loginToken.access_token}" .roomId="${Number.parseInt(this.roomId,10)}" .professionalHash="${this.professionalHash}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room>`:s}</mq-floating-bubble>`:s}`}};t([r({type:String})],lt.prototype,"consultationId",void 0),t([r({type:String})],lt.prototype,"apiKey",void 0),t([r({type:String})],lt.prototype,"token",void 0),t([r({type:String})],lt.prototype,"roomId",void 0),t([r({type:String})],lt.prototype,"professionalHash",void 0),t([r({type:Object})],lt.prototype,"session",void 0),t([r({type:String})],lt.prototype,"professionalName",void 0),t([r({type:String})],lt.prototype,"startsAt",void 0),t([r({type:Boolean,reflect:!0,attribute:"is-waiting-room"})],lt.prototype,"isWaitingRoom",void 0),t([r({type:Boolean})],lt.prototype,"hasChatInAppointment",void 0),t([d({context:Y})],lt.prototype,"openTokService",void 0),t([d({context:O})],lt.prototype,"loginToken",void 0),t([L("#video-publisher")],lt.prototype,"publisherEl",void 0),t([f()],lt.prototype,"isAudioOn",void 0),t([f()],lt.prototype,"isVideoOn",void 0),t([f()],lt.prototype,"isChatOpen",void 0),lt=t([e("video-publisher")],lt);let dt=class VideoSubscriber extends i{constructor(){super(...arguments),this.isVideoOn=!0,this._subscriberProperties={fitMode:"contain",insertMode:"append",width:"100%",height:"100%"},this._handleVisibilityChange=()=>{"visible"===document.visibilityState&&this.subscriber&&(this.subscriber.subscribeToAudio(!1),this.subscriber.subscribeToVideo(!1),setTimeout(()=>{this.subscriber?.subscribeToAudio(!0),this.subscriber?.subscribeToVideo(!0)},500),setTimeout(()=>this._resubscribe(),600))}}static{this.styles=o`:host{position:absolute;inset:0}.OT_subscriber{width:100%;height:100%;position:absolute;inset:0;background:var(--color-neutrals-background-default)}video{width:100%;height:100%}.video-disabled{position:absolute;inset:0;background:var(--color-gray-dark)}.hidden{display:none}`}firstUpdated(){this._subscribe(),document.addEventListener("visibilitychange",this._handleVisibilityChange)}_subscribe(){this.subscriber=this.openTokService.subscribe(this.session,this.stream,this.subscriberEl,this._subscriberProperties,t=>{}),this._attachSubscriberEvents()}_attachSubscriberEvents(){this.subscriber.on("connected",t=>{this.isVideoOn=t.target.stream?.hasVideo??!0}),this.subscriber.on("videoDisabled",()=>{this.isVideoOn=!1}),this.subscriber.on("videoEnabled",()=>{this.isVideoOn=!0}),this.subscriber.on("disconnected",()=>{this.isVideoOn=!1})}_resubscribe(){if(this.subscriber&&this.session&&this.subscriberEl){try{this.session.unsubscribe(this.subscriber)}catch{}this.subscriberEl.innerHTML="",this._subscribe()}}disconnectedCallback(){if(document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.subscriber&&this.session)try{this.session.unsubscribe(this.subscriber)}catch{}super.disconnectedCallback()}render(){return n`<div id="video-subscriber" class="${this.isVideoOn?"":"hidden"}"></div>${this.isVideoOn?n``:n`<div class="video-disabled"></div>`}`}};t([r({type:Object})],dt.prototype,"session",void 0),t([r({type:Object})],dt.prototype,"stream",void 0),t([f()],dt.prototype,"isVideoOn",void 0),t([d({context:Y})],dt.prototype,"openTokService",void 0),t([L("#video-subscriber")],dt.prototype,"subscriberEl",void 0),dt=t([e("video-subscriber")],dt);let ct=class VideocallContent extends i{constructor(){super(...arguments),this.streams=[],this.isWaitingRoom=!1,this.isReconnecting=!1}static{this.styles=o`:host{display:block;position:relative;width:100%;height:100%;background:var(--color-gray-darkest);aspect-ratio:16/9}.reconnecting-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--size-3);background:rgba(0,0,0,.6);z-index:100}.reconnecting-overlay__text{color:var(--color-white);font-size:var(--text-sm);line-height:var(--text-sm--line-height)}.reconnecting-overlay__subtitle{color:var(--color-white);font-size:var(--text-xs);line-height:var(--text-xs--line-height);opacity:.85}`}firstUpdated(){this.isWaitingRoom||q.track(V(this.loginToken.patient.hash,this.appointment.id??""))}updated(t){t.has("isWaitingRoom")&&!0===t.get("isWaitingRoom")&&!this.isWaitingRoom&&q.track(V(this.loginToken.patient.hash,this.appointment.id??""))}render(){return n`<video-publisher .consultationId="${this.appointment.id}" .session="${this.session}" ?is-waiting-room="${this.isWaitingRoom}" .professionalName="${this.appointment.from.name??""}" .professionalHash="${this.appointment.from.hash}" .startsAt="${this.appointment.started_at??(new Date).toISOString()}" .apiKey="${this.apiKey}" .token="${this.token}" .roomId="${this.appointment.room_id}" .hasChatInAppointment="${!0===this.appointment.has_chat_in_appointment}"></video-publisher>${0===this.streams.length?n``:this.streams.map(t=>n`<video-subscriber .session="${this.session}" .stream="${t}"></video-subscriber>`)} ${this.isReconnecting?n`<div class="reconnecting-overlay">${a({color:"var(--color-white)"})} <span class="reconnecting-overlay__text">${x("Reconectando...")} </span><span class="reconnecting-overlay__subtitle">${x("Espere mientras se restablece la conexión")}</span></div>`:""}`}};t([r({type:Object})],ct.prototype,"session",void 0),t([r({type:Array})],ct.prototype,"streams",void 0),t([r({type:String})],ct.prototype,"apiKey",void 0),t([r({type:String})],ct.prototype,"token",void 0),t([r({type:Object})],ct.prototype,"appointment",void 0),t([r({type:Boolean,reflect:!0,attribute:"is-waiting-room"})],ct.prototype,"isWaitingRoom",void 0),t([r({type:Boolean,reflect:!0,attribute:"is-reconnecting"})],ct.prototype,"isReconnecting",void 0),t([d({context:O})],ct.prototype,"loginToken",void 0),ct=t([k(),e("mq-videocall-content")],ct);class ReviewSubmittedEvent extends Event{static{this.eventName="review-submitted"}constructor(){super(ReviewSubmittedEvent.eventName,{bubbles:!0,composed:!0})}}class ReviewSkippedEvent extends Event{static{this.eventName="review-skipped"}constructor(){super(ReviewSkippedEvent.eventName,{bubbles:!0,composed:!0})}}let pt=class ReviewView extends i{constructor(){super(...arguments),this.rating=0,this.comment="",this._reviewMutation=new F(this,{mutationFn:({rating:t,comment:e})=>this.apiClient.consultations.postReview({consultation_id:this.appointment.id??"",consultation_type:u.appointment,rating:t,comment:e.trim()?e.trim():null}),onSuccess:()=>{this.dispatchEvent(new ReviewSubmittedEvent)},onError:t=>{!function(t){const e=t,i=e?.response?.status;return 400===i&&/already exists/i.test(e?.response?.data?.message??"")}(t)?H.error(x("No se ha podido enviar el cuestionario")):this.dispatchEvent(new ReviewSubmittedEvent)}}),this._reconnectMutation=new F(this,{mutationFn:t=>this.apiClient.appointments.reconnectAppointment(t),onSuccess:()=>{this.dispatchEvent(new CustomEvent("review-reconnect",{bubbles:!0,composed:!0}))},onError:()=>{H.error(x("No se ha podido volver a la sala de espera"))}}),this.handleSkip=()=>{this.dispatchEvent(new ReviewSkippedEvent)},this.handleSubmit=()=>{this.rating<1||this.rating>5||this._reviewMutation.isPending||this._reviewMutation.run({rating:this.rating,comment:this.comment})}}static{this.styles=o`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100%;background-color:var(--color-background);box-sizing:border-box}.container{width:100%;max-width:500px;padding:var(--sp-6);display:flex;flex-direction:column;gap:var(--sp-5);box-sizing:border-box}.title{margin:0;padding:0 var(--sp-6);font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-normal);color:var(--color-primary);text-align:center}.rating{display:flex;flex-direction:column;align-items:center;gap:var(--sp-2);padding:var(--sp-1) var(--sp-6)}.subtitle{margin:0;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-text-icons--secondary);text-align:center}.comment-card{background-color:var(--color-white);border:var(--action-border-width) solid var(--color-border);border-radius:var(--border-radius-lg);box-shadow:0 4px 4px rgba(0,0,0,.05);padding:var(--sp-5);display:flex;flex-direction:column;gap:var(--sp-5)}.comment-header{display:flex;justify-content:space-between;align-items:flex-start;gap:var(--sp-3)}.comment-label{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm);font-weight:var(--font-weight-medium);color:var(--color-neutrals-text-default)}.comment-counter{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-text-icons--secondary);white-space:nowrap}.textarea{width:100%;box-sizing:border-box;height:var(--size-44);padding:var(--sp-3) var(--sp-4);background-color:var(--color-gray-lighter);border:var(--action-border-width) solid var(--color-border);border-radius:var(--border-radius-md);font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);resize:none}.textarea::placeholder{color:var(--color-text-icons--secondary);opacity:.6}.textarea:focus{outline:0;border-color:var(--color-primary)}.actions{display:flex;gap:var(--sp-4)}.btn{flex:1;height:var(--button-height-md);padding:var(--sp-2) var(--sp-4);border-radius:var(--border-radius-md);font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);cursor:pointer;transition:opacity .15s ease-in-out}.btn:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.btn:disabled{cursor:not-allowed}.btn-skip{background:var(--color-white);border:var(--action-border-width) solid var(--color-primary);color:var(--color-primary)}.btn-skip:hover:not(:disabled){background:var(--color-primary-background-extraWeak)}.btn-submit{background:var(--color-primary);border:var(--action-border-width) solid var(--color-primary);color:var(--color-white)}.btn-submit:hover:not(:disabled){background:var(--color-primary-dark)}.btn-submit:disabled{opacity:.5}.waiting-card{background-color:var(--color-background-primary-light);border-radius:var(--border-radius-lg);padding:var(--sp-4);display:flex;flex-direction:column;gap:var(--sp-2)}.waiting-header{display:flex;align-items:center;gap:var(--sp-2);color:var(--color-neutrals-text-default)}.waiting-title{font-family:var(--font-body);font-size:var(--text-xs);line-height:1;font-weight:var(--font-weight-medium);color:var(--color-neutrals-text-default)}.waiting-body{margin:0;font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);color:var(--color-text-icons--secondary)}.waiting-link{background:0 0;border:0;padding:0;cursor:pointer;color:#3c50ec;font:inherit;text-decoration:none}.waiting-link:hover{text-decoration:none}.waiting-link:disabled{cursor:not-allowed;opacity:.6}`}render(){return n`<div class="container"><h1 class="title">${x("¿Qué tal ha ido tu cita?")}</h1><div class="rating"><mq-rating .value="${this.rating}" .label="${x("Valoración de la consulta")}" @mq-rating-change="${t=>{this.rating=t.value}}"></mq-rating><p class="subtitle">${x("(1 es muy malo, 5 es excelente)")}</p></div><div class="comment-card"><div class="comment-header"><span class="comment-label">${x("¿Tienes comentarios sobre la consulta?")}</span> <span class="comment-counter">${this.comment.length}/${240}</span></div><textarea class="textarea" maxlength="${240}" placeholder="${x("Comparte cómo fue la atención o si tuviste algún problema con la videollamada…")}" .value="${this.comment}" @input="${t=>{this.comment=t.target.value}}"></textarea><div class="actions"><button type="button" class="btn btn-skip" ?disabled="${this._reviewMutation.isPending}" @click="${this.handleSkip}">${x("Omitir")}</button> <button type="button" class="btn btn-submit" ?disabled="${this.rating<1||this._reviewMutation.isPending}" @click="${this.handleSubmit}">${x("Enviar")}</button></div></div><div class="waiting-card"><div class="waiting-header">${B({color:"currentColor",size:18})} <span class="waiting-title">${x("¿Ocurrió algún problema?")}</span></div><p class="waiting-body">${x("Si la cita no se ha podido realizar, puedes")} <button type="button" class="waiting-link" ?disabled="${this._reconnectMutation.isPending}" @click="${()=>this._reconnectMutation.run({appointmentId:this.appointment.id})}">${x("volver a la sala de espera.")}</button></p></div></div>`}};t([d({context:p,subscribe:!0})],pt.prototype,"apiClient",void 0),t([r({type:Object})],pt.prototype,"appointment",void 0),t([f()],pt.prototype,"rating",void 0),t([f()],pt.prototype,"comment",void 0),pt=t([k(),e("review-view")],pt);let ht=class ErrorView extends i{static{this.styles=o`.container{display:grid;place-items:center;width:100%;max-width:447px;margin:0 auto}.card>:not(:first-child){margin-top:var(--size-8)}.title{font-family:var(--font-titles);color:var(--color-neutrals-text-default);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0;margin-bottom:var(--size-3)}.description{color:var(--color-neutrals-text-default);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:400}`}render(){return n`<div class="container"><div class="card"><slot name="icon"></slot><div class="content"><h1 class="title">${this.title}</h1><p class="description">${this.message}</p></div></div></div>`}};t([r({type:String})],ht.prototype,"title",void 0),t([r({type:String})],ht.prototype,"message",void 0),ht=t([e("error-view")],ht);let mt=class UnexpectedErrorView extends i{render(){return n`<error-view .title="${x("Error desconocido")}" .message="${x("Ha ocurrido un error al cargar la página. Por favor, intenta nuevamente o contacta al soporte.")}"><div slot="icon">${Q()}</div></error-view>`}};mt=t([k(),e("unexpected-error-view")],mt);let ut=class ExpiredAppointmentErrorView extends i{render(){return n`<error-view .title="${x("Consulta caducada")}" .message="${x("Parece que no te hemos encontrado a la hora de tu cita. Puedes programar otra consulta para resolver tus dudas.")}"><div slot="icon">${G()}</div></error-view>`}};ut=t([k(),e("expired-appointment-error-view")],ut);let vt=class NotFoundErrorView extends i{static{this.styles=o`div{display:flex;flex-direction:column;gap:2px}span{font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:400;color:var(--color-gray-medium)}`}render(){return n`<error-view .title="${x("Página no encontrada")}" .message="${x("La página que estás buscando fue removida, renombrada o puede que no exista.")}"><div slot="icon"><span>404</span> ${Q()}</div></error-view>`}};function gt(t){try{return function(t,e){if("string"!=typeof t)throw new InvalidTokenError("Invalid token specified: must be a string");e||(e={});const i=!0===e.header?0:1,o=t.split(".")[i];if("string"!=typeof o)throw new InvalidTokenError(`Invalid token specified: missing part #${i+1}`);let s;try{s=J(o)}catch(t){throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${i+1} (${t.message})`)}try{return JSON.parse(s)}catch(t){throw new InvalidTokenError(`Invalid token specified: invalid json for part #${i+1} (${t.message})`)}}(t)}catch{return null}}vt=t([k(),e("not-found-error-view")],vt);let bt=class MqVideocallProvider extends i{static{this.styles=o`*{box-sizing:border-box}:host{display:block;margin:0 auto;width:100%;height:100%}.centered{display:grid;place-items:center;height:100%;min-height:var(--mq-container-min-height)}documentation-view{display:block;padding:var(--sp-4)}`}constructor(){super(),this.apiClient=v(),this.opentokService=new OpenTokService,this.params={appointmentId:this.appointmentId,token:this.token,apiKey:this.apiKey},this.appointmentTask=new c(this,{task:async([t,,])=>{const[e,i,o]=await Promise.all([this.apiClient.flash.getAppointment({appointmentId:t}),this.apiClient.consultations.getReview(t).then(()=>!0).catch(()=>!1),this.apiClient.organizations.getOrganizationSetup().catch(()=>{})]);return{appointment:e,hasReview:i,hasNps:!0===o?.appointments?.has_nps}},args:()=>[this.appointmentId,this.apiKey,this.token]})}willUpdate(t){const e=g(t,{apiKey:this.apiKey,token:this.token},this.inheritedApiClient);if(e&&(this.apiClient=e),this.appointmentTask.value&&!this.opentokController){const{appointment:t,hasReview:e,hasNps:i}=this.appointmentTask.value,o=function(t,e){return h(t)?t.status===m.finished||t.status===m.reporting?e?ot:et:X:it}(t,i);this.screen=o===ot&&e?et:o,this.params={appointmentId:this.appointmentId,token:this.token,apiKey:this.apiKey},this.opentokController=new OpenTokController(this,this.apiClient,t,this.token,()=>{this.screen=tt},()=>{this.screen=!i||e?et:ot})}}render(){const t=n`<div class="centered">${a({color:"var(--color-primary)"})}</div>`,e=n`<mq-layout background="transparent"><not-found-error-view></not-found-error-view></mq-layout>`;return this.appointmentTask.render({pending:()=>t,error:t=>{const i=gt(this.token);return i?.exp&&i.exp<Date.now()/1e3?n`<mq-layout background="transparent"><expired-appointment-error-view></expired-appointment-error-view></mq-layout>`:b(t)&&t.response?.status&&t.response.status<500?e:n`<mq-layout background="transparent"><unexpected-error-view></unexpected-error-view></mq-layout>`},complete:({appointment:i,hasNps:o})=>{if(this.opentokController?.isLoading)return t;if(this.opentokController?.errorMessage||!this.opentokController)return e;if(this.screen===it)return n`<mq-layout background="transparent"><not-time-yet-view .appointment="${i}"></not-time-yet-view></mq-layout>`;if(this.screen===ot)return n`<mq-layout background="transparent"><review-view .appointment="${i}" @review-submitted="${()=>{this.screen=et}}" @review-skipped="${()=>{this.screen=et}}" @review-reconnect="${()=>{this.screen=X}}"></review-view></mq-layout>`;if(this.screen===et)return n`<mq-layout background="transparent"><documentation-view .appointment="${i}" .token="${this.token}" ?can-reconnect="${!o}" @reconnect="${()=>{this.screen=X}}"></documentation-view></mq-layout>`;if(this.screen===X||this.screen===tt){const e=this.opentokController.session;return e?n`<waiting-room-layout .appointment="${i}" ?is-waiting-room="${this.screen===X}"><mq-videocall-content .apiKey="${this.apiKey}" .token="${this.token}" .session="${e}" .streams="${this.opentokController?.streams??[]}" ?is-waiting-room="${this.screen===X}" ?is-reconnecting="${this.opentokController.isReconnecting}" .appointment="${i}"></mq-videocall-content></waiting-room-layout>`:t}return n`<mq-layout background="transparent"><unexpected-error-view></unexpected-error-view></mq-layout>`}})}};t([r({type:String,attribute:"appointment-id"})],bt.prototype,"appointmentId",void 0),t([r({type:String,attribute:"api-key"})],bt.prototype,"apiKey",void 0),t([r({type:String})],bt.prototype,"token",void 0),t([d({context:p,subscribe:!0}),f()],bt.prototype,"inheritedApiClient",void 0),t([l({context:p}),f()],bt.prototype,"apiClient",void 0),t([f()],bt.prototype,"screen",void 0),t([l({context:Y})],bt.prototype,"opentokService",void 0),t([l({context:Z})],bt.prototype,"params",void 0),bt=t([e("mq-videocall-provider")],bt);let ft=class PermissionsRequiredErrorView extends i{static{this.styles=o`.img-container{display:flex;justify-content:center}img{width:100%;height:auto;max-width:229px}`}render(){return n`<error-view .title="${x("Acepta los permisos de cámara y micrófono")}" .message="${x("Parece que has denegado los permisos necesarios para entrar a la videollamada. Edita los permisos en tu navegador para entrar. Una vez concedidos, debes refrescar esta pantalla.")}"><div class="img-container" slot="icon"><img src="${`${w.ASSETS_BASE_URL}/wc-videocall/Miccam_asset.png`}" alt="Miccam_asset" width="229" height="166.44"></div></error-view>`}};ft=t([k(),e("permissions-required-error-view")],ft);let yt=class MqVideocall extends i{constructor(){super(...arguments),this._permissionController=new PermissionController(this)}static{this.styles=o`:host{display:block;width:100%;height:100%}.loading-spinner-container{height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center}.permissions-required-error-view-container{height:100%;padding-left:var(--size-4);padding-right:var(--size-4);display:grid;place-items:center}`}render(){return"prompt"===this._permissionController.state?n`<div class="loading-spinner-container">${a({color:"var(--color-primary)"})}</div>`:"denied"===this._permissionController.state?n`<div class="permissions-required-error-view-container"><permissions-required-error-view></permissions-required-error-view></div>`:n`<mq-videocall-provider .appointmentId="${this.appointmentId}" .token="${this.token}" .apiKey="${this.apiKey}"></mq-videocall-provider>`}};t([r({type:String,attribute:"appointment-id"})],yt.prototype,"appointmentId",void 0),t([r({type:String,attribute:"api-key"})],yt.prototype,"apiKey",void 0),t([r({type:String})],yt.prototype,"token",void 0),yt=t([e("mq-videocall")],yt);export{DownloadFileEvent as D,yt as M,ReviewSkippedEvent as R,ToggleAudioEvent as T,ViewDocumentationEvent as V,ReviewSubmittedEvent as a,ToggleChatEvent as b,ToggleVideoEvent as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./chunk-6CCJWPGL-TiaqZaPV.js";import{D as t}from"./chunk-5EJXDIGT-Bb4_pfDr.js";import{_ as i,c as n}from"./custom-element-D2ziPxYE.js";import{c as o}from"./consume-CovVqBjI.js";import{m as a,s}from"./runtime-Bg1WXVCx.js";import{l as r}from"./localized-decorator-BlOuLhym.js";import{Q as l}from"./query-controller-B1byDHlF.js";import{A as p}from"./api-client-context-BXGqBAlO.js";import{l as c}from"./chunk-S5RWG6G2-CQJ38pW6.js";import{d,e as m}from"./api-chat-client-3tgSK-oL.js";import{g as h,a as u}from"./chunk-2TKJJNS7-DzhxHWWb.js";import{g}from"./get-organization-setup-query-De7eM6V3.js";import{g as f,t as v,f as b,i as y,j as $,k as x,a as C}from"./telemetry-client-dwDzxn9N.js";import{g as w}from"./chunk-Y4EKUX25-Bix9r5ry.js";import{c as k}from"./refund-cancel-policy-C_9LyN_y.js";import{a as q,i as j,x as O,E as M}from"./lit-element-DiWJYFwC.js";import{n as z}from"./property-scuRaFcM.js";import{r as E}from"./state-LQivXIgA.js";import{MqAppointmentJoinVideocallEvent as S,MqAppointmentRescheduleEvent as I}from"../events.js";import{getLocale as D}from"../i18n.js";import{calendarIcon as R}from"../ui/icons/calendar-icon.js";import{dotsHorizontalIcon as _}from"../ui/icons/dots-horizontal-icon.js";import{messageBubbleIcon as A}from"../ui/icons/message-bubble-icon.js";import{phoneIcon as T}from"../ui/icons/phone-icon.js";import{videoIcon as P}from"../ui/icons/video-icon.js";import"./mq-chat-room-3PU4Fsub.js";import"../ui/mq-button.js";import"../ui/mq-dialog.js";import{Q as U}from"./chunk-RCFIJTXZ-C6Ir0-sM.js";import{M as L}from"./mutation-controller-CR2qcqhH.js";import{h as N,f as H}from"./price-DU3YLTpk.js";import"./professional-overview-B4E05rLd.js";import"../ui/mq-floating-bubble.js";import"../ui/mq-unread-badge.js";import{toast as Q}from"../ui/mq-toast.js";function J(i,n){return{queryKey:e(i,"appointments",n),queryFn:()=>i.appointments.getAppointments(n),staleTime:t}}function F(e){const{action:t,refundPolicySeconds:i}=e,n=null!=i&&i<3600,o=Math.ceil((i??0)/60),r=Math.ceil((i??0)/3600);return a(0===(n?o:r)?"modify"===t?"Esta cita ya ha pasado, por lo que no se puede modificar.":"Esta cita ya ha pasado, por lo que no se puede anular.":"modify"===t?n?s`Lo sentimos, como faltan menos de ${o} minutos para tu cita no podemos modificarla.`:s`Lo sentimos, como faltan menos de ${r} horas para tu cita no podemos modificarla.`:n?s`Lo sentimos, como faltan menos de ${o} minutos para tu cita no podemos anularla.`:s`Lo sentimos, como faltan menos de ${r} horas para tu cita no podemos anularla.`)}let K=class AppointmentActionUnavailableDialog extends q{constructor(){super(...arguments),this.open=!1,this.heading="",this.message="",this.handleClose=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}}static{this.styles=j`:host{display:contents}mq-dialog::part(dialog){max-width:343px;min-width:0}h2{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0}p{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}.actions{display:flex;margin-top:var(--sp-4)}`}render(){return O`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${this.heading}</h2><p slot="subheading">${this.message}</p><div class="actions"><mq-button variant="primary" fullwidth @click="${this.handleClose}">${a("Volver")}</mq-button></div></mq-dialog>`}};i([z({type:Boolean,reflect:!0})],K.prototype,"open",void 0),i([z({type:String})],K.prototype,"heading",void 0),i([z({type:String})],K.prototype,"message",void 0),K=i([r(),n("appointment-action-unavailable-dialog")],K);let V=class CancelAppointmentConfirmationDialog extends q{constructor(){super(...arguments),this.open=!1,this.cancelAppointmentMutation=new L(this,{mutationFn:async e=>this.apiClient.appointments.cancelAppointment(e),onSuccess:()=>{this.queryClientContext?.invalidateQueries({queryKey:e(this.apiClient)}),this.dispatchEvent(new CustomEvent("success",{bubbles:!0,composed:!0}))}}),this.handleClose=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},this.handleDismissClick=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},this.handleConfirmClick=()=>{this.cancelAppointmentMutation.run({id:this.appointmentId})}}static{this.styles=j`:host{display:contents}h2{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0}p{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}.subheading-payable{font-size:var(--text-base);line-height:22px}.price-rows{display:flex;flex-direction:column;font-family:var(--font-body);font-size:var(--text-sm);font-weight:var(--font-weight-medium);line-height:var(--text-sm--line-height);color:var(--color-card-foreground);width:100%;margin-bottom:var(--sp-4)}.price-row{display:flex;align-items:center;justify-content:space-between;min-height:34px;gap:var(--sp-2)}.price-row span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.actions{display:flex;gap:var(--sp-3);margin-top:var(--sp-4);justify-content:flex-end;flex-wrap:wrap}`}render(){const e=D(),t=this.price,i=N(t),n=this.cancelAppointmentMutation.isPending;if(i){const i=H(t,e),o=`-${i}`;return O`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${a("Confirmar cancelación")}</h2><p slot="subheading" class="subheading-payable">${a("¿Seguro que quieres cancelar esta cita? Se te devolverá el importe pagado en un plazo de 5-10 días hábiles.")}</p><div><div class="price-rows"><div class="price-row"><span>${a("Importe pagado")}</span> <span>${i}</span></div><div class="price-row"><span>${a("Importe a devolver")}</span> <span>${o}</span></div></div><div class="actions"><mq-button variant="outline" ?disabled="${n}" @click="${this.handleDismissClick}">${a("Volver")}</mq-button><mq-button variant="primary" ?disabled="${n}" @click="${this.handleConfirmClick}">${a("Confirmar")}</mq-button></div></div></mq-dialog>`}return O`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${a("Confirmar cancelación")}</h2><p slot="subheading">${a("¿Seguro que quieres cancelar esta cita?")}</p><div><div class="actions"><mq-button variant="outline" ?disabled="${n}" @click="${this.handleDismissClick}">${a("Cancelar")}</mq-button><mq-button variant="primary" ?disabled="${n}" @click="${this.handleConfirmClick}">${a("Confirmar")}</mq-button></div></div></mq-dialog>`}};i([o({context:p,subscribe:!0})],V.prototype,"apiClient",void 0),i([z({type:Boolean,reflect:!0})],V.prototype,"open",void 0),i([o({context:U,subscribe:!0})],V.prototype,"queryClientContext",void 0),i([z({type:String})],V.prototype,"appointmentId",void 0),i([z({type:Object})],V.prototype,"price",void 0),V=i([r(),n("cancel-appointment-confirmation-dialog")],V);const B=j`:host{display:flex;flex-direction:column;justify-content:space-between;gap:var(--sp-6);flex:1;width:100%;min-width:0;box-sizing:border-box;color:var(--color-text-icons--primary,#0a0a22)}professional-overview{--avatar-size-lg:66px;--text-lg--line-height:1.35;display:block}.details{display:flex;flex-direction:column;align-items:flex-start;gap:var(--sp-3)}.detail-row{display:inline-flex;align-items:center;gap:var(--sp-2);font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;font-weight:var(--font-weight-normal)}.detail-row svg{flex-shrink:0}.detail-row span::first-letter{text-transform:uppercase}.footer{display:flex;flex-direction:column;gap:var(--sp-4)}.reminder{font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;font-weight:var(--font-weight-normal);color:var(--color-text-icons--secondary,#6d658b);margin:0}.actions{--button-height-md:2.75rem;display:flex;align-items:stretch;gap:10px}.actions>mq-button{flex:1;min-width:0}.overflow{position:relative;flex:0 0 auto}.chat-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-badge{--mq-unread-badge-size:8px;flex-shrink:0}@media (max-width:767px){.actions{flex-wrap:wrap}.actions>mq-button.join{order:1;flex:1 0 100%}}.menu{position:absolute;right:0;bottom:calc(100% + var(--sp-2));z-index:2;display:flex;flex-direction:column;min-width:176px;padding:var(--sp-1);background-color:var(--color-card,#fff);border:1px solid var(--color-border-subtle,#edecf1);border-radius:var(--border-radius-lg);box-shadow:var(--shadow-lg)}.menu-item{display:block;width:100%;background:0 0;border:none;border-radius:var(--border-radius-sm);padding:var(--sp-2) var(--sp-3);cursor:pointer;text-align:left;font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;color:var(--color-text-icons--primary,#0a0a22)}.menu-item:hover{background-color:var(--color-muted)}.menu-item.negative{color:var(--color-negative)}`;let G=class NextAppointmentCard extends q{constructor(){super(...arguments),this.token="",this.patientHash="",this.isChatOpen=!1,this.isMenuOpen=!1,this.isCancelDialogOpen=!1,this.openDialog=null,this.getUnreadMessagesQuery=new l(this,()=>({...w(this.apiClient,{roomId:this.appointmentResource?.room?.id}),enabled:!!this.appointmentResource?.room?.id})),this.getOrganizationSetupQuery=new l(this,()=>g(this.apiClient)),this.getOrganizationSpecialtiesQuery=new l(this,()=>f(this.apiClient,{enabled:!!this.appointmentResource?.speciality?.id})),this.closeMenuOnOutsideClick=e=>{e.composedPath().includes(this)||(this.isMenuOpen=!1)},this.closeMenuOnEscape=e=>{"Escape"===e.key&&(this.isMenuOpen=!1)},this.handleJoinVideocall=()=>{v.track(b(this.sessionPatientHash,this.appointmentId)),this.dispatchEvent(new S({appointmentId:this.appointmentId}))},this.handleToggleChat=()=>{this.isChatOpen=!this.isChatOpen,this.isChatOpen&&v.track(y(this.sessionPatientHash,this.appointmentId))},this.handleModify=()=>{this.isMenuOpen=!1,this.isModifyUnavailable?this.openDialog="modify":(v.track($(this.sessionPatientHash,this.appointmentId)),this.dispatchEvent(new I({appointmentId:this.appointmentId})))},this.handleCancel=()=>{this.isMenuOpen=!1,this.isCancelUnavailable?this.openDialog="cancel":(v.track(x(this.sessionPatientHash,this.appointmentId)),this.isCancelDialogOpen=!0)}}static{this.styles=B}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.closeMenuOnOutsideClick),document.addEventListener("keydown",this.closeMenuOnEscape)}disconnectedCallback(){document.removeEventListener("click",this.closeMenuOnOutsideClick),document.removeEventListener("keydown",this.closeMenuOnEscape),super.disconnectedCallback()}get appointmentId(){return this.appointmentResource.appointment.id??""}get channel(){return this.appointmentResource.appointment.channel}get sessionToken(){return this.token||this.loginToken?.access_token||""}get sessionPatientHash(){return this.patientHash||this.loginToken?.patient?.hash||""}get sessionTimezone(){return this.timezone??this.loginToken?.patient?.timezone}get unreadCount(){return this.getUnreadMessagesQuery.result?.data?.unread_count??0}get specialtyName(){const e=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>Number(e.id)===Number(this.appointmentResource.speciality?.id));return C(e?.code??"",D(),e?.name??this.appointmentResource.speciality?.name)}get hasChatSupport(){return this.appointmentResource.appointment.has_chat_in_appointment??this.getOrganizationSetupQuery.result?.data?.appointments?.has_chat_in_appointment??!1}get isExpired(){return d(this.appointmentResource.appointment.expires_at)}get refundPolicySeconds(){return this.getOrganizationSetupQuery.result?.data?.appointments?.seconds_before_start_to_refund_on_cancel}get policyAllowsModifyOrCancel(){return k({startsAtIso:this.appointmentResource.appointment.starts_at,refundPolicySeconds:this.refundPolicySeconds})}get isModifyUnavailable(){return this.isExpired||0===this.appointmentResource.slots.length||!this.policyAllowsModifyOrCancel}get isCancelUnavailable(){return this.isExpired||!this.policyAllowsModifyOrCancel}get modifyUnavailableMessage(){return F({action:"modify",refundPolicySeconds:this.refundPolicySeconds})}get cancelUnavailableMessage(){return F({action:"cancel",refundPolicySeconds:this.refundPolicySeconds})}channelIcon(){switch(this.channel){case m.videocall:return P({size:20});case m.phonecall:return T({size:20});default:return A({size:20})}}channelLabel(){switch(this.channel){case m.videocall:return a("Videoconsulta");case m.phonecall:return a("Consulta telefónica");default:return a("Chat")}}formatWhen(){const e=D().replace("_","-"),t=h(this.sessionTimezone),i=t?{timeZone:t}:{},n=new Date(this.appointmentResource.appointment.starts_at);if(Number.isNaN(n.getTime()))return"";const o=new Intl.DateTimeFormat(e,{weekday:"long",day:"numeric",month:"long",year:"numeric",...i}).format(n),r=new Intl.DateTimeFormat(e,{timeStyle:"short",hourCycle:"h23",...i}).format(n),l=t?u(t,n):"";return a(s`${o}, ${r} h${l?` (${l})`:""}`)}renderActions(){const e=this.channel===m.videocall;return O`<div class="actions">${this.hasChatSupport?O`<mq-button variant="outline" @click="${this.handleToggleChat}"><span class="chat-label">${a("Ir a chat")}</span> ${this.unreadCount>0?O`<mq-unread-badge class="chat-badge"></mq-unread-badge>`:M}</mq-button>`:M} ${e?O`<mq-button class="join" variant="primary" @click="${this.handleJoinVideocall}">${a("Unirse a la videoconsulta")}</mq-button>`:M}<div class="overflow"><mq-button variant="outline" size="icon-lg" aria-label="${a("Más opciones")}" aria-haspopup="menu" aria-expanded="${this.isMenuOpen}" @click="${()=>{this.isMenuOpen=!this.isMenuOpen}}">${_({size:16})}</mq-button>${this.isMenuOpen?O`<div class="menu" role="menu"><button class="menu-item" type="button" role="menuitem" @click="${this.handleModify}">${a("Modificar cita")}</button> <button class="menu-item negative" type="button" role="menuitem" @click="${this.handleCancel}">${a("Anular cita")}</button></div>`:M}</div></div>`}render(){const{professional:e}=this.appointmentResource,t=this.formatWhen();return O`<professional-overview .name="${e.name}" .specialtyName="${this.specialtyName}" .collegiateNumber="${e.collegiate_number??void 0}" .description="${e.description??""}" .languages="${e.languages??[]}" .avatar="${e.avatar??""}"></professional-overview><div class="details">${t?O`<div class="detail-row">${R({size:20})} <span>${t}</span></div>`:M}<div class="detail-row">${this.channelIcon()} <span>${this.channelLabel()}</span></div></div><div class="footer"><p class="reminder">${a("Recibirás un recordatorio 15 minutos antes de la consulta")}</p>${this.renderActions()}</div><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" hideCloseButton @mq-close="${()=>{this.isChatOpen=!1}}">${this.isChatOpen?O`<mq-chat-room slot="content" .consultationId="${this.appointmentResource.appointment.id}" consultation-type="appointment" token="${this.sessionToken}" .roomId="${this.appointmentResource.room.id}" .professionalHash="${e.hash}" ?readonly="${this.isExpired}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room>`:M}</mq-floating-bubble><appointment-action-unavailable-dialog .open="${"modify"===this.openDialog}" .heading="${a("Modificar cita")}" .message="${this.modifyUnavailableMessage}" @close="${()=>{this.openDialog=null}}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"cancel"===this.openDialog}" .heading="${a("Anular cita")}" .message="${this.cancelUnavailableMessage}" @close="${()=>{this.openDialog=null}}"></appointment-action-unavailable-dialog><cancel-appointment-confirmation-dialog .appointmentId="${this.appointmentResource.appointment.id}" .price="${this.appointmentResource.price??void 0}" .open="${this.isCancelDialogOpen}" @cancel="${()=>{this.isCancelDialogOpen=!1}}" @success="${()=>{this.isCancelDialogOpen=!1,Q.success(a("Consulta anulada correctamente")),this.dispatchEvent(new CustomEvent("appointment-cancel-confirmed",{bubbles:!0,composed:!0,detail:{id:this.appointmentId}}))}}"></cancel-appointment-confirmation-dialog>`}};i([o({context:p,subscribe:!0})],G.prototype,"apiClient",void 0),i([o({context:c,subscribe:!0})],G.prototype,"loginToken",void 0),i([z({type:Object})],G.prototype,"appointmentResource",void 0),i([z({type:String})],G.prototype,"token",void 0),i([z({type:String})],G.prototype,"patientHash",void 0),i([z({type:String})],G.prototype,"timezone",void 0),i([E()],G.prototype,"isChatOpen",void 0),i([E()],G.prototype,"isMenuOpen",void 0),i([E()],G.prototype,"isCancelDialogOpen",void 0),i([E()],G.prototype,"openDialog",void 0),G=i([r(),n("next-appointment-card")],G);export{F as a,J as g};
|
|
1
|
+
import{s as e}from"./chunk-6CCJWPGL-TiaqZaPV.js";import{D as t}from"./chunk-5EJXDIGT-Bb4_pfDr.js";import{_ as i,c as n}from"./custom-element-D2ziPxYE.js";import{c as o}from"./consume-CovVqBjI.js";import{m as a,s}from"./runtime-Bg1WXVCx.js";import{l as r}from"./localized-decorator-BlOuLhym.js";import{Q as l}from"./query-controller-B1byDHlF.js";import{A as p}from"./api-client-context-BXGqBAlO.js";import{l as c}from"./chunk-S5RWG6G2-CQJ38pW6.js";import{d,e as m}from"./api-chat-client-D5BosjTp.js";import{g as h,a as u}from"./chunk-2TKJJNS7-DzhxHWWb.js";import{g}from"./get-organization-setup-query-De7eM6V3.js";import{g as f,t as v,f as b,i as y,j as $,k as x,a as C}from"./telemetry-client-dwDzxn9N.js";import{g as w}from"./chunk-Y4EKUX25-Bdei04iw.js";import{c as k}from"./refund-cancel-policy-C_9LyN_y.js";import{a as q,i as j,x as O,E as M}from"./lit-element-DiWJYFwC.js";import{n as z}from"./property-scuRaFcM.js";import{r as E}from"./state-LQivXIgA.js";import{MqAppointmentJoinVideocallEvent as S,MqAppointmentRescheduleEvent as I}from"../events.js";import{getLocale as D}from"../i18n.js";import{calendarIcon as R}from"../ui/icons/calendar-icon.js";import{dotsHorizontalIcon as _}from"../ui/icons/dots-horizontal-icon.js";import{messageBubbleIcon as A}from"../ui/icons/message-bubble-icon.js";import{phoneIcon as T}from"../ui/icons/phone-icon.js";import{videoIcon as P}from"../ui/icons/video-icon.js";import"./mq-chat-room-C7FB_wOo.js";import"../ui/mq-button.js";import"../ui/mq-dialog.js";import{Q as U}from"./chunk-RCFIJTXZ-C6Ir0-sM.js";import{M as L}from"./mutation-controller-CR2qcqhH.js";import{h as N,f as H}from"./price-DU3YLTpk.js";import"./professional-overview-B4E05rLd.js";import"../ui/mq-floating-bubble.js";import"../ui/mq-unread-badge.js";import{toast as Q}from"../ui/mq-toast.js";function J(i,n){return{queryKey:e(i,"appointments",n),queryFn:()=>i.appointments.getAppointments(n),staleTime:t}}function F(e){const{action:t,refundPolicySeconds:i}=e,n=null!=i&&i<3600,o=Math.ceil((i??0)/60),r=Math.ceil((i??0)/3600);return a(0===(n?o:r)?"modify"===t?"Esta cita ya ha pasado, por lo que no se puede modificar.":"Esta cita ya ha pasado, por lo que no se puede anular.":"modify"===t?n?s`Lo sentimos, como faltan menos de ${o} minutos para tu cita no podemos modificarla.`:s`Lo sentimos, como faltan menos de ${r} horas para tu cita no podemos modificarla.`:n?s`Lo sentimos, como faltan menos de ${o} minutos para tu cita no podemos anularla.`:s`Lo sentimos, como faltan menos de ${r} horas para tu cita no podemos anularla.`)}let K=class AppointmentActionUnavailableDialog extends q{constructor(){super(...arguments),this.open=!1,this.heading="",this.message="",this.handleClose=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}}static{this.styles=j`:host{display:contents}mq-dialog::part(dialog){max-width:343px;min-width:0}h2{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0}p{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}.actions{display:flex;margin-top:var(--sp-4)}`}render(){return O`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${this.heading}</h2><p slot="subheading">${this.message}</p><div class="actions"><mq-button variant="primary" fullwidth @click="${this.handleClose}">${a("Volver")}</mq-button></div></mq-dialog>`}};i([z({type:Boolean,reflect:!0})],K.prototype,"open",void 0),i([z({type:String})],K.prototype,"heading",void 0),i([z({type:String})],K.prototype,"message",void 0),K=i([r(),n("appointment-action-unavailable-dialog")],K);let V=class CancelAppointmentConfirmationDialog extends q{constructor(){super(...arguments),this.open=!1,this.cancelAppointmentMutation=new L(this,{mutationFn:async e=>this.apiClient.appointments.cancelAppointment(e),onSuccess:()=>{this.queryClientContext?.invalidateQueries({queryKey:e(this.apiClient)}),this.dispatchEvent(new CustomEvent("success",{bubbles:!0,composed:!0}))}}),this.handleClose=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},this.handleDismissClick=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},this.handleConfirmClick=()=>{this.cancelAppointmentMutation.run({id:this.appointmentId})}}static{this.styles=j`:host{display:contents}h2{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0}p{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}.subheading-payable{font-size:var(--text-base);line-height:22px}.price-rows{display:flex;flex-direction:column;font-family:var(--font-body);font-size:var(--text-sm);font-weight:var(--font-weight-medium);line-height:var(--text-sm--line-height);color:var(--color-card-foreground);width:100%;margin-bottom:var(--sp-4)}.price-row{display:flex;align-items:center;justify-content:space-between;min-height:34px;gap:var(--sp-2)}.price-row span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.actions{display:flex;gap:var(--sp-3);margin-top:var(--sp-4);justify-content:flex-end;flex-wrap:wrap}`}render(){const e=D(),t=this.price,i=N(t),n=this.cancelAppointmentMutation.isPending;if(i){const i=H(t,e),o=`-${i}`;return O`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${a("Confirmar cancelación")}</h2><p slot="subheading" class="subheading-payable">${a("¿Seguro que quieres cancelar esta cita? Se te devolverá el importe pagado en un plazo de 5-10 días hábiles.")}</p><div><div class="price-rows"><div class="price-row"><span>${a("Importe pagado")}</span> <span>${i}</span></div><div class="price-row"><span>${a("Importe a devolver")}</span> <span>${o}</span></div></div><div class="actions"><mq-button variant="outline" ?disabled="${n}" @click="${this.handleDismissClick}">${a("Volver")}</mq-button><mq-button variant="primary" ?disabled="${n}" @click="${this.handleConfirmClick}">${a("Confirmar")}</mq-button></div></div></mq-dialog>`}return O`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${a("Confirmar cancelación")}</h2><p slot="subheading">${a("¿Seguro que quieres cancelar esta cita?")}</p><div><div class="actions"><mq-button variant="outline" ?disabled="${n}" @click="${this.handleDismissClick}">${a("Cancelar")}</mq-button><mq-button variant="primary" ?disabled="${n}" @click="${this.handleConfirmClick}">${a("Confirmar")}</mq-button></div></div></mq-dialog>`}};i([o({context:p,subscribe:!0})],V.prototype,"apiClient",void 0),i([z({type:Boolean,reflect:!0})],V.prototype,"open",void 0),i([o({context:U,subscribe:!0})],V.prototype,"queryClientContext",void 0),i([z({type:String})],V.prototype,"appointmentId",void 0),i([z({type:Object})],V.prototype,"price",void 0),V=i([r(),n("cancel-appointment-confirmation-dialog")],V);const B=j`:host{display:flex;flex-direction:column;justify-content:space-between;gap:var(--sp-6);flex:1;width:100%;min-width:0;box-sizing:border-box;color:var(--color-text-icons--primary,#0a0a22)}professional-overview{--avatar-size-lg:66px;--text-lg--line-height:1.35;display:block}.details{display:flex;flex-direction:column;align-items:flex-start;gap:var(--sp-3)}.detail-row{display:inline-flex;align-items:center;gap:var(--sp-2);font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;font-weight:var(--font-weight-normal)}.detail-row svg{flex-shrink:0}.detail-row span::first-letter{text-transform:uppercase}.footer{display:flex;flex-direction:column;gap:var(--sp-4)}.reminder{font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;font-weight:var(--font-weight-normal);color:var(--color-text-icons--secondary,#6d658b);margin:0}.actions{--button-height-md:2.75rem;display:flex;align-items:stretch;gap:10px}.actions>mq-button{flex:1;min-width:0}.overflow{position:relative;flex:0 0 auto}.chat-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-badge{--mq-unread-badge-size:8px;flex-shrink:0}@media (max-width:767px){.actions{flex-wrap:wrap}.actions>mq-button.join{order:1;flex:1 0 100%}}.menu{position:absolute;right:0;bottom:calc(100% + var(--sp-2));z-index:2;display:flex;flex-direction:column;min-width:176px;padding:var(--sp-1);background-color:var(--color-card,#fff);border:1px solid var(--color-border-subtle,#edecf1);border-radius:var(--border-radius-lg);box-shadow:var(--shadow-lg)}.menu-item{display:block;width:100%;background:0 0;border:none;border-radius:var(--border-radius-sm);padding:var(--sp-2) var(--sp-3);cursor:pointer;text-align:left;font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;color:var(--color-text-icons--primary,#0a0a22)}.menu-item:hover{background-color:var(--color-muted)}.menu-item.negative{color:var(--color-negative)}`;let G=class NextAppointmentCard extends q{constructor(){super(...arguments),this.token="",this.patientHash="",this.isChatOpen=!1,this.isMenuOpen=!1,this.isCancelDialogOpen=!1,this.openDialog=null,this.getUnreadMessagesQuery=new l(this,()=>({...w(this.apiClient,{roomId:this.appointmentResource?.room?.id}),enabled:!!this.appointmentResource?.room?.id})),this.getOrganizationSetupQuery=new l(this,()=>g(this.apiClient)),this.getOrganizationSpecialtiesQuery=new l(this,()=>f(this.apiClient,{enabled:!!this.appointmentResource?.speciality?.id})),this.closeMenuOnOutsideClick=e=>{e.composedPath().includes(this)||(this.isMenuOpen=!1)},this.closeMenuOnEscape=e=>{"Escape"===e.key&&(this.isMenuOpen=!1)},this.handleJoinVideocall=()=>{v.track(b(this.sessionPatientHash,this.appointmentId)),this.dispatchEvent(new S({appointmentId:this.appointmentId}))},this.handleToggleChat=()=>{this.isChatOpen=!this.isChatOpen,this.isChatOpen&&v.track(y(this.sessionPatientHash,this.appointmentId))},this.handleModify=()=>{this.isMenuOpen=!1,this.isModifyUnavailable?this.openDialog="modify":(v.track($(this.sessionPatientHash,this.appointmentId)),this.dispatchEvent(new I({appointmentId:this.appointmentId})))},this.handleCancel=()=>{this.isMenuOpen=!1,this.isCancelUnavailable?this.openDialog="cancel":(v.track(x(this.sessionPatientHash,this.appointmentId)),this.isCancelDialogOpen=!0)}}static{this.styles=B}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.closeMenuOnOutsideClick),document.addEventListener("keydown",this.closeMenuOnEscape)}disconnectedCallback(){document.removeEventListener("click",this.closeMenuOnOutsideClick),document.removeEventListener("keydown",this.closeMenuOnEscape),super.disconnectedCallback()}get appointmentId(){return this.appointmentResource.appointment.id??""}get channel(){return this.appointmentResource.appointment.channel}get sessionToken(){return this.token||this.loginToken?.access_token||""}get sessionPatientHash(){return this.patientHash||this.loginToken?.patient?.hash||""}get sessionTimezone(){return this.timezone??this.loginToken?.patient?.timezone}get unreadCount(){return this.getUnreadMessagesQuery.result?.data?.unread_count??0}get specialtyName(){const e=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>Number(e.id)===Number(this.appointmentResource.speciality?.id));return C(e?.code??"",D(),e?.name??this.appointmentResource.speciality?.name)}get hasChatSupport(){return this.appointmentResource.appointment.has_chat_in_appointment??this.getOrganizationSetupQuery.result?.data?.appointments?.has_chat_in_appointment??!1}get isExpired(){return d(this.appointmentResource.appointment.expires_at)}get refundPolicySeconds(){return this.getOrganizationSetupQuery.result?.data?.appointments?.seconds_before_start_to_refund_on_cancel}get policyAllowsModifyOrCancel(){return k({startsAtIso:this.appointmentResource.appointment.starts_at,refundPolicySeconds:this.refundPolicySeconds})}get isModifyUnavailable(){return this.isExpired||0===this.appointmentResource.slots.length||!this.policyAllowsModifyOrCancel}get isCancelUnavailable(){return this.isExpired||!this.policyAllowsModifyOrCancel}get modifyUnavailableMessage(){return F({action:"modify",refundPolicySeconds:this.refundPolicySeconds})}get cancelUnavailableMessage(){return F({action:"cancel",refundPolicySeconds:this.refundPolicySeconds})}channelIcon(){switch(this.channel){case m.videocall:return P({size:20});case m.phonecall:return T({size:20});default:return A({size:20})}}channelLabel(){switch(this.channel){case m.videocall:return a("Videoconsulta");case m.phonecall:return a("Consulta telefónica");default:return a("Chat")}}formatWhen(){const e=D().replace("_","-"),t=h(this.sessionTimezone),i=t?{timeZone:t}:{},n=new Date(this.appointmentResource.appointment.starts_at);if(Number.isNaN(n.getTime()))return"";const o=new Intl.DateTimeFormat(e,{weekday:"long",day:"numeric",month:"long",year:"numeric",...i}).format(n),r=new Intl.DateTimeFormat(e,{timeStyle:"short",hourCycle:"h23",...i}).format(n),l=t?u(t,n):"";return a(s`${o}, ${r} h${l?` (${l})`:""}`)}renderActions(){const e=this.channel===m.videocall;return O`<div class="actions">${this.hasChatSupport?O`<mq-button variant="outline" @click="${this.handleToggleChat}"><span class="chat-label">${a("Ir a chat")}</span> ${this.unreadCount>0?O`<mq-unread-badge class="chat-badge"></mq-unread-badge>`:M}</mq-button>`:M} ${e?O`<mq-button class="join" variant="primary" @click="${this.handleJoinVideocall}">${a("Unirse a la videoconsulta")}</mq-button>`:M}<div class="overflow"><mq-button variant="outline" size="icon-lg" aria-label="${a("Más opciones")}" aria-haspopup="menu" aria-expanded="${this.isMenuOpen}" @click="${()=>{this.isMenuOpen=!this.isMenuOpen}}">${_({size:16})}</mq-button>${this.isMenuOpen?O`<div class="menu" role="menu"><button class="menu-item" type="button" role="menuitem" @click="${this.handleModify}">${a("Modificar cita")}</button> <button class="menu-item negative" type="button" role="menuitem" @click="${this.handleCancel}">${a("Anular cita")}</button></div>`:M}</div></div>`}render(){const{professional:e}=this.appointmentResource,t=this.formatWhen();return O`<professional-overview .name="${e.name}" .specialtyName="${this.specialtyName}" .collegiateNumber="${e.collegiate_number??void 0}" .description="${e.description??""}" .languages="${e.languages??[]}" .avatar="${e.avatar??""}"></professional-overview><div class="details">${t?O`<div class="detail-row">${R({size:20})} <span>${t}</span></div>`:M}<div class="detail-row">${this.channelIcon()} <span>${this.channelLabel()}</span></div></div><div class="footer"><p class="reminder">${a("Recibirás un recordatorio 15 minutos antes de la consulta")}</p>${this.renderActions()}</div><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" hideCloseButton @mq-close="${()=>{this.isChatOpen=!1}}">${this.isChatOpen?O`<mq-chat-room slot="content" .consultationId="${this.appointmentResource.appointment.id}" consultation-type="appointment" token="${this.sessionToken}" .roomId="${this.appointmentResource.room.id}" .professionalHash="${e.hash}" ?readonly="${this.isExpired}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room>`:M}</mq-floating-bubble><appointment-action-unavailable-dialog .open="${"modify"===this.openDialog}" .heading="${a("Modificar cita")}" .message="${this.modifyUnavailableMessage}" @close="${()=>{this.openDialog=null}}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"cancel"===this.openDialog}" .heading="${a("Anular cita")}" .message="${this.cancelUnavailableMessage}" @close="${()=>{this.openDialog=null}}"></appointment-action-unavailable-dialog><cancel-appointment-confirmation-dialog .appointmentId="${this.appointmentResource.appointment.id}" .price="${this.appointmentResource.price??void 0}" .open="${this.isCancelDialogOpen}" @cancel="${()=>{this.isCancelDialogOpen=!1}}" @success="${()=>{this.isCancelDialogOpen=!1,Q.success(a("Consulta anulada correctamente")),this.dispatchEvent(new CustomEvent("appointment-cancel-confirmed",{bubbles:!0,composed:!0,detail:{id:this.appointmentId}}))}}"></cancel-appointment-confirmation-dialog>`}};i([o({context:p,subscribe:!0})],G.prototype,"apiClient",void 0),i([o({context:c,subscribe:!0})],G.prototype,"loginToken",void 0),i([z({type:Object})],G.prototype,"appointmentResource",void 0),i([z({type:String})],G.prototype,"token",void 0),i([z({type:String})],G.prototype,"patientHash",void 0),i([z({type:String})],G.prototype,"timezone",void 0),i([E()],G.prototype,"isChatOpen",void 0),i([E()],G.prototype,"isMenuOpen",void 0),i([E()],G.prototype,"isCancelDialogOpen",void 0),i([E()],G.prototype,"openDialog",void 0),G=i([r(),n("next-appointment-card")],G);export{F as a,J as g};
|
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.10.
|
|
1
|
+
const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.10.5",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 t}from"./chunks/chunk-FUCSYDW7-Duj5hy8S.js";import{z as n}from"./chunks/external-
|
|
1
|
+
import{c as e}from"./chunks/runtime-Bg1WXVCx.js";import{l as t}from"./chunks/chunk-FUCSYDW7-Duj5hy8S.js";import{z as n}from"./chunks/external-cM_kgYO_.js";const c=["ca_ES","de_DE","en_US","pt_PT"],s=n.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 n=i();if(!n.initialized){n.initialized=!0;try{const{setLocale:t,getLocale:s}=e({sourceLocale:"es_ES",targetLocales:c,loadLocale:async e=>{switch(e){case"en_US":default:return import("./chunks/en_US-mxYf5Jqv.js");case"pt_PT":return import("./chunks/pt_PT-g8meEZVV.js");case"de_DE":return import("./chunks/de_DE-DUtzXD1z.js");case"ca_ES":return import("./chunks/ca_ES-DMretbb7.js")}}});n.setLocale=t,n.getLocale=s}catch(e){t.warn("Localization was already configured on this page.",e)}}}const u="Localization not initialized yet.";async function l(e){const{setLocale:n}=i();if(n)return n(e);t.warn(u)}function _(){const{getLocale:e}=i();return e?e():(t.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 r}from"./chunks/api-client-context-BXGqBAlO.js";import{a as s,x as i}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-
|
|
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 r}from"./chunks/api-client-context-BXGqBAlO.js";import{a as s,x as i}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-D5BosjTp.js";import{e as u}from"./chunks/ensure-context-root-DbdqwnKB.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/external-cM_kgYO_.js";import"./chunks/chunk-2TKJJNS7-DzhxHWWb.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-Dfww5192.js";u();let h=class MqApiClientProvider extends s{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 i`<slot></slot>`}};t([n({type:String,attribute:"api-key"})],h.prototype,"apiKey",void 0),t([n({type:String,attribute:"token"})],h.prototype,"token",void 0),t([n({type:String,attribute:"locale"})],h.prototype,"locale",void 0),t([n({type:String,attribute:"env"})],h.prototype,"env",void 0),t([o({context:r}),p()],h.prototype,"apiClient",void 0),h=t([e("mq-api-client-provider")],h);export{h 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 s}from"./chunks/consume-CovVqBjI.js";import{m as i}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{A as o}from"./chunks/api-client-context-BXGqBAlO.js";import{L as r}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-FUCSYDW7-Duj5hy8S.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-
|
|
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 s}from"./chunks/consume-CovVqBjI.js";import{m as i}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{A as o}from"./chunks/api-client-context-BXGqBAlO.js";import{L as r}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-FUCSYDW7-Duj5hy8S.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-D5BosjTp.js";import{u as P,s as _,r as E}from"./chunks/apple-pay-outcomes-DJDSt0US.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-cM_kgYO_.js";import"./chunks/chunk-2TKJJNS7-DzhxHWWb.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-Dfww5192.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:s,consultation_id:i}=a.data,n=E(s,i,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">${i("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:h`<p class="state">${i("Apple Pay no está disponible")}</p>`:h`<p class="state">${i("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>h`<p class="state">${i("Preparando Apple Pay…")}</p>`,error:()=>h`<p class="state">${i("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?h`<p class="state">${i("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():h`${this._showQrHelper?h`<p class="helper">${i("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="${i("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([s({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-
|
|
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-D5BosjTp.js";import"./chunks/external-cM_kgYO_.js";import"./chunks/chunk-2TKJJNS7-DzhxHWWb.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-Dfww5192.js";import"./env.js";import"./chunks/api-client-context-BXGqBAlO.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/login-token-task-Yib__6a9.js";import"./chunks/chunk-FUCSYDW7-Duj5hy8S.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,payable_reference:this.payableReference,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({type:String,attribute:"payable-reference"})],r.prototype,"payableReference",void 0),t([i({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as o,c as s}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-B1byDHlF.js";import{A as c}from"./chunks/api-client-context-BXGqBAlO.js";import{g as d}from"./chunks/get-appointment-query-DuHrjd8L.js";import{a as p,i as l,x as m}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as h}from"./chunks/state-LQivXIgA.js";import{setEnv as k}from"./env.js";import{c as v,n as b}from"./chunks/api-chat-client-
|
|
1
|
+
import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as o,c as s}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-B1byDHlF.js";import{A as c}from"./chunks/api-client-context-BXGqBAlO.js";import{g as d}from"./chunks/get-appointment-query-DuHrjd8L.js";import{a as p,i as l,x as m}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as h}from"./chunks/state-LQivXIgA.js";import{setEnv as k}from"./env.js";import{c as v,n as b}from"./chunks/api-chat-client-D5BosjTp.js";import"./chunks/documentation-view-BnKC8xEu.js";import"./ui/mq-card.js";import"./chunks/mq-layout-BndHxkbb.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/chunk-FUCSYDW7-Duj5hy8S.js";import"./chunks/external-cM_kgYO_.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"@tanstack/query-core";import"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import"./chunks/chunk-5EJXDIGT-Bb4_pfDr.js";import"./chunks/chunk-2TKJJNS7-DzhxHWWb.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-Dfww5192.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/addSeconds-CXt0dUch.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-CQJ38pW6.js";import"./ui/icons/message-bubble-icon.js";import"./chunks/mq-chat-room-C7FB_wOo.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-Bdei04iw.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-sBILRfPo.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-dwDzxn9N.js";let j=class DocumentationViewSkeleton extends p{static{this.styles=l`.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 m`<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>`}};j=o([s("documentation-view-skeleton")],j);let g=class MqAppointmentDocumentation extends p{constructor(){super(...arguments),this.showMediquoBranding=!0,this.getAppointmentQuery=new a(this,()=>d(this.apiClient,{id:this.appointmentId})),this.apiClient=v()}willUpdate(i){i.has("env")&&this.env&&k(this.env),i.has("locale")&&this.locale&&t(this.locale)&&e(this.locale);const o=b(i,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);o&&(this.apiClient=o)}render(){return m`<mq-layout background="transparent" .showMediquoBranding="${this.showMediquoBranding}">${this.getAppointmentQuery.render({complete:t=>m`<documentation-view .token="${this.token}" .appointment="${t}"></documentation-view>`,error:()=>m``,pending:()=>m`<documentation-view-skeleton></documentation-view-skeleton>`})}</mq-layout>`}};o([u({type:String,attribute:"appointment-id"})],g.prototype,"appointmentId",void 0),o([u({type:String,attribute:"token"})],g.prototype,"token",void 0),o([u({type:String,attribute:"api-key"})],g.prototype,"apiKey",void 0),o([u({type:String,attribute:"locale"})],g.prototype,"locale",void 0),o([u({type:String,attribute:"env"})],g.prototype,"env",void 0),o([u({type:Boolean,attribute:"show-mediquo-branding",converter:{fromAttribute:t=>null===t||"false"!==t&&"0"!==t,toAttribute:t=>t?"":"false"}})],g.prototype,"showMediquoBranding",void 0),o([n({context:c,subscribe:!0}),h()],g.prototype,"inheritedApiClient",void 0),o([r({context:c}),h()],g.prototype,"apiClient",void 0),g=o([s("mq-appointment-documentation")],g),i();export{g as MqAppointmentDocumentation};
|
package/dist/mq-chat-room.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{M as MqChatRoom,a as MqChatRoomCloseEvent,b as MqChatRoomProfileEvent}from"./chunks/mq-chat-room-
|
|
1
|
+
export{M as MqChatRoom,a as MqChatRoomCloseEvent,b as MqChatRoomProfileEvent}from"./chunks/mq-chat-room-C7FB_wOo.js";import"./chunks/custom-element-D2ziPxYE.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/localized-decorator-BlOuLhym.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/api-client-context-BXGqBAlO.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/lit-element-DiWJYFwC.js";import"./chunks/property-scuRaFcM.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/icons/types.js";import"./ui/mq-avatar.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./ui/mq-button.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/query-controller-B1byDHlF.js";import"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import"@tanstack/query-core";import"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./chunks/chunk-FUCSYDW7-Duj5hy8S.js";import"./events.js";import"./chunks/api-chat-client-D5BosjTp.js";import"./chunks/external-cM_kgYO_.js";import"./chunks/chunk-2TKJJNS7-DzhxHWWb.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-Dfww5192.js";import"./env.js";import"./chunks/chunk-Y4EKUX25-Bdei04iw.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./i18n.js";import"./chunks/chunk-YTQUGGS3-sBILRfPo.js";import"./chunks/mutation-controller-CR2qcqhH.js";
|
package/dist/mq-checkout.js
CHANGED
|
@@ -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-
|
|
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-D5BosjTp.js";import{A as d}from"./chunks/api-client-context-BXGqBAlO.js";import{L as l}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-FUCSYDW7-Duj5hy8S.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/external-cM_kgYO_.js";import"./chunks/chunk-2TKJJNS7-DzhxHWWb.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-Dfww5192.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};
|