@mediquo/elements 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/chunks/api-chat-client-BTBtu01T.js +1 -0
- package/dist/chunks/apple-pay-outcomes-BlytM6W-.js +1 -0
- package/dist/chunks/appointment-details-DpzdYLjq.d.ts +24 -0
- package/dist/chunks/appointment.model.d-Dy50gMPg.d.ts +171 -0
- package/dist/chunks/ca_ES-nttMFJzr.js +1 -0
- package/dist/chunks/chunk-S5RWG6G2-oTcdgk2H.js +1 -0
- package/dist/chunks/chunk-YTQUGGS3-DN-JZpgG.js +1 -0
- package/dist/chunks/class-map-Co76I6aw.js +1 -0
- package/dist/chunks/context-provider-CiMFpvDA.js +1 -0
- package/dist/chunks/context-request-event-Dfydf1ub.js +1 -0
- package/dist/chunks/custom-element-DA9Fxvxd.js +1 -0
- package/dist/chunks/de_DE-CrwfSJnS.js +1 -0
- package/dist/chunks/default-IpEn36CA.d.ts +5 -0
- package/dist/chunks/directive-2EDmOukv.js +1 -0
- package/dist/chunks/en_US-BslWF9nj.js +1 -0
- package/dist/chunks/ensure-context-root-DbdqwnKB.js +1 -0
- package/dist/chunks/exports-XZaVrMLd.js +1 -0
- package/dist/chunks/external-zAbuzxDj.js +1 -0
- package/dist/chunks/format-Cm3B1GMy.js +1 -0
- package/dist/chunks/get-organization-setup-query-BMbuRi6v.js +1 -0
- package/dist/chunks/get-patient-profile-query-C8T8DJ7z.js +1 -0
- package/dist/chunks/if-defined-BYeVdwgd.js +1 -0
- package/dist/chunks/index-B9iWdvW3.js +1 -0
- package/dist/chunks/index-BYHKNPG2.js +1 -0
- package/dist/chunks/index-Bxh8Qfwr.js +1 -0
- package/dist/chunks/isBefore-Cof0D841.js +1 -0
- package/dist/chunks/isSameDay-DPfclwIL.js +1 -0
- package/dist/chunks/lit-element-DiWJYFwC.js +1 -0
- package/dist/chunks/login-token-task-BI-L2zSV.js +1 -0
- package/dist/chunks/mq-chat-room-DuG4RuIp.d.ts +503 -0
- package/dist/chunks/mq-layout-D8Mak16a.d.ts +21 -0
- package/dist/chunks/mq-layout-DpzeL9_i.js +1 -0
- package/dist/chunks/mutation-controller-OVT8NEt6.js +1 -0
- package/dist/chunks/parseISO-jT42c8Ob.js +1 -0
- package/dist/chunks/price-Dtdjx70D.js +1 -0
- package/dist/chunks/price.d-CwLosdAN.d.ts +10 -0
- package/dist/chunks/professional-overview-mO3tuMuH.d.ts +25 -0
- package/dist/chunks/property-scuRaFcM.js +1 -0
- package/dist/chunks/provide-CfT7g_Zi.js +1 -0
- package/dist/chunks/pt_PT-CFbbWowX.js +1 -0
- package/dist/chunks/query-CeeutdfT.js +1 -0
- package/dist/chunks/query-QJ1INUTG.js +1 -0
- package/dist/chunks/refund-cancel-policy-Bm5djPds.js +1 -0
- package/dist/chunks/runtime-Bg1WXVCx.js +1 -0
- package/dist/chunks/schemas.d-BEA8Pl6w.d.ts +44 -0
- package/dist/chunks/state-LQivXIgA.js +1 -0
- package/dist/chunks/style-map-CIdqdn7C.js +1 -0
- package/dist/chunks/task-Bj8p7kJX.js +1 -0
- package/dist/chunks/telemetry-client-CKCb9Gnf.js +1 -0
- package/dist/env.d.ts +21 -0
- package/dist/env.js +1 -0
- package/dist/events.d.ts +141 -0
- package/dist/events.js +1 -0
- package/dist/i18n.d.ts +11 -0
- package/dist/i18n.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/dist/mq-apple-pay-checkout.d.ts +82 -0
- package/dist/mq-apple-pay-checkout.js +1 -0
- package/dist/mq-appointment-checkout.d.ts +55 -0
- package/dist/mq-appointment-checkout.js +1 -0
- package/dist/mq-chat-room.d.ts +20 -0
- package/dist/mq-chat-room.js +1 -0
- package/dist/mq-checkout.d.ts +108 -0
- package/dist/mq-checkout.js +1 -0
- package/dist/mq-google-pay-checkout.d.ts +117 -0
- package/dist/mq-google-pay-checkout.js +1 -0
- package/dist/mq-immediate-videocall-checkout.d.ts +47 -0
- package/dist/mq-immediate-videocall-checkout.js +1 -0
- package/dist/mq-my-appointments.d.ts +602 -0
- package/dist/mq-my-appointments.js +1 -0
- package/dist/mq-query-client-provider.d.ts +17 -0
- package/dist/mq-query-client-provider.js +1 -0
- package/dist/mq-schedule-success.d.ts +84 -0
- package/dist/mq-schedule-success.js +4 -0
- package/dist/mq-schedule.d.ts +1013 -0
- package/dist/mq-schedule.js +1 -0
- package/dist/mq-socket-provider.d.ts +103 -0
- package/dist/mq-socket-provider.js +1 -0
- package/dist/mq-support-chat.d.ts +86 -0
- package/dist/mq-support-chat.js +1 -0
- package/dist/mq-theme-provider.d.ts +34 -0
- package/dist/mq-theme-provider.js +1 -0
- package/dist/mq-videocall.d.ts +151 -0
- package/dist/mq-videocall.js +1 -0
- package/dist/theme.d.ts +200 -0
- package/dist/theme.js +1 -0
- package/dist/ui/back-link.d.ts +21 -0
- package/dist/ui/back-link.js +1 -0
- package/dist/ui/icons/alert-circle-icon.d.ts +6 -0
- package/dist/ui/icons/alert-circle-icon.js +1 -0
- package/dist/ui/icons/annotation-question-icon.d.ts +6 -0
- package/dist/ui/icons/annotation-question-icon.js +1 -0
- package/dist/ui/icons/briefcase-icon.d.ts +6 -0
- package/dist/ui/icons/briefcase-icon.js +1 -0
- package/dist/ui/icons/calendar-icon.d.ts +6 -0
- package/dist/ui/icons/calendar-icon.js +1 -0
- package/dist/ui/icons/chat-bubble-icon.d.ts +6 -0
- package/dist/ui/icons/chat-bubble-icon.js +1 -0
- package/dist/ui/icons/check-circle-icon.d.ts +5 -0
- package/dist/ui/icons/check-circle-icon.js +1 -0
- package/dist/ui/icons/check-double-icon.d.ts +6 -0
- package/dist/ui/icons/check-double-icon.js +1 -0
- package/dist/ui/icons/check-icon.d.ts +6 -0
- package/dist/ui/icons/check-icon.js +1 -0
- package/dist/ui/icons/chevron-down-icon.d.ts +6 -0
- package/dist/ui/icons/chevron-down-icon.js +1 -0
- package/dist/ui/icons/chevron-left-icon.d.ts +6 -0
- package/dist/ui/icons/chevron-left-icon.js +1 -0
- package/dist/ui/icons/chevron-right-icon.d.ts +6 -0
- package/dist/ui/icons/chevron-right-icon.js +1 -0
- package/dist/ui/icons/clock-icon.d.ts +6 -0
- package/dist/ui/icons/clock-icon.js +1 -0
- package/dist/ui/icons/download-icon.d.ts +6 -0
- package/dist/ui/icons/download-icon.js +1 -0
- package/dist/ui/icons/file-icon.d.ts +6 -0
- package/dist/ui/icons/file-icon.js +1 -0
- package/dist/ui/icons/heartbeat-icon.d.ts +5 -0
- package/dist/ui/icons/heartbeat-icon.js +1 -0
- package/dist/ui/icons/info-circle-outine-icon.d.ts +6 -0
- package/dist/ui/icons/info-circle-outine-icon.js +1 -0
- package/dist/ui/icons/message-bubble-icon.d.ts +6 -0
- package/dist/ui/icons/message-bubble-icon.js +1 -0
- package/dist/ui/icons/message-square-icon.d.ts +6 -0
- package/dist/ui/icons/message-square-icon.js +1 -0
- package/dist/ui/icons/mic-icon.d.ts +6 -0
- package/dist/ui/icons/mic-icon.js +1 -0
- package/dist/ui/icons/mic-off-icon.d.ts +6 -0
- package/dist/ui/icons/mic-off-icon.js +1 -0
- package/dist/ui/icons/phone-icon.d.ts +6 -0
- package/dist/ui/icons/phone-icon.js +1 -0
- package/dist/ui/icons/spinner-icon.d.ts +6 -0
- package/dist/ui/icons/spinner-icon.js +1 -0
- package/dist/ui/icons/tag-icon.d.ts +6 -0
- package/dist/ui/icons/tag-icon.js +1 -0
- package/dist/ui/icons/time-left-icon.d.ts +5 -0
- package/dist/ui/icons/time-left-icon.js +1 -0
- package/dist/ui/icons/types.d.ts +9 -0
- package/dist/ui/icons/types.js +1 -0
- package/dist/ui/icons/upload-icon.d.ts +6 -0
- package/dist/ui/icons/upload-icon.js +1 -0
- package/dist/ui/icons/video-icon.d.ts +6 -0
- package/dist/ui/icons/video-icon.js +1 -0
- package/dist/ui/icons/video-off-icon.d.ts +6 -0
- package/dist/ui/icons/video-off-icon.js +1 -0
- package/dist/ui/icons/x-icon.d.ts +6 -0
- package/dist/ui/icons/x-icon.js +1 -0
- package/dist/ui/mq-avatar.d.ts +37 -0
- package/dist/ui/mq-avatar.js +1 -0
- package/dist/ui/mq-button.d.ts +34 -0
- package/dist/ui/mq-button.js +1 -0
- package/dist/ui/mq-calendar.d.ts +66 -0
- package/dist/ui/mq-calendar.js +1 -0
- package/dist/ui/mq-callout.d.ts +23 -0
- package/dist/ui/mq-callout.js +1 -0
- package/dist/ui/mq-card.d.ts +18 -0
- package/dist/ui/mq-card.js +1 -0
- package/dist/ui/mq-checkbox.d.ts +41 -0
- package/dist/ui/mq-checkbox.js +1 -0
- package/dist/ui/mq-clamped-text.d.ts +46 -0
- package/dist/ui/mq-clamped-text.js +1 -0
- package/dist/ui/mq-dialog.d.ts +53 -0
- package/dist/ui/mq-dialog.js +1 -0
- package/dist/ui/mq-floating-bubble.d.ts +42 -0
- package/dist/ui/mq-floating-bubble.js +1 -0
- package/dist/ui/mq-input.d.ts +41 -0
- package/dist/ui/mq-input.js +1 -0
- package/dist/ui/mq-rating.d.ts +30 -0
- package/dist/ui/mq-rating.js +1 -0
- package/dist/ui/mq-select.d.ts +83 -0
- package/dist/ui/mq-select.js +1 -0
- package/dist/ui/mq-skeleton.d.ts +18 -0
- package/dist/ui/mq-skeleton.js +1 -0
- package/dist/ui/mq-tabs.d.ts +56 -0
- package/dist/ui/mq-tabs.js +1 -0
- package/dist/ui/mq-text-button.d.ts +39 -0
- package/dist/ui/mq-text-button.js +1 -0
- package/dist/ui/mq-textarea.d.ts +38 -0
- package/dist/ui/mq-textarea.js +1 -0
- package/dist/ui/mq-time-slot-picker.d.ts +84 -0
- package/dist/ui/mq-time-slot-picker.js +1 -0
- package/dist/ui/mq-toast.d.ts +111 -0
- package/dist/ui/mq-toast.js +1 -0
- package/dist/ui/mq-unread-badge.d.ts +15 -0
- package/dist/ui/mq-unread-badge.js +1 -0
- package/package.json +176 -0
|
@@ -0,0 +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{a as n,P as r}from"./chunks/api-chat-client-BTBtu01T.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};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as lit from 'lit';
|
|
2
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
3
|
+
import { Env } from './env.js';
|
|
4
|
+
import { Locale } from './i18n.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
|
|
7
|
+
type GooglePayGatewayEnvironment = "test" | "production";
|
|
8
|
+
|
|
9
|
+
declare class GooglePayCheckoutSuccessEvent extends Event {
|
|
10
|
+
readonly detail: {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
reference: string;
|
|
13
|
+
};
|
|
14
|
+
static eventName: string;
|
|
15
|
+
constructor(detail: {
|
|
16
|
+
sessionId: string;
|
|
17
|
+
reference: string;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
declare class GooglePayCheckoutDeniedEvent extends Event {
|
|
21
|
+
readonly detail: {
|
|
22
|
+
sessionId: string;
|
|
23
|
+
};
|
|
24
|
+
static eventName: string;
|
|
25
|
+
constructor(detail: {
|
|
26
|
+
sessionId: string;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
type GooglePayCheckoutErrorReason = "auth" | "unsupported" | "authorize" | "cancelled";
|
|
30
|
+
declare class GooglePayCheckoutErrorEvent extends Event {
|
|
31
|
+
readonly detail: {
|
|
32
|
+
reason: GooglePayCheckoutErrorReason;
|
|
33
|
+
};
|
|
34
|
+
static eventName: string;
|
|
35
|
+
constructor(detail: {
|
|
36
|
+
reason: GooglePayCheckoutErrorReason;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Google Pay checkout for top-level pages on checkout.mediquo.com.
|
|
41
|
+
* The host must load the Google Pay JS SDK before mounting this element.
|
|
42
|
+
*
|
|
43
|
+
* @fires payment-success - Payment authorized. Detail: `{ sessionId, reference }`.
|
|
44
|
+
* @fires payment-denied - Payment rejected by the backend. Detail: `{ sessionId }`.
|
|
45
|
+
* @fires payment-error - Auth, unsupported device or authorization failure. Detail: `{ reason }`.
|
|
46
|
+
* `reason: "unsupported"` also fires — at most once per mount — when the availability
|
|
47
|
+
* check rules out this device or page, so hosts can fall back to another payment method
|
|
48
|
+
* instead of waiting on a payment that cannot happen. A missing merchant id is not
|
|
49
|
+
* reported this way: a later refresh can still resolve it.
|
|
50
|
+
*/
|
|
51
|
+
declare class MqGooglePayCheckout extends LitElement {
|
|
52
|
+
static styles: lit.CSSResult;
|
|
53
|
+
env?: Env;
|
|
54
|
+
/** Google Pay gateway environment (`test` or `production`), independent of `env`. */
|
|
55
|
+
gatewayEnvironment?: GooglePayGatewayEnvironment;
|
|
56
|
+
apiKey: string;
|
|
57
|
+
token: string;
|
|
58
|
+
locale: Locale;
|
|
59
|
+
/** Google Pay merchant identifier (Google Business Console). */
|
|
60
|
+
merchantId: string;
|
|
61
|
+
/** Global Payments / Realex merchant id for gateway tokenization. */
|
|
62
|
+
gatewayMerchantId: string;
|
|
63
|
+
merchantName: string;
|
|
64
|
+
/** Backend order id (same as the integrator's `session_id`). */
|
|
65
|
+
sessionId: string;
|
|
66
|
+
amount: string;
|
|
67
|
+
currency: string;
|
|
68
|
+
country: string;
|
|
69
|
+
label: string;
|
|
70
|
+
private _availabilityPhase;
|
|
71
|
+
private _unavailableReason;
|
|
72
|
+
private _paying;
|
|
73
|
+
private _paymentsClient;
|
|
74
|
+
private _paymentsClientEnvironment;
|
|
75
|
+
private _buttonHost;
|
|
76
|
+
private _availabilityGeneration;
|
|
77
|
+
private _availabilityAbortController;
|
|
78
|
+
private _terminalErrorDispatched;
|
|
79
|
+
private _loginTokenTask;
|
|
80
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
81
|
+
connectedCallback(): void;
|
|
82
|
+
disconnectedCallback(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Emits at most one terminal `payment-error` per mount so a host is not told
|
|
85
|
+
* repeatedly to fall back while refreshes keep failing.
|
|
86
|
+
*/
|
|
87
|
+
private _dispatchTerminalError;
|
|
88
|
+
private _resetPaymentsClient;
|
|
89
|
+
private _getPaymentsClient;
|
|
90
|
+
private _refreshAvailability;
|
|
91
|
+
/**
|
|
92
|
+
* Light-DOM container for Google's button, projected into the shadow slot.
|
|
93
|
+
* Must stay outside the shadow root — see the `::slotted` note in `styles`.
|
|
94
|
+
*/
|
|
95
|
+
private _ensureButtonHost;
|
|
96
|
+
private _removeButtonHost;
|
|
97
|
+
private _mountGooglePayButton;
|
|
98
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
99
|
+
private _onPayClick;
|
|
100
|
+
private _processPayment;
|
|
101
|
+
/**
|
|
102
|
+
* Renders the message for the reason the availability check reported. Do not
|
|
103
|
+
* re-derive it from the current DOM state: `pay.js` may finish loading right
|
|
104
|
+
* after a `sdk-missing` result, which would then surface as the generic
|
|
105
|
+
* "not available" copy and hide a real configuration problem.
|
|
106
|
+
*/
|
|
107
|
+
private _renderUnavailable;
|
|
108
|
+
render(): unknown;
|
|
109
|
+
}
|
|
110
|
+
declare global {
|
|
111
|
+
interface HTMLElementTagNameMap {
|
|
112
|
+
"mq-google-pay-checkout": MqGooglePayCheckout;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { GooglePayCheckoutDeniedEvent, GooglePayCheckoutErrorEvent, GooglePayCheckoutSuccessEvent, MqGooglePayCheckout };
|
|
117
|
+
export type { GooglePayCheckoutErrorReason, GooglePayGatewayEnvironment };
|
|
@@ -0,0 +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,a as g}from"./chunks/api-chat-client-BTBtu01T.js";import{r as v}from"./chunks/apple-pay-outcomes-BlytM6W-.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"],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 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};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as lit_html from 'lit-html';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { Env } from './env.js';
|
|
4
|
+
import { Locale } from './i18n.js';
|
|
5
|
+
import './mq-checkout.js';
|
|
6
|
+
import 'zod';
|
|
7
|
+
import './ui/mq-skeleton.js';
|
|
8
|
+
|
|
9
|
+
declare class ImmediateVideocallPaidEvent extends Event {
|
|
10
|
+
readonly detail: {
|
|
11
|
+
videoCallId: string;
|
|
12
|
+
};
|
|
13
|
+
static eventName: string;
|
|
14
|
+
constructor(detail: {
|
|
15
|
+
videoCallId: string;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Immediate-videocall checkout. Creates a payment session from a
|
|
20
|
+
* `video-call-schedule-id` via `createImmediateVideocallPaymentLink` and
|
|
21
|
+
* delegates the entire payment UX to the agnostic `<mq-checkout>`. Re-creation
|
|
22
|
+
* on retry is handled by `mq-checkout` calling the same `provideSession` factory
|
|
23
|
+
* again — no host wiring required. Addon Payments only (no coupons).
|
|
24
|
+
*
|
|
25
|
+
* Must be rendered inside `<mq-theme-provider>`.
|
|
26
|
+
*
|
|
27
|
+
* @fires payment-success - Payment confirmed. Detail: `{ videoCallId }`.
|
|
28
|
+
* @fires payment-denied - Payment rejected. Bubbles from `<mq-checkout>`. Detail: `{ sessionId }`.
|
|
29
|
+
* @fires payment-error - Auth, session creation or timeout failure. Bubbles from `<mq-checkout>`. Detail: `{ reason }`.
|
|
30
|
+
*/
|
|
31
|
+
declare class MqImmediateVideocallCheckout extends LitElement {
|
|
32
|
+
env?: Env;
|
|
33
|
+
apiKey: string;
|
|
34
|
+
token: string;
|
|
35
|
+
locale: Locale;
|
|
36
|
+
videoCallScheduleId: string;
|
|
37
|
+
private _provideSession;
|
|
38
|
+
private _onSuccess;
|
|
39
|
+
render(): lit_html.TemplateResult<1>;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface HTMLElementTagNameMap {
|
|
43
|
+
"mq-immediate-videocall-checkout": MqImmediateVideocallCheckout;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { ImmediateVideocallPaidEvent, MqImmediateVideocallCheckout };
|
|
@@ -0,0 +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{a}from"./chunks/api-chat-client-BTBtu01T.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 r=class MqImmediateVideocallCheckout extends i{constructor(){super(...arguments),this._provideSession=async()=>{const e=await a.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"})],r.prototype,"env",void 0),e([o({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),e([o({type:String,attribute:"token"})],r.prototype,"token",void 0),e([o({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),e([o({type:String,attribute:"video-call-schedule-id"})],r.prototype,"videoCallScheduleId",void 0),r=e([t("mq-immediate-videocall-checkout")],r);export{ImmediateVideocallPaidEvent,r as MqImmediateVideocallCheckout};
|