@mediquo/elements 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +84 -1
  2. package/dist/chunks/api-chat-client-CqMn2JEn.js +1 -0
  3. package/dist/chunks/{apple-pay-outcomes-BNkcTbbM.js → apple-pay-outcomes-CjCnBYOD.js} +1 -1
  4. package/dist/chunks/chunk-4FFT6DC2-CVWibomC.js +1 -0
  5. package/dist/chunks/chunk-GZF3YFSX-DM-GTqxg.js +1 -0
  6. package/dist/chunks/chunk-RCFIJTXZ-C6Ir0-sM.js +1 -0
  7. package/dist/chunks/chunk-S5RWG6G2-DPesx3Od.js +1 -0
  8. package/dist/chunks/chunk-YMQSBQHL-De_r7BNk.js +1 -0
  9. package/dist/chunks/chunk-YTQUGGS3-DmCGIoFy.js +1 -0
  10. package/dist/chunks/consume-CovVqBjI.js +1 -0
  11. package/dist/chunks/context-consumer-ESdICVAb.js +1 -0
  12. package/dist/chunks/context-provider--AKuwfs9.js +1 -0
  13. package/dist/chunks/create-context-DqP79qjF.js +1 -0
  14. package/dist/chunks/documentation-view-fFbvjJqx.js +1 -0
  15. package/dist/chunks/external-CJj32K_p.js +1 -0
  16. package/dist/chunks/{format-Cm3B1GMy.js → format-CRFiCNHw.js} +1 -1
  17. package/dist/chunks/get-appointment-query-Ck68BEMg.js +1 -0
  18. package/dist/chunks/get-patient-profile-query-B0tUDJmT.js +1 -0
  19. package/dist/chunks/i18n-formats-DYS91YEa.js +1 -0
  20. package/dist/chunks/index-CGnPsMVQ.js +1 -0
  21. package/dist/chunks/index-CLdWVaEs.js +1 -0
  22. package/dist/chunks/index-CvDnN2NR.js +1 -0
  23. package/dist/chunks/index-DNUbmrQl.d.ts +31 -0
  24. package/dist/chunks/index-Xcn-xs13.js +1 -0
  25. package/dist/chunks/index-czcKClL3.d.ts +47 -0
  26. package/dist/chunks/isBefore-CPpTogxo.js +1 -0
  27. package/dist/chunks/{isSameDay-DPfclwIL.js → isSameDay-CuhZMy1T.js} +1 -1
  28. package/dist/chunks/localized-decorator-BlOuLhym.js +1 -0
  29. package/dist/chunks/mq-layout-CGcdxGMQ.js +1 -0
  30. package/dist/chunks/mq-professional-presence-sync-cmg6CXhz.d.ts +22 -0
  31. package/dist/chunks/mq-unread-count-sync-DTn9dfR4.d.ts +22 -0
  32. package/dist/chunks/mutation-controller-CR2qcqhH.js +1 -0
  33. package/dist/chunks/parseISO-Dj3qSTG8.js +1 -0
  34. package/dist/chunks/price-BmA2Dl9f.js +1 -0
  35. package/dist/chunks/professional-overview-CfjgnTw4.js +1 -0
  36. package/dist/chunks/{provide-CfT7g_Zi.js → provide-D2fnEhT2.js} +1 -1
  37. package/dist/chunks/query-Cjvi4_dT.js +1 -0
  38. package/dist/chunks/query-controller-BlO1Ax65.js +1 -0
  39. package/dist/chunks/{refund-cancel-policy-CnbrIqH0.js → refund-cancel-policy-D_tUYPyv.js} +1 -1
  40. package/dist/chunks/schemas.d-5LR6aN9I.d.ts +134 -0
  41. package/dist/chunks/telemetry-client-Ca71sobH.js +1 -0
  42. package/dist/env.js +1 -1
  43. package/dist/i18n.js +1 -1
  44. package/dist/mq-apple-pay-checkout.js +1 -1
  45. package/dist/mq-appointment-checkout.js +1 -1
  46. package/dist/mq-appointment-documentation.d.ts +48 -0
  47. package/dist/mq-appointment-documentation.js +1 -0
  48. package/dist/mq-chat-room.js +1 -1
  49. package/dist/mq-checkout.js +1 -1
  50. package/dist/mq-documents.d.ts +46 -0
  51. package/dist/mq-documents.js +1 -0
  52. package/dist/mq-google-pay-checkout.js +1 -1
  53. package/dist/mq-immediate-videocall-checkout.js +1 -1
  54. package/dist/mq-my-appointments.d.ts +48 -178
  55. package/dist/mq-my-appointments.js +1 -1
  56. package/dist/mq-professional-presence-sync.d.ts +30 -0
  57. package/dist/mq-professional-presence-sync.js +1 -0
  58. package/dist/mq-query-client-provider.js +1 -1
  59. package/dist/mq-schedule-success.d.ts +9 -0
  60. package/dist/mq-schedule-success.js +2 -2
  61. package/dist/mq-schedule.d.ts +22 -10
  62. package/dist/mq-schedule.js +1 -1
  63. package/dist/mq-session-provider.d.ts +28 -0
  64. package/dist/mq-session-provider.js +1 -0
  65. package/dist/mq-socket-provider.js +1 -1
  66. package/dist/mq-support-chat.js +1 -1
  67. package/dist/mq-terms-and-conditions.d.ts +23 -0
  68. package/dist/mq-terms-and-conditions.js +1 -0
  69. package/dist/mq-unread-count-sync.d.ts +21 -0
  70. package/dist/mq-unread-count-sync.js +1 -0
  71. package/dist/mq-videocall.d.ts +35 -26
  72. package/dist/mq-videocall.js +1 -1
  73. package/dist/react/mq-apple-pay-checkout.js +1 -1
  74. package/dist/react/mq-appointment-checkout.js +1 -1
  75. package/dist/react/mq-appointment-documentation.d.ts +28 -0
  76. package/dist/react/mq-appointment-documentation.js +2 -0
  77. package/dist/react/mq-chat-room.d.ts +2 -0
  78. package/dist/react/mq-chat-room.js +1 -1
  79. package/dist/react/mq-checkout.js +1 -1
  80. package/dist/react/mq-documents.d.ts +13 -0
  81. package/dist/react/mq-documents.js +2 -0
  82. package/dist/react/mq-google-pay-checkout.js +1 -1
  83. package/dist/react/mq-immediate-videocall-checkout.js +1 -1
  84. package/dist/react/mq-my-appointments.d.ts +1 -0
  85. package/dist/react/mq-my-appointments.js +1 -1
  86. package/dist/react/mq-professional-presence-sync.d.ts +7 -0
  87. package/dist/react/mq-professional-presence-sync.js +2 -0
  88. package/dist/react/mq-query-client-provider.js +1 -1
  89. package/dist/react/mq-schedule-success.d.ts +3 -0
  90. package/dist/react/mq-schedule-success.js +1 -1
  91. package/dist/react/mq-schedule.d.ts +2 -0
  92. package/dist/react/mq-schedule.js +1 -1
  93. package/dist/react/mq-session-provider.d.ts +10 -0
  94. package/dist/react/mq-session-provider.js +2 -0
  95. package/dist/react/mq-socket-provider.js +1 -1
  96. package/dist/react/mq-support-chat.js +1 -1
  97. package/dist/react/mq-terms-and-conditions.d.ts +14 -0
  98. package/dist/react/mq-terms-and-conditions.js +2 -0
  99. package/dist/react/mq-toast-container.d.ts +8 -0
  100. package/dist/react/mq-toast-container.js +2 -0
  101. package/dist/react/mq-unread-count-sync.d.ts +7 -0
  102. package/dist/react/mq-unread-count-sync.js +2 -0
  103. package/dist/react/mq-videocall.d.ts +14 -2
  104. package/dist/react/mq-videocall.js +1 -1
  105. package/dist/toast.d.ts +3 -0
  106. package/dist/toast.js +1 -0
  107. package/dist/ui/mq-calendar.js +1 -1
  108. package/dist/ui/mq-time-slot-picker.js +1 -1
  109. package/dist/ui/mq-toast.js +1 -1
  110. package/package.json +29 -1
  111. package/dist/chunks/api-chat-client-C8SqZtCa.js +0 -1
  112. package/dist/chunks/chunk-S5RWG6G2-oTcdgk2H.js +0 -1
  113. package/dist/chunks/chunk-YTQUGGS3-DN-JZpgG.js +0 -1
  114. package/dist/chunks/context-provider-CiMFpvDA.js +0 -1
  115. package/dist/chunks/exports-G_7Ih_GH.js +0 -1
  116. package/dist/chunks/external-zAbuzxDj.js +0 -1
  117. package/dist/chunks/get-patient-profile-query-C8T8DJ7z.js +0 -1
  118. package/dist/chunks/index-Bxh8Qfwr.js +0 -1
  119. package/dist/chunks/index-DiqYAEHW.js +0 -1
  120. package/dist/chunks/isBefore-Cof0D841.js +0 -1
  121. package/dist/chunks/mq-layout-CpIZTsV2.js +0 -1
  122. package/dist/chunks/mutation-controller-OVT8NEt6.js +0 -1
  123. package/dist/chunks/parseISO-jT42c8Ob.js +0 -1
  124. package/dist/chunks/price-tImUmtpX.js +0 -1
  125. package/dist/chunks/query-QJ1INUTG.js +0 -1
  126. package/dist/chunks/telemetry-client-BRVJU-fZ.js +0 -1
@@ -0,0 +1 @@
1
+ import{c as t,t as e}from"./parseISO-Dj3qSTG8.js";function n(n,i,a){return function(n,i){return t(n,+e(n)+i)}(n,1e3*i)}function i(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function a(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function p(t,e){return{action_type:"event",event_type:"modify appoinment button click",patient_hash:t,id_appointment:e}}function o(t,e){return{action_type:"event",event_type:"cancel appoinment button click",patient_hash:t,id_appointment:e}}function s(t,e){return{action_type:"event",event_type:"view appointment document list button click",patient_hash:t,id_appointment:e}}function c(t,e){return{action_type:"event",event_type:"repeat appointment button click",patient_hash:t,id_appointment:e}}function _(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function r(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function u(t,e){return{action_type:"event",event_type:"add to calendar button click",patient_hash:t,id_appointment:e}}function h(t,e){return{action_type:"pageview",event_type:"appointment success page view",patient_hash:t,id_appointment:e}}function l(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function y(t,e){return{action_type:"event",event_type:"update documentation",patient_hash:t,id_appointment:e}}function v(t,e){return{action_type:"pageview",event_type:"documentation page view",patient_hash:t,id_appointment:e}}function d(t,e,n){return{action_type:"event",event_type:"find availability button click",patient_hash:t,speciality_id:e,service_id:n}}function f(t,e,n,i,a,p,o){return{action_type:"debug",event_type:"find availability result",patient_hash:t,speciality_id:e,service_id:n,first_slot_date:i,first_slot_professional_hash:a,total_professionals:p,total_slots:o}}function m(t,e,n,i,a){return{action_type:"event",event_type:"professional schedule slot button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function b(t,e,n,i){return{action_type:"event",event_type:"professional availability button click",patient_hash:t,professional_hash:e,speciality_id:n,service_id:i}}function k(t,e,n,i,a){return{action_type:"event",event_type:"confirm appointment button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function g(t){return{action_type:"pageview",event_type:"select professional step page view",patient_hash:t}}function w(t,e){return{action_type:"pageview",event_type:"not time yet pageview",patient_hash:t,id_appointment:e}}function T(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function K(t,e){return{action_type:"pageview",event_type:"waiting room pageview",patient_hash:t,id_appointment:e}}function q(t,e){return{action_type:"pageview",event_type:"videocall pageview",patient_hash:t,id_appointment:e}}class HttpTransport{endpoint;apiKey;constructor(t,e){this.endpoint=t,this.apiKey=e}send(t){fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(t)}).catch(()=>{})}}class MediquoTelemetryClient{_apiKey=null;_transport=null;setApiKey(t){this._apiKey=t,this._buildTransport()}track(t){null!==this._transport&&this._transport.send(t)}_buildTransport(){null!==this._apiKey&&(this._transport=new HttpTransport("https://tracking.____.mediquo.com/sdk",this._apiKey))}}const x=new class AppTelemetryClient extends MediquoTelemetryClient{track(t){}};export{n as a,y as b,l as c,v as d,h as e,u as f,_ as g,r as h,p as i,o as j,c as k,i as l,s as m,a as n,d as o,m as p,b as q,f as r,k as s,x as t,g as u,w as v,T as w,K as x,q as y};
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.4.0",n={development:{MODE:"development",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"47836441",ASSETS_BASE_URL:E},production:{MODE:"production",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"46655102",ASSETS_BASE_URL:E}};let t=o;const _=new Proxy({},{get:(E,o)=>n[t??"production"][o]});function S(E){t=E}export{E as ASSETS_BASE_URL,_ as env,S as setEnv};
1
+ const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.5.0",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{z as t,l as n}from"./chunks/external-zAbuzxDj.js";const c=["ca_ES","de_DE","en_US","pt_PT"],a=t.enum(["en_US","pt_PT","de_DE","es_ES","ca_ES"]);function s(e){return a.safeParse(e).success}const o="__mqElementsLocalization__";function i(){const e=globalThis;return e[o]||(e[o]={initialized:!1}),e[o]}function r(){const t=i();if(!t.initialized){t.initialized=!0;try{const{setLocale:n,getLocale:a}=e({sourceLocale:"es_ES",targetLocales:c,loadLocale:async e=>{switch(e){case"en_US":default:return import("./chunks/en_US-BslWF9nj.js");case"pt_PT":return import("./chunks/pt_PT-CFbbWowX.js");case"de_DE":return import("./chunks/de_DE-CrwfSJnS.js");case"ca_ES":return import("./chunks/ca_ES-nttMFJzr.js")}}});t.setLocale=n,t.getLocale=a}catch(e){n.warn("Localization was already configured on this page.",e)}}}const u="Localization not initialized yet.";async function l(e){const{setLocale:t}=i();if(t)return t(e);n.warn(u)}function _(){const{getLocale:e}=i();return e?e():(n.warn(u),"es_ES")}export{_ as getLocale,r as initLocalization,s as isValidLocale,l as setLocale};
1
+ import{c as e}from"./chunks/runtime-Bg1WXVCx.js";import{l as t}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{z as n}from"./chunks/external-CJj32K_p.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-BslWF9nj.js");case"pt_PT":return import("./chunks/pt_PT-CFbbWowX.js");case"de_DE":return import("./chunks/de_DE-CrwfSJnS.js");case"ca_ES":return import("./chunks/ca_ES-nttMFJzr.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 e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l as s}from"./chunks/parseISO-jT42c8Ob.js";import{L as i}from"./chunks/login-token-task-BI-L2zSV.js";import{l as n}from"./chunks/external-zAbuzxDj.js";import{i as o,a as r,x as p}from"./chunks/lit-element-DiWJYFwC.js";import{n as l}from"./chunks/property-scuRaFcM.js";import{r as c}from"./chunks/state-LQivXIgA.js";import{setEnv as h}from"./env.js";import{initLocalization as u,isValidLocale as y,setLocale as d}from"./i18n.js";import{b as m}from"./chunks/api-chat-client-C8SqZtCa.js";import{u as v,s as b,r as f}from"./chunks/apple-pay-outcomes-BNkcTbbM.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";function k(){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 P(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:!k()}}}((await t.applePayCapabilities(e)).paymentCredentialStatus)}catch{return t.canMakePayments()?{available:!0,usesQrFlow:!k()}:{available:!1,reason:"unsupported"}}return t.canMakePayments()?{available:!0,usesQrFlow:!k()}:{available:!1,reason:"unsupported"}}const g={es_ES:"es-ES",en_US:"en-US",pt_PT:"pt-PT",de_DE:"de-DE",ca_ES:"ca-ES"};try{u()}catch{}const E=["visa","masterCard","amex"],_=["supports3DS"],S=o`: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 A(e,t){n.warn(e,{error:t instanceof Error?t.message:String(t)})}let w=class MqApplePayCheckout extends r{constructor(){super(...arguments),this._availabilityPhase="checking",this._showQrHelper=!1,this._paying=!1,this._suppressCancelEvent=!1,this._availabilityGeneration=0,this._loginTokenTask=new i(this,m,{args:()=>[this.apiKey,this.token],onComplete:e=>{m.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 A("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 m.payments.validateApplePayMerchant({order_id:this.sessionId,validation_url:t.validationURL});e.completeMerchantValidation(v(a))}catch(t){A("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 m.payments.authorizeApplePay({order_id:this.sessionId,token:b(t.payment.token)}),{status:s,consultation_id:i}=a.data,n=f(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){A("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){A("mq-apple-pay-checkout: session.begin() failed",e),this._paying=!1,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}}}static{this.styles=S}willUpdate(e){if(e.has("env")&&this.env&&h(this.env),e.has("apiKey")&&m.setApiKey(this.apiKey),e.has("locale")){const e=y(this.locale)?this.locale:"es_ES";d(e),m.setLanguage(e)}e.has("merchantId")&&this._loginTokenTask.value&&this._refreshAvailability()}async _refreshAvailability(){const e=++this._availabilityGeneration;this._availabilityPhase="checking",this._showQrHelper=!1;const t=await P(this.merchantId??"");e===this._availabilityGeneration&&(t.available?(this._availabilityPhase="ready",this._showQrHelper=t.usesQrFlow):this._availabilityPhase="unavailable")}get _resolvedLocale(){return y(this.locale)?this.locale:"es_ES"}_buildPaymentRequest(){return{countryCode:this.country,currencyCode:this.currency,supportedNetworks:[...E],merchantCapabilities:[..._],total:{label:this.label,amount:this.amount}}}_renderUnavailable(){return this.merchantId?.trim()?"undefined"==typeof ApplePaySession?p`<p class="state">${a("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:p`<p class="state">${a("Apple Pay no está disponible")}</p>`:p`<p class="state">${a("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>p`<p class="state">${a("Preparando Apple Pay…")}</p>`,error:()=>p`<p class="state">${a("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?p`<p class="state">${a("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():p`${this._showQrHelper?p`<p class="helper">${a("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,g[e]??"es-ES"}" aria-label="${a("Pagar con Apple Pay")}" @click="${this._onPayClick}"></apple-pay-button></div>`;var e}})}};e([l({type:String,attribute:"env"})],w.prototype,"env",void 0),e([l({type:String,attribute:"api-key"})],w.prototype,"apiKey",void 0),e([l({type:String,attribute:"token"})],w.prototype,"token",void 0),e([l({type:String,attribute:"locale",reflect:!0})],w.prototype,"locale",void 0),e([l({type:String,attribute:"merchant-id"})],w.prototype,"merchantId",void 0),e([l({type:String,attribute:"session-id"})],w.prototype,"sessionId",void 0),e([l({type:String,attribute:"amount"})],w.prototype,"amount",void 0),e([l({type:String,attribute:"currency"})],w.prototype,"currency",void 0),e([l({type:String,attribute:"country"})],w.prototype,"country",void 0),e([l({type:String,attribute:"label"})],w.prototype,"label",void 0),e([c()],w.prototype,"_availabilityPhase",void 0),e([c()],w.prototype,"_showQrHelper",void 0),e([c()],w.prototype,"_paying",void 0),w=e([s(),t("mq-apple-pay-checkout")],w);export{ApplePayCheckoutDeniedEvent,ApplePayCheckoutErrorEvent,ApplePayCheckoutSuccessEvent,w as MqApplePayCheckout};
1
+ import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l as s}from"./chunks/localized-decorator-BlOuLhym.js";import{L as i}from"./chunks/login-token-task-BI-L2zSV.js";import{l as n}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as o,a as r,x as p}from"./chunks/lit-element-DiWJYFwC.js";import{n as l}from"./chunks/property-scuRaFcM.js";import{r as c}from"./chunks/state-LQivXIgA.js";import{setEnv as h}from"./env.js";import{initLocalization as u,isValidLocale as y,setLocale as d}from"./i18n.js";import{a as m}from"./chunks/api-chat-client-CqMn2JEn.js";import{u as v,s as b,r as k}from"./chunks/apple-pay-outcomes-CjCnBYOD.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/external-CJj32K_p.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";function f(){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 P(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:!f()}}}((await t.applePayCapabilities(e)).paymentCredentialStatus)}catch{return t.canMakePayments()?{available:!0,usesQrFlow:!f()}:{available:!1,reason:"unsupported"}}return t.canMakePayments()?{available:!0,usesQrFlow:!f()}:{available:!1,reason:"unsupported"}}const g={es_ES:"es-ES",en_US:"en-US",pt_PT:"pt-PT",de_DE:"de-DE",ca_ES:"ca-ES"};try{u()}catch{}const E=["visa","masterCard","amex"],_=["supports3DS"],S=o`: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 A(e,t){n.warn(e,{error:t instanceof Error?t.message:String(t)})}let C=class MqApplePayCheckout extends r{constructor(){super(...arguments),this._availabilityPhase="checking",this._showQrHelper=!1,this._paying=!1,this._suppressCancelEvent=!1,this._availabilityGeneration=0,this._loginTokenTask=new i(this,m,{args:()=>[this.apiKey,this.token],onComplete:e=>{m.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 A("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 m.payments.validateApplePayMerchant({order_id:this.sessionId,validation_url:t.validationURL});e.completeMerchantValidation(v(a))}catch(t){A("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 m.payments.authorizeApplePay({order_id:this.sessionId,token:b(t.payment.token)}),{status:s,consultation_id:i}=a.data,n=k(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){A("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){A("mq-apple-pay-checkout: session.begin() failed",e),this._paying=!1,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}}}static{this.styles=S}willUpdate(e){if(e.has("env")&&this.env&&h(this.env),e.has("apiKey")&&m.setApiKey(this.apiKey),e.has("locale")){const e=y(this.locale)?this.locale:"es_ES";d(e),m.setLanguage(e)}e.has("merchantId")&&this._loginTokenTask.value&&this._refreshAvailability()}async _refreshAvailability(){const e=++this._availabilityGeneration;this._availabilityPhase="checking",this._showQrHelper=!1;const t=await P(this.merchantId??"");e===this._availabilityGeneration&&(t.available?(this._availabilityPhase="ready",this._showQrHelper=t.usesQrFlow):this._availabilityPhase="unavailable")}get _resolvedLocale(){return y(this.locale)?this.locale:"es_ES"}_buildPaymentRequest(){return{countryCode:this.country,currencyCode:this.currency,supportedNetworks:[...E],merchantCapabilities:[..._],total:{label:this.label,amount:this.amount}}}_renderUnavailable(){return this.merchantId?.trim()?"undefined"==typeof ApplePaySession?p`<p class="state">${a("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:p`<p class="state">${a("Apple Pay no está disponible")}</p>`:p`<p class="state">${a("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>p`<p class="state">${a("Preparando Apple Pay…")}</p>`,error:()=>p`<p class="state">${a("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?p`<p class="state">${a("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():p`${this._showQrHelper?p`<p class="helper">${a("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,g[e]??"es-ES"}" aria-label="${a("Pagar con Apple Pay")}" @click="${this._onPayClick}"></apple-pay-button></div>`;var e}})}};e([l({type:String,attribute:"env"})],C.prototype,"env",void 0),e([l({type:String,attribute:"api-key"})],C.prototype,"apiKey",void 0),e([l({type:String,attribute:"token"})],C.prototype,"token",void 0),e([l({type:String,attribute:"locale",reflect:!0})],C.prototype,"locale",void 0),e([l({type:String,attribute:"merchant-id"})],C.prototype,"merchantId",void 0),e([l({type:String,attribute:"session-id"})],C.prototype,"sessionId",void 0),e([l({type:String,attribute:"amount"})],C.prototype,"amount",void 0),e([l({type:String,attribute:"currency"})],C.prototype,"currency",void 0),e([l({type:String,attribute:"country"})],C.prototype,"country",void 0),e([l({type:String,attribute:"label"})],C.prototype,"label",void 0),e([c()],C.prototype,"_availabilityPhase",void 0),e([c()],C.prototype,"_showQrHelper",void 0),e([c()],C.prototype,"_paying",void 0),C=e([s(),t("mq-apple-pay-checkout")],C);export{ApplePayCheckoutDeniedEvent,ApplePayCheckoutErrorEvent,ApplePayCheckoutSuccessEvent,C as MqApplePayCheckout};
@@ -1 +1 @@
1
- import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{a as i,x as o}from"./chunks/lit-element-DiWJYFwC.js";import{n as s}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import{b as p}from"./chunks/api-chat-client-C8SqZtCa.js";import"./mq-checkout.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/login-token-task-BI-L2zSV.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 i{constructor(){super(...arguments),this._provideSession=async()=>{const t=await p.payments.createPaymentLink({slot_id:this.slotId,service_id:this.serviceId,specialty_id:this.specialtyId,consultation_reason:this.consultationReason,discount_code:this.discountCode,preconsultation_documents:this.preconsultationDocuments});return{sessionId:t.session_id,paymentUrl:t.payment_link}},this._onSuccess=t=>{t.stopPropagation(),this.dispatchEvent(new AppointmentPaidEvent({appointmentId:t.detail.reference}))}}render(){return o`<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([s({type:String,attribute:"env"})],r.prototype,"env",void 0),t([s({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),t([s({type:String,attribute:"token"})],r.prototype,"token",void 0),t([s({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),t([s({type:String,attribute:"slot-id"})],r.prototype,"slotId",void 0),t([s({type:String,attribute:"service-id"})],r.prototype,"serviceId",void 0),t([s({type:String,attribute:"specialty-id"})],r.prototype,"specialtyId",void 0),t([s({type:String,attribute:"consultation-reason"})],r.prototype,"consultationReason",void 0),t([s({type:String,attribute:"discount-code"})],r.prototype,"discountCode",void 0),t([s({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
1
+ import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{a as o,x as i}from"./chunks/lit-element-DiWJYFwC.js";import{n as s}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import{a as p}from"./chunks/api-chat-client-CqMn2JEn.js";import"./mq-checkout.js";import"./chunks/external-CJj32K_p.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/login-token-task-BI-L2zSV.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class AppointmentPaidEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(AppointmentPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let r=class MqAppointmentCheckout extends o{constructor(){super(...arguments),this._provideSession=async()=>{const t=await p.payments.createPaymentLink({slot_id:this.slotId,service_id:this.serviceId,specialty_id:this.specialtyId,consultation_reason:this.consultationReason,discount_code:this.discountCode,preconsultation_documents:this.preconsultationDocuments});return{sessionId:t.session_id,paymentUrl:t.payment_link}},this._onSuccess=t=>{t.stopPropagation(),this.dispatchEvent(new AppointmentPaidEvent({appointmentId:t.detail.reference}))}}render(){return i`<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([s({type:String,attribute:"env"})],r.prototype,"env",void 0),t([s({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),t([s({type:String,attribute:"token"})],r.prototype,"token",void 0),t([s({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),t([s({type:String,attribute:"slot-id"})],r.prototype,"slotId",void 0),t([s({type:String,attribute:"service-id"})],r.prototype,"serviceId",void 0),t([s({type:String,attribute:"specialty-id"})],r.prototype,"specialtyId",void 0),t([s({type:String,attribute:"consultation-reason"})],r.prototype,"consultationReason",void 0),t([s({type:String,attribute:"discount-code"})],r.prototype,"discountCode",void 0),t([s({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
@@ -0,0 +1,48 @@
1
+ import * as lit_html from 'lit-html';
2
+ import { LitElement, PropertyValues } from 'lit';
3
+ import { Env } from './env.js';
4
+ import './ui/mq-button.js';
5
+ import './chunks/mq-chat-room-DuG4RuIp.js';
6
+ import './ui/mq-floating-bubble.js';
7
+ import './ui/mq-card.js';
8
+ import './ui/mq-unread-badge.js';
9
+ import './ui/back-link.js';
10
+ import './chunks/index-DNUbmrQl.js';
11
+ import './chunks/mq-layout-D8Mak16a.js';
12
+ import './ui/mq-avatar.js';
13
+ import './ui/mq-skeleton.js';
14
+ import 'zod';
15
+ import './chunks/appointment.model.d-Dy50gMPg.js';
16
+ import '@tanstack/query-core';
17
+ import './ui/mq-text-button.js';
18
+
19
+ /**
20
+ * Standalone "appointment documentation" screen: fetches an appointment by id
21
+ * and renders the shared `documentation-view` (professional summary + shared
22
+ * documents + finished-consultation actions).
23
+ *
24
+ * `documentation-view` reads the patient session (hash + timezone) from
25
+ * `loginTokenContext`, so mount this element under `mq-session-provider`
26
+ * (alongside the query-client provider it needs for data fetching).
27
+ */
28
+ declare class MqAppointmentDocumentation extends LitElement {
29
+ appointmentId: string;
30
+ /** Already-exchanged access token. Required when used standalone. */
31
+ token: string;
32
+ /** Mediquo API key. Required when used standalone. */
33
+ apiKey?: string;
34
+ /** Locale (e.g. "es_ES"). Optional; defaults to the host/build locale. */
35
+ locale?: string;
36
+ /** Environment override ("development" | "production"). Optional. */
37
+ env?: Env;
38
+ private getAppointmentQuery;
39
+ protected willUpdate(changed: PropertyValues<this>): void;
40
+ render(): lit_html.TemplateResult<1>;
41
+ }
42
+ declare global {
43
+ interface HTMLElementTagNameMap {
44
+ "mq-appointment-documentation": MqAppointmentDocumentation;
45
+ }
46
+ }
47
+
48
+ export { MqAppointmentDocumentation };
@@ -0,0 +1 @@
1
+ import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as s,t as o}from"./chunks/custom-element-DA9Fxvxd.js";import{Q as r}from"./chunks/query-controller-BlO1Ax65.js";import{g as n}from"./chunks/get-appointment-query-Ck68BEMg.js";import{a,i as c,x as m}from"./chunks/lit-element-DiWJYFwC.js";import{n as d}from"./chunks/property-scuRaFcM.js";import{setEnv as p}from"./env.js";import{a as l}from"./chunks/api-chat-client-CqMn2JEn.js";import"./chunks/documentation-view-fFbvjJqx.js";import"./ui/mq-card.js";import"./chunks/mq-layout-CGcdxGMQ.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-CJj32K_p.js";import"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/telemetry-client-Ca71sobH.js";import"./ui/icons/calendar-icon.js";import"./ui/icons/types.js";import"./ui/icons/clock-icon.js";import"./chunks/state-LQivXIgA.js";import"./ui/icons/info-circle-outine-icon.js";import"./ui/mq-button.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import"./ui/icons/message-bubble-icon.js";import"./mq-chat-room.js";import"./chunks/provide-D2fnEhT2.js";import"./chunks/context-provider--AKuwfs9.js";import"./chunks/consume-CovVqBjI.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-YMQSBQHL-De_r7BNk.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./chunks/chunk-GZF3YFSX-DM-GTqxg.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import"./chunks/mutation-controller-CR2qcqhH.js";import"./ui/mq-floating-bubble.js";import"./ui/mq-unread-badge.js";import"./ui/back-link.js";import"./ui/mq-text-button.js";import"./chunks/index-Xcn-xs13.js";import"./ui/icons/download-icon.js";import"./chunks/get-organization-setup-query-BMbuRi6v.js";import"./chunks/i18n-formats-DYS91YEa.js";let u=class DocumentationViewSkeleton extends a{static{this.styles=c`.skeleton{border-radius:var(--border-radius-md);background-color:#f0f0f0;animation:skeleton-pulse 1.5s infinite}.back-link-skeleton{width:60px;height:20px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-6)}.title-skeleton{width:200px;height:32px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-3)}.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="skeleton back-link-skeleton"></div><div class="skeleton title-skeleton"></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>`}};u=s([o("documentation-view-skeleton")],u);let k=class MqAppointmentDocumentation extends a{constructor(){super(...arguments),this.getAppointmentQuery=new r(this,()=>n(l,{id:this.appointmentId}))}willUpdate(i){i.has("env")&&this.env&&p(this.env),i.has("apiKey")&&this.apiKey&&l.setApiKey(this.apiKey),i.has("token")&&this.token&&l.setAuthToken(this.token),i.has("locale")&&this.locale&&t(this.locale)&&(e(this.locale),l.setLanguage(this.locale))}render(){return m`<mq-layout background="transparent">${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>`}};s([d({type:String,attribute:"appointment-id"})],k.prototype,"appointmentId",void 0),s([d({type:String,attribute:"token"})],k.prototype,"token",void 0),s([d({type:String,attribute:"api-key"})],k.prototype,"apiKey",void 0),s([d({type:String,attribute:"locale"})],k.prototype,"locale",void 0),s([d({type:String,attribute:"env"})],k.prototype,"env",void 0),k=s([o("mq-appointment-documentation")],k),i();export{k as MqAppointmentDocumentation};
@@ -1 +1 @@
1
- export{M as MqChatRoom,b as MqChatRoomCloseEvent,c as MqChatRoomProfileEvent}from"./chunks/exports-G_7Ih_GH.js";import"./chunks/custom-element-DA9Fxvxd.js";import"./chunks/provide-CfT7g_Zi.js";import"./chunks/context-provider-CiMFpvDA.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/mutation-controller-OVT8NEt6.js";import"./chunks/query-QJ1INUTG.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/lit-element-DiWJYFwC.js";import"./chunks/property-scuRaFcM.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./chunks/api-chat-client-C8SqZtCa.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./ui/icons/x-icon.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/if-defined-BYeVdwgd.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./i18n.js";import"./chunks/chunk-YTQUGGS3-DN-JZpgG.js";
1
+ import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{e as s}from"./chunks/provide-D2fnEhT2.js";import{c as o}from"./chunks/consume-CovVqBjI.js";import{l as i}from"./chunks/localized-decorator-BlOuLhym.js";import{m as a,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{i as n,a as l,x as d,E as c}from"./chunks/lit-element-DiWJYFwC.js";import{n as h}from"./chunks/property-scuRaFcM.js";import{r as m}from"./chunks/state-LQivXIgA.js";import{n as p}from"./chunks/create-context-DqP79qjF.js";import{tokens as g}from"./theme.js";import{a as u,M as v}from"./chunks/api-chat-client-CqMn2JEn.js";import{xIcon as y}from"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-button.js";import"./ui/mq-skeleton.js";import{Q as b}from"./chunks/query-controller-BlO1Ax65.js";import{g as f}from"./chunks/chunk-YMQSBQHL-De_r7BNk.js";import{o as w}from"./chunks/if-defined-BYeVdwgd.js";import{chevronLeftIcon as k}from"./ui/icons/chevron-left-icon.js";import{e as x}from"./chunks/query-CeeutdfT.js";import{l as $}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{DownloadFileEvent as I}from"./events.js";import{S as z,g as C}from"./chunks/chunk-GZF3YFSX-DM-GTqxg.js";import{checkDoubleIcon as T}from"./ui/icons/check-double-icon.js";import{checkIcon as D}from"./ui/icons/check-icon.js";import{getLocale as M}from"./i18n.js";import{S as j,a as q}from"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import{s as S}from"./chunks/context-consumer-ESdICVAb.js";import{Q as P}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{e as _}from"./chunks/class-map-Co76I6aw.js";import{M as A}from"./chunks/mutation-controller-CR2qcqhH.js";import"./chunks/context-provider--AKuwfs9.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/external-CJj32K_p.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";import"./ui/icons/types.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/query-Cjvi4_dT.js";const E=p("apiKey"),R=p("token"),B=p("professionalHash"),U=p("roomId"),H=p("consultationId"),N=p("consultationType");class MqChatRoomCloseEvent extends Event{static{this.eventName="mq-chat-room-close"}constructor(){super(MqChatRoomCloseEvent.eventName,{bubbles:!0,composed:!0})}}class MqChatRoomProfileEvent extends Event{static{this.eventName="mq-chat-room-profile"}constructor(){super(MqChatRoomProfileEvent.eventName,{bubbles:!0,composed:!0})}}const L=n`header{padding:var(--size-3) var(--size-4);background-color:var(--color-background-primary);display:flex;justify-content:space-between;gap:var(--size-1)}.left-side{display:flex;flex:1;min-width:0;align-items:center;gap:var(--size-3)}.left-side mq-avatar{flex-shrink:0}.info{min-width:0}.ghost-btn{text-align:left;background:0 0;border:none;padding:0;cursor:pointer}.right-side{display:flex;align-items:center}.name{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-bold);margin:0;color:var(--color-background);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.specialty{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0;color:var(--color-white);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.name-skeleton{margin-bottom:var(--size-1)}.profile-title{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);margin:0;color:var(--color-white)}`;let K=class ChatRoomHeader extends l{constructor(){super(...arguments),this.hideCloseButton=!1,this.getProfessionalQuery=new b(this,()=>f(u,{hash:this.professionalHash}))}static{this.styles=L}handleClose(){this.dispatchEvent(new MqChatRoomCloseEvent)}handleClickProfile(){this.dispatchEvent(new MqChatRoomProfileEvent)}renderProfile(){return d`<div class="left-side"><mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${()=>{this.dispatchEvent(new CustomEvent("goto-chat",{bubbles:!0,composed:!0}))}}">${k({size:24})}</mq-button><p class="profile-title">${a("Perfil de profesional")}</p></div>`}renderChat(){return d`${this.getProfessionalQuery.render({complete:e=>d`<button type="button" class="left-side ghost-btn" @click="${this.handleClickProfile}"><mq-avatar src="${w(e.avatar??void 0)}" alt="User Avatar" fallback="John Doe" size="sm"></mq-avatar><div class="info"><p class="name">${e.name}</p><p class="specialty">${e.title}</p></div></button>`,pending:()=>d`<div class="left-side"><mq-skeleton width="45px" height="45px" border-radius="full"></mq-skeleton><div><mq-skeleton class="name-skeleton" height="14px" width="120px"></mq-skeleton><mq-skeleton height="14px" width="100px"></mq-skeleton></div></div>`})}`}render(){return d`<header>${"profile"===this.view?this.renderProfile():this.renderChat()}<div class="right-side">${this.hideCloseButton?c:d`<mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${this.handleClose}">${y({size:24})}</mq-button>`}</div></header>`}};e([h({type:String})],K.prototype,"professionalHash",void 0),e([h({type:Boolean})],K.prototype,"hideCloseButton",void 0),e([h({type:String})],K.prototype,"view",void 0),K=e([i(),t("chat-room-header")],K);const F=/(https?:\/\/[^\s,;:!)\]}\]]+|www\.[^\s,;:!)\]}\]]+|[a-zA-Z0-9][-a-zA-Z0-9]*(?:\.[a-zA-Z0-9][-a-zA-Z0-9]*)+(?:\/[^\s,;:!)\]}\]]*|(?:\?|#|&)[^\s,;:!)\]}\]]*)?)/gi;function O(e){return e.split(F).map((e,t)=>{if(t%2==1){const t=e.startsWith("http")?e:`https://${e}`;return d`<a href="${t}" target="_blank" rel="noopener noreferrer" class="message-link">${e}</a>`}return e})}let Q=class TextMessageBubble extends l{static{this.styles=[n`:host{display:block}.message-bubble{padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal)}.message-bubble.received{background-color:var(--chat-received-message-background);color:var(--chat-received-message-foreground);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);color:var(--chat-sent-message-foreground);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}.message-bubble.received .message-content a.message-link,.message-bubble.sent .message-content a.message-link{color:var(--color-primary-link-default);text-decoration:underline}.message-bubble.received .message-content a.message-link:hover,.message-bubble.sent .message-content a.message-link:hover{opacity:.8}`]}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return d`<div class="message-content">${O(e)}</div>`;const s=t.map(e=>d`<div class="message-paragraph">${O(e.trim())}</div>`);return d`<div class="message-content">${s}</div>`}render(){return d`<div class="message-bubble ${this.kind}">${this.formatMessageContent(this.message.string)}</div>`}};e([h({type:Object})],Q.prototype,"message",void 0),e([h({type:String})],Q.prototype,"kind",void 0),Q=e([t("text-message-bubble")],Q);const V=n`:host{display:block}.message-bubble{padding:var(--size-2);border-radius:var(--border-radius-lg);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);overflow:hidden}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.image-content{display:block;width:229px;height:229px;object-fit:cover;border-radius:var(--border-radius-md)}.image-placeholder{display:flex;align-items:center;justify-content:center;width:100%;max-width:300px;height:200px;background-color:var(--color-gray-light);border-radius:var(--border-radius-md);color:var(--chat-sent-message-foreground);font-size:var(--text-sm)}.image-content{cursor:pointer;transition:opacity .2s ease}.image-content:hover{opacity:.9}.preview-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:var(--dialog-underlay);display:flex;align-items:center;justify-content:center;z-index:1000;cursor:pointer;opacity:0;transition:opacity var(--dialog-transition-duration) ease}.preview-overlay.open{opacity:1}.preview-image{position:fixed;z-index:1000;inset:var(--mq-safe-top,0) var(--mq-safe-right,0) var(--mq-safe-bottom,0) var(--mq-safe-left,0);max-width:calc(100% - var(--mq-safe-left,4px) - var(--mq-safe-right,4px));max-height:calc(100% - var(--mq-safe-top,4px) - var(--mq-safe-bottom,4px));margin:auto;object-fit:contain;cursor:default;box-shadow:var(--dialog-shadow);transform:scale(.95);transition:transform var(--dialog-transition-duration) ease}.preview-overlay.open .preview-image{transform:scale(1)}.preview-close{z-index:1001;display:inline-flex;align-items:center;justify-content:center;height:var(--size-10);width:var(--size-10);position:absolute;top:var(--mq-safe-top,4px);right:var(--mq-safe-right,4px);background:rgba(255,255,255,.3);border:none;color:var(--color-neutrals-text-default);font-size:var(--text-xl);padding:var(--size-2) var(--size-3);border-radius:var(--border-radius-md);cursor:pointer;transition:background var(--dialog-transition-duration) ease}.preview-close:hover{background:var(--dialog-close-hover-bg)}`;let Y=class ImageMessageBubble extends l{constructor(){super(...arguments),this.showPreview=!1,this.isPreviewRendered=!1,this.isPreviewActive=!1,this.closeTimer=null}static{this.styles=V}handleImageError(e){const t=e.target;t.style.display="none";const s=t.nextElementSibling;s&&(s.style.display="flex")}handleImageLoad(e){const t=e.target.nextElementSibling;t&&(t.style.display="none")}handleImageClick(){this.showPreview=!0,this.isPreviewRendered=!0,this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.isPreviewActive=!0})})}handleImageKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleImageClick())}handleClosePreview(e){e&&e.stopPropagation(),this.isPreviewActive=!1,this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=window.setTimeout(()=>{this.isPreviewRendered=!1,this.showPreview=!1,this.closeTimer=null},200)}handleOverlayClick(e){e.target===e.currentTarget&&this.handleClosePreview()}handleOverlayKeyDown(e){"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),this.handleClosePreview())}handleKeyDown(e){"Escape"===e.key&&this.showPreview&&(e.preventDefault(),this.handleClosePreview())}handlePreviewImageKeyDown(e){e.stopPropagation()}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown.bind(this)),this.closeTimer&&(window.clearTimeout(this.closeTimer),this.closeTimer=null)}render(){const e=this.message.attachment.signed_url??this.message.attachment.url;return d`<div class="message-bubble ${this.kind}"><img class="image-content" src="${e}" width="229" height="229" alt="Shared attachment" @error="${this.handleImageError}" @load="${this.handleImageLoad}" @click="${this.handleImageClick}" @keydown="${this.handleImageKeyDown}" tabindex="0"><div class="image-placeholder" style="display:none">Image unavailable</div></div>${this.showPreview&&this.isPreviewRendered?d`<div class="preview-overlay ${this.isPreviewActive?"open":""}" @click="${this.handleOverlayClick}" @keydown="${this.handleOverlayKeyDown}" tabindex="0"><button class="preview-close" @click="${this.handleClosePreview}" aria-label="Close preview">${y({size:24})}</button> <img class="preview-image" src="${e}" alt="Shared attachment preview" @click="${e=>e.stopPropagation()}" @keydown="${this.handlePreviewImageKeyDown}" tabindex="0"></div>`:""}`}};e([h({type:Object})],Y.prototype,"message",void 0),e([h({type:String})],Y.prototype,"kind",void 0),e([o({context:R})],Y.prototype,"token",void 0),e([m()],Y.prototype,"showPreview",void 0),e([m()],Y.prototype,"isPreviewRendered",void 0),e([m()],Y.prototype,"isPreviewActive",void 0),Y=e([t("image-message-bubble")],Y);const Z=n`:host{background-color:var(--chat-system-message-background);color:var(--chat-system-message-foreground);display:block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal)}a.message-link{color:var(--color-primary-link-default);text-decoration:underline}a.message-link:hover{opacity:.8}`;let J=class SystemMessageBubble extends l{static{this.styles=Z}render(){return d`<div class="system-message-bubble">${O(this.message.string)}</div>`}};e([h({type:Object})],J.prototype,"message",void 0),J=e([t("system-message-bubble")],J);const G=n`:host{display:block}.message-bubble{display:inline-block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);text-decoration:underline;color:var(--color-primary-link-default);border:none;cursor:pointer;text-align:left}.message-bubble:hover:not(:disabled){opacity:.8}.message-bubble:disabled{opacity:.5;cursor:not-allowed}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}`;let X=class FileMessageBubble extends l{constructor(){super(...arguments),this.isDownloading=!1}static{this.styles=G}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return d`<div class="message-content">${e}</div>`;const s=t.map(e=>d`<div class="message-paragraph">${e.trim()}</div>`);return d`<div class="message-content">${s}</div>`}async handleDownload(){if(this.isDownloading)return;const e=this.message.attachment.url;try{this.isDownloading=!0;const t=await fetch(e,{headers:{Authorization:`Bearer ${this.token}`}});if(!t.ok)throw new Error(`Failed to fetch file: ${t.statusText}`);const s=await t.blob(),o=new FileReader;o.onloadend=()=>{const e=o.result,t=new I({url:e,filename:this.message.attachment.file_name});this.dispatchEvent(t),this.isDownloading=!1},o.onerror=()=>{$.error("Error reading file as data URL"),this.isDownloading=!1},o.readAsDataURL(s)}catch(e){$.error("Error downloading file:",e),this.isDownloading=!1}}render(){return d`<button type="button" @click="${this.handleDownload}" class="message-bubble ${this.kind}" ?disabled="${this.isDownloading}">${this.formatMessageContent(this.message.attachment.file_name)}</button>`}};e([h({type:Object})],X.prototype,"message",void 0),e([h({type:String})],X.prototype,"kind",void 0),e([o({context:R})],X.prototype,"token",void 0),e([m()],X.prototype,"isDownloading",void 0),X=e([t("file-message-bubble")],X);let W=class MessageBubble extends l{constructor(){super(...arguments),this.showTimestamp=!0}static{this.styles=[n`:host{display:block}.timestamp{font-family:var(--font-body);font-size:var(--text-xs);color:var(--color-gray-medium);font-weight:var(--font-weight-normal);text-align:left;display:flex;align-items:center;gap:var(--size-1)}.timestamp.sent{text-align:right;justify-content:flex-end}.status-icon{width:12px;height:12px}.status-icon.read{color:var(--color-primary)}`]}formatTimestamp(e){if(!e)return"";try{const t=new Date(e);return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}catch{return e}}renderStatusIcon(){switch(this.message.status){case v.Sent:return D({size:12,color:"currentColor"});case v.Received:return T({size:12,color:"currentColor"});case v.Read:return T({size:12,color:"currentColor",className:"read"});default:return null}}renderBubbleContent(){switch(this.message.type){case"image":return d`<image-message-bubble .message="${this.message}" .kind="${this.kind}"></image-message-bubble>`;case"file":return d`<file-message-bubble .message="${this.message}" .kind="${this.kind}"></file-message-bubble>`;default:return d`<text-message-bubble .message="${this.message}" .kind="${this.kind}"></text-message-bubble>`}}render(){if(this.message.senderType===z.system)return d`<system-message-bubble .message="${this.message}"></system-message-bubble>`;const e=this.message.createdAt?new Date(this.message.createdAt):this.message.time?new Date(this.message.time):null;return d`${this.renderBubbleContent()} ${this.showTimestamp&&e?d`<div class="timestamp ${this.kind}">${this.formatTimestamp(e.toISOString())} ${"sent"===this.kind?d`<span class="status-icon ${this.message.status===v.Read?"read":""}">${this.renderStatusIcon()}</span>`:""}</div>`:""}`}};e([h({type:String})],W.prototype,"kind",void 0),e([h({type:Object})],W.prototype,"message",void 0),e([h({type:Boolean})],W.prototype,"showTimestamp",void 0),W=e([t("message-bubble")],W);let ee=class DateBanner extends l{constructor(){super(...arguments),this.date=""}static{this.styles=[g,n`:host{display:block;margin-bottom:var(--size-2)}.date-banner{display:flex;align-items:center;justify-content:center;position:relative}.date-text{background-color:var(--color-gray-light);color:var(--color-gray-darker);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);padding:var(--size-1) var(--size-2);border-radius:var(--border-radius-2xl);white-space:nowrap}`]}formatDate(e){const t=M().replace("_","-"),s=new Date(e),o=new Date,i=new Date(o);i.setDate(i.getDate()-1);const r=new Date(s.getFullYear(),s.getMonth(),s.getDate()),n=new Date(o.getFullYear(),o.getMonth(),o.getDate()),l=new Date(i.getFullYear(),i.getMonth(),i.getDate());return r.getTime()===n.getTime()?a("Hoy"):r.getTime()===l.getTime()?a("Ayer"):s.toLocaleDateString(t,{dateStyle:"medium"})}render(){return d`<div class="date-banner"><span class="date-text">${this.formatDate(this.date)}</span></div>`}};function te(e){return e.createdAt?new Date(e.createdAt):e.time?new Date(e.time):new Date}e([h({type:String})],ee.prototype,"date",void 0),ee=e([i(),t("date-banner")],ee);let se=class MessagesList extends l{constructor(){super(...arguments),this.messages=[]}static{this.styles=[g,n`:host{display:block;width:100%;height:100%;overflow-y:auto;overflow-x:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-1);background-color:var(--color-white);padding-bottom:var(--size-4)}.message-wrapper{display:flex;width:100%}.message-wrapper.received{justify-content:flex-start}.message-wrapper.sent{justify-content:flex-end}.message-wrapper.system{justify-content:center}message-bubble{max-width:70%}`]}scrollToBottom(){requestAnimationFrame(()=>{const e=this.messagesContainerEnd;e&&e.scrollIntoView({behavior:"instant",block:"end"})})}shouldShowMessageTimestamp(e,t){if(e.senderType===z.system)return!1;if(!t)return!0;if(t.senderType!==e.senderType)return!0;if(t.senderType===z.ordinary&&e.senderType===z.ordinary&&t.fromUserHash!==e.fromUserHash)return!0;return(te(t).getTime()-te(e).getTime())/6e4>1}groupMessagesByDate(e){const t=[];let s=null;return e.forEach((o,i)=>{const a=te(o),r=a?.toDateString();r!==s&&(t.push({type:"date",data:a.toDateString()}),s=r??null);const n=e[i+1],l=this.shouldShowMessageTimestamp(o,n);t.push({type:"message",data:o,showTimestamp:l})}),t}firstUpdated(){this.scrollToBottom()}willUpdate(e){e.has("messages")&&this.scrollToBottom()}render(){const e=this.groupMessagesByDate(this.messages),t=e.map((t,s)=>{if("date"===t.type)return d`<date-banner .date="${t.data}"></date-banner>`;const o=this.professionalHash!==t.data.fromUserHash,i=t.data.senderType===z.system?"system":o?"sent":"received";return d`<div class="message-wrapper ${i}"><message-bubble .message="${t.data}" .kind="${i}" .showTimestamp="${t.showTimestamp||"date"===e[s+1]?.type}"></message-bubble></div>`});return d`<div class="messages-container">${t}<div class="messages-container-end"></div></div>`}};e([h({type:Array})],se.prototype,"messages",void 0),e([h({type:String})],se.prototype,"professionalHash",void 0),e([x(".messages-container-end")],se.prototype,"messagesContainerEnd",void 0),se=e([t("messages-list")],se);let oe=class MessageBubbleSkeleton extends l{constructor(){super(...arguments),this.variant="patient",this.height="md",this.showTimestamp=!0}static{this.styles=[n`:host{display:block}.message-bubble{padding:var(--size-4);border-radius:var(--border-radius-lg);margin-bottom:var(--size-1);position:relative;overflow:hidden}.message-bubble.doctor{background-color:var(--color-gray-light);border-bottom-left-radius:0}.message-bubble.patient{background-color:var(--color-background-primary-light);border-bottom-right-radius:0}:host([height=sm]) .message-bubble{height:var(--size-8)}:host([height=md]) .message-bubble{height:var(--size-12)}`]}render(){return d`<div class="message-bubble ${this.variant}"></div>${this.showTimestamp?d`<div class="timestamp-skeleton ${this.variant}"></div>`:""}`}};e([h({type:String})],oe.prototype,"variant",void 0),e([h({type:String})],oe.prototype,"height",void 0),e([h({type:Boolean})],oe.prototype,"showTimestamp",void 0),oe=e([t("message-bubble-skeleton")],oe);let ie=class MessagesSkeleton extends l{constructor(){super(...arguments),this.messageCount=6}static{this.styles=[g,n`:host{display:block;width:100%;height:100%;overflow:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-3);max-width:100%;height:100%;background-color:var(--color-white)}.message-wrapper{display:flex;width:100%}.message-wrapper.doctor{justify-content:flex-start}.message-wrapper.patient{justify-content:flex-end}message-bubble-skeleton{max-width:85%;min-width:60%;width:100%}`]}getSkeletonHeight(e){const t=["sm","md","sm","md","sm","md"];return t[e%t.length]}getSkeletonVariant(e){const t=["doctor","patient","doctor","doctor","patient","doctor","patient"];return t[e%t.length]}renderSkeletonMessages(){return Array.from({length:this.messageCount},(e,t)=>{const s=this.getSkeletonVariant(t),o=this.getSkeletonHeight(t);return d`<div class="message-wrapper ${s}"><message-bubble-skeleton variant="${s}" height="${o}" ?showTimestamp="${t===this.messageCount-1||Math.random()>.7}"></message-bubble-skeleton></div>`})}render(){return d`<div class="messages-container">${this.renderSkeletonMessages()}</div>`}};e([h({type:Number})],ie.prototype,"messageCount",void 0),ie=e([t("messages-skeleton")],ie);var ae=class{constructor(e,t){this.host=e,this.listeners=[],this.host.addController(this),this.socketContext=new S(this.host,{context:j,subscribe:!0,callback:e=>{if(e&&(this.socket=e,t?.listeners)){this.listeners=t.listeners;for(const e of this.listeners)this.socket?.on(e.eventName,e.callback)}}})}hostConnected(){}hostDisconnected(){for(const e of this.listeners)this.socket?.off(e.eventName,e.callback)}};function re(e,t){return{queryKey:["rooms",t.roomId],queryFn:()=>e.rooms.getRoomMessages(t),staleTime:0}}class OptimisticUpdatesController{constructor(e){this.host=e,this.queryClientContext=new S(this.host,{context:P,subscribe:!0,callback:e=>{e&&(this.queryClient=e)}}),this.host.addController(this)}hostConnected(){}appendMessageToRoom(e,t){const s=re(u,{roomId:t}).queryKey;this.queryClient?.setQueriesData({queryKey:s,exact:!0},t=>[...t??[],e])}deleteMessage(e,t){if(!this.queryClient)return;const s=re(u,{roomId:t}).queryKey;this.queryClient.setQueryData(s,t=>(t??[]).map(t=>t.messageId===e?{...t,deletedAt:(new Date).toISOString(),string:a("Este mensaje fue eliminado")}:t))}updateMessageStatus({messageId:e,status:t,roomId:s}){if(!this.queryClient)return;const o=re(u,{roomId:s}).queryKey;this.queryClient.setQueryData(o,s=>(s??[]).map(s=>s.messageId===e?{...s,status:t}:s))}}let ne=class ChatRoomMessages extends l{constructor(){super(...arguments),this.getRoomMessagesQuery=new b(this,()=>re(u,{roomId:this.roomId})),this.optimisticUpdatesController=new OptimisticUpdatesController(this),this.onMessageReceived=e=>{if(e.roomId!==this.roomId)return;const t=function(e){const t={roomId:"string"==typeof e.roomId?Number.parseInt(e.roomId,10):e.roomId,messageId:e.messageId,status:e.status,senderType:e.senderType,fromUserHash:e.fromUserHash,time:e.time,createdAt:e.time?new Date(e.time).toISOString():null,deletedAt:null};switch(e.type){case"string":return{...t,type:"string",string:e.string,auto:e.auto?1:0,attachment:null};case"image":return{...t,type:"image",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.imageUrl,type:"uncategorized",meta:{duration:0},signed_url:e.imageUrl}};case"file":return{...t,type:"file",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.fileUrl,type:"uncategorized",meta:{duration:0},signed_url:e.fileUrl}};default:return{...t,type:"string",string:"",auto:0,attachment:null}}}(e);this.optimisticUpdatesController.appendMessageToRoom(t,t.roomId),t.roomId===this.roomId&&e.fromUserHash===this.professionalHash&&this._socketController.socket?.emit(q.messageStatus,e.messageId,this.roomId,v.Read)},this.onMessageDeleted=e=>{e.room_id===this.roomId&&this.optimisticUpdatesController.deleteMessage(e.message_id,e.room_id)},this.onMessageStatusUpdated=e=>{e.roomId===this.roomId&&this.optimisticUpdatesController.updateMessageStatus({messageId:e.messageId,status:e.status,roomId:e.roomId})},this._socketController=new ae(this,{listeners:[{eventName:q.message,callback:this.onMessageReceived},{eventName:q.message_deleted,callback:this.onMessageDeleted},{eventName:q.messageStatus,callback:this.onMessageStatusUpdated}]})}static{this.styles=[g,n`:host{display:block;width:100%;height:100%}`]}render(){return this.getRoomMessagesQuery.render({pending:()=>d`<messages-skeleton messageCount="8"></messages-skeleton>`,complete:e=>d`<messages-list .messages="${e}" .professionalHash="${this.professionalHash}"></messages-list>`})}};e([h({type:Number})],ne.prototype,"roomId",void 0),e([h({type:String})],ne.prototype,"professionalHash",void 0),ne=e([t("chat-room-messages")],ne);var le=class{constructor(e){this.string=e.string,this.roomId=e.roomId,this.messageId=e.messageId,this.type=e.type,this.fileName=e.fileName,this.autoMessage=e.autoMessage,this.senderType=e.senderType,this.attachmentType=e.attachmentType,this.consultationId=e.consultationId,this.consultationType=e.consultationType}toSocketMessage(){return[q.message,this.string,this.roomId,this.messageId,this.type,this.fileName,this.autoMessage,this.senderType,this.attachmentType,this.consultationId,this.consultationType]}},de=class extends le{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.string,type:"string",fileName:null,autoMessage:!1,senderType:z.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}},ce=class extends le{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.base64Attachment,fileName:e.fileName,type:e.type,autoMessage:!1,senderType:z.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}};async function he(e){return await Promise.all(e.map(async e=>{const t=await function(e){return new Promise((t,s)=>{const o=new FileReader;o.onload=()=>{const i=o.result.split(",")[1];i?t(i):s(new Error(`Invalid data URL format for file: ${e.name}`))},o.onerror=()=>{s(new Error(`Failed to read file: ${e.name}`))},o.readAsDataURL(e)})}(e);return{name:e.name,size:e.size,type:e.type,base64:t}}))}const me=n`:host{display:block;position:absolute;bottom:0;padding:var(--size-2) var(--size-2);background:#fff}.footer-container{display:flex;align-items:center;gap:var(--size-1);max-width:100%}.input-container{flex:1;position:relative;display:flex;align-items:center;border:1px solid var(--color-neutrals-border-disabled);border-radius:var(--border-radius-2xl);padding:0 var(--size-1);overflow:hidden}.input-container:focus-within{border-color:var(--color-primary)}.message-input{flex:1;border:none;outline:0;background:0 0;font-family:var(--font-body);font-size:var(--text-base);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);padding-left:var(--sp-2)}.message-input::placeholder{color:var(--color-neutrals-text-medium)}.attachment-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.send-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.send-button{color:var(--color-neutrals-link-disabled);background:0 0;border:none;padding:var(--size-2);border-radius:var(--border-radius-md);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .2s ease}.send-button:hover:not(.disabled){background:var(--color-primary-light)}.send-button:active:not(.disabled){background-color:var(--color-neutrals-background-active)}.send-button.disabled{cursor:not-allowed;opacity:.4}.send-button.disabled .send-icon{color:var(--color-neutrals-text-disabled)}`;let pe=class ChatRoomFooter extends l{constructor(){super(...arguments),this.isTyping=!1,this.typingTimeoutId=null,this.inputValue="",this.socketController=new ae(this)}static{this.styles=[me]}handleInputChange(e){const t=e.target;this.inputValue=t.value,this.isTyping||(this.socketController.socket?.emit(q.typing,this.roomId),this.isTyping=!0),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId),this.typingTimeoutId=setTimeout(()=>{this.isTyping&&(this.socketController.socket?.emit(q.stop_typing,this.roomId),this.isTyping=!1)},1500)}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())}async handleAttachment(e){const t=e.target.files;if(!t||0===t.length)return;const s=t.item(0);if(s)try{const e=(await he([s]))[0];if(!e)return void $.error("Error converting file to base64");const t=e?.type.includes("image")?"image":"file",o=crypto.randomUUID(),i=s.name,a=new ce({type:t,base64Attachment:e.base64,fileName:i,roomId:this.roomId,messageId:o,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...a.toSocketMessage())}catch(e){$.error("Error converting files to base64:",e)}}handleAttachmentClick(){this.attachmentInput.click()}handleSendMessage(){const e=this.inputValue.trim();if(!e)return;const t=crypto.randomUUID();this.isTyping&&(this.socketController.socket?.emit(q.stop_typing,this.roomId),this.isTyping=!1,this.typingTimeoutId&&clearTimeout(this.typingTimeoutId));const s=new de({messageId:t,string:e,roomId:this.roomId,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...s.toSocketMessage()),this.inputValue=""}disconnectedCallback(){this.isTyping&&(this.socketController.socket?.emit(q.stop_typing,this.roomId),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId))}render(){const e=this.inputValue.trim().length>0;return d`<div class="footer-container"><div class="input-container"><input class="message-input" type="text" placeholder="${a("Escribe aquí...")}" .value="${this.inputValue}" @input="${this.handleInputChange}" @keydown="${this.handleKeyDown}"><div><input class="attachment-input sr-only" type="file" accept="image/jpeg,image/jpg,image/png,image/gif,image/bmp,image/tiff,application/pdf,text/*,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,audio/*,video/*" @change="${this.handleAttachment}"><mq-button variant="ghost" size="icon-sm" @click="${this.handleAttachmentClick}" title="${a("Adjuntar archivo")}">${d`<svg class="attachment-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`}</mq-button></div></div><button class="send-button ${e?"":"disabled"}" @click="${this.handleSendMessage}" ?disabled="${!e}" title="${a("Enviar mensaje")}">${d`<svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 2L11 13"/><path d="M22 2L15 22L11 13L2 9L22 2z"/></svg>`}</button></div>`}};e([o({context:H})],pe.prototype,"consultationId",void 0),e([o({context:N})],pe.prototype,"consultationType",void 0),e([h({type:Number})],pe.prototype,"roomId",void 0),e([m()],pe.prototype,"inputValue",void 0),e([x(".attachment-input")],pe.prototype,"attachmentInput",void 0),pe=e([t("chat-room-footer")],pe);const ge=e=>({all_week:!0,monday:1===e,tuesday:2===e,wednesday:3===e,thursday:4===e,friday:5===e,saturday:6===e,sunday:7===e,working_week:e>=1&&e<=5,weekend:0===e||6===e});function ue(e,t){const s=ge(6===e?0:e+1);return t.some(e=>{const t=e.days_of_week;return!0===s[t]})}let ve=class AvailabilitySection extends l{constructor(){super(...arguments),this.gaps=[],this.selectedDay=function(){const e=(new Date).getDay();return 0===e?6:e-1}()}static{this.styles=n`:host{display:flex;flex-direction:column;gap:var(--size-3)}.availability-header{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-normal);color:var(--color-primary);text-align:center;margin:0;margin-bottom:var(--size-4) 0}.availability-days{display:flex;flex-direction:row;justify-content:center;gap:var(--size-1);overflow-x:auto;padding-bottom:var(--size-4)}.availability-button{outline:0;border:1px solid var(--color-gray-medium);background:0 0;color:var(--color-gray-medium);cursor:pointer;height:var(--size-9);width:var(--size-10);border-radius:var(--border-radius-sm);text-transform:capitalize;font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium)}.availability-button:hover{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button:focus{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button.active{background:var(--color-primary);color:var(--color-white);border:none}.availability-button:disabled{opacity:.5;cursor:not-allowed;background-color:var(--color-gray-light)}.time-title{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-gray-dark);margin:0;margin-bottom:var(--size-1)}.time-entries{display:flex;flex-direction:column;gap:var(--size-1);margin-bottom:var(--size-6)}.time-entry{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal);color:var(--color-gray-medium);margin:0}`}updated(e){e.has("gaps")&&(void 0===this.selectedDay||ue(this.selectedDay,this.gaps)||(this.selectedDay=void 0))}render(){const e=[{shortLabel:a("Lu"),label:a("Lunes"),key:"monday",disabled:!ue(0,this.gaps)},{shortLabel:a("Ma"),label:a("Martes"),key:"tuesday",disabled:!ue(1,this.gaps)},{shortLabel:a("Mi"),label:a("Miércoles"),key:"wednesday",disabled:!ue(2,this.gaps)},{shortLabel:a("Ju"),label:a("Jueves"),key:"thursday",disabled:!ue(3,this.gaps)},{shortLabel:a("Vi"),label:a("Viernes"),key:"friday",disabled:!ue(4,this.gaps)},{shortLabel:a("Sa"),label:a("Sábado"),key:"saturday",disabled:!ue(5,this.gaps)},{shortLabel:a("Do"),label:a("Domingo"),key:"sunday",disabled:!ue(6,this.gaps)}];return d`<h2 class="availability-header">${a("Disponibilidad")}</h2><div class="availability-days">${e.map((e,t)=>d`<button type="button" class="availability-button ${_({active:this.selectedDay===t&&!e.disabled})}" ?disabled="${e.disabled}" @click="${()=>{e.disabled||(this.selectedDay=t)}}">${e.shortLabel}</button>`)}</div>${void 0===this.selectedDay||e[this.selectedDay]?.disabled?"":(()=>{const t=function(e,t){const s=ge(6===e?0:e+1);return t.filter(e=>{const t=e.days_of_week;return!0===s[t]}).map(e=>({from_time:e.from_time,to_time:e.to_time}))}(this.selectedDay,this.gaps);return d`<div class="availability-time"><p class="time-title">${e[this.selectedDay]?.label}</p><div class="time-entries">${t.length>0?t.map(e=>d`<p class="time-entry">${a("De")} ${e.from_time} ${a("a")} ${e.to_time}</p>`):d`<p class="time-entry">${a("No hay horarios disponibles")}</p>`}</div></div>`})()}`}};e([h({type:Array})],ve.prototype,"gaps",void 0),e([m()],ve.prototype,"selectedDay",void 0),ve=e([i(),t("availability-section")],ve);const ye=n`:host{display:flex;flex-direction:column;height:100%;overflow-y:auto;background-color:var(--color-white)}.profile-container{padding:var(--size-6);display:flex;flex-direction:column}.profile-header{display:flex;flex-direction:column;align-items:center;text-align:center;padding-bottom:var(--size-6);border-bottom:1px solid var(--color-gray-medium);margin-bottom:var(--size-6)}.profile-avatar{margin-bottom:var(--size-2)}.profile-name{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-primary);margin:var(--size-4) 0}.profile-specialty{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-icons--secondary);margin:0;margin-bottom:var(--size-2);text-transform:uppercase}.profile-collegiate{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);color:var(--color-gray-medium);text-transform:uppercase;margin:0}.description-header{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);color:var(--color-primary);margin:0;margin-bottom:var(--size-3)}.description-text{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-foreground);margin:0}`;let be=class ChatRoomProfile extends l{constructor(){super(...arguments),this.getProfessionalQuery=new b(this,()=>f(u,{hash:this.professionalHash}))}static{this.styles=[g,ye]}renderProfile(e){return d`<div class="profile-container"><div class="profile-header"><mq-avatar class="profile-avatar" src="${e.avatar||""}" fallback="${e.name}" alt="${e.name}'s profile picture" size="xl"></mq-avatar><div><h1 class="profile-name">${e.name}</h1>${e.title?d`<p class="profile-specialty">${e.title}</p>`:""} ${e.collegiate_number?d`<p class="profile-collegiate">${a(r`Nº COL. ${e.collegiate_number}`)}</p>`:""}</div></div>${e.chat_schedule&&e.chat_schedule.gaps.length>0?d`<availability-section .gaps="${e.chat_schedule.gaps}"></availability-section>`:c} ${e.description||e.overview?d`<div><h2 class="description-header">${a("Descripción")}</h2><p class="description-text">${e.description||e.overview}</p></div>`:""}</div>`}render(){return this.getProfessionalQuery.render({pending:()=>d``,complete:e=>this.renderProfile(e)})}};e([h({type:String})],be.prototype,"professionalHash",void 0),be=e([i(),t("chat-room-profile")],be);const fe=n`.root{display:flex;flex-direction:column;height:100%;overflow:hidden}chat-room-header{flex-shrink:0}chat-room-messages{flex:1;overflow-y:auto;overflow-x:hidden}chat-room-footer{position:sticky;bottom:0;left:0;right:0;flex-shrink:0}`;let we=class MqChatRoom extends l{constructor(){super(...arguments),this.consultationId=void 0,this.consultationType=void 0,this.readonly=!1,this.hideCloseButton=!1,this.view="chat",this.socketController=new ae(this),this.readAllMessagesMutation=new A(this,{mutationFn:()=>u.professionals.readAllMessages({roomId:this.roomId}),onSuccess:()=>{this.queryClientContext?.invalidateQueries({queryKey:C(u,{roomId:this.roomId}).queryKey})}})}static{this.styles=[g,fe]}willUpdate(e){e.has("apiKey")&&this.apiKey&&u.setApiKey(this.apiKey),e.has("token")&&u.setAuthToken(this.token),e.has("roomId")&&(this.socketController.socket?.emit(q.joinRoom,this.roomId),this.readAllMessagesMutation.run(void 0))}render(){return d`<div class="root"><chat-room-header .professionalHash="${this.professionalHash}" .view="${this.view}" .hideCloseButton="${this.hideCloseButton}" @mq-chat-room-profile="${()=>{this.view="profile"}}" @goto-chat="${()=>{this.view="chat"}}"></chat-room-header>${"chat"===this.view?d`<chat-room-messages .roomId="${this.roomId}" .professionalHash="${this.professionalHash}"></chat-room-messages>${this.readonly?c:d`<chat-room-footer .roomId="${this.roomId}"></chat-room-footer>`}`:d`<chat-room-profile .professionalHash="${this.professionalHash}" @mq-chat-room-chat="${()=>{this.view="chat"}}"></chat-room-profile>`}</div>`}};e([s({context:E}),h({type:String,attribute:"api-key"})],we.prototype,"apiKey",void 0),e([s({context:R}),h({type:String,attribute:"token"})],we.prototype,"token",void 0),e([s({context:B}),h({type:String,attribute:"professional-hash"})],we.prototype,"professionalHash",void 0),e([s({context:U}),h({type:Number,attribute:"room-id"})],we.prototype,"roomId",void 0),e([s({context:H}),h({type:String,attribute:"consultation-id"})],we.prototype,"consultationId",void 0),e([s({context:N}),h({type:String,attribute:"consultation-type"})],we.prototype,"consultationType",void 0),e([h({type:Boolean,reflect:!0})],we.prototype,"readonly",void 0),e([h({type:Boolean,attribute:"hide-close-button"})],we.prototype,"hideCloseButton",void 0),e([m()],we.prototype,"view",void 0),e([o({context:P,subscribe:!0})],we.prototype,"queryClientContext",void 0),we=e([i(),t("mq-chat-room")],we);export{we as MqChatRoom,MqChatRoomCloseEvent,MqChatRoomProfileEvent};
@@ -1 +1 @@
1
- import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{m as s}from"./chunks/runtime-Bg1WXVCx.js";import{l as i}from"./chunks/parseISO-jT42c8Ob.js";import{h as o}from"./chunks/task-Bj8p7kJX.js";import{b as n,P as r}from"./chunks/api-chat-client-C8SqZtCa.js";import{L as a}from"./chunks/login-token-task-BI-L2zSV.js";import{l as h}from"./chunks/external-zAbuzxDj.js";import{i as d,a as l,x as c}from"./chunks/lit-element-DiWJYFwC.js";import{n as p}from"./chunks/property-scuRaFcM.js";import{r as m}from"./chunks/state-LQivXIgA.js";import{setEnv as u}from"./env.js";import{tokens as v}from"./theme.js";import{initLocalization as _,isValidLocale as f,setLocale as y}from"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";var g=class{constructor(e,t){this.host=e,this.options=t,this._deadline=0,this._timedOut=!1,this.host.addController(this)}get timedOut(){return this._timedOut}hostConnected(){const e=this.options.intervalMs??1e3,t=void 0!==this.options.startDelayMs?this.options.startDelayMs:e;this._deadline=Date.now()+this.options.timeoutMs,this._timedOut=!1,this._startTimeoutId=setTimeout(()=>{this._startTimeoutId=void 0,this._poll(),this._intervalId=setInterval(()=>{this._poll()},e)},t)}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 e=await this.options.refetchFn();this.options.shouldComplete(e)&&(this._stop(),this.options.onComplete?.(e))}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{_()}catch{}const k=d`: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}`,E="mediquo:payment:retry",b="mediquo:payment:resize";class CheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(CheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(CheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(CheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutRetryEvent extends Event{static{this.eventName="payment-retry"}constructor(){super(CheckoutRetryEvent.eventName,{bubbles:!0,composed:!0})}}let w=class MqCheckout extends l{constructor(){super(...arguments),this._iframeLoaded=!1,this._iframeHeight=null,this._sessionEpoch=0,this._currentSessionId=null,this._paymentOrigin=null,this._loginTokenTask=new a(this,n,{args:()=>[this.apiKey,this.token],onComplete:e=>{n.setAuthToken(e.access_token),this._sessionTask.run()},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"auth"}))}}),this._sessionTask=new o(this,{task:async()=>{if("function"!=typeof this.provideSession)throw new Error("mq-checkout: `provideSession` property is required");return this.provideSession()},args:()=>[this._sessionEpoch],autoRun:!1,onComplete:e=>{this._currentSessionId=e.sessionId,this._iframeLoaded=!1,this._iframeHeight=null;try{this._paymentOrigin=new URL(e.paymentUrl).origin}catch{this._paymentOrigin=null,h.warn(`mq-checkout: invalid paymentUrl "${e.paymentUrl}"`)}},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"session"}))}}),this._paymentPoll=new g(this,{startDelayMs:5e3,intervalMs:3e3,timeoutMs:6e5,refetchFn:async()=>{if(!this._currentSessionId)throw new Error("mq-checkout: session not ready");const e=await n.payments.getPaymentSession(this._currentSessionId);return e.status===r.Denied&&(this._paymentPoll.stop(),this.dispatchEvent(new CheckoutDeniedEvent({sessionId:this._currentSessionId}))),e},shouldComplete:e=>e.status===r.Paid,onComplete:e=>{this.dispatchEvent(new CheckoutSuccessEvent({sessionId:this._currentSessionId??"",reference:e.consultation_id}))},onTimeout:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"timeout"}))}}),this._onMessage=e=>{if(!this._paymentOrigin||e.origin===this._paymentOrigin)switch(e.data?.type){case E:return this.dispatchEvent(new CheckoutRetryEvent),this._sessionEpoch+=1,void this._sessionTask.run();case b:return void("number"==typeof e.data.height&&(this._iframeHeight=e.data.height))}}}static{this.styles=[v,k]}get _timedOut(){return this._paymentPoll.timedOut}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),super.disconnectedCallback()}willUpdate(e){if(e.has("env")&&this.env&&u(this.env),e.has("apiKey")&&n.setApiKey(this.apiKey),e.has("locale")){const e=f(this.locale)?this.locale:"es_ES";y(e),n.setLanguage(e)}}_onIframeLoad(){this._iframeLoaded=!0}_renderState(e,t){return c`<div class="state"><p class="state-title">${e}</p>${t?c`<p class="state-message">${t}</p>`:null}</div>`}_renderLoading(){return c`<div class="payment-frame"><mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${s("Cargando portal de pago")}"></mq-skeleton></div>`}_renderFrame(e){return c`<div class="payment-frame">${this._iframeLoaded?null:this._renderLoading()}<iframe class="${this._iframeLoaded?"loaded":""}" src="${e}" title="${s("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(s("No hemos podido confirmar tu pago"),s("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(s("No hemos podido iniciar el pago"),s("Por favor, inténtalo de nuevo más tarde.")),complete:()=>this._sessionTask.render({initial:()=>this._renderLoading(),pending:()=>this._renderLoading(),error:()=>this._renderState(s("No hemos podido iniciar el pago"),s("Por favor, inténtalo de nuevo más tarde.")),complete:e=>this._renderFrame(e.paymentUrl)})})}};e([p({type:String,attribute:"env"})],w.prototype,"env",void 0),e([p({type:String,attribute:"api-key"})],w.prototype,"apiKey",void 0),e([p({type:String,attribute:"token"})],w.prototype,"token",void 0),e([p({type:String,attribute:"locale",reflect:!0})],w.prototype,"locale",void 0),e([p({attribute:!1})],w.prototype,"provideSession",void 0),e([m()],w.prototype,"_iframeLoaded",void 0),e([m()],w.prototype,"_iframeHeight",void 0),e([m()],w.prototype,"_sessionEpoch",void 0),w=e([i(),t("mq-checkout")],w);export{CheckoutDeniedEvent,CheckoutErrorEvent,CheckoutRetryEvent,CheckoutSuccessEvent,w as MqCheckout};
1
+ import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{m as s}from"./chunks/runtime-Bg1WXVCx.js";import{l as i}from"./chunks/localized-decorator-BlOuLhym.js";import{h as o}from"./chunks/task-Bj8p7kJX.js";import{a as n,P as r}from"./chunks/api-chat-client-CqMn2JEn.js";import{L as a}from"./chunks/login-token-task-BI-L2zSV.js";import{l as h}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as d,a as l,x as c}from"./chunks/lit-element-DiWJYFwC.js";import{n as p}from"./chunks/property-scuRaFcM.js";import{r as m}from"./chunks/state-LQivXIgA.js";import{setEnv as u}from"./env.js";import{tokens as v}from"./theme.js";import{initLocalization as _,isValidLocale as f,setLocale as y}from"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/external-CJj32K_p.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";var g=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{_()}catch{}const k=d`: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}`,E="mediquo:payment:retry",b="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 C=class MqCheckout extends l{constructor(){super(...arguments),this._iframeLoaded=!1,this._iframeHeight=null,this._sessionEpoch=0,this._currentSessionId=null,this._paymentOrigin=null,this._loginTokenTask=new a(this,n,{args:()=>[this.apiKey,this.token],onComplete:t=>{n.setAuthToken(t.access_token),this._sessionTask.run()},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"auth"}))}}),this._sessionTask=new o(this,{task:async()=>{if("function"!=typeof this.provideSession)throw new Error("mq-checkout: `provideSession` property is required");return this.provideSession()},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,h.warn(`mq-checkout: invalid paymentUrl "${t.paymentUrl}"`)}},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"session"}))}}),this._paymentPoll=new g(this,{startDelayMs:5e3,intervalMs:3e3,timeoutMs:6e5,refetchFn:async()=>{if(!this._currentSessionId)throw new Error("mq-checkout: session not ready");const t=await n.payments.getPaymentSession(this._currentSessionId);return t.status===r.Denied&&(this._paymentPoll.stop(),this.dispatchEvent(new CheckoutDeniedEvent({sessionId:this._currentSessionId}))),t},shouldComplete:t=>t.status===r.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 E:return this.dispatchEvent(new CheckoutRetryEvent),this._sessionEpoch+=1,void this._sessionTask.run();case b:return void("number"==typeof t.data.height&&(this._iframeHeight=t.data.height))}}}static{this.styles=[v,k]}get _timedOut(){return this._paymentPoll.timedOut}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),super.disconnectedCallback()}willUpdate(t){if(t.has("env")&&this.env&&u(this.env),t.has("apiKey")&&n.setApiKey(this.apiKey),t.has("locale")){const t=f(this.locale)?this.locale:"es_ES";y(t),n.setLanguage(t)}}_onIframeLoad(){this._iframeLoaded=!0}_renderState(t,e){return c`<div class="state"><p class="state-title">${t}</p>${e?c`<p class="state-message">${e}</p>`:null}</div>`}_renderLoading(){return c`<div class="payment-frame"><mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${s("Cargando portal de pago")}"></mq-skeleton></div>`}_renderFrame(t){return c`<div class="payment-frame">${this._iframeLoaded?null:this._renderLoading()}<iframe class="${this._iframeLoaded?"loaded":""}" src="${t}" title="${s("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(s("No hemos podido confirmar tu pago"),s("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(s("No hemos podido iniciar el pago"),s("Por favor, inténtalo de nuevo más tarde.")),complete:()=>this._sessionTask.render({initial:()=>this._renderLoading(),pending:()=>this._renderLoading(),error:()=>this._renderState(s("No hemos podido iniciar el pago"),s("Por favor, inténtalo de nuevo más tarde.")),complete:t=>this._renderFrame(t.paymentUrl)})})}};t([p({type:String,attribute:"env"})],C.prototype,"env",void 0),t([p({type:String,attribute:"api-key"})],C.prototype,"apiKey",void 0),t([p({type:String,attribute:"token"})],C.prototype,"token",void 0),t([p({type:String,attribute:"locale",reflect:!0})],C.prototype,"locale",void 0),t([p({attribute:!1})],C.prototype,"provideSession",void 0),t([m()],C.prototype,"_iframeLoaded",void 0),t([m()],C.prototype,"_iframeHeight",void 0),t([m()],C.prototype,"_sessionEpoch",void 0),C=t([i(),e("mq-checkout")],C);export{CheckoutDeniedEvent,CheckoutErrorEvent,CheckoutRetryEvent,CheckoutSuccessEvent,C as MqCheckout};
@@ -0,0 +1,46 @@
1
+ import * as lit_html from 'lit-html';
2
+ import * as lit from 'lit';
3
+ import { LitElement, PropertyValues } from 'lit';
4
+ import { Env } from './env.js';
5
+ import './chunks/index-DNUbmrQl.js';
6
+ import './ui/mq-skeleton.js';
7
+ import './ui/mq-button.js';
8
+ import 'zod';
9
+
10
+ /**
11
+ * Patient documents list (prescriptions, reports). Fetches the patient's
12
+ * documents page by page and renders them as `patient-document` rows, each of
13
+ * which emits `mq-download-file` when the user downloads it.
14
+ *
15
+ * Pagination is internal component state — no router or URL coupling — so the
16
+ * element is self-contained in any host.
17
+ */
18
+ declare class MqDocuments extends LitElement {
19
+ static styles: lit.CSSResult;
20
+ /** Mediquo API key. Required when used standalone. */
21
+ apiKey?: string;
22
+ /** Already-exchanged access token. Required when used standalone. */
23
+ token?: string;
24
+ /** Locale (e.g. "es_ES"). Optional; defaults to the host/build locale. */
25
+ locale?: string;
26
+ /** Environment override ("development" | "production"). Optional. */
27
+ env?: Env;
28
+ private currentPage;
29
+ protected willUpdate(changed: PropertyValues<this>): void;
30
+ private getPatientProfileQuery;
31
+ private get _patientHash();
32
+ private getPatientDocumentsQuery;
33
+ private getOrganizationSpecialtiesQuery;
34
+ private handlePreviousPage;
35
+ private handleNextPage;
36
+ private renderDocuments;
37
+ private renderPagination;
38
+ render(): lit_html.TemplateResult<1>;
39
+ }
40
+ declare global {
41
+ interface HTMLElementTagNameMap {
42
+ "mq-documents": MqDocuments;
43
+ }
44
+ }
45
+
46
+ export { MqDocuments };
@@ -0,0 +1 @@
1
+ import{isValidLocale as t,setLocale as e,getLocale as n,initLocalization as i}from"./i18n.js";import{_ as r,t as s}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a,s as o}from"./chunks/runtime-Bg1WXVCx.js";import{l as c}from"./chunks/localized-decorator-BlOuLhym.js";import{Q as p}from"./chunks/query-controller-BlO1Ax65.js";import{g as l,a as u}from"./chunks/i18n-formats-DYS91YEa.js";import{g as d}from"./chunks/get-patient-profile-query-B0tUDJmT.js";import{i as m,a as h,x as g,E as v}from"./chunks/lit-element-DiWJYFwC.js";import{n as k}from"./chunks/property-scuRaFcM.js";import{r as y}from"./chunks/state-LQivXIgA.js";import{setEnv as f}from"./env.js";import{a as j}from"./chunks/api-chat-client-CqMn2JEn.js";import{chevronLeftIcon as b}from"./ui/icons/chevron-left-icon.js";import{chevronRightIcon as x}from"./ui/icons/chevron-right-icon.js";import"./chunks/index-Xcn-xs13.js";import"./ui/mq-skeleton.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-CJj32K_p.js";import"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/icons/types.js";import"./ui/icons/download-icon.js";import"./ui/mq-button.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./events.js";import"./chunks/style-map-CIdqdn7C.js";const P=m`:host{display:block}.container{background-color:var(--color-card);padding:var(--sp-5) var(--sp-4);border-radius:var(--border-radius-md)}.documents-list{border-radius:var(--border-radius-md);background-color:var(--color-muted);padding:var(--sp-3);display:flex;flex-direction:column;gap:var(--sp-4)}.empty{font-family:var(--font-body);font-size:var(--text-sm);color:var(--color-neutrals-text-default);text-align:center;padding:var(--sp-6) var(--sp-4);margin:0}hr{width:100%;border:none;border-top:1px solid var(--color-border);margin:0}.pagination{display:flex;align-items:center;justify-content:center;gap:var(--sp-2_5);margin-top:var(--sp-4)}.pagination-text{font-family:var(--font-body);font-size:var(--text-sm);font-weight:var(--font-weight-normal);color:var(--color-neutrals-text-default);line-height:normal}.pagination-button{background:0 0;border:none;cursor:pointer;padding:0;display:flex;align-items:center;justify-content:center;width:24px;height:24px;color:var(--color-neutrals-text-default)}.pagination-button:disabled{opacity:0;cursor:not-allowed}.pagination-button:not(:disabled):hover{opacity:.7}@media (min-width:768px){.documents-list{padding:var(--sp-6)}}`;let $=class MqDocuments extends h{constructor(){super(...arguments),this.currentPage=1,this.getPatientProfileQuery=new p(this,()=>d(j)),this.getPatientDocumentsQuery=new p(this,()=>{return{...(t=j,e={patient_hash:this._patientHash,page:this.currentPage,per_page:6},{queryKey:["patient-documents",e],queryFn:()=>t.flash.getPatientDocuments(e)}),enabled:!!this._patientHash};var t,e}),this.getOrganizationSpecialtiesQuery=new p(this,()=>l(j))}static{this.styles=P}willUpdate(n){n.has("env")&&this.env&&f(this.env),n.has("apiKey")&&this.apiKey&&j.setApiKey(this.apiKey),n.has("token")&&this.token&&j.setAuthToken(this.token),n.has("locale")&&this.locale&&t(this.locale)&&(e(this.locale),j.setLanguage(this.locale))}get _patientHash(){return this.getPatientProfileQuery.result?.data?.hash??""}handlePreviousPage(){this.currentPage>1&&(this.currentPage-=1)}handleNextPage(){const t=this.getPatientDocumentsQuery.result?.data?.meta?.last_page??1;this.currentPage<t&&(this.currentPage+=1)}renderDocuments(){return this.getPatientDocumentsQuery.render({complete:t=>{const e=n();return 0===t.data.length?g`<p class="empty">${a("Aquí se mostrarán tus recetas e informes médicos.")}</p>`:g`<div class="documents-list">${t.data.map((n,i)=>g`<patient-document filename="${n.name}" kind="${n.document_type}" specialty="${(()=>{const t=this.getOrganizationSpecialtiesQuery.result?.data?.find(t=>t.id===n.professional.speciality_id);return u(t?.code??"",e,t?.name)})()}" description="${n.name}" date="${n.created_at}" downloadUrl="${n.url}"></patient-document>${i<t.data.length-1?g`<hr>`:v}`)}</div>${this.renderPagination(t.meta)}`},pending:()=>g`<div class="documents-list"><mq-skeleton height="57px"></mq-skeleton><hr><mq-skeleton height="57px"></mq-skeleton><hr><mq-skeleton height="57px"></mq-skeleton></div>`})}renderPagination(t){const e=t.current_page>1,n=t.current_page<t.last_page;return g`<div class="pagination"><button class="pagination-button" @click="${this.handlePreviousPage}" ?disabled="${!e}" aria-label="${a("Página anterior")}">${b({size:24})}</button> <span class="pagination-text">${a(o`${t.current_page} de ${t.last_page}`)} </span><button class="pagination-button" @click="${this.handleNextPage}" ?disabled="${!n}" aria-label="${a("Página siguiente")}">${x({size:24})}</button></div>`}render(){return g`<div class="container">${this.renderDocuments()}</div>`}};r([k({type:String,attribute:"api-key"})],$.prototype,"apiKey",void 0),r([k({type:String,attribute:"token"})],$.prototype,"token",void 0),r([k({type:String,attribute:"locale"})],$.prototype,"locale",void 0),r([k({type:String,attribute:"env"})],$.prototype,"env",void 0),r([y()],$.prototype,"currentPage",void 0),$=r([c(),s("mq-documents")],$),i();export{$ as MqDocuments};
@@ -1 +1 @@
1
- import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/parseISO-jT42c8Ob.js";import{L as o}from"./chunks/login-token-task-BI-L2zSV.js";import{l as i}from"./chunks/external-zAbuzxDj.js";import{i as s,a as r,x as l}from"./chunks/lit-element-DiWJYFwC.js";import{n as c}from"./chunks/property-scuRaFcM.js";import{r as h}from"./chunks/state-LQivXIgA.js";import{setEnv as u}from"./env.js";import{initLocalization as p,isValidLocale as y,setLocale as d}from"./i18n.js";import{i as m,b as g}from"./chunks/api-chat-client-C8SqZtCa.js";import{r as v}from"./chunks/apple-pay-outcomes-BNkcTbbM.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";function b(){return"undefined"!=typeof google&&"function"==typeof google.payments?.api?.PaymentsClient}const _=["PAN_ONLY","CRYPTOGRAM_3DS"],f=["VISA","MASTERCARD","AMEX"];function k(t){return{type:"PAYMENT_GATEWAY",parameters:{gateway:"globalpayments",gatewayMerchantId:t}}}function C(t){return{type:"CARD",parameters:{allowedAuthMethods:[..._],allowedCardNetworks:[...f]},tokenizationSpecification:k(t)}}function w(t){return[C(t)]}function E(t,e){return"test"===e?"TEST":"production"===e?"PRODUCTION":"development"===t?"TEST":"PRODUCTION"}function P(t,e){return function(t,e){return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:w(t.gatewayMerchantId),merchantInfo:{merchantId:t.merchantId,merchantName:t.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPrice:e.amount,currencyCode:e.currencyCode,countryCode:e.countryCode}}}(t,e)}async function I(t,e,a,n={}){if("undefined"==typeof window||!window.isSecureContext)return i.warn("google-pay: unavailable outside a secure context"),{available:!1,reason:"unsupported"};if(!t.trim())return i.warn("google-pay: missing merchant id"),{available:!1,reason:"merchant-id-missing"};if(!e.trim())return i.warn("google-pay: missing gateway merchant id"),{available:!1,reason:"gateway-merchant-id-missing"};if(!await function(t=8e3,e){return b()?Promise.resolve(!0):t<=0||e?.aborted?Promise.resolve(!1):new Promise(a=>{const n=Date.now()+t,o=t=>{clearInterval(s),e?.removeEventListener("abort",i),a(t)},i=()=>o(!1),s=setInterval(()=>{b()?o(!0):Date.now()>=n&&o(!1)},100);e?.addEventListener("abort",i,{once:!0})})}(n.sdkWaitTimeoutMs,n.signal))return i.warn("google-pay: pay.js was not loaded by the host page"),{available:!1,reason:"sdk-missing"};const o=E(a,n.gatewayEnvironment);try{const t=new google.payments.api.PaymentsClient({environment:o}),a=await t.isReadyToPay(function(t){return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:w(t)}}(e));return a.result?{available:!0}:(i.warn("google-pay: isReadyToPay returned false",{environment:o}),{available:!1,reason:"unsupported"})}catch(t){return i.warn("google-pay: isReadyToPay threw",{environment:o,error:t instanceof Error?t.message:String(t)}),{available:!1,reason:"unsupported"}}}function G(t,e){return function(t){if(function(t){return"object"==typeof t&&null!==t&&"statusCode"in t&&"string"==typeof t.statusCode}(t)){const e=t.statusCode.toUpperCase();if("CANCELED"===e||"CANCELLED"===e)return!0}if(t instanceof Error){const e=t.message.toLowerCase();return e.includes("cancel")||e.includes("closed")||e.includes("abort")}return!1}(t)?{kind:"cancelled"}:m(t)&&400===t.response?.status?{kind:"denied",sessionId:e}:{kind:"authorize"}}function S(t){if(null!==t&&"object"==typeof t){const e=t.paymentMethodData?.tokenizationData,a=e?.token;if("string"==typeof a&&a.length>0)return a}throw new Error("Invalid Google Pay payment data: missing tokenizationData.token")}try{p()}catch{}const A=s`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}::slotted([slot=google-pay-button]){display:block;width:100%;height:var(--mq-google-pay-button-height,48px)}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class GooglePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(GooglePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class GooglePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(t){super(GooglePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class GooglePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(t){super(GooglePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}const T=new Set(["sdk-missing","unsupported"]);function D(t,e){i.warn(t,{error:e instanceof Error?e.message:String(e)})}let N=class MqGooglePayCheckout extends r{constructor(){super(...arguments),this._availabilityPhase="checking",this._unavailableReason=null,this._paying=!1,this._paymentsClient=null,this._paymentsClientEnvironment=null,this._buttonHost=null,this._availabilityGeneration=0,this._availabilityAbortController=null,this._terminalErrorDispatched=!1,this._loginTokenTask=new o(this,g,{args:()=>[this.apiKey,this.token],onComplete:t=>{g.setAuthToken(t.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{this._paying||"ready"!==this._availabilityPhase||this._processPayment()}}static{this.styles=A}willUpdate(t){if(t.has("env")&&(this.env&&u(this.env),this._resetPaymentsClient()),t.has("gatewayEnvironment")&&this._resetPaymentsClient(),t.has("apiKey")&&g.setApiKey(this.apiKey),t.has("locale")){const t=y(this.locale)?this.locale:"es_ES";d(t),g.setLanguage(t)}(t.has("merchantId")||t.has("gatewayMerchantId")||t.has("env")||t.has("gatewayEnvironment"))&&this._loginTokenTask.value&&this._refreshAvailability()}connectedCallback(){super.connectedCallback(),this._availabilityAbortController=new AbortController,this._terminalErrorDispatched=!1}disconnectedCallback(){this._availabilityAbortController?.abort(),this._availabilityAbortController=null,this._resetPaymentsClient(),super.disconnectedCallback()}_dispatchTerminalError(){this._terminalErrorDispatched||(this._terminalErrorDispatched=!0,this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"unsupported"})))}_resetPaymentsClient(){this._paymentsClient=null,this._paymentsClientEnvironment=null,this._removeButtonHost()}_getPaymentsClient(){const t=E(this.env,this.gatewayEnvironment);return this._paymentsClient&&this._paymentsClientEnvironment===t||(this._paymentsClient=new google.payments.api.PaymentsClient({environment:t}),this._paymentsClientEnvironment=t,this._buttonHost=null),this._paymentsClient}async _refreshAvailability(){const t=++this._availabilityGeneration;this._availabilityPhase="checking",this._unavailableReason=null,this._removeButtonHost();const e=await I(this.merchantId??"",this.gatewayMerchantId??"",this.env,{signal:this._availabilityAbortController?.signal,gatewayEnvironment:this.gatewayEnvironment});if(t===this._availabilityGeneration&&this.isConnected){if(!e.available)return this._availabilityPhase="unavailable",this._unavailableReason=e.reason,void(T.has(e.reason)&&this._dispatchTerminalError());this._availabilityPhase="ready",this._unavailableReason=null}}_ensureButtonHost(){const t=this.querySelector(':scope > [slot="google-pay-button"]');if(t)return t;const e=document.createElement("div");return e.slot="google-pay-button",this.appendChild(e),e}_removeButtonHost(){this.querySelector(':scope > [slot="google-pay-button"]')?.remove(),this._buttonHost=null}_mountGooglePayButton(){if(this._buttonHost||"ready"!==this._availabilityPhase)return;const t=this._ensureButtonHost();try{const e=this._getPaymentsClient().createButton({onClick:this._onPayClick,buttonColor:"black",buttonType:"pay",buttonSizeMode:"fill"});t.replaceChildren(e),this._buttonHost=t}catch(t){D("mq-google-pay-checkout: failed to create Google Pay button",t),this._removeButtonHost(),this._availabilityPhase="unavailable",this._unavailableReason="unsupported",this._dispatchTerminalError()}}updated(t){super.updated(t),"ready"===this._availabilityPhase&&this._mountGooglePayButton()}async _processPayment(){this._paying=!0;try{const t=await this._getPaymentsClient().loadPaymentData(P({merchantId:this.merchantId,gatewayMerchantId:this.gatewayMerchantId,merchantName:this.merchantName||this.label},{amount:this.amount,currencyCode:this.currency,countryCode:this.country})),e=await g.payments.authorizeGooglePay({order_id:this.sessionId,token:S(t)}),{status:a,consultation_id:n}=e.data,o=v(a,n,this.sessionId);switch(o.kind){case"success":this.dispatchEvent(new GooglePayCheckoutSuccessEvent({sessionId:o.sessionId,reference:o.reference}));break;case"denied":this.dispatchEvent(new GooglePayCheckoutDeniedEvent({sessionId:o.sessionId}));break;case"error":this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:o.reason}))}}catch(t){const e=G(t,this.sessionId);switch(e.kind){case"cancelled":this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"cancelled"}));break;case"denied":this.dispatchEvent(new GooglePayCheckoutDeniedEvent({sessionId:e.sessionId}));break;case"authorize":D("mq-google-pay-checkout: authorize failed",t),this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"authorize"}))}}finally{this._paying=!1}}_renderUnavailable(){switch(this._unavailableReason){case"merchant-id-missing":return l`<p class="state">${a("Falta el identificador de comercio de Google Pay")}</p>`;case"gateway-merchant-id-missing":return l`<p class="state">${a("Falta el identificador de pasarela de Google Pay")}</p>`;case"sdk-missing":return l`<p class="state">${a("No se ha podido cargar Google Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`;default:return l`<p class="state">${a("Google Pay no está disponible. Prueba con tarjeta u otro método de pago.")}</p>`}}render(){return this._loginTokenTask.render({pending:()=>l`<p class="state">${a("Preparando Google Pay…")}</p>`,error:()=>l`<p class="state">${a("No hemos podido iniciar el pago")}</p>`,complete:()=>"checking"===this._availabilityPhase?l`<p class="state">${a("Comprobando Google Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():l`<div class="pay-row ${this._paying?"pay-row--paying":""}"><slot name="google-pay-button"></slot></div>`})}};t([c({type:String,attribute:"env"})],N.prototype,"env",void 0),t([c({type:String,attribute:"gateway-environment"})],N.prototype,"gatewayEnvironment",void 0),t([c({type:String,attribute:"api-key"})],N.prototype,"apiKey",void 0),t([c({type:String,attribute:"token"})],N.prototype,"token",void 0),t([c({type:String,attribute:"locale",reflect:!0})],N.prototype,"locale",void 0),t([c({type:String,attribute:"merchant-id"})],N.prototype,"merchantId",void 0),t([c({type:String,attribute:"gateway-merchant-id"})],N.prototype,"gatewayMerchantId",void 0),t([c({type:String,attribute:"merchant-name"})],N.prototype,"merchantName",void 0),t([c({type:String,attribute:"session-id"})],N.prototype,"sessionId",void 0),t([c({type:String,attribute:"amount"})],N.prototype,"amount",void 0),t([c({type:String,attribute:"currency"})],N.prototype,"currency",void 0),t([c({type:String,attribute:"country"})],N.prototype,"country",void 0),t([c({type:String,attribute:"label"})],N.prototype,"label",void 0),t([h()],N.prototype,"_availabilityPhase",void 0),t([h()],N.prototype,"_unavailableReason",void 0),t([h()],N.prototype,"_paying",void 0),N=t([n(),e("mq-google-pay-checkout")],N);export{GooglePayCheckoutDeniedEvent,GooglePayCheckoutErrorEvent,GooglePayCheckoutSuccessEvent,N as MqGooglePayCheckout};
1
+ import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{L as o}from"./chunks/login-token-task-BI-L2zSV.js";import{l as i}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as s,a as r,x as l}from"./chunks/lit-element-DiWJYFwC.js";import{n as c}from"./chunks/property-scuRaFcM.js";import{r as h}from"./chunks/state-LQivXIgA.js";import{setEnv as u}from"./env.js";import{initLocalization as p,isValidLocale as y,setLocale as d}from"./i18n.js";import{c as m,a as g}from"./chunks/api-chat-client-CqMn2JEn.js";import{r as v}from"./chunks/apple-pay-outcomes-CjCnBYOD.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/external-CJj32K_p.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";function b(){return"undefined"!=typeof google&&"function"==typeof google.payments?.api?.PaymentsClient}const _=["PAN_ONLY","CRYPTOGRAM_3DS"],k=["VISA","MASTERCARD","AMEX"];function f(t){return{type:"PAYMENT_GATEWAY",parameters:{gateway:"globalpayments",gatewayMerchantId:t}}}function C(t){return{type:"CARD",parameters:{allowedAuthMethods:[..._],allowedCardNetworks:[...k]},tokenizationSpecification:f(t)}}function w(t){return[C(t)]}function E(t,e){return"test"===e?"TEST":"production"===e?"PRODUCTION":"development"===t?"TEST":"PRODUCTION"}function P(t,e){return function(t,e){return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:w(t.gatewayMerchantId),merchantInfo:{merchantId:t.merchantId,merchantName:t.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPrice:e.amount,currencyCode:e.currencyCode,countryCode:e.countryCode}}}(t,e)}async function I(t,e,a,n={}){if("undefined"==typeof window||!window.isSecureContext)return i.warn("google-pay: unavailable outside a secure context"),{available:!1,reason:"unsupported"};if(!t.trim())return i.warn("google-pay: missing merchant id"),{available:!1,reason:"merchant-id-missing"};if(!e.trim())return i.warn("google-pay: missing gateway merchant id"),{available:!1,reason:"gateway-merchant-id-missing"};if(!await function(t=8e3,e){return b()?Promise.resolve(!0):t<=0||e?.aborted?Promise.resolve(!1):new Promise(a=>{const n=Date.now()+t,o=t=>{clearInterval(s),e?.removeEventListener("abort",i),a(t)},i=()=>o(!1),s=setInterval(()=>{b()?o(!0):Date.now()>=n&&o(!1)},100);e?.addEventListener("abort",i,{once:!0})})}(n.sdkWaitTimeoutMs,n.signal))return i.warn("google-pay: pay.js was not loaded by the host page"),{available:!1,reason:"sdk-missing"};const o=E(a,n.gatewayEnvironment);try{const t=new google.payments.api.PaymentsClient({environment:o}),a=await t.isReadyToPay(function(t){return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:w(t)}}(e));return a.result?{available:!0}:(i.warn("google-pay: isReadyToPay returned false",{environment:o}),{available:!1,reason:"unsupported"})}catch(t){return i.warn("google-pay: isReadyToPay threw",{environment:o,error:t instanceof Error?t.message:String(t)}),{available:!1,reason:"unsupported"}}}function G(t,e){return function(t){if(function(t){return"object"==typeof t&&null!==t&&"statusCode"in t&&"string"==typeof t.statusCode}(t)){const e=t.statusCode.toUpperCase();if("CANCELED"===e||"CANCELLED"===e)return!0}if(t instanceof Error){const e=t.message.toLowerCase();return e.includes("cancel")||e.includes("closed")||e.includes("abort")}return!1}(t)?{kind:"cancelled"}:m(t)&&400===t.response?.status?{kind:"denied",sessionId:e}:{kind:"authorize"}}function S(t){if(null!==t&&"object"==typeof t){const e=t.paymentMethodData?.tokenizationData,a=e?.token;if("string"==typeof a&&a.length>0)return a}throw new Error("Invalid Google Pay payment data: missing tokenizationData.token")}try{p()}catch{}const T=s`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}::slotted([slot=google-pay-button]){display:block;width:100%;height:var(--mq-google-pay-button-height,48px)}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class GooglePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(GooglePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class GooglePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(t){super(GooglePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class GooglePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(t){super(GooglePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}const A=new Set(["sdk-missing","unsupported"]);function j(t,e){i.warn(t,{error:e instanceof Error?e.message:String(e)})}let D=class MqGooglePayCheckout extends r{constructor(){super(...arguments),this._availabilityPhase="checking",this._unavailableReason=null,this._paying=!1,this._paymentsClient=null,this._paymentsClientEnvironment=null,this._buttonHost=null,this._availabilityGeneration=0,this._availabilityAbortController=null,this._terminalErrorDispatched=!1,this._loginTokenTask=new o(this,g,{args:()=>[this.apiKey,this.token],onComplete:t=>{g.setAuthToken(t.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{this._paying||"ready"!==this._availabilityPhase||this._processPayment()}}static{this.styles=T}willUpdate(t){if(t.has("env")&&(this.env&&u(this.env),this._resetPaymentsClient()),t.has("gatewayEnvironment")&&this._resetPaymentsClient(),t.has("apiKey")&&g.setApiKey(this.apiKey),t.has("locale")){const t=y(this.locale)?this.locale:"es_ES";d(t),g.setLanguage(t)}(t.has("merchantId")||t.has("gatewayMerchantId")||t.has("env")||t.has("gatewayEnvironment"))&&this._loginTokenTask.value&&this._refreshAvailability()}connectedCallback(){super.connectedCallback(),this._availabilityAbortController=new AbortController,this._terminalErrorDispatched=!1}disconnectedCallback(){this._availabilityAbortController?.abort(),this._availabilityAbortController=null,this._resetPaymentsClient(),super.disconnectedCallback()}_dispatchTerminalError(){this._terminalErrorDispatched||(this._terminalErrorDispatched=!0,this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"unsupported"})))}_resetPaymentsClient(){this._paymentsClient=null,this._paymentsClientEnvironment=null,this._removeButtonHost()}_getPaymentsClient(){const t=E(this.env,this.gatewayEnvironment);return this._paymentsClient&&this._paymentsClientEnvironment===t||(this._paymentsClient=new google.payments.api.PaymentsClient({environment:t}),this._paymentsClientEnvironment=t,this._buttonHost=null),this._paymentsClient}async _refreshAvailability(){const t=++this._availabilityGeneration;this._availabilityPhase="checking",this._unavailableReason=null,this._removeButtonHost();const e=await I(this.merchantId??"",this.gatewayMerchantId??"",this.env,{signal:this._availabilityAbortController?.signal,gatewayEnvironment:this.gatewayEnvironment});if(t===this._availabilityGeneration&&this.isConnected){if(!e.available)return this._availabilityPhase="unavailable",this._unavailableReason=e.reason,void(A.has(e.reason)&&this._dispatchTerminalError());this._availabilityPhase="ready",this._unavailableReason=null}}_ensureButtonHost(){const t=this.querySelector(':scope > [slot="google-pay-button"]');if(t)return t;const e=document.createElement("div");return e.slot="google-pay-button",this.appendChild(e),e}_removeButtonHost(){this.querySelector(':scope > [slot="google-pay-button"]')?.remove(),this._buttonHost=null}_mountGooglePayButton(){if(this._buttonHost||"ready"!==this._availabilityPhase)return;const t=this._ensureButtonHost();try{const e=this._getPaymentsClient().createButton({onClick:this._onPayClick,buttonColor:"black",buttonType:"pay",buttonSizeMode:"fill"});t.replaceChildren(e),this._buttonHost=t}catch(t){j("mq-google-pay-checkout: failed to create Google Pay button",t),this._removeButtonHost(),this._availabilityPhase="unavailable",this._unavailableReason="unsupported",this._dispatchTerminalError()}}updated(t){super.updated(t),"ready"===this._availabilityPhase&&this._mountGooglePayButton()}async _processPayment(){this._paying=!0;try{const t=await this._getPaymentsClient().loadPaymentData(P({merchantId:this.merchantId,gatewayMerchantId:this.gatewayMerchantId,merchantName:this.merchantName||this.label},{amount:this.amount,currencyCode:this.currency,countryCode:this.country})),e=await g.payments.authorizeGooglePay({order_id:this.sessionId,token:S(t)}),{status:a,consultation_id:n}=e.data,o=v(a,n,this.sessionId);switch(o.kind){case"success":this.dispatchEvent(new GooglePayCheckoutSuccessEvent({sessionId:o.sessionId,reference:o.reference}));break;case"denied":this.dispatchEvent(new GooglePayCheckoutDeniedEvent({sessionId:o.sessionId}));break;case"error":this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:o.reason}))}}catch(t){const e=G(t,this.sessionId);switch(e.kind){case"cancelled":this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"cancelled"}));break;case"denied":this.dispatchEvent(new GooglePayCheckoutDeniedEvent({sessionId:e.sessionId}));break;case"authorize":j("mq-google-pay-checkout: authorize failed",t),this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"authorize"}))}}finally{this._paying=!1}}_renderUnavailable(){switch(this._unavailableReason){case"merchant-id-missing":return l`<p class="state">${a("Falta el identificador de comercio de Google Pay")}</p>`;case"gateway-merchant-id-missing":return l`<p class="state">${a("Falta el identificador de pasarela de Google Pay")}</p>`;case"sdk-missing":return l`<p class="state">${a("No se ha podido cargar Google Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`;default:return l`<p class="state">${a("Google Pay no está disponible. Prueba con tarjeta u otro método de pago.")}</p>`}}render(){return this._loginTokenTask.render({pending:()=>l`<p class="state">${a("Preparando Google Pay…")}</p>`,error:()=>l`<p class="state">${a("No hemos podido iniciar el pago")}</p>`,complete:()=>"checking"===this._availabilityPhase?l`<p class="state">${a("Comprobando Google Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():l`<div class="pay-row ${this._paying?"pay-row--paying":""}"><slot name="google-pay-button"></slot></div>`})}};t([c({type:String,attribute:"env"})],D.prototype,"env",void 0),t([c({type:String,attribute:"gateway-environment"})],D.prototype,"gatewayEnvironment",void 0),t([c({type:String,attribute:"api-key"})],D.prototype,"apiKey",void 0),t([c({type:String,attribute:"token"})],D.prototype,"token",void 0),t([c({type:String,attribute:"locale",reflect:!0})],D.prototype,"locale",void 0),t([c({type:String,attribute:"merchant-id"})],D.prototype,"merchantId",void 0),t([c({type:String,attribute:"gateway-merchant-id"})],D.prototype,"gatewayMerchantId",void 0),t([c({type:String,attribute:"merchant-name"})],D.prototype,"merchantName",void 0),t([c({type:String,attribute:"session-id"})],D.prototype,"sessionId",void 0),t([c({type:String,attribute:"amount"})],D.prototype,"amount",void 0),t([c({type:String,attribute:"currency"})],D.prototype,"currency",void 0),t([c({type:String,attribute:"country"})],D.prototype,"country",void 0),t([c({type:String,attribute:"label"})],D.prototype,"label",void 0),t([h()],D.prototype,"_availabilityPhase",void 0),t([h()],D.prototype,"_unavailableReason",void 0),t([h()],D.prototype,"_paying",void 0),D=t([n(),e("mq-google-pay-checkout")],D);export{GooglePayCheckoutDeniedEvent,GooglePayCheckoutErrorEvent,GooglePayCheckoutSuccessEvent,D as MqGooglePayCheckout};
@@ -1 +1 @@
1
- import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{a as i,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n as o}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import{b as r}from"./chunks/api-chat-client-C8SqZtCa.js";import"./mq-checkout.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/login-token-task-BI-L2zSV.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 ImmediateVideocallPaidEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ImmediateVideocallPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}let a=class MqImmediateVideocallCheckout extends i{constructor(){super(...arguments),this._provideSession=async()=>{const e=await r.payments.createImmediateVideocallPaymentLink({video_call_schedule_id:this.videoCallScheduleId});return{sessionId:e.session_id,paymentUrl:e.payment_link}},this._onSuccess=e=>{e.stopPropagation(),this.dispatchEvent(new ImmediateVideocallPaidEvent({videoCallId:e.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>`}};e([o({type:String,attribute:"env"})],a.prototype,"env",void 0),e([o({type:String,attribute:"api-key"})],a.prototype,"apiKey",void 0),e([o({type:String,attribute:"token"})],a.prototype,"token",void 0),e([o({type:String,attribute:"locale",reflect:!0})],a.prototype,"locale",void 0),e([o({type:String,attribute:"video-call-schedule-id"})],a.prototype,"videoCallScheduleId",void 0),a=e([t("mq-immediate-videocall-checkout")],a);export{ImmediateVideocallPaidEvent,a as MqImmediateVideocallCheckout};
1
+ import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{a as i,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n as o}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import{a as r}from"./chunks/api-chat-client-CqMn2JEn.js";import"./mq-checkout.js";import"./chunks/external-CJj32K_p.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/login-token-task-BI-L2zSV.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class ImmediateVideocallPaidEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ImmediateVideocallPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}let a=class MqImmediateVideocallCheckout extends i{constructor(){super(...arguments),this._provideSession=async()=>{const e=await r.payments.createImmediateVideocallPaymentLink({video_call_schedule_id:this.videoCallScheduleId});return{sessionId:e.session_id,paymentUrl:e.payment_link}},this._onSuccess=e=>{e.stopPropagation(),this.dispatchEvent(new ImmediateVideocallPaidEvent({videoCallId:e.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>`}};e([o({type:String,attribute:"env"})],a.prototype,"env",void 0),e([o({type:String,attribute:"api-key"})],a.prototype,"apiKey",void 0),e([o({type:String,attribute:"token"})],a.prototype,"token",void 0),e([o({type:String,attribute:"locale",reflect:!0})],a.prototype,"locale",void 0),e([o({type:String,attribute:"video-call-schedule-id"})],a.prototype,"videoCallScheduleId",void 0),a=e([t("mq-immediate-videocall-checkout")],a);export{ImmediateVideocallPaidEvent,a as MqImmediateVideocallCheckout};