@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{g as i,c as s}from"./chunks/refund-cancel-policy-Bm5djPds.js";import{MqBackEvent as a}from"./events.js";import{a as o,i as r,A as n,c as l,P as d,S as c,h as p,j as h,k as u}from"./chunks/api-chat-client-BTBtu01T.js";import"./chunks/mq-layout-DpzeL9_i.js";import{Q as m,c as v,M as f}from"./chunks/mutation-controller-OVT8NEt6.js";import{g,a as y}from"./chunks/get-patient-profile-query-C8T8DJ7z.js";import{g as b}from"./chunks/get-organization-setup-query-BMbuRi6v.js";import{S as w,u as S,g as x,c as _,w as $,t as k,x as E,y as C,z as M,A as P,B as I,C as A,D as F}from"./chunks/telemetry-client-CKCb9Gnf.js";import"./ui/mq-button.js";import{n as D,i as q}from"./chunks/context-provider-CiMFpvDA.js";import{m as V,s as z}from"./chunks/runtime-Bg1WXVCx.js";import{t as j,l as L,p as B,s as O}from"./chunks/parseISO-jT42c8Ob.js";import{E as T,i as N,a as U,x as Q}from"./chunks/lit-element-DiWJYFwC.js";import{n as R}from"./chunks/property-scuRaFcM.js";import{setEnv as W}from"./env.js";import{getLocale as H,initLocalization as K,isValidLocale as G,setLocale as Z}from"./i18n.js";import{e as J}from"./chunks/class-map-Co76I6aw.js";import{o as X}from"./chunks/if-defined-BYeVdwgd.js";import{z as Y,l as ee}from"./chunks/external-zAbuzxDj.js";import"./ui/mq-input.js";import"./ui/mq-callout.js";import{e as te,t as ie}from"./chunks/directive-2EDmOukv.js";import{f as se}from"./chunks/index-B9iWdvW3.js";import{chevronLeftIcon as ae}from"./ui/icons/chevron-left-icon.js";import"./ui/mq-text-button.js";import{h as oe,f as re,c as ne}from"./chunks/price-Dtdjx70D.js";import"./ui/mq-card.js";import{r as le}from"./chunks/state-LQivXIgA.js";import{spinnerIcon as de}from"./ui/icons/spinner-icon.js";import{tagIcon as ce}from"./ui/icons/tag-icon.js";import{toast as pe}from"./ui/mq-toast.js";import{e as he}from"./chunks/query-CeeutdfT.js";import{fileIcon as ue}from"./ui/icons/file-icon.js";import{uploadIcon as me}from"./ui/icons/upload-icon.js";import{xIcon as ve}from"./ui/icons/x-icon.js";import"./ui/mq-textarea.js";import{Q as fe,z as ge}from"./chunks/query-QJ1INUTG.js";import"./ui/mq-skeleton.js";import"./ui/mq-select.js";import{i as ye,f as be}from"./chunks/format-Cm3B1GMy.js";import{i as we,s as Se,e as xe}from"./chunks/index-BYHKNPG2.js";import{calendarIcon as _e}from"./ui/icons/calendar-icon.js";import{a as $e}from"./chunks/index-Bxh8Qfwr.js";import{breakpoints as ke}from"./theme.js";import{i as Ee}from"./chunks/isBefore-Cof0D841.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./ui/icons/chevron-down-icon.js";import"./ui/icons/types.js";import"./ui/mq-avatar.js";import"./ui/icons/info-circle-outine-icon.js";import"./chunks/style-map-CIdqdn7C.js";import"./ui/icons/briefcase-icon.js";import"./ui/icons/clock-icon.js";import"./ui/icons/message-bubble-icon.js";import"./ui/icons/phone-icon.js";import"./ui/icons/chevron-right-icon.js";import"./chunks/isSameDay-DPfclwIL.js";function Ce(e,t){const i=+j(e)-+j(t);return i<0?-1:i>0?1:i}function Me(e,t){const i=j(e,t?.in);return i.setHours(23,59,59,999),i}var Pe=class{constructor(e,t,i){this.host=e,this.steps=t,this._history=[],this._ctx=i,this._index=this._skipForward(0),this.host.addController(this)}hostConnected(){}hostDisconnected(){}get current(){const e=this.steps[this._index];if(!e)throw new Error(`WizardController: invalid index ${this._index} for ${this.steps.length}-step wizard`);return e.name}get ctx(){return this._ctx}get canGoBack(){return this._history.length>0}next(e){if(e&&(this._ctx={...this._ctx,...e}),this._index>=this.steps.length-1)return void this.host.requestUpdate();const t=this._skipForward(this._index+1);t!==this._index&&(this._history.push(this._index),this._index=t),this.host.requestUpdate()}goTo(e,t,i={}){t&&(this._ctx={...this._ctx,...t});const s=this.steps.findIndex(t=>t.name===e);if(s<0)throw new Error(`WizardController: unknown step "${e}"`);const a=this._skipForward(s);i.replace?(this._history[this._history.length-1]===a&&this._history.pop(),this._index=a):a!==this._index&&(this._history.push(this._index),this._index=a),this.host.requestUpdate()}back(){const e=this._history.pop();return void 0!==e&&(this._index=e,this.host.requestUpdate(),!0)}reconcile(e){const t={...this._ctx,...e},i=!function(e,t){if(e===t)return!0;const i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(const s of i)if(e[s]!==t[s])return!1;return!0}(this._ctx,t);this._ctx=t;const s=this._skipForward(this._index),a=s!==this._index;a&&(this._history.push(this._index),this._index=s),(i||a)&&this.host.requestUpdate()}_skipForward(e){let t=e;for(;t<this.steps.length-1;){const e=this.steps[t];if(!e?.skipIf?.(this._ctx))return t;t++}return t}};const Ie=D(Symbol.for("mq-schedule:patient"));class DiscountAppliedEvent extends Event{static{this.eventName="discount-applied"}constructor(e){super(DiscountAppliedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class AuthRequiredEvent extends Event{static{this.eventName="auth-required"}constructor(e){super(AuthRequiredEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}function Ae(e,t){if(!e)return;const i=function(e){if(e)return S[e]??e}(e);return t?.find(t=>t.code===i||String(t.id)===e)?.id}function Fe(e,t){if(!e)return;const i=w[e];return i?t?.find(e=>e.channel===i):t?.find(t=>t.code===e||t.id===e)}function De(e){const t=Ae(e.defaultSpecialty,e.specialties),i=Fe(e.defaultService,e.services),s=e.defaultProfessionalHash?{avatar:e.professional?.avatar??null,collegiate_number:e.professional?.collegiate_number??null,description:e.professional?.description??null,languages:e.professional?.languages??[],name:e.professional?.name??"",id:e.professional?.hash??"",speciality:{id:t??0}}:void 0;return{service:i,specialty:t?.toString(),slot:void 0,professional:s,firstAvailableSlotDate:void 0,paymentSessionId:void 0,paymentUrl:void 0,paymentRequest:void 0,appliedDiscount:void 0,profileComplete:e.profileComplete,requiresPayment:e.requiresPayment,error:!1}}const qe={name:"completeProfile",skipIf:e=>e.profileComplete},Ve={name:"payment",skipIf:e=>!e.requiresPayment},ze=[{name:"selectProfessional"},{name:"selectSlot"},qe,{name:"confirm"},Ve,{name:"done"}],je=[{name:"selectSlot"},qe,{name:"confirm"},Ve,{name:"done"}],Le=[{name:"selectSlot"},qe,{name:"confirm"},{name:"done"}];function Be(e){return e.totalAmount<=0}class InvalidDiscountCodeError extends Error{constructor(e="Invalid discount code"){super(e),this.name="InvalidDiscountCodeError"}}const Oe=new WeakMap,Te=new WeakMap,Ne={current:[]};let Ue=!1,Qe=0;const Re=new Set,We=new Map;function He(e){const t=Array.from(e).sort((e,t)=>e instanceof Derived&&e.options.deps.includes(t)?1:t instanceof Derived&&t.options.deps.includes(e)?-1:0);for(const e of t){if(Ne.current.includes(e))continue;Ne.current.push(e),e.recompute();const t=Te.get(e);if(t)for(const e of t){const t=Oe.get(e);t&&He(t)}}}function Ke(e){const t={prevVal:e.prevState,currentVal:e.state};for(const i of e.listeners)i(t)}function Ge(e){const t={prevVal:e.prevState,currentVal:e.state};for(const i of e.listeners)i(t)}function Ze(e){if(Qe>0&&!We.has(e)&&We.set(e,e.prevState),Re.add(e),!(Qe>0||Ue))try{for(Ue=!0;Re.size>0;){const e=Array.from(Re);Re.clear();for(const t of e){const e=We.get(t)??t.prevState;t.prevState=e,Ke(t)}for(const t of e){const e=Oe.get(t);e&&(Ne.current.push(t),He(e))}for(const t of e){const e=Oe.get(t);if(e)for(const t of e)Ge(t)}}}finally{Ue=!1,Ne.current=[],We.clear()}}function Je(e){Qe++;try{e()}finally{if(Qe--,0===Qe){const e=Re.values().next().value;e&&Ze(e)}}}class Store{constructor(e,t){this.listeners=new Set,this.subscribe=e=>{var t,i;this.listeners.add(e);const s=null==(i=null==(t=this.options)?void 0:t.onSubscribe)?void 0:i.call(t,e,this);return()=>{this.listeners.delete(e),null==s||s()}},this.prevState=e,this.state=e,this.options=t}setState(e){var t,i,s;this.prevState=this.state,(null==(t=this.options)?void 0:t.updateFn)?this.state=this.options.updateFn(this.prevState)(e):!function(e){return"function"==typeof e}(e)?this.state=e:this.state=e(this.prevState),null==(s=null==(i=this.options)?void 0:i.onUpdate)||s.call(i),Ze(this)}}class Derived{constructor(e){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const e=this.options.deps.length,t=new Array(e),i=new Array(e);for(let s=0;s<e;s++){const e=this.options.deps[s];t[s]=e.prevState,i[s]=e.state}return this.lastSeenDepValues=i,{prevDepVals:t,currDepVals:i,prevVal:this.prevState??void 0}},this.recompute=()=>{var e,t;this.prevState=this.state;const i=this.getDepVals();this.state=this.options.fn(i),null==(t=(e=this.options).onUpdate)||t.call(e)},this.checkIfRecalculationNeededDeeply=()=>{for(const e of this.options.deps)e instanceof Derived&&e.checkIfRecalculationNeededDeeply();let e=!1;const t=this.lastSeenDepValues,{currDepVals:i}=this.getDepVals();for(let s=0;s<i.length;s++)if(i[s]!==t[s]){e=!0;break}e&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const e of this._subscriptions)e()}),this.subscribe=e=>{var t,i;this.listeners.add(e);const s=null==(i=(t=this.options).onSubscribe)?void 0:i.call(t,e,this);return()=>{this.listeners.delete(e),null==s||s()}},this.options=e,this.state=e.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(e=this.options.deps){for(const t of e)if(t instanceof Derived)t.registerOnGraph(),this.registerOnGraph(t.options.deps);else if(t instanceof Store){let e=Oe.get(t);e||(e=new Set,Oe.set(t,e)),e.add(this);let i=Te.get(this);i||(i=new Set,Te.set(this,i)),i.add(t)}}unregisterFromGraph(e=this.options.deps){for(const t of e)if(t instanceof Derived)this.unregisterFromGraph(t.options.deps);else if(t instanceof Store){const e=Oe.get(t);e&&e.delete(this);const i=Te.get(this);i&&i.delete(t)}}}function Xe(e,t){return"function"==typeof e?e(t):e}function Ye(e,t){return lt(t).reduce((e,t)=>null===e?null:void 0!==e?e[t]:void 0,e)}function et(e,t,i){const s=lt(t);return function e(t){if(!s.length)return Xe(i,t);const a=s.shift();if("string"==typeof a||"number"==typeof a&&!Array.isArray(t))return"object"==typeof t?(null===t&&(t={}),{...t,[a]:e(t[a])}):{[a]:e()};if(Array.isArray(t)&&"number"==typeof a){const i=t.slice(0,a);return[...i.length?i:new Array(a),e(t[a]),...t.slice(a+1)]}return[...new Array(a),e()]}(e)}const tt=/^(\d+)$/gm,it=/\.(\d+)(?=\.)/gm,st=/^(\d+)\./gm,at=/\.(\d+$)/gm,ot=/\.{2,}/gm,rt="__int__",nt=`${rt}$1`;function lt(e){if(Array.isArray(e))return[...e];if("string"!=typeof e)throw new Error("Path must be a string.");return e.replace(/(^\[)|]/gm,"").replace(/\[/g,".").replace(tt,nt).replace(it,`.${nt}.`).replace(st,`${nt}.`).replace(at,`.${nt}`).replace(ot,".").split(".").map(e=>{if(e.startsWith(rt)){const t=e.substring(rt.length),i=parseInt(t,10);return String(i)===t?i:t}return e})}function dt(e){return!(Array.isArray(e)&&0===e.length)}function ct(e,t){return t.validationLogic({form:t.form,validators:t.validators,event:{type:e,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function pt(e,t){const{asyncDebounceMs:i}=t,{onBlurAsyncDebounceMs:s,onChangeAsyncDebounceMs:a,onDynamicAsyncDebounceMs:o}=t.validators||{},r=i??0;return t.validationLogic({form:t.form,validators:t.validators,event:{type:e,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{const i=t?.cause||e;let n=r;switch(i){case"change":n=a??r;break;case"blur":n=s??r;break;case"dynamic":n=o??r;break;case"submit":n=0}return"submit"===e&&(n=0),{cause:i,validate:t.fn,debounceMs:n}})})}const ht=e=>!!e&&"object"==typeof e&&"fields"in e;function ut(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[i,s]of e)if(!t.has(i)||!Object.is(s,t.get(i)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}const i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(const a of i)if(!s.includes(a)||!ut(e[a],t[a]))return!1;return!0}const mt=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:i})=>e?{newErrorValue:e,newSource:"form"}:t?{newErrorValue:void 0,newSource:void 0}:i?{newErrorValue:i,newSource:"field"}:{newErrorValue:void 0,newSource:void 0},vt=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:"field"}:e?{newErrorValue:e,newSource:"form"}:{newErrorValue:void 0,newSource:void 0};function ft(e,t){return null==e?t:{...e,...t}}let gt=256;const yt=[];let bt;for(;gt--;)yt[gt]=(gt+256).toString(16).substring(1);const wt=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});const t=e.event.async,i=t?void 0:{fn:e.validators.onMount,cause:"mount"},s={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:"change"},a={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:"blur"},o={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:"submit"},r=t?void 0:{fn:()=>{},cause:"server"};switch(e.event.type){case"mount":return e.runValidation({validators:[i],form:e.form});case"submit":return e.runValidation({validators:[s,a,o,r],form:e.form});case"server":return e.runValidation({validators:[],form:e.form});case"blur":return e.runValidation({validators:[a,r],form:e.form});case"change":return e.runValidation({validators:[s,r],form:e.form});default:throw new Error(`Unknown validation event type: ${e.event.type}`)}};const St=(e,t)=>{const i=function(e,t){const i=new Map;for(const s of e){const e=s.path??[];let a=t,o="";for(let t=0;t<e.length;t++){const i=e[t];if(void 0===i)continue;const s="object"==typeof i?i.key:i,r=Number(s);Array.isArray(a)&&!Number.isNaN(r)?o+=`[${r}]`:o+=(t>0?".":"")+String(s),a="object"==typeof a&&null!==a?a[s]:void 0}i.set(o,(i.get(o)??[]).concat(s))}return Object.fromEntries(i)}(e,t);return{form:i,fields:i}},xt={validate({value:e,validationSource:t},i){const s=i["~standard"].validate(e);if(s instanceof Promise)throw new Error("async function passed to sync validator");if(s.issues)return"field"===t?s.issues:St(s.issues,e)},async validateAsync({value:e,validationSource:t},i){const s=await i["~standard"].validate(e);if(s.issues)return"field"===t?s.issues:St(s.issues,e)}},_t=e=>!!e&&"~standard"in e,$t={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{}};function kt(e){function t(e,t){return`${e}[${t}]`}function i(t,i){("up"===i?t:[...t].reverse()).forEach(t=>{const a=function(e,t){return e.replace(/\[(\d+)\]/,(e,i)=>{const s=parseInt(i,10);return`[${"up"===t?s+1:Math.max(0,s-1)}]`})}(t.toString(),i),o=e.getFieldMeta(a);o?e.setFieldMeta(t,o):e.setFieldMeta(t,s())})}const s=()=>$t,a=(a,o,r)=>{i(a,"down"),a.forEach(i=>{i.toString().startsWith(t(o,r))&&e.setFieldMeta(i,s())})},o=e=>{i(e,"up")},r=(s,a,o,r)=>{const n=new Map(Object.keys(e.fieldInfo).filter(e=>e.startsWith(t(a,o))).map(t=>[t,e.getFieldMeta(t)]));i(s,o<r?"up":"down"),Object.keys(e.fieldInfo).filter(e=>e.startsWith(t(a,r))).forEach(i=>{const s=i.replace(t(a,r),t(a,o)),l=n.get(s);l&&e.setFieldMeta(i,l)})},n=(i,s,a,o)=>{i.forEach(i=>{if(!i.toString().startsWith(t(s,a)))return;const r=i.toString().replace(t(s,a),t(s,o)),[n,l]=[e.getFieldMeta(i),e.getFieldMeta(r)];n&&e.setFieldMeta(r,n),l&&e.setFieldMeta(i,l)})};return{handleArrayFieldMetaShift:function(i,s,l,d){const c=function(i,s,a,o){const r=[t(i,s)];if("swap"===a)r.push(t(i,o));else if("move"===a){const[e,a]=[Math.min(s,o),Math.max(s,o)];for(let s=e;s<=a;s++)r.push(t(i,s))}else{const a=e.getFieldValue(i),o=Array.isArray(a)?a.length:0;for(let e=s+1;e<o;e++)r.push(t(i,e))}return Object.keys(e.fieldInfo).filter(e=>r.some(t=>e.startsWith(t)))}(i,s,l,d);({insert:()=>a(c,i,s),remove:()=>o(c),swap:()=>void 0!==d&&n(c,i,s,d),move:()=>void 0!==d&&r(c,i,s,d)})[l]()}}}class EventClient{#e;#t;#i;#s;#a;#o;#r;#n=0;#l=5;#d=()=>{this.debugLog("Connected to event bus"),this.#a=!0,this.debugLog("Emitting queued events",this.#s),this.#s.forEach(e=>this.emitEventToBus(e)),this.#s=[],this.stopConnectLoop(),this.#t().removeEventListener("tanstack-connect-success",this.#d)};#c=()=>{if(this.#t().addEventListener("tanstack-connect-success",this.#d),this.#n<this.#l)return this.#n++,void this.dispatchCustomEvent("tanstack-connect",{});this.#t().removeEventListener("tanstack-connect",this.#c),this.debugLog("Max retries reached, giving up on connection"),this.stopConnectLoop()};constructor({pluginId:e,debug:t=!1}){this.#e=e,this.#t=this.getGlobalTarget,this.#i=t,this.debugLog(" Initializing event subscription for plugin",this.#e),this.#s=[],this.#a=!1,this.#o=null,this.#r=500}startConnectLoop(){null!==this.#o||this.#a||(this.debugLog(`Starting connect loop (every ${this.#r}ms)`),this.#o=setInterval(this.#c,this.#r))}stopConnectLoop(){null!==this.#o&&(clearInterval(this.#o),this.#o=null,this.debugLog("Stopped connect loop"))}debugLog(...e){this.#i&&console.log(`🌴 [tanstack-devtools:${this.#e}-plugin]`,...e)}getGlobalTarget(){if("undefined"!=typeof globalThis&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog("Using global event target"),globalThis.__TANSTACK_EVENT_TARGET__;if("undefined"!=typeof window&&void 0!==window.addEventListener)return this.debugLog("Using window as event target"),window;const e="undefined"!=typeof EventTarget?new EventTarget:void 0;return void 0===e||void 0===e.addEventListener?(this.debugLog("No event mechanism available, running in non-web environment"),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog("Using new EventTarget as fallback"),e)}getPluginId(){return this.#e}dispatchCustomEventShim(e,t){try{const i=new Event(e,{detail:t});this.#t().dispatchEvent(i)}catch(e){this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,t){try{this.#t().dispatchEvent(new CustomEvent(e,{detail:t}))}catch(i){this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog("Emitting event to client bus",e),this.dispatchCustomEvent("tanstack-dispatch-event",e)}emit(e,t){return this.#a?this.emitEventToBus({type:`${this.#e}:${e}`,payload:t,pluginId:this.#e}):(this.debugLog("Bus not available, will be pushed as soon as connected"),this.#s.push({type:`${this.#e}:${e}`,payload:t,pluginId:this.#e}),void("undefined"!=typeof CustomEvent&&(this.#c(),this.startConnectLoop())))}on(e,t){const i=`${this.#e}:${e}`,s=e=>{this.debugLog("Received event from bus",e.detail),t(e.detail)};return this.#t().addEventListener(i,s),this.debugLog("Registered event to bus",i),()=>{this.#t().removeEventListener(i,s)}}onAll(e){const t=t=>{const i=t.detail;e(i)};return this.#t().addEventListener("tanstack-devtools-global",t),()=>this.#t().removeEventListener("tanstack-devtools-global",t)}onAllPluginEvents(e){const t=t=>{const i=t.detail;this.#e&&i.pluginId!==this.#e||e(i)};return this.#t().addEventListener("tanstack-devtools-global",t),()=>this.#t().removeEventListener("tanstack-devtools-global",t)}}const Et=new class FormEventClient extends EventClient{constructor(){super({pluginId:"form-devtools"})}};function Ct(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}class FormApi{constructor(e){this.options={},this.fieldInfo={},this.prevTransformArray=[],this.mount=()=>{const e=this.fieldMetaDerived.mount(),t=this.store.mount(),i=()=>{e(),t(),Et.emit("form-unmounted",{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});const{onMount:s}=this.options.validators||{};return Et.emit("form-state-change",{id:this._formId,state:this.store.state,options:this.options}),s?(this.validateSync("mount"),i):i},this.update=e=>{if(!e)return;const t=this.options;this.options=e;const i=!!e.transform?.deps?.some((e,t)=>e!==this.prevTransformArray[t]),s=e.defaultValues&&!ut(e.defaultValues,t.defaultValues)&&!this.state.isTouched,a=!ut(e.defaultState,t.defaultState)&&!this.state.isTouched;(s||a||i)&&Je(()=>{this.baseStore.setState(()=>Ct(Object.assign({},this.state,a?e.defaultState:{},s?{values:e.defaultValues}:{},i?{_force_re_eval:!this.state._force_re_eval}:{})))})},this.reset=(e,t)=>{const{fieldMeta:i}=this.state,s=this.resetFieldMeta(i);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>Ct({...this.options.defaultState,values:e??this.options.defaultValues??this.options.defaultState?.values,fieldMetaBase:s}))},this.validateAllFields=async e=>{const t=[];Je(()=>{Object.values(this.fieldInfo).forEach(i=>{if(!i.instance)return;const s=i.instance;t.push(Promise.resolve().then(()=>s.validate(e,{skipFormValidation:!0}))),i.instance.state.meta.isTouched||i.instance.setMeta(e=>({...e,isTouched:!0}))})});return(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,i)=>{const s=this.getFieldValue(e),a=Array.isArray(s)?Math.max(s.length-1,0):null,o=[`${e}[${t}]`];for(let i=t+1;i<=(a??0);i++)o.push(`${e}[${i}]`);const r=Object.keys(this.fieldInfo).filter(e=>o.some(t=>e.startsWith(t))),n=[];Je(()=>{r.forEach(e=>{n.push(Promise.resolve().then(()=>this.validateField(e,i)))})});return(await Promise.all(n)).flat()},this.validateField=(e,t)=>{const i=this.fieldInfo[e]?.instance;return i?(i.state.meta.isTouched||i.setMeta(e=>({...e,isTouched:!0})),i.validate(t)):[]},this.validateSync=e=>{const t=ct(e,{...this.options,form:this,validationLogic:this.options.validationLogic||wt});let i=!1;const s={};return Je(()=>{for(const e of t){if(!e.validate)continue;const t=this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:a,fieldErrors:o}=Mt(t),r=Pt(e.cause);for(const e of Object.keys(this.state.fieldMeta)){const t=this.getFieldMeta(e);if(!t)continue;const{errorMap:i,errorSourceMap:a}=t,n=o?.[e],{newErrorValue:l,newSource:d}=mt({newFormValidatorError:n,isPreviousErrorFromFormValidator:"form"===a?.[r],previousErrorValue:i?.[r]});"form"===d&&(s[e]={...s[e],[r]:n}),i?.[r]!==l&&this.setFieldMeta(e,e=>({...e,errorMap:{...e.errorMap,[r]:l},errorSourceMap:{...e.errorSourceMap,[r]:d}}))}this.state.errorMap?.[r]!==a&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[r]:a}})),(a||o)&&(i=!0)}const a=Pt("submit");this.state.errorMap?.[a]&&"submit"!==e&&!i&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));const o=Pt("server");this.state.errorMap?.[o]&&"server"!==e&&!i&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:i,fieldsErrorMap:s}},this.validateAsync=async e=>{const t=pt(e,{...this.options,form:this,validationLogic:this.options.validationLogic||wt});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));const i=[];let s;for(const e of t){if(!e.validate)continue;const t=Pt(e.cause),a=this.state.validationMetaMap[t];a?.lastAbortController.abort();const o=new AbortController;this.state.validationMetaMap[t]={lastAbortController:o},i.push(new Promise(async t=>{let i;try{i=await new Promise((t,i)=>{setTimeout(async()=>{if(o.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:o.signal},type:"validateAsync"}))}catch(e){i(e)}},e.debounceMs)})}catch(e){i=e}const{formError:a,fieldErrors:r}=Mt(i);r&&(s=s?{...s,...r}:r);const n=Pt(e.cause);for(const e of Object.keys(this.state.fieldMeta)){const t=this.getFieldMeta(e);if(!t)continue;const{errorMap:i,errorSourceMap:a}=t,o=s?.[e],{newErrorValue:r,newSource:l}=mt({newFormValidatorError:o,isPreviousErrorFromFormValidator:"form"===a?.[n],previousErrorValue:i?.[n]});i?.[n]!==r&&this.setFieldMeta(e,e=>({...e,errorMap:{...e.errorMap,[n]:r},errorSourceMap:{...e.errorSourceMap,[n]:l}}))}this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:a}})),t(s?{fieldErrors:s,errorMapKey:n}:void 0)}))}let a=[];const o={};if(i.length){a=await Promise.all(i);for(const e of a)if(e?.fieldErrors){const{errorMapKey:t}=e;for(const[i,s]of Object.entries(e.fieldErrors)){const e={...o[i]||{},[t]:s};o[i]=e}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=e=>{const{hasErrored:t,fieldsErrorMap:i}=this.validateSync(e);return t&&!this.options.asyncAlways?i:this.validateAsync(e)},this.getFieldValue=e=>Ye(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(i=>({...i,fieldMetaBase:{...i.fieldMetaBase,[e]:Xe(t,i.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>(e[t]=$t,e),{}),this.setFieldValue=(e,t,i)=>{const s=i?.dontUpdateMeta??!1,a=i?.dontRunListeners??!1,o=i?.dontValidate??!1;Je(()=>{s||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(i=>({...i,values:et(i.values,e,t)}))}),a||this.getFieldInfo(e).instance?.triggerOnChangeListener(),o||this.validateField(e,"change")},this.deleteField=e=>{const t=Object.keys(this.fieldInfo).filter(t=>{const i=e.toString();return t!==i&&t.startsWith(i)}),i=[...t,e];this.baseStore.setState(e=>{const t={...e};return i.forEach(e=>{t.values=function(e,t){const i=lt(t);return function e(t){if(!t)return;if(1===i.length){const e=i[0];if(Array.isArray(t)&&"number"==typeof e)return t.filter((t,i)=>i!==e);const{[e]:s,...a}=t;return a}const s=i.shift();if("string"==typeof s&&"object"==typeof t)return{...t,[s]:e(t[s])};if("number"==typeof s&&Array.isArray(t)){if(s>=t.length)return t;const i=t.slice(0,s);return[...i.length?i:new Array(s),e(t[s]),...t.slice(s+1)]}throw new Error("It seems we have created an infinite loop in deleteBy. ")}(e)}(t.values,e),delete this.fieldInfo[e],delete t.fieldMetaBase[e]}),t})},this.pushFieldValue=(e,t,i)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],i)},this.insertFieldValue=async(e,t,i,s)=>{this.setFieldValue(e,e=>[...e.slice(0,t),i,...e.slice(t)],ft(s,{dontValidate:!0})),await this.validateField(e,"change"),kt(this).handleArrayFieldMetaShift(e,t,"insert"),await this.validateArrayFieldsStartingFrom(e,t,"change")},this.replaceFieldValue=async(e,t,i,s)=>{this.setFieldValue(e,e=>e.map((e,s)=>s===t?i:e),ft(s,{dontValidate:!0})),await this.validateField(e,"change"),await this.validateArrayFieldsStartingFrom(e,t,"change")},this.removeFieldValue=async(e,t,i)=>{const s=this.getFieldValue(e),a=Array.isArray(s)?Math.max(s.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,i)=>i!==t),ft(i,{dontValidate:!0})),kt(this).handleArrayFieldMetaShift(e,t,"remove"),null!==a){const t=`${e}[${a}]`;this.deleteField(t)}await this.validateField(e,"change"),await this.validateArrayFieldsStartingFrom(e,t,"change")},this.swapFieldValues=(e,t,i,s)=>{this.setFieldValue(e,e=>{const s=e[t],a=e[i];return et(et(e,`${t}`,a),`${i}`,s)},ft(s,{dontValidate:!0})),kt(this).handleArrayFieldMetaShift(e,t,"swap",i),this.validateField(e,"change"),this.validateField(`${e}[${t}]`,"change"),this.validateField(`${e}[${i}]`,"change")},this.moveFieldValues=(e,t,i,s)=>{this.setFieldValue(e,e=>{const s=[...e];return s.splice(i,0,s.splice(t,1)[0]),s},ft(s,{dontValidate:!0})),kt(this).handleArrayFieldMetaShift(e,t,"move",i),this.validateField(e,"change"),this.validateField(`${e}[${t}]`,"change"),this.validateField(`${e}[${i}]`,"change")},this.clearFieldValues=(e,t)=>{const i=this.getFieldValue(e),s=Array.isArray(i)?Math.max(i.length-1,0):null;if(this.setFieldValue(e,[],ft(t,{dontValidate:!0})),null!==s)for(let t=0;t<=s;t++){const i=`${e}[${t}]`;this.deleteField(i)}this.validateField(e,"change")},this.resetField=e=>{this.baseStore.setState(t=>({...t,fieldMetaBase:{...t.fieldMetaBase,[e]:$t},values:this.options.defaultValues?et(t.values,e,Ye(this.options.defaultValues,e)):t.values}))},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,i])=>(Object.keys(i).length&&i.errors.length&&(e[t]={errors:i.errors,errorMap:i.errorMap}),e),{})}),this.parseValuesWithSchema=e=>xt.validate({value:this.state.values,validationSource:"form"},e),this.parseValuesWithSchemaAsync=e=>xt.validateAsync({value:this.state.values,validationSource:"form"},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??function(){let e,t=0,i="";if(!bt||gt+16>256){for(bt=new Array(256),t=256;t--;)bt[t]=256*Math.random()|0;t=0,gt=0}for(;t<16;t++)e=bt[gt+t],i+=6===t?yt[15&e|64]:8===t?yt[63&e|128]:yt[e],1&t&&t>1&&t<11&&(i+="-");return gt++,i}(),this._devtoolsSubmissionOverride=!1,this.baseStore=new Store(Ct({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values})),this.fieldMetaDerived=new Derived({deps:[this.baseStore],fn:({prevDepVals:e,currDepVals:t,prevVal:i})=>{const s=i,a=e?.[0],o=t[0];let r=0;const n={};for(const e of Object.keys(o.fieldMetaBase)){const t=o.fieldMetaBase[e],i=a?.fieldMetaBase[e],l=s?.[e],d=Ye(o.values,e);let c=l?.errors;if(!i||t.errorMap!==i.errorMap){c=Object.values(t.errorMap??{}).filter(e=>void 0!==e);const i=this.getFieldInfo(e)?.instance;i&&!i.options.disableErrorFlat&&(c=c?.flat(1))}const p=!dt(c??[]),h=!t.isDirty,u=ut(d,Ye(this.options.defaultValues,e))||ut(d,this.getFieldInfo(e)?.instance?.options.defaultValue);l&&l.isPristine===h&&l.isValid===p&&l.isDefaultValue===u&&l.errors===c&&t===i?(n[e]=l,r++):n[e]={...t,errors:c,isPristine:h,isValid:p,isDefaultValue:u}}return Object.keys(o.fieldMetaBase).length&&s&&r===Object.keys(o.fieldMetaBase).length?s:n}}),this.store=new Derived({deps:[this.baseStore,this.fieldMetaDerived],fn:({prevDepVals:e,currDepVals:t,prevVal:i})=>{const s=i,a=e?.[0],o=t[0],r=t[1],n=Object.values(r).filter(Boolean),l=n.some(e=>e.isValidating),d=n.every(e=>e.isValid),c=n.some(e=>e.isTouched),p=n.some(e=>e.isBlurred),h=n.every(e=>e.isDefaultValue),u=c&&o.errorMap?.onMount,m=n.some(e=>e.isDirty),v=!m,f=Boolean(o.errorMap?.onMount||n.some(e=>e?.errorMap?.onMount)),g=!!l;let y=s?.errors??[];a&&o.errorMap===a.errorMap||(y=Object.values(o.errorMap).reduce((e,t)=>void 0===t?e:t&&ht(t)?(e.push(t.form),e):(e.push(t),e),[]));const b=0===y.length,w=d&&b,S=this.options.canSubmitWhenInvalid??!1,x=0===o.submissionAttempts&&!c&&!f||!g&&!o.isSubmitting&&w||S;let _=o.errorMap;if(u&&(y=y.filter(e=>e!==o.errorMap.onMount),_=Object.assign(_,{onMount:void 0})),s&&a&&s.errorMap===_&&s.fieldMeta===this.fieldMetaDerived.state&&s.errors===y&&s.isFieldsValidating===l&&s.isFieldsValid===d&&s.isFormValid===b&&s.isValid===w&&s.canSubmit===x&&s.isTouched===c&&s.isBlurred===p&&s.isPristine===v&&s.isDefaultValue===h&&s.isDirty===m&&ut(a,o))return s;let $={...o,errorMap:_,fieldMeta:this.fieldMetaDerived.state,errors:y,isFieldsValidating:l,isFieldsValid:d,isFormValid:b,isValid:w,canSubmit:x,isTouched:c,isBlurred:p,isPristine:v,isDefaultValue:h,isDirty:m};const k=this.options.transform?.deps??[],E=k.length!==this.prevTransformArray.length||k.some((e,t)=>e!==this.prevTransformArray[t]);if(E){const e=Object.assign({},this,{state:$});this.options.transform?.fn(e),$=e.state,this.prevTransformArray=k}return $}}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{}),this.store.subscribe(()=>{Et.emit("form-state-change",{id:this._formId,state:this.store.state,options:this.options})}),Et.on("request-form-state",e=>{e.payload.id===this._formId&&Et.emit("form-state-change",{id:this._formId,state:this.store.state,options:this.options})}),Et.on("request-form-reset",e=>{e.payload.id===this._formId&&this.reset()}),Et.on("request-form-force-submit",e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return _t(e.validate)?xt[e.type](e.value,e.validate):e.validate(e.value)}async handleSubmit(e){if(this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),Je(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})}),!this.state.canSubmit&&!this._devtoolsSubmissionOverride)return;const t=e??this.options.onSubmitMeta;this.baseStore.setState(e=>({...e,isSubmitting:!0}));const i=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid)return i(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),void Et.emit("form-submission-state-change",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validateAllFields",errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});if(await this.validate("submit"),!this.state.isValid)return i(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),void Et.emit("form-submission-state-change",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validate",errors:this.state.errors});Je(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.options.listeners?.onSubmit?.({value:e.instance.state.value,fieldApi:e.instance})})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await(this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t})),Je(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),Et.emit("form-submission-state-change",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),i()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),Et.emit("form-submission-state-change",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"inflight",onError:e}),i(),e}}setErrorMap(e){Je(()=>{Object.entries(e).forEach(([e,t])=>{const i=e;if(ht(t)){const{formError:e,fieldErrors:s}=Mt(t);for(const e of Object.keys(this.fieldInfo)){this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[i]:s?.[e]},errorSourceMap:{...t.errorSourceMap,[i]:"form"}}))}this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[i]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[i]:t}}))})})}}function Mt(e){if(e){if(ht(e)){return{formError:Mt(e.form).formError,fieldErrors:e.fields}}return{formError:e}}return{formError:void 0}}function Pt(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";default:return"onChange"}}class FieldApi{constructor(e){this.options={},this.mount=()=>{const e=this.store.mount();void 0!==this.options.defaultValue&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});this.getInfo().instance=this,this.update(this.options);const{onMount:t}=this.options.validators||{};if(t){const e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:"field"},type:"validate"});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:"field"}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),e},this.update=e=>{this.options=e;const t=this.name!==e.name;if(this.name=e.name,void 0===this.state.value){const i=Ye(e.form.options.defaultValues,e.name),s=e.defaultValue??i;t?this.setValue(e=>e||s,{dontUpdateMeta:!0}):void 0!==s&&this.setValue(s,{dontUpdateMeta:!0})}void 0===this.form.getFieldMeta(this.name)&&this.setMeta(this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,ft(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,ft(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,i)=>{this.form.insertFieldValue(this.name,e,t,ft(i,{dontRunListeners:!0})),i?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,i)=>{this.form.replaceFieldValue(this.name,e,t,ft(i,{dontRunListeners:!0})),i?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,ft(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,i)=>{this.form.swapFieldValues(this.name,e,t,ft(i,{dontRunListeners:!0})),i?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,i)=>{this.form.moveFieldValues(this.name,e,t,ft(i,{dontRunListeners:!0})),i?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,ft(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=e=>{const t=Object.values(this.form.fieldInfo),i=[];for(const s of t){if(!s.instance)continue;const{onChangeListenTo:t,onBlurListenTo:a}=s.instance.options.validators||{};"change"===e&&t?.includes(this.name)&&i.push(s.instance),"blur"===e&&a?.includes(this.name)&&i.push(s.instance)}return i},this.validateSync=(e,t)=>{const i=ct(e,{...this.options,form:this.form,validationLogic:this.form.options.validationLogic||wt}),s=this.getLinkedFields(e).reduce((t,i)=>{const s=ct(e,{...i.options,form:i.form,validationLogic:i.form.options.validationLogic||wt});return s.forEach(e=>{e.field=i}),t.concat(s)},[]);let a=!1;Je(()=>{const e=(e,i)=>{const s=At(i.cause),o=i.validate?It(e.runValidator({validate:i.validate,value:{value:e.store.state.value,validationSource:"field",fieldApi:e},type:"validate"})):void 0,r=t[s],{newErrorValue:n,newSource:l}=vt({formLevelError:r,fieldLevelError:o});e.state.meta.errorMap?.[s]!==n&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:n},errorSourceMap:{...e.errorSourceMap,[s]:l}})),n&&(a=!0)};for(const t of i)e(this,t);for(const t of s)t.validate&&e(t.field,t)});const o=At("submit");return this.state.meta.errorMap?.[o]&&"submit"!==e&&!a&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[o]:void 0},errorSourceMap:{...e.errorSourceMap,[o]:void 0}})),{hasErrored:a}},this.validateAsync=async(e,t)=>{const i=pt(e,{...this.options,form:this.form,validationLogic:this.form.options.validationLogic||wt}),s=await t,a=this.getLinkedFields(e),o=a.reduce((t,i)=>{const s=pt(e,{...i.options,form:i.form,validationLogic:i.form.options.validationLogic||wt});return s.forEach(e=>{e.field=i}),t.concat(s)},[]);this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(const e of a)e.setMeta(e=>({...e,isValidating:!0}));const r=[],n=[],l=(e,t,i)=>{const a=At(t.cause),o=e.getInfo().validationMetaMap[a];o?.lastAbortController.abort();const r=new AbortController;this.getInfo().validationMetaMap[a]={lastAbortController:r},i.push(new Promise(async i=>{let o;try{o=await new Promise((i,s)=>{this.timeoutIds.validations[t.cause]&&clearTimeout(this.timeoutIds.validations[t.cause]),this.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(r.signal.aborted)return i(void 0);try{i(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:r.signal,validationSource:"field"},type:"validateAsync"}))}catch(e){s(e)}},t.debounceMs)})}catch(e){o=e}if(r.signal.aborted)return i(void 0);const n=It(o),l=s[this.name]?.[a],{newErrorValue:d,newSource:c}=vt({formLevelError:l,fieldLevelError:n});e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[a]:d},errorSourceMap:{...e.errorSourceMap,[a]:c}})),i(d)}))};for(const e of i)e.validate&&l(this,e,r);for(const e of o)e.validate&&l(e.field,e,n);let d=[];(r.length||n.length)&&(d=await Promise.all(r),await Promise.all(n)),this.setMeta(e=>({...e,isValidating:!1}));for(const e of a)e.setMeta(e=>({...e,isValidating:!1}));return d.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];const{fieldsErrorMap:i}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e),{hasErrored:s}=this.validateSync(e,i[this.name]??{});if(s&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[At(e)]?.lastAbortController.abort(),this.state.meta.errors;const a=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e);return this.validateAsync(e,a)},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate("blur"),this.triggerOnBlurListener()},this.parseValueWithSchema=e=>xt.validate({value:this.state.value,validationSource:"field"},e),this.parseValueWithSchemaAsync=e=>xt.validateAsync({value:this.state.value,validationSource:"field"},e),this.form=e.form,this.name=e.name,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=new Derived({deps:[this.form.store],fn:()=>({value:this.form.getFieldValue(this.name),meta:this.form.getFieldMeta(this.name)??{...$t,...e.defaultMeta}})}),this.options=e}get state(){return this.store.state}runValidator(e){return _t(e.validate)?xt[e.type](e.value,e.validate):e.validate(e.value)}setErrorMap(e){this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))}triggerOnBlurListener(){const e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});const t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})}triggerOnChangeListener(){const e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});const t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})}}function It(e){if(e)return e}function At(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";default:return"onChange"}}var Ft,Dt,qt,Vt,zt,jt=function(e,t,i,s,a){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?a.call(e,i):a?a.value=i:t.set(e,i),i},Lt=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class TanStackFormController{constructor(e,t){Ft.set(this,void 0),Dt.set(this,void 0),this.api=new FormApi(t),jt(this,Ft,e,"f").addController(this)}hostConnected(){jt(this,Dt,this.api.store.subscribe(()=>{Lt(this,Ft,"f").requestUpdate()}),"f")}hostDisconnected(){Lt(this,Dt,"f")?.call(this)}field(e,t){return Bt(this.api,e,t)}}Ft=new WeakMap,Dt=new WeakMap;qt=new WeakMap,Vt=new WeakMap,zt=new WeakMap;const Bt=te(class FieldDirective extends se{constructor(e){if(super(e),qt.set(this,!1),Vt.set(this,void 0),zt.set(this,void 0),e.type!==ie.CHILD)throw new Error("The `field` directive must be used in the `child` attribute")}update(e,[t,i,s]){if(!Lt(this,qt,"f")){if(!Lt(this,Vt,"f")){const e={...i,form:t};jt(this,Vt,new FieldApi(e),"f"),jt(this,zt,Lt(this,Vt,"f").mount(),"f")}jt(this,qt,!0,"f")}return this.render(t,i,s)}disconnected(){super.disconnected(),Lt(this,zt,"f")?.call(this)}reconnected(){super.reconnected(),Lt(this,Vt,"f")&&jt(this,zt,Lt(this,Vt,"f").mount(),"f")}render(e,t,i){return Lt(this,Vt,"f")?i(Lt(this,Vt,"f")):T}}),Ot=N`.form-container{display:flex;flex-direction:column;gap:var(--size-4)}.form-content{display:flex;flex-direction:column;gap:var(--size-4);width:100%}.field{display:flex;flex-direction:column;gap:var(--size-2);width:100%}.field-title{font-family:var(--font-body);font-size:var(--text-base);font-weight:var(--font-weight-bold);line-height:22px;color:var(--color-neutrals-text-default);margin:0}.field-error{font-style:normal;color:var(--color-error-text-default);font-size:var(--text-base);line-height:var(--text-base--line-height);font-weight:var(--font-weight-normal)}.field.hidden{display:none}`,Tt=Y.object({first_name:Y.string({required_error:"required"}).min(1,"required"),last_name:Y.string({required_error:"required"}).min(1,"required"),email:Y.string({required_error:"required"}).email("email_invalid").min(1,"required"),phone:Y.string({required_error:"required"}).min(9,"phone_invalid"),birth_date:Y.string({required_error:"required"}).min(1,"required"),tax_id:Y.string({required_error:"required"}).min(1,"required")});class CompleteProfileFormSuccessEvent extends CustomEvent{static{this.eventName="success"}constructor(e){super(CompleteProfileFormSuccessEvent.eventName,{bubbles:!0,composed:!0,detail:e})}}let Nt=class CompleteProfileForm extends U{constructor(){super(...arguments),this.isPending=!1,this.errorMap={required:V("Este campo es obligatorio"),email_invalid:V("El email no es válido"),phone_invalid:V("El teléfono no es válido")},this.form=new TanStackFormController(this,{defaultValues:this.defaultValues,onSubmit:e=>{this.dispatchEvent(new CompleteProfileFormSuccessEvent(e.value))},validators:{onSubmit:Tt}}),this.getScheduleServicesQuery=new m(this,()=>i(o))}static{this.styles=Ot}translateError(e){return this.errorMap[e]||e}willUpdate(e){e.has("defaultValues")&&(this.form.api.setFieldValue("first_name",this.defaultValues.first_name),this.form.api.setFieldValue("last_name",this.defaultValues.last_name),this.form.api.setFieldValue("email",this.defaultValues.email),this.form.api.setFieldValue("phone",this.defaultValues.phone),this.form.api.setFieldValue("birth_date",this.defaultValues.birth_date),this.form.api.setFieldValue("tax_id",this.defaultValues.tax_id))}render(){const e=this.getScheduleServicesQuery.result?.data?.find(e=>e.id===this.serviceId),t=e?.channel===n.phonecall;return Q`<div class="form-container"><form class="form-content" @submit="${e=>{e.preventDefault(),e.stopPropagation(),this.form.api.handleSubmit()}}"><div class="${J({field:!0,hidden:!!this.defaultValues.first_name})}">${this.form.field({name:"first_name"},e=>Q`<mq-input label="${V("Nombre")}" id="${X(e.name)}" value="${X(e.state.value)}" name="${X(e.name)}" required ?error="${!e.state.meta.isValid}" @onvaluechange="${t=>{e.handleChange(t.value)}}"></mq-input>${!e.state.meta.isValid&&e.state.meta.errors.length>0?Q`<em class="field-error">${this.translateError(e.state.meta.errors[0]?.message||"")}</em>`:T}`)}</div><div class="${J({field:!0,hidden:!!this.defaultValues.last_name})}">${this.form.field({name:"last_name"},e=>Q`<mq-input label="${V("Apellidos")}" id="${X(e.name)}" value="${X(e.state.value)}" name="${X(e.name)}" required ?error="${!e.state.meta.isValid}" @onvaluechange="${t=>{e.handleChange(t.value)}}"></mq-input>${!e.state.meta.isValid&&e.state.meta.errors.length>0?Q`<em class="field-error">${this.translateError(e.state.meta.errors[0]?.message||"")}</em>`:T}`)}</div><div class="${J({field:!0,hidden:!!this.defaultValues.email})}">${this.form.field({name:"email"},e=>Q`<mq-input type="email" label="${V("Email")}" id="${X(e.name)}" value="${X(e.state.value)}" name="${X(e.name)}" required ?error="${!e.state.meta.isValid}" @onvaluechange="${t=>{e.handleChange(t.value)}}"></mq-input>${!e.state.meta.isValid&&e.state.meta.errors.length>0?Q`<em class="field-error">${this.translateError(e.state.meta.errors[0]?.message||"")}</em>`:T}`)}</div><div class="${J({field:!0,hidden:!!this.defaultValues.phone})}">${this.form.field({name:"phone"},e=>Q`<mq-input type="tel" label="${V("Teléfono")}" id="${X(e.name)}" value="${X(e.state.value)}" name="${X(e.name)}" required ?error="${!e.state.meta.isValid}" @onvaluechange="${t=>{e.handleChange(t.value)}}"></mq-input>${!e.state.meta.isValid&&e.state.meta.errors.length>0?Q`<em class="field-error">${this.translateError(e.state.meta.errors[0]?.message||"")}</em>`:T}`)}</div><div class="${J({field:!0,hidden:!!this.defaultValues.birth_date})}">${this.form.field({name:"birth_date"},e=>Q`<mq-input type="date" label="${V("Fecha de nacimiento")}" id="${X(e.name)}" value="${X(e.state.value)}" name="${X(e.name)}" required ?error="${!e.state.meta.isValid}" @onvaluechange="${t=>{e.handleChange(t.value)}}"></mq-input>${!e.state.meta.isValid&&e.state.meta.errors.length>0?Q`<em class="field-error">${this.translateError(e.state.meta.errors[0]?.message||"")}</em>`:T}`)}</div><div class="${J({field:!0,hidden:!!this.defaultValues.tax_id})}">${this.form.field({name:"tax_id"},e=>Q`<mq-input label="${V("DNI/NIE")}" id="${X(e.name)}" value="${X(e.state.value)}" name="${X(e.name)}" required ?error="${!e.state.meta.isValid}" @onvaluechange="${t=>{e.handleChange(t.value)}}"></mq-input>${!e.state.meta.isValid&&e.state.meta.errors.length>0?Q`<em class="field-error">${this.translateError(e.state.meta.errors[0]?.message||"")}</em>`:T}`)}</div>${t?Q`<mq-callout background="default" variant="info" noPadding>${V("El profesional te llamará al número que indiques en este campo.")}</mq-callout>`:T}<mq-button type="submit" fullwidth size="xl" ?disabled="${this.isPending}">${V("Continuar")}</mq-button></form></div>`}};e([R({type:Boolean})],Nt.prototype,"isPending",void 0),e([R({type:String})],Nt.prototype,"serviceId",void 0),e([R({type:Object})],Nt.prototype,"defaultValues",void 0),Nt=e([L(),t("complete-profile-form")],Nt);const Ut=N`.header-container{display:flex;justify-content:center;width:100%;margin:0 auto;flex-direction:column;gap:var(--size-4);box-sizing:border-box}.header-nav{display:flex;align-items:center;justify-content:space-between;width:100%}.title-section{display:flex;flex-direction:column;gap:var(--size-1);align-items:center;width:100%}.title-content{display:flex;flex-direction:column;gap:var(--size-1);align-items:flex-start;padding-bottom:var(--size-2);width:100%;box-sizing:border-box}.main-title{font-family:var(--font-titles);font-size:var(--text-3xl);line-height:var(--text-3xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0;white-space:nowrap}.subtitle{font-family:var(--font-body);font-size:var(--text-base);font-weight:var(--font-weight-normal);line-height:22px;color:var(--color-neutrals-text-default);margin:0;min-width:100%;width:min-content}.empty-space{height:32px;width:auto}@media (min-width:768px){.main-title{font-size:var(--text-4xl);line-height:var(--text-4xl--line-height)}}`;let Qt=class NewAppointmentHeader extends U{constructor(){super(...arguments),this.kind="schedule",this.showBack=!0}static{this.styles=Ut}render(){return Q`<div class="header-container"><div class="header-nav">${this.showBack?Q`<mq-text-button @click="${()=>this.dispatchEvent(new CustomEvent("back"))}" fontWeight="bold">${ae({color:"var(--color-primary)",size:24})} ${V("Volver")}</mq-text-button>`:Q`<div class="empty-space"></div>`}<div class="empty-space"></div></div><div class="title-section"><div class="title-content"><h1 class="main-title">${"schedule"===this.kind?V("Petición de cita"):V("Modificar cita")}</h1><p class="subtitle">${V(z`Para: ${this.patient.name}`)}</p></div></div></div>`}};e([R({type:String})],Qt.prototype,"kind",void 0),e([R({type:Boolean})],Qt.prototype,"showBack",void 0),e([v({context:Ie,subscribe:!0})],Qt.prototype,"patient",void 0),Qt=e([L(),t("new-appointment-header")],Qt);const Rt=N`:host{display:block}.trigger{width:100%;display:flex;align-items:center;gap:var(--sp-1);padding:0;border:none;background:0 0;cursor:pointer;font-family:var(--font-titles);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-primary)}.trigger:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px;border-radius:var(--border-radius-sm)}.trigger__label{flex:1;text-align:left}.chevron{transition:transform .2s ease}.chevron--open{transform:rotate(180deg)}.reveal{display:grid;grid-template-rows:0fr;overflow:hidden;transition:grid-template-rows .2s ease-out}.reveal[data-expanded=true]{grid-template-rows:1fr}.reveal__content{min-height:0;overflow:hidden}.field{display:flex;flex-direction:column;gap:var(--sp-2);margin-top:var(--sp-3)}.row{display:flex;gap:var(--sp-2)}.input{box-sizing:border-box;flex:1;min-width:0;height:var(--size-9);padding:var(--sp-1) var(--sp-3);border:1px solid var(--color-neutrals-border-disabled);border-radius:var(--border-radius-md);background:var(--color-neutrals-background-extraWeak,var(--color-white));font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);outline:0;transition:border-color .2s ease}.input::placeholder{color:var(--color-text-icons--secondary)}.input:focus{border-color:var(--color-primary)}.input--error{border-color:var(--color-error-text-default)}.error{margin:0;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-error-text-default)}.btn{box-sizing:border-box;flex:0 0 auto;height:var(--size-9);display:flex;align-items:center;justify-content:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-6);border:1px solid var(--color-primary);border-radius:var(--border-radius-md);background:var(--color-primary);color:var(--color-white);font-family:var(--font-titles);font-size:var(--text-xs);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);cursor:pointer;transition:background-color .2s ease,opacity .2s ease}.btn:hover:not(:disabled){background:var(--color-primary-dark);border-color:var(--color-primary-dark)}.btn:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.btn:disabled{opacity:.5;cursor:default}.applied{display:flex;flex-direction:column;gap:var(--sp-3)}.applied__status{display:flex;align-items:center;gap:var(--sp-1);font-family:var(--font-titles);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-text-icons--success-dark,#105b5b)}.applied__change{display:inline-flex;align-items:center;gap:var(--sp-1);align-self:flex-start;padding:0;border:none;background:0 0;cursor:pointer;font-family:var(--font-titles);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);text-decoration:underline;color:var(--color-text-icons--secondary)}.applied__change:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px;border-radius:var(--border-radius-sm)}`;let Wt=class DiscountCodeField extends U{constructor(){super(...arguments),this.basePrice=null,this.appliedDiscount=null,this.expanded=!1,this.form=new TanStackFormController(this,{defaultValues:{code:""}})}static{this.styles=Rt}async validateCode(e){const t=e.trim();if(this.basePrice&&""!==t)try{const e=await async function(e){const{basePrice:t}=e,i=e.code.trim();try{const e=await o.payments.getConsultationCoupon(i,t.amount),s=e.percent_off,a=e.after_discount_amount??t.amount-Math.round(t.amount*s/100);return{code:i,percentage:s,discountAmount:t.amount-a,totalAmount:a,currency:t.currency}}catch(e){if(r(e)&&404===e.response?.status)throw new InvalidDiscountCodeError;throw e}}({code:t,basePrice:this.basePrice});return this.dispatchEvent(new DiscountAppliedEvent(e)),this.expanded=!1,void this.form.api.reset()}catch(e){return V(e instanceof InvalidDiscountCodeError?"Este código no es válido.":"No hemos podido validar el código. Inténtalo de nuevo.")}}toggle(){this.expanded=!this.expanded}onChangeCode(){this.form.api.reset(),this.expanded=!0}renderInputForm(){const{isSubmitting:e,values:t}=this.form.api.state;return Q`<form class="field" @submit="${e=>{e.preventDefault(),e.stopPropagation(),this.form.api.handleSubmit()}}">${this.form.field({name:"code",validators:{onSubmitAsync:({value:e})=>this.validateCode(e)}},i=>{const s=i.state.meta.errors[0];return Q`<div class="row"><input class="input ${s?"input--error":""}" type="text" .value="${i.state.value}" ?disabled="${e}" placeholder="${V("Ingresa el código")}" @input="${e=>i.handleChange(e.target.value)}"> <button type="submit" class="btn" ?disabled="${!t.code.trim()||e}">${e?Q`${de({color:"currentColor",size:16})}`:V("Aplicar")}</button></div>${s?Q`<p class="error">${s}</p>`:T}`})}</form>`}render(){return this.appliedDiscount&&!this.expanded?Q`<div class="applied"><span class="applied__status" role="status">${Q`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`} ${V("Código de promoción aplicado")} </span><button type="button" class="applied__change" @click="${this.onChangeCode}">${Q`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 8H20M20 8L16 4M20 8L16 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M20 16H4M4 16L8 12M4 16L8 20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`} ${V("Cambiar código")}</button></div>`:Q`<button type="button" class="trigger" aria-expanded="${this.expanded}" @click="${this.toggle}">${ce({size:20})} <span class="trigger__label">${V("Añadir código de promoción")}</span> ${e=this.expanded,Q`<svg class="chevron ${e?"chevron--open":""}" width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 9L12 15L18 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`}</button><div class="reveal" data-expanded="${this.expanded}" .inert="${!this.expanded}"><div class="reveal__content">${this.renderInputForm()}</div></div>`;var e}};e([R({type:Object})],Wt.prototype,"basePrice",void 0),e([R({type:Object})],Wt.prototype,"appliedDiscount",void 0),e([le()],Wt.prototype,"expanded",void 0),Wt=e([L(),t("discount-code-field")],Wt);const Ht=N`.summary{box-sizing:border-box;max-width:var(--content-max-width);margin:0 auto;padding:var(--sp-4);display:flex;flex-direction:column;gap:var(--sp-4)}hr{width:100%;border:none;border-top:1px solid var(--color-neutrals-border-disabled);margin:0}.payment-info{display:flex;justify-content:space-between;color:var(--color-neutrals-text-default);font-size:16px}.payment-info__name{font-weight:600}.payment-info__price{font-weight:500}.discount-info{display:flex;justify-content:space-between;gap:var(--sp-4);color:var(--color-neutrals-text-default);font-size:var(--text-base)}.total-info{display:flex;justify-content:space-between;gap:var(--sp-4);color:var(--color-neutrals-text-default);font-size:var(--text-base);font-weight:600}.previous-starts-at{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default)}.reservation-conditions{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-text-icons--secondary)}.reservation-conditions__prefix{font-weight:var(--font-weight-semibold)}.reservation-conditions__body{font-weight:var(--font-weight-normal)}:host([fill-column]){width:100%;min-width:0;align-self:flex-start}:host([fill-column]) .summary{max-width:none;margin:0}@media (min-width:768px){.summary{padding:var(--sp-6)}}`;let Kt=class NewAppointmentSummary extends U{constructor(){super(...arguments),this.startsAt=void 0,this.duration=void 0,this.channel=void 0,this.previousStartsAt=void 0,this.previousDuration=void 0,this.serviceCode=void 0,this.serviceName=void 0,this.servicePrice=null,this.fillColumn=!1,this.appliedDiscount=null,this.showPrice=!0,this.onDiscountApplied=e=>{this.appliedDiscount=e.detail,pe.success(V("Código de promoción validado correctamente"))},this.getOrganizationSpecialtiesQuery=new m(this,()=>x(o,{enabled:!!this.professional?.speciality.id})),this.getOrganizationSetupQuery=new m(this,()=>b(o))}static{this.styles=Ht}renderAppointmentDetails(){return Q`${this.startsAt&&this.channel&&this.duration?Q`<appointment-details .startsAt="${l(this.startsAt).toISOString()}" .duration="${this.duration}" .channel="${this.channel}" .timezone="${this.patient.timezone}" variant="wide"></appointment-details>`:T} ${this.previousStartsAt&&this.previousDuration?Q`<hr><span class="previous-starts-at">${V("Cita previa:")}</span><appointment-details .startsAt="${l(this.previousStartsAt).toISOString()}" .duration="${this.previousDuration}" .timezone="${this.patient.timezone}" strike-through variant="wide"></appointment-details>`:T}`}render(){const e=H(),t=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>e.id===this.professional?.speciality.id),i=_(t?.code??"",e,t?.name),s=this.serviceCode?$(this.serviceCode,e,this.serviceName):this.serviceName??"",a=this.getOrganizationSetupQuery.result?.data?.appointments,o=a?.reserve_conditions?.trim()??"",r=!0===a?.has_discount_coupons_show,n=this.servicePrice;return Q`<mq-card class="summary" roundness="md"><professional-overview .name="${this.professional.name??""}" .specialtyName="${i??""}" .collegiateNumber="${this.professional.collegiate_number??void 0}" .description="${this.professional.description??""}" .languages="${this.professional.languages}" .avatar="${this.professional.avatar??""}" always-expanded-on-desktop></professional-overview>${this.renderAppointmentDetails()} ${oe(n)?Q`${this.showPrice?Q`${r?Q`<discount-code-field .basePrice="${{amount:n.amount,currency:n.currency}}" .appliedDiscount="${this.appliedDiscount}" @discount-applied="${this.onDiscountApplied}"></discount-code-field>`:T}<div class="payment-info">${s?Q`<span class="payment-info__name">${s}</span>`:T} <span class="payment-info__price">${re({amount:n.amount,currency:n.currency},e)}</span></div>${r&&this.appliedDiscount?Q`<div class="discount-info"><span>${V("Promoción")} ${this.appliedDiscount.code} (-${this.appliedDiscount.percentage}%)</span> <span>${re({amount:-this.appliedDiscount.discountAmount,currency:this.appliedDiscount.currency},e)}</span></div><hr><div class="total-info"><span>${V("Total")}</span> <span>${re({amount:this.appliedDiscount.totalAmount,currency:this.appliedDiscount.currency},e)}</span></div>`:T}`:T} ${o.length>0?Q`<hr><mq-clamped-text class="reservation-conditions" .lines="${2}" expand-label="${V("Ver más")}" collapse-label="${V("Ver menos")}"><span class="reservation-conditions__prefix">${V("Condiciones de reserva:")}</span> ${" "} <span class="reservation-conditions__body">${o}</span></mq-clamped-text>`:T}`:T}</mq-card>`}};e([R({type:Object})],Kt.prototype,"professional",void 0),e([R({type:String})],Kt.prototype,"startsAt",void 0),e([R({type:Number})],Kt.prototype,"duration",void 0),e([R({type:String})],Kt.prototype,"channel",void 0),e([R({type:String})],Kt.prototype,"previousStartsAt",void 0),e([R({type:Number})],Kt.prototype,"previousDuration",void 0),e([R({type:String})],Kt.prototype,"serviceCode",void 0),e([R({type:String})],Kt.prototype,"serviceName",void 0),e([R({type:Object})],Kt.prototype,"servicePrice",void 0),e([R({type:Boolean,attribute:"fill-column",reflect:!0})],Kt.prototype,"fillColumn",void 0),e([R({type:Object})],Kt.prototype,"appliedDiscount",void 0),e([R({type:Boolean})],Kt.prototype,"showPrice",void 0),e([v({context:Ie,subscribe:!0})],Kt.prototype,"patient",void 0),Kt=e([L(),t("new-appointment-summary")],Kt);let Gt=class CompleteProfileStep extends U{constructor(){super(...arguments),this.showBack=!0,this.channel=void 0,this.getPatientProfileQuery=new m(this,()=>g(o)),this.updatePatientProfileMutation=new f(this,{mutationFn:async e=>o.flash.updatePatientProfile(e)})}static{this.styles=N`.content{box-sizing:border-box;display:flex;flex-direction:column;gap:var(--sp-6)}.right-side{padding:var(--sp-4);background-color:var(--color-neutrals-background-weak)}h2{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0;margin-bottom:var(--sp-4)}@media (min-width:768px){.content{flex-direction:row;align-items:start;gap:var(--sp-6)}.right-side{width:50%;padding:var(--sp-6)}new-appointment-summary{width:50%}}`}handleSubmit(e){const t=e.detail;this.updatePatientProfileMutation.run({first_name:t.first_name,last_name:t.last_name,email:t.email,phone:t.phone,birth_date:t.birth_date,phone_prefix:"+34",tax_id:t.tax_id,privacy_accepted:!0,terms_accepted:!0}),this.dispatchEvent(new CustomEvent("success"))}render(){return this.getPatientProfileQuery.render({complete:e=>Q`<new-appointment-header .showBack="${this.showBack}" @back="${()=>this.dispatchEvent(new CustomEvent("back"))}"></new-appointment-header><div class="content"><new-appointment-summary .professional="${this.professional}" .startsAt="${this.scheduleSlot.starts_at}" .duration="${this.scheduleSlot.duration}" .channel="${this.channel??this.scheduleSlot.channel}"></new-appointment-summary><div class="right-side"><h2>${V("Completa tu perfil")}</h2><complete-profile-form .serviceId="${this.serviceId}" @success="${this.handleSubmit}" .defaultValues="${{first_name:e?.profile.first_name,last_name:e?.profile.last_name,email:e?.profile.email,phone_prefix:e?.profile.phone_prefix,phone:e?.profile.phone,birth_date:e?.profile.birth_date,gender:e?.profile.gender,tax_id:e?.profile.billing.tax_id}}" .isPending="${this.updatePatientProfileMutation.isPending}"></complete-profile-form></div></div>`})}};e([R({type:String})],Gt.prototype,"serviceId",void 0),e([R({type:Boolean})],Gt.prototype,"showBack",void 0),e([R({type:Object})],Gt.prototype,"scheduleSlot",void 0),e([R({type:Object})],Gt.prototype,"professional",void 0),e([R({type:String})],Gt.prototype,"channel",void 0),Gt=e([L(),t("complete-profile-step")],Gt);const Zt=N`:host{display:block}.field{display:flex;flex-direction:column;gap:var(--sp-4)}.label{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.hint{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-neutrals-text-default);margin:0}.files{display:flex;flex-direction:column;gap:var(--sp-2)}.file{font-family:var(--font-body);border-radius:var(--border-radius-md);padding:var(--sp-2);display:flex;align-items:center;justify-content:space-between;gap:var(--sp-1);background-color:var(--color-white)}.file.uploading{opacity:.5;pointer-events:none}.file-info{flex:1;display:flex;align-items:center;gap:var(--sp-2);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0;min-width:0}.file-info svg{flex-shrink:0}.file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.file-close{line-height:0;flex-shrink:0}@keyframes animate-spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:animate-spin 750ms linear infinite}@media (min-width:768px){mq-button{max-width:323px;margin:0 auto}}`;class FileAttachmentsChangeEvent extends CustomEvent{static{this.eventName="onfileschange"}constructor(e){super(FileAttachmentsChangeEvent.eventName,{bubbles:!0,composed:!0,detail:{files:e}})}}let Jt=class FileAttachments extends U{constructor(){super(...arguments),this.uploadedFiles=[],this.uploadingFile=null,this.uploadFileMutation=new f(this,{mutationFn:e=>o.documents.uploadFile({file:e}),throwOnError:!0})}static{this.styles=Zt}handleClickUploadFile(){const e=this.shadowRoot?.querySelector("input[type='file']");e&&e.click()}getErrorMessageFromCode(e){switch(e){case 422:default:return V("Ha ocurrido un error en el envío del archivo");case 413:return V("El archivo supera el tamaño máximo permitido");case 415:return V("Formato de archivo no soportado")}}async handleUploadFile(e){const t=e.target.files?.[0];if(t){if(t.size>314572800)return pe.error(V("El archivo supera el tamaño máximo permitido"),{duration:3e3}),void(this.fileInput.value="");this.uploadingFile=t;try{const e=await this.uploadFileMutation.run(t),i={id:crypto.randomUUID(),file_path:e.url,file_name:t.name},s=[...this.uploadedFiles,i];this.dispatchEvent(new CustomEvent("onfileschange",{bubbles:!0,composed:!0,detail:{files:s,newFile:i}})),this.uploadingFile=null}catch(e){if(!r(e))return;const t=this.getErrorMessageFromCode(e.response?.status??500);pe.error(t,{duration:3e3}),this.uploadingFile=null}finally{this.fileInput.value=""}}}handleRemoveFile(e){const t=this.uploadedFiles.filter((t,i)=>i!==e);this.dispatchEvent(new CustomEvent("onfileschange",{bubbles:!0,composed:!0,detail:{files:t}}))}render(){return Q`<div class="field"><input type="file" hidden @change="${this.handleUploadFile}"><p class="label">${V("Adjuntar archivos")}</p><p class="hint">${V("Puedes adjuntar imágenes o documentación adicional (analíticas, resultados de pruebas, etc.) para que los evalúe el médico")}</p><mq-button size="md" variant="outline" fullwidth @click="${this.handleClickUploadFile}">${me()} ${V("Subir archivo")}</mq-button><div class="files">${this.uploadedFiles.map((e,t)=>Q`<div class="file"><div class="file-info">${ue()} <span class="file-name">${e.file_name}</span></div><div class="file-close"><mq-button size="icon-xs" variant="ghost" @click="${()=>this.handleRemoveFile(t)}">${ve({color:"var(--color-neutrals-text-default)",size:24})}</mq-button></div></div>`)} ${this.uploadingFile?Q`<div class="file uploading"><div class="file-info">${Q`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="animate-spin"><path opacity="0.12" fill-rule="evenodd" clip-rule="evenodd" d="M12 4C9.87827 4 7.84344 4.84285 6.34315 6.34315C4.84285 7.84344 4 9.87827 4 12C4 14.1217 4.84285 16.1566 6.34315 17.6569C7.84344 19.1571 9.87827 20 12 20C14.1217 20 16.1566 19.1571 17.6569 17.6569C19.1571 16.1566 20 14.1217 20 12C20 9.87827 19.1571 7.84344 17.6569 6.34315C16.1566 4.84285 14.1217 4 12 4ZM2 12C2 6.477 6.477 2 12 2C17.523 2 22 6.477 22 12C22 17.523 17.523 22 12 22C6.477 22 2 17.523 2 12Z" fill="#333333"/><path fill-rule="evenodd" clip-rule="evenodd" d="M11.9985 4.00001C9.93591 3.99566 7.9522 4.7923 6.46551 6.22201C6.3707 6.31289 6.25891 6.3842 6.13654 6.43187C6.01417 6.47955 5.8836 6.50265 5.7523 6.49986C5.621 6.49708 5.49153 6.46846 5.37129 6.41564C5.25105 6.36282 5.14239 6.28683 5.05151 6.19201C4.96064 6.0972 4.88933 5.98541 4.84165 5.86304C4.79398 5.74067 4.77088 5.6101 4.77366 5.4788C4.77645 5.3475 4.80507 5.21803 4.85789 5.09779C4.91071 4.97755 4.9867 4.86889 5.08151 4.77801C6.94058 2.99145 9.42015 1.9956 11.9985 2.00001C12.2637 2.00001 12.5181 2.10537 12.7056 2.29291C12.8932 2.48044 12.9985 2.7348 12.9985 3.00001C12.9985 3.26523 12.8932 3.51959 12.7056 3.70712C12.5181 3.89466 12.2637 4.00001 11.9985 4.00001Z" fill="#333333"/></svg>`} <span class="file-name">${this.uploadingFile.name}</span></div></div>`:""}</div></div>`}};function Xt(e){return o.appointments.createAppointment(e)}e([R({type:Array})],Jt.prototype,"uploadedFiles",void 0),e([le()],Jt.prototype,"uploadingFile",void 0),e([he("input[type='file']")],Jt.prototype,"fileInput",void 0),Jt=e([L(),t("file-attachments")],Jt);class ScheduleAppointmentMutationController{constructor(e,t){this.mutation=new f(e,{mutationFn:Xt,onSuccess:async e=>{await(t.getQueryClient()?.invalidateQueries()),await t.onSuccess(e.appointment.id)},onError:async()=>{await(t.getQueryClient()?.invalidateQueries()),await t.onError()}})}run(e){return this.mutation.run(function(e){return{slot_id:e.slotId,service_id:e.serviceId,consultation_reason:e.consultationReason,preconsultation_documents:e.preconsultationDocuments,discount_code:e.discountCode}}(e))}get isPending(){return this.mutation.isPending}get isError(){return this.mutation.isError}get isSuccess(){return this.mutation.isSuccess}get isIdle(){return this.mutation.isIdle}get data(){return this.mutation.data}get error(){return this.mutation.error}reset(){this.mutation.reset()}}const Yt=N`:host{height:100%;display:flex;flex-direction:column;gap:var(--sp-4)}.content{display:flex;flex-direction:column;gap:var(--sp-4)}.questionnaire{width:100%;padding:var(--sp-4)}.questionnaire>:not(:last-child){margin-bottom:var(--sp-4)}.questionnaire-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;margin-bottom:var(--sp-4)}.field{display:flex;flex-direction:column;gap:var(--sp-4)}.label{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}@media (min-width:768px){.content{flex-direction:row;gap:var(--sp-6)}new-appointment-summary{width:50%}.questionnaire{width:50%;padding:var(--sp-6)}}`;let ei=class SuccessEvent extends Event{static{this.eventName="success"}constructor(e){super(SuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}};class PaymentStartedEvent extends Event{static{this.eventName="payment-started"}constructor(e){super(PaymentStartedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}let ti=class ConfirmStep extends U{constructor(){super(...arguments),this.kind="schedule",this.showBack=!0,this.requiresPayment=!0,this.channel=void 0,this.appointment=void 0,this.specialityId="",this.service=void 0,this.appliedDiscount=null,this.reason="",this.attachedFiles=[],this.createScheduleAppointment=new ScheduleAppointmentMutationController(this,{getQueryClient:()=>this.queryClientContext,onSuccess:e=>{this.dispatchEvent(new ei({appointmentId:e}))},onError:()=>{this.dispatchEvent(new CustomEvent("error"))}}),this.rescheduleAppointmentMutation=new f(this,{mutationFn:async e=>o.appointments.rescheduleAppointment(e),onSuccess:async()=>{await(this.queryClientContext?.invalidateQueries());const e=this.appointment?.id;if(!e)return ee.error("confirm-step: reschedule succeeded but appointment id is missing"),void this.dispatchEvent(new CustomEvent("error"));this.dispatchEvent(new ei({appointmentId:e}))},onError:async()=>{await(this.queryClientContext?.invalidateQueries()),this.dispatchEvent(new CustomEvent("error"))}}),this.createPaymentLinkMutation=new f(this,{mutationFn:async e=>({result:await o.payments.createPaymentLink(e),request:e}),onSuccess:({result:e,request:t})=>{this.dispatchEvent(new PaymentStartedEvent({sessionId:e.session_id,paymentUrl:e.payment_link,request:t}))},onError:async()=>{await(this.queryClientContext?.invalidateQueries()),this.dispatchEvent(new CustomEvent("error"))}})}static{this.styles=Yt}get isPaymentFlow(){return this.requiresPayment&&"schedule"===this.kind&&oe(this.service?.price)}get isFullyDiscounted(){return null!=this.appliedDiscount&&Be(this.appliedDiscount)}get ctaLabel(){return this.isFullyDiscounted?V("Confirmar cita"):this.isPaymentFlow?V("Continuar al pago"):V("Continuar")}async handleSubmit(){if(k.track(E(this.patient.hash,this.professional.id??"",this.startsAt??"",this.specialityId,this.serviceId??"")),!this.isPaymentFlow||this.isFullyDiscounted)if("schedule"===this.kind)this.createScheduleAppointment.run({slotId:this.scheduleSlot.id,serviceId:this.serviceId,consultationReason:this.reason,preconsultationDocuments:this.attachedFiles,discountCode:this.isFullyDiscounted?this.appliedDiscount?.code:void 0});else{const e=this.appointment?.id;if(!e)return void this.dispatchEvent(new CustomEvent("error"));this.rescheduleAppointmentMutation.run({id:e,slot_id:this.scheduleSlot.id,consultation_reason:this.reason,preconsultation_documents:this.attachedFiles})}else this.createPaymentLinkMutation.run({slot_id:this.scheduleSlot.id,service_id:this.serviceId,specialty_id:this.specialityId,consultation_reason:this.reason,preconsultation_documents:this.attachedFiles,discount_code:this.appliedDiscount?.code})}handleFilesChange(e){this.attachedFiles=e.detail.files}firstUpdated(){!this.reason&&this.appointment&&(this.reason=this.appointment.consultation_reason??""),!this.attachedFiles.length&&this.appointment&&(this.attachedFiles=this.appointment.preconsultation_documents?.map(e=>({id:e.id,file_path:e.file_path,file_name:e.file_name}))??[])}render(){return Q`<new-appointment-header .kind="${this.kind}" .showBack="${this.showBack}" @back="${()=>this.dispatchEvent(new CustomEvent("back"))}"></new-appointment-header><div class="content"><new-appointment-summary .professional="${this.professional}" .startsAt="${this.startsAt}" .duration="${this.duration}" .previousStartsAt="${this.appointment?.start_date}" .previousDuration="${this.appointment?.duration}" .channel="${this.channel??this.appointment?.channel}" .serviceCode="${this.service?.code}" .serviceName="${this.service?.name}" .servicePrice="${this.scheduleSlot?.speciality?.price??null}" .appliedDiscount="${this.appliedDiscount}" .showPrice="${"reschedule"!==this.kind}" @discount-applied="${e=>{this.appliedDiscount=e.detail}}"></new-appointment-summary><mq-card class="questionnaire" roundness="md"><p class="questionnaire-title">${V("Cuestionario preconsulta")}</p><div class="field"><p class="label">${V("Motivo de consulta")}</p><mq-textarea maxlength="${240}" label="${V("¿Por qué necesitas la consulta?")}" rows="${4}" .value="${this.reason}" @onvaluechange="${e=>{this.reason=e.value}}"></mq-textarea></div><file-attachments .uploadedFiles="${this.attachedFiles}" @onfileschange="${this.handleFilesChange}"></file-attachments><mq-button size="xl" type="button" ?disabled="${this.createScheduleAppointment.isPending||this.rescheduleAppointmentMutation.isPending||this.createPaymentLinkMutation.isPending}" @click="${this.handleSubmit}" fullwidth>${this.ctaLabel}</mq-button></mq-card></div>`}};e([v({context:Ie,subscribe:!0})],ti.prototype,"patient",void 0),e([R({type:String})],ti.prototype,"kind",void 0),e([R({type:Boolean})],ti.prototype,"showBack",void 0),e([R({type:Boolean})],ti.prototype,"requiresPayment",void 0),e([R({type:Object})],ti.prototype,"scheduleSlot",void 0),e([R({type:Object})],ti.prototype,"professional",void 0),e([R({type:String})],ti.prototype,"startsAt",void 0),e([R({type:Number})],ti.prototype,"duration",void 0),e([R({type:String})],ti.prototype,"channel",void 0),e([R({type:Object})],ti.prototype,"appointment",void 0),e([R({type:String})],ti.prototype,"serviceId",void 0),e([R({type:String})],ti.prototype,"specialityId",void 0),e([R({type:Object})],ti.prototype,"service",void 0),e([R({type:Object})],ti.prototype,"appliedDiscount",void 0),e([le()],ti.prototype,"reason",void 0),e([le()],ti.prototype,"attachedFiles",void 0),e([v({context:fe,subscribe:!0})],ti.prototype,"queryClientContext",void 0),ti=e([L(),t("confirm-step")],ti);class PaymentSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(PaymentSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}const ii=N`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;gap:var(--sp-4);padding:var(--sp-8);text-align:center}.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}.error-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}`;let si=class PaymentPendingStep extends U{constructor(){super(...arguments),this._timedOut=!1,this._remaining=6e4}static{this.styles=ii}connectedCallback(){super.connectedCallback(),this._intervalId=setInterval(async()=>{if(this._remaining-=1e3,this._remaining<=0)return clearInterval(this._intervalId),this._timedOut=!0,void this.dispatchEvent(new CustomEvent("error"));try{const e=await o.payments.getPaymentSession(this.sessionId);"paid"===e.status&&(clearInterval(this._intervalId),this.dispatchEvent(new PaymentSuccessEvent({appointmentId:e.consultation_id})))}catch{}},1e3)}disconnectedCallback(){super.disconnectedCallback(),clearInterval(this._intervalId)}render(){return this._timedOut?Q`<p class="error-title">${V("No hemos podido confirmar tu pago")}</p><p class="message">${V("Ha ocurrido un problema al verificar el estado de tu pago. Por favor, contacta con soporte si el cargo se ha realizado.")}</p>`:Q`${de({size:40,color:"var(--color-primary-default)"})}<p class="message">${V("Verificando tu pago...")}</p>`}};e([R({type:String})],si.prototype,"sessionId",void 0),e([le()],si.prototype,"_timedOut",void 0),si=e([L(),t("payment-pending-step")],si);class PaymentMethodSelectedEvent extends Event{static{this.eventName="payment-method-selected"}constructor(e){super(PaymentMethodSelectedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}const ai=N`:host{display:block;width:100%}.panel{width:100%;box-sizing:border-box;padding:24px}.header{display:flex;flex-direction:column;gap:6px;margin-bottom:10px}.title{font-family:var(--font-titles);font-size:var(--text-base);line-height:var(--text-base--line-height);font-weight:var(--font-weight-semibold);letter-spacing:-.025em;color:var(--color-neutrals-text-default);margin:0}.subtitle{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-neutrals-text-medium);margin:0}.body{display:flex;flex-direction:column;gap:var(--sp-4)}.options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--sp-4)}.options--with-apple-pay{grid-template-columns:repeat(3,minmax(0,1fr))}.option{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;width:100%;min-width:0;padding:var(--sp-4);border:2px solid var(--color-border,#edecf1);border-radius:var(--border-radius-md);background:var(--color-card,#fff);cursor:pointer;text-align:center;font:inherit;color:var(--color-neutrals-text-default);box-sizing:border-box;transition:border-color .15s ease}.option:hover:not(:disabled):not(.option--selected){border-color:var(--color-neutrals-border-default)}.option:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.option--selected{border-color:var(--color-primary)}.option--disabled,.option--disabled:hover{opacity:.55;cursor:not-allowed}.option__icon{display:flex;align-items:center;justify-content:center;width:16px;height:16px;color:var(--color-neutrals-text-default);flex-shrink:0}.option__icon svg{display:block;max-width:100%;max-height:100%}.option__label{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-neutrals-text-default);margin:0;white-space:nowrap}.confirm{display:block;width:100%}`;let oi=class PaymentMethodSelector extends U{constructor(){super(...arguments),this._selected=null,this._confirm=()=>{this._selected&&this.dispatchEvent(new PaymentMethodSelectedEvent({method:this._selected}))}}static{this.styles=ai}_select(e){this._selected=e}render(){const e="undefined"!=typeof window&&window.isSecureContext;return Q`<mq-card class="panel" elevation="none" roundness="lg"><div class="header"><h2 class="title">${V("Método de pago")}</h2><p class="subtitle">${V("Selecciona un método para realizar el pago de la cita")}</p></div><div class="body"><div class="${J({options:!0,"options--with-apple-pay":e})}" role="radiogroup" aria-label="${V("Método de pago")}"><button type="button" class="${J({option:!0,"option--selected":"card"===this._selected})}" role="radio" aria-checked="${"card"===this._selected}" @click="${()=>this._select("card")}"><span class="option__icon">${Q`<svg width="16" height="16" viewBox="0 0 14.3333 10.3333" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M0.5 3.83333H13.8333M1.83333 0.5H12.5C13.2364 0.5 13.8333 1.09695 13.8333 1.83333V8.5C13.8333 9.23638 13.2364 9.83333 12.5 9.83333H1.83333C1.09695 9.83333 0.5 9.23638 0.5 8.5V1.83333C0.5 1.09695 1.09695 0.5 1.83333 0.5Z" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}</span><p class="option__label">${V("Tarjeta")}</p></button> <button type="button" class="option option--disabled" role="radio" aria-checked="false" disabled="disabled" aria-disabled="true"><span class="option__icon">${Q`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.4l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .535 5.387.535 12s5.332 12 11.945 12c3.467 0 6.08-1.147 8.08-3.253 2.053-2.053 2.68-4.947 2.68-7.267 0-.72-.053-1.467-.173-2.053H12.48z" fill="currentColor"/></svg>`}</span><p class="option__label">${V("Google")}</p></button> ${e?Q`<button type="button" class="${J({option:!0,"option--selected":"apple-pay"===this._selected})}" role="radio" aria-checked="${"apple-pay"===this._selected}" @click="${()=>this._select("apple-pay")}"><span class="option__icon">${Q`<svg width="16" height="16" viewBox="0 0 13.0333 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M6.61801 4.59733C5.98601 4.59733 5.00801 3.87867 3.97801 3.904C2.61801 3.922 1.37134 4.69267 0.670675 5.91333C-0.740658 8.36333 0.306675 11.982 1.68334 13.9733C2.35868 14.9427 3.15534 16.0333 4.21134 15.9993C5.22467 15.956 5.60468 15.3413 6.83468 15.3413C8.05534 15.3413 8.40134 15.9993 9.47467 15.9733C10.566 15.956 11.2587 14.9867 11.9253 14.008C12.696 12.8827 13.016 11.7913 13.0333 11.7313C13.0073 11.7227 10.912 10.9173 10.8867 8.49333C10.8693 6.46667 12.54 5.49733 12.618 5.454C11.6653 4.06067 10.2027 3.90467 9.69134 3.87C8.35801 3.766 7.24134 4.59733 6.61801 4.59733ZM8.87001 2.55333C9.43201 1.87867 9.80334 0.935333 9.70001 0C8.89534 0.0346667 7.92534 0.536667 7.34534 1.212C6.82534 1.80933 6.37601 2.77067 6.49668 3.688C7.38868 3.75733 8.30668 3.22933 8.86934 2.554" fill="currentColor"/></svg>`}</span><p class="option__label">${V("Apple")}</p></button>`:null}</div><mq-button class="confirm" variant="primary" size="md" fullwidth type="button" ?disabled="${null===this._selected}" @click="${this._confirm}">${V("Confirmar y pagar")}</mq-button></div></mq-card>`}};e([le()],oi.prototype,"_selected",void 0),oi=e([L(),t("payment-method-selector")],oi);const ri=N`:host{height:100%;min-height:0;display:flex;flex-direction:column;gap:var(--sp-6);flex:1}.content{display:flex;flex-direction:column;flex:1;min-height:0;gap:var(--sp-4)}.summary-col{display:flex;flex-direction:column;gap:var(--sp-4);min-width:0}.confirm-reveal{display:grid;grid-template-rows:0fr;transition:grid-template-rows .25s ease-out}.content--free .confirm-reveal{grid-template-rows:1fr}.confirm-reveal__inner{min-height:0;overflow:hidden}.payment-col{display:grid;grid-template-rows:1fr;overflow:hidden;transition:grid-template-rows .3s ease,opacity .25s ease}.content--free .payment-col{grid-template-rows:0fr;opacity:0}.payment-col__inner{min-height:0;overflow:hidden}.payment-frame{position:relative;width:100%;min-width:0;display:flex;flex-direction:column;flex:0 0 auto;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}.panel{width:100%;box-sizing:border-box;padding:24px}.apple-pay-waiting{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--sp-4);text-align:center;min-height:200px}.apple-pay-waiting__title{font-family:var(--font-titles);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-semibold);color:var(--color-neutrals-text-default);margin:0}.apple-pay-waiting__message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-subtle);margin:0}.error{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;gap:var(--sp-4);padding:var(--sp-8);text-align:center}.error-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}.error-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}@media (min-width:768px){.content{display:grid;grid-template-columns:1fr 1fr;align-items:start;gap:var(--sp-6);transition:grid-template-columns .3s ease}.content--free{grid-template-columns:1fr 0fr}.summary-col{max-width:calc((var(--content-max-width) - var(--sp-6))/ 2)}.content--free .summary-col{margin-inline:auto}.payment-col,.payment-frame{min-width:0}}`,ni="mediquo:payment:retry",li="mediquo:payment:resize";class PaymentRetryEvent extends Event{static{this.eventName="payment-retry"}constructor(){super(PaymentRetryEvent.eventName,{bubbles:!0,composed:!0})}}class ApplePayOpenedEvent extends Event{static{this.eventName="apple-pay-opened"}constructor(e){super(ApplePayOpenedEvent.eventName,{bubbles:!0,composed:!0,cancelable:!0}),this.detail=e}}let di=class PaymentStep extends U{constructor(){super(...arguments),this.showBack=!0,this.paymentUrl="",this.channel=void 0,this.service=void 0,this.scheduleSlot=void 0,this.appliedDiscount=null,this.bookingRequest=null,this.env="production",this.locale="es_ES",this.countryCode="ES",this._view="select",this._applePayWaiting=!1,this._applePayUrl=null,this._applePayPopupBlocked=!1,this._applePayConfigError=!1,this._timedOut=!1,this._iframeLoaded=!1,this._iframeHeight=null,this._applePayPopup=null,this._pollDeadline=0,this.createScheduleAppointment=new ScheduleAppointmentMutationController(this,{getQueryClient:()=>this.queryClientContext,onSuccess:e=>{this.dispatchEvent(new CustomEvent("success",{detail:{appointmentId:e}}))},onError:()=>{this.dispatchEvent(new CustomEvent("error"))}}),this._onPaymentMethodSelected=e=>{if("card"===e.detail.method)return this._view="card",this._applePayWaiting=!1,this._applePayConfigError=!1,void this._startPaymentPolling();const t=this._buildApplePayUrl();if(!t)return this._applePayConfigError=!0,this._applePayWaiting=!0,this._applePayUrl=null,void(this._applePayPopupBlocked=!1);this._applePayUrl=t,this._applePayConfigError=!1,this._applePayPopupBlocked=!1,this._applePayWaiting=!0;const i=new ApplePayOpenedEvent({url:t,sessionId:this.sessionId});if(this.dispatchEvent(i),i.defaultPrevented)this._applePayPopup=null;else{const e=this._openApplePayPopup(t);this._applePayPopup=e,e||(this._applePayPopupBlocked=!0)}this._startPaymentPolling()},this._onHeaderBack=()=>"card"===this._view?(this._stopPaymentPolling(),this._view="select",this._iframeLoaded=!1,void(this._iframeHeight=null)):this._applePayWaiting?(this._stopPaymentPolling(),this._applePayWaiting=!1,this._applePayConfigError=!1,this._applePayPopup?.close(),void(this._applePayPopup=null)):void this.dispatchEvent(new CustomEvent("back")),this._onMessage=e=>{if("card"===this._view)switch(e.data?.type){case ni:return void this.dispatchEvent(new PaymentRetryEvent);case li:return void("number"==typeof e.data.height&&(this._iframeHeight=e.data.height))}}}static{this.styles=ri}get isFullyDiscounted(){return null!=this.appliedDiscount&&Be(this.appliedDiscount)}confirmFree(){const e=this.bookingRequest;e&&this.createScheduleAppointment.run({slotId:e.slot_id,serviceId:e.service_id,consultationReason:e.consultation_reason,preconsultationDocuments:e.preconsultation_documents,discountCode:this.appliedDiscount?.code})}_paymentAmountCents(){return this.appliedDiscount?this.appliedDiscount.totalAmount:this.scheduleSlot?.speciality?.price?.amount??0}_paymentCurrency(){return this.appliedDiscount?.currency??this.scheduleSlot?.speciality?.price?.currency??"EUR"}_paymentAmountLabel(){return ne(this._paymentAmountCents()).toFixed(2)}_buildApplePayUrl(){return this.apiKey&&this.userToken?function(e){const t=new URL("https://checkout.mediquo.com/apple-pay");return t.searchParams.set("api_key",e.apiKey),t.searchParams.set("session_id",e.sessionId),t.searchParams.set("amount",e.amount),t.searchParams.set("currency",e.currency),t.searchParams.set("country",e.country),t.searchParams.set("label",e.label),t.searchParams.set("env",e.env),t.searchParams.set("locale",e.locale),e.successUrl&&t.searchParams.set("success_url",e.successUrl),t.hash=`token=${encodeURIComponent(e.token)}`,t.toString()}({apiKey:this.apiKey,token:this.userToken,sessionId:this.sessionId,amount:this._paymentAmountLabel(),currency:this._paymentCurrency(),country:this.countryCode,label:this.service?.name??V("Consulta"),env:this.env,locale:this.locale,successUrl:this.successUrl}):null}_stopPaymentPolling(){void 0!==this._pollIntervalId&&(clearInterval(this._pollIntervalId),this._pollIntervalId=void 0),void 0!==this._pollStartTimeoutId&&(clearTimeout(this._pollStartTimeoutId),this._pollStartTimeoutId=void 0)}_startPaymentPolling(){this._stopPaymentPolling(),this._timedOut=!1,this._pollDeadline=Date.now()+6e5,this._pollStartTimeoutId=setTimeout(()=>{this._pollStartTimeoutId=void 0,this._pollOnce(),this._pollIntervalId=setInterval(()=>{this._pollOnce()},3e3)},5e3)}async _pollOnce(){if(Date.now()>=this._pollDeadline)return this._stopPaymentPolling(),this._timedOut=!0,this.requestUpdate(),void this.dispatchEvent(new CustomEvent("error"));try{const e=await o.payments.getPaymentSession(this.sessionId);e.status===d.Paid&&(this._stopPaymentPolling(),this._applePayPopup?.close(),this._applePayPopup=null,this.dispatchEvent(new PaymentSuccessEvent({appointmentId:e.consultation_id})))}catch{}}_openApplePayPopup(e){return window.open(e,"mediquo-apple-pay",["width=480","height=720",`left=${Math.max(0,Math.round((window.screen.availWidth-480)/2))}`,`top=${Math.max(0,Math.round((window.screen.availHeight-720)/2))}`,"menubar=no","toolbar=no","location=yes","status=no","scrollbars=yes","resizable=yes"].join(","))}_reopenApplePayPopup(){if(!this._applePayUrl)return;const e=this._openApplePayPopup(this._applePayUrl);this._applePayPopup=e,this._applePayPopupBlocked=!e}updated(e){super.updated(e),e.has("paymentUrl")&&(this._iframeLoaded=!1,this._iframeHeight=null)}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),this._stopPaymentPolling(),this._applePayPopup?.close(),this._applePayPopup=null,super.disconnectedCallback()}_onIframeLoad(){this._iframeLoaded=!0}_renderSummaryColumn(){return Q`<div class="summary-col"><new-appointment-summary .professional="${this.professional}" .startsAt="${this.startsAt}" .duration="${this.duration}" .channel="${this.channel}" .serviceCode="${this.service?.code}" .serviceName="${this.service?.name}" .servicePrice="${this.scheduleSlot?.speciality?.price??null}" .appliedDiscount="${this.appliedDiscount}" .fillColumn="${!0}"></new-appointment-summary><div class="confirm-reveal" .inert="${!this.isFullyDiscounted}"><div class="confirm-reveal__inner"><mq-button size="xl" type="button" fullwidth ?disabled="${this.createScheduleAppointment.isPending}" @click="${this.confirmFree}">${V("Confirmar cita")}</mq-button></div></div></div>`}_renderPaymentColumn(){return this._applePayWaiting?this._applePayConfigError?Q`<div class="payment-col__inner"><mq-card class="panel" elevation="none" roundness="lg"><div class="apple-pay-waiting"><p class="apple-pay-waiting__title">${V("No se puede iniciar Apple Pay")}</p><p class="apple-pay-waiting__message">${V("Faltan credenciales de pago. Vuelve atrás e inténtalo de nuevo, o paga con tarjeta.")}</p><mq-text-button type="button" @click="${()=>{this._applePayWaiting=!1,this._applePayConfigError=!1}}">${V("Elegir otro método")}</mq-text-button></div></mq-card></div>`:Q`<div class="payment-col__inner"><mq-card class="panel" elevation="none" roundness="lg"><div class="apple-pay-waiting"><p class="apple-pay-waiting__title">${V("Esperando confirmación de Apple Pay")}</p><p class="apple-pay-waiting__message">${V("No cierres esta página.")}</p>${this._applePayPopupBlocked&&this._applePayUrl?Q`<a href="${this._applePayUrl}" target="_blank" rel="noopener noreferrer">${V("Abrir ventana de Apple Pay")}</a>`:Q`<mq-text-button type="button" @click="${this._reopenApplePayPopup}">${V("Volver a abrir Apple Pay")}</mq-text-button>`}</div></mq-card></div>`:"select"===this._view?Q`<div class="payment-col__inner"><payment-method-selector @payment-method-selected="${this._onPaymentMethodSelected}"></payment-method-selector></div>`:Q`<div class="payment-col__inner"><div class="payment-frame">${this._iframeLoaded?null:Q`<mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${V("Cargando portal de pago")}"></mq-skeleton>`}<iframe class="${this._iframeLoaded?"loaded":""}" src="${this.paymentUrl}" title="${V("Portal de pago")}" style="${null!==this._iframeHeight?`min-height: ${this._iframeHeight}px; height: ${this._iframeHeight}px;`:""}" @load="${this._onIframeLoad}"></iframe></div></div>`}render(){if(this._timedOut)return Q`<div class="error"><p class="error-title">${V("No hemos podido confirmar tu pago")}</p><p class="error-message">${V("Ha ocurrido un problema al verificar el estado de tu pago. Por favor, contacta con soporte si el cargo se ha realizado.")}</p></div>`;const e=Q`<new-appointment-header kind="schedule" .showBack="${this.showBack}" @back="${this._onHeaderBack}"></new-appointment-header>`;return this.isFullyDiscounted?Q`${e}<div class="content content--free">${this._renderSummaryColumn()}<div class="payment-col" .inert="${!0}"></div></div>`:Q`${e}<div class="content">${this._renderSummaryColumn()}<div class="payment-col">${this._renderPaymentColumn()}</div></div>`}};e([R({type:String})],di.prototype,"sessionId",void 0),e([R({type:Boolean})],di.prototype,"showBack",void 0),e([R({type:String})],di.prototype,"paymentUrl",void 0),e([R({type:Object})],di.prototype,"professional",void 0),e([R({type:String})],di.prototype,"startsAt",void 0),e([R({type:Number})],di.prototype,"duration",void 0),e([R({type:String})],di.prototype,"channel",void 0),e([R({type:Object})],di.prototype,"service",void 0),e([R({type:Object})],di.prototype,"scheduleSlot",void 0),e([R({type:Object})],di.prototype,"appliedDiscount",void 0),e([R({type:Object})],di.prototype,"bookingRequest",void 0),e([R({type:String,attribute:!1})],di.prototype,"apiKey",void 0),e([R({type:String,attribute:!1})],di.prototype,"userToken",void 0),e([R({type:String,attribute:!1})],di.prototype,"env",void 0),e([R({type:String,attribute:!1})],di.prototype,"locale",void 0),e([R({type:String,attribute:!1})],di.prototype,"countryCode",void 0),e([R({type:String,attribute:!1})],di.prototype,"successUrl",void 0),e([v({context:fe,subscribe:!0})],di.prototype,"queryClientContext",void 0),e([le()],di.prototype,"_view",void 0),e([le()],di.prototype,"_applePayWaiting",void 0),e([le()],di.prototype,"_applePayUrl",void 0),e([le()],di.prototype,"_applePayPopupBlocked",void 0),e([le()],di.prototype,"_applePayConfigError",void 0),e([le()],di.prototype,"_timedOut",void 0),e([le()],di.prototype,"_iframeLoaded",void 0),e([le()],di.prototype,"_iframeHeight",void 0),di=e([L(),t("payment-step")],di);const ci=N`:host{display:block;width:100%;box-sizing:border-box}.banner{align-items:center;background-color:var(--color-primary-background-extraWeak);border-radius:var(--border-radius-sm);box-sizing:border-box;color:var(--color-primary-default,var(--color-primary));display:flex;gap:10px;font-family:var(--font-body);font-size:var(--text-sm);font-weight:var(--font-weight-normal);line-height:var(--text-sm--line-height);padding:var(--size-2) var(--size-4);width:100%}.label{margin:0}`;let pi=class ScheduleLoadingBanner extends U{static{this.styles=ci}render(){return Q`<div class="banner" role="status" aria-live="polite">${de({size:24,color:"var(--color-primary-default, var(--color-primary))"})}<p class="label">${V("Cargando")}</p></div>`}};pi=e([L(),t("schedule-loading-banner")],pi);const hi=N`.form-container{display:flex;flex-direction:column;gap:var(--size-4)}.form-content{display:flex;flex-direction:column;gap:var(--size-4);width:100%}.field{display:flex;flex-direction:column;gap:var(--size-2);width:100%}.field-title{font-family:var(--font-body, "Roboto");font-size:var(--text-base,16px);font-weight:var(--font-weight-bold,700);line-height:22px;color:var(--color-neutrals-text-default,#333);margin:0}.action-button{flex-shrink:0;width:100%}.filters-loading-banner{flex-basis:100%;width:100%}@media (min-width:768px){.form-content{flex-direction:row;gap:var(--size-6);align-items:end}.action-button{--button-height-md:var(--button-height-lg);min-width:254px;width:auto}}`,ui=Y.object({service:Y.string().min(1),specialty:Y.string().min(1)});class SearchProfessionalsFormSuccessEvent extends CustomEvent{static{this.eventName="success"}constructor(e){super(SearchProfessionalsFormSuccessEvent.eventName,{bubbles:!0,composed:!0,detail:e})}}let mi=class SearchProfessionalsForm extends U{constructor(){super(...arguments),this.form=new TanStackFormController(this,{defaultValues:this.defaultValues,onSubmit:e=>{const t=e.value;k.track(C(this.patient.hash,t.specialty??"",t.service??"")),this.dispatchEvent(new SearchProfessionalsFormSuccessEvent(t))},validators:{onSubmit:ui}}),this.getScheduleServicesQuery=new m(this,()=>i(o)),this.getOrganizationSpecialtiesQuery=new m(this,()=>x(o))}static{this.styles=hi}get filtersLoading(){const e=this.getScheduleServicesQuery.result,t=this.getOrganizationSpecialtiesQuery.result;return(e?.isPending??!0)||(t?.isPending??!0)}willUpdate(e){e.has("defaultValues")&&(this.form.api.setFieldValue("service",this.defaultValues.service),this.form.api.setFieldValue("specialty",this.defaultValues.specialty))}renderScheduleServices({name:e,value:t,onValueChange:i,error:s},a){const o=H();return Q`<mq-select label="${V("Modalidad de la cita")}" id="${X(e)}" value="${X(t)}" name="${X(e)}" size="lg" ?error="${s}" @onvaluechange="${e=>{i(e.value)}}">${a.map(e=>Q`<mq-option value="${e.id}">${$(e.code??"",o,e.name)}</mq-option>`)}</mq-select>`}renderOrganizationSpecialties({name:e,value:t,onValueChange:i,error:s},a){const o=H();return Q`<mq-select label="${V("Especialidad")}" id="${X(e)}" value="${X(t)}" name="${X(e)}" size="lg" ?error="${s}" @onvaluechange="${e=>{i(e.value)}}">${a.map(e=>Q`<mq-option value="${e.id}">${M[e.code]?.[o]??e.name}</mq-option>`)}</mq-select>`}render(){const e=this.getScheduleServicesQuery.result,t=this.getOrganizationSpecialtiesQuery.result,i=e?.data,s=t?.data,a=!0===e?.isSuccess&&!0===t?.isSuccess&&null!=i&&null!=s;return Q`<div class="form-container"><form class="form-content" @submit="${e=>{e.preventDefault(),e.stopPropagation(),this.form.api.handleSubmit()}}">${this.filtersLoading?Q`<schedule-loading-banner class="filters-loading-banner"></schedule-loading-banner>`:a?Q`<div class="field">${this.form.field({name:"service"},e=>Q`<p class="field-title">${V("Modalidad de la cita*")}</p>${this.renderScheduleServices({name:e.name,value:e.state.value,onValueChange:e.handleChange,error:!e.state.meta.isValid},i)}`)}</div><div class="field">${this.form.field({name:"specialty"},e=>Q`<p class="field-title">${V("Especialidad*")}</p>${this.renderOrganizationSpecialties({name:e.name,value:e.state.value,onValueChange:e.handleChange,error:!e.state.meta.isValid},s)}`)}</div><mq-button type="submit" class="action-button" fullwidth>${V("Buscar disponibilidad")}</mq-button>`:T}</form></div>`}};function vi(e){if(!e)return new Date(Number.NaN);const t=l(e);if(ye(t))return t;const i=B(e);if(ye(i))return i;const s=new Date(e);return Number.isNaN(s.getTime())?new Date(Number.NaN):s}function fi(e){const t=new Date;let i;for(const s of e){const e=vi(s.starts_at);ye(e)&&(we(e,t)&&(!i||Ce(e,i)<0)&&(i=e))}return i?O(i):void 0}function gi(e,t){if(!e.length)return[];const i=e.reduce((e,i)=>{const s=vi(i.starts_at);if(!ye(s))return e;const a=function(e,t){if(!ye(e))return"";if(t)try{const i=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(e),s=e=>i.find(t=>t.type===e)?.value??"";return`${s("year")}-${s("month")}-${s("day")}`}catch{}return be(e,"yyyy-MM-dd")}(s,t);if(!a)return e;const o={slot:i,parsedDate:s};if(!e.has(a))return e.set(a,[o]),e;const r=e.get(a);return r?.push(o),e},new Map);return 0===i.size?[]:Array.from(i.entries()).map(([e,t])=>({key:e,slots:t.sort((e,t)=>Ce(e.parsedDate,t.parsedDate)),date:t[0]?.parsedDate??new Date(Number.NaN)})).filter(({date:e})=>ye(e)).sort((e,t)=>Ce(e.date,t.date))}e([v({context:Ie,subscribe:!0})],mi.prototype,"patient",void 0),e([R({type:Object})],mi.prototype,"defaultValues",void 0),mi=e([L(),t("search-professionals-form")],mi);const yi=N`:host{display:block}.card{padding:var(--sp-6) var(--sp-4);display:flex;flex-direction:column;gap:var(--sp-4)}.schedules{display:flex;flex-direction:column;gap:var(--sp-2)}.schedule{align-self:stretch;display:flex;align-items:center;column-gap:var(--sp-2_5);flex-wrap:nowrap;min-width:0;overflow:hidden}.day-slot{box-sizing:border-box;padding:var(--sp-2);width:var(--size-15);height:var(--size-15);display:flex;flex-direction:column;gap:var(--sp-1);align-items:center;justify-content:center}.day-slot-day{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal)}.day-slot-date{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.schedules-container{flex:1;display:flex;flex-direction:column;gap:var(--sp-4);transition:opacity .2s}.schedules-container.is-pending{opacity:.5;pointer-events:none}.schedule-slot{box-sizing:border-box;padding:var(--sp-2) var(--sp-1);background:var(--color-muted);flex:1 1 0;min-width:0;height:var(--sp-11);display:flex;align-items:center;justify-content:center;border:1px solid var(--color-border);border-radius:var(--border-radius-md);cursor:pointer;transition:all .2s;font-family:var(--font-body);font-size:var(--text-sm);font-weight:var(--font-weight-medium);color:var(--color-neutrals-text-default);text-align:center;white-space:nowrap;outline:0;position:relative;--mq-slot-ring-color:var(--color-primary)}.schedule-slot:hover:not(.is-empty){background-color:var(--color-primary-light)}.schedule-slot:focus-visible{box-shadow:0 0 0 1.5px var(--color-background,#fff),0 0 0 3.5px var(--mq-slot-ring-color,var(--color-primary));z-index:1}.schedule-slot.is-empty{cursor:default;background-color:transparent}.schedule-slot.is-empty:focus-visible{box-shadow:none}.schedule-slot:nth-child(n + 5){display:none}.no-slots{font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-neutrals-text-default);text-align:center}.error-message{color:var(--color-error-text-default);font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);margin:0;text-align:center}@media (min-width:768px){.card{flex-direction:row;justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-8)}professional-overview{width:100%;max-width:327px;flex-shrink:0}.schedules-container{gap:var(--sp-3)}mq-button{margin:0 auto;max-width:323px}.schedule-slot:nth-child(n + 5){display:flex}.schedule-slot:nth-child(n + 9){display:none}}`;class SelectedSlotEvent extends Event{static{this.eventName="selected-slot"}constructor(e){super(SelectedSlotEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}let bi=class ShowFullScheduleEvent extends Event{static{this.eventName="show-full-schedule"}constructor(){super(ShowFullScheduleEvent.eventName,{bubbles:!0,composed:!0})}},wi=class ProfessionalCard extends U{constructor(){super(...arguments),this.serviceId="",this.specialtyId="",this.showSlotUnavailableError=!1,this.getOrganizationSpecialtiesQuery=new m(this,()=>x(o)),this.checkForSlotAvailabilityMutation=new f(this,{mutationFn:e=>o.schedules.getScheduleSlot({slot_id:e,service_id:this.serviceId||void 0,speciality_id:this.specialtyId?Number(this.specialtyId):void 0})})}static{this.styles=yi}get groupedSlots(){const e=this.professional?.slots??[];return 0===e.length?[]:gi(e,this.patient.timezone).map(e=>({key:e.key,dayLabel:this.formatDay(e.date),dateLabel:this.formatDate(e.date),slots:e.slots,date:e.date}))}get timezone(){return this.patient.timezone}formatDay(e){const t=H().replace("_","-"),i=new Intl.DateTimeFormat(t,{weekday:"short",...this.timezone?{timeZone:this.timezone}:{}}).format(e).replace(/\.$/,"");return`${i.charAt(0).toUpperCase()}${i.slice(1)}`}formatDate(e){const t=H().replace("_","-"),i=this.timezone?{timeZone:this.timezone}:{},s=new Intl.DateTimeFormat(t,{day:"numeric",...i}).format(e),a=new Intl.DateTimeFormat(t,{month:"short",...i}).format(e).replace(/\.$/,"");return`${s} ${`${a.charAt(0).toUpperCase()}${a.slice(1)}`}`}formatTime(e){return function(e,t,i){return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit",hour12:!1,...i?{timeZone:i}:{}}).format(e)}(e,H().replace("_","-"),this.timezone)}async handleSlotClick(e){const t=await this.checkForSlotAvailabilityMutation.run(e.id);t.status===c.available?(this.showSlotUnavailableError=!1,k.track(P(this.patient.hash,this.professional.id,e.starts_at,this.specialtyId,this.serviceId)),this.dispatchEvent(new SelectedSlotEvent({slot:t,professional:this.professional}))):(this.showSlotUnavailableError=!0,this.queryClientContext?.invalidateQueries())}render(){const e=H(),t=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>e.id===this.professional.speciality.id),i=_(t?.code??"",e,t?.name);return Q`<mq-card class="card" elevation="md" roundness="lg"><professional-overview .name="${this.professional.name}" .specialtyName="${i??""}" .collegiateNumber="${this.professional.collegiate_number??void 0}" .description="${this.professional.description??""}" .languages="${this.professional.languages}" .avatar="${this.professional.avatar??""}"></professional-overview><div class="${J({"schedules-container":!0,"is-pending":this.checkForSlotAvailabilityMutation.isPending})}">${this.showSlotUnavailableError?Q`<p class="error-message">${V("Este horario no está disponible. Por favor, seleccione otro.")}</p>`:T}<div class="schedules">${this.groupedSlots.length>0?this.groupedSlots.map(e=>Q`<div class="schedule"><div class="day-slot"><span class="day-slot-day">${e.dayLabel}</span> <span class="day-slot-date">${e.dateLabel}</span></div>${e.slots.map(({slot:e,parsedDate:t})=>Q`<button class="schedule-slot" data-slot-id="${e.id}" @click="${()=>this.handleSlotClick(e)}">${this.formatTime(t)}</button>`)} ${Array.from({length:Math.max(0,7-e.slots.length)}).map(()=>Q`<div class="schedule-slot is-empty">-</div>`)}</div>`):Q`<div class="no-slots">${V("Sin huecos disponibles actualmente")}</div>`}</div><mq-button fullwidth @click="${()=>{k.track(I(this.patient.hash,this.professional.id,this.specialtyId,this.serviceId)),this.dispatchEvent(new bi)}}">${_e({size:24})} ${V("Ver agenda completa")}</mq-button></div></mq-card>`}};e([v({context:Ie,subscribe:!0})],wi.prototype,"patient",void 0),e([R({type:Object})],wi.prototype,"professional",void 0),e([R({type:String})],wi.prototype,"serviceId",void 0),e([R({type:String})],wi.prototype,"specialtyId",void 0),e([le()],wi.prototype,"showSlotUnavailableError",void 0),e([v({context:fe,subscribe:!0})],wi.prototype,"queryClientContext",void 0),wi=e([L(),t("professional-card")],wi);const Si=N`:host{display:flex;flex-direction:column;gap:var(--sp-4)}.title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0;margin-bottom:var(--sp-2)}.description{font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0}`;class ShowFullScheduleEvent extends Event{static{this.eventName="show-full-schedule"}constructor(e){super(ShowFullScheduleEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}let xi=class ProfessionalsList extends U{constructor(){super(...arguments),this.specialty_id=void 0,this.service_id=void 0,this.getOrganizationSpecialtiesQuery=new m(this,()=>x(o)),this.getScheduleServicesQuery=new m(this,()=>i(o)),this.getProfessionalsBySpecialtyAndServiceQuery=new m(this,()=>{return e=o,{queryKey:["professionals-by-specialty-and-service",t={closest_slots_days:2,slots_per_day:7,speciality_id:this.specialty_id?Number(this.specialty_id):void 0,organization_schedule_service_id:this.service_id?this.service_id:void 0}],queryFn:t.speciality_id&&t.organization_schedule_service_id?()=>e.schedules.getProfessionalsBySpecialtyAndService(t):ge,staleTime:0};var e,t})}static{this.styles=Si}render(){const e=H(),t=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>e.id===Number(this.specialty_id)),i=this.getScheduleServicesQuery.result?.data?.find(e=>e.id===this.service_id);if(!this.specialty_id||!this.service_id)return T;const s=M[t?.code]?.[e]??t?.name??"",a=$(i?.code??"",e,i?.name);return this.getProfessionalsBySpecialtyAndServiceQuery.render({pending:()=>Q`<div id="professionals-results"><schedule-loading-banner></schedule-loading-banner></div>`,complete:e=>{if(0===e.length)return Q`<mq-callout background="default" variant="info">${V("No hay profesionales disponibles para la especialidad seleccionada. Por favor, vuelve a intentarlo en otro momento o selecciona otra especialidad.")}</mq-callout>`;const t=e[0],o=t?.slots?.[0];return k.track(A(this.patient.hash,this.specialty_id??"",this.service_id??"",o?.starts_at??"",t?.id??"",e.length,e.reduce((e,t)=>e+(t.slots?.length??0),0))),Q`<div id="professionals-results"><p class="title">${V("Selecciona tu especialista")}</p><p class="description">${V(z`Resultados de citas de ${a} para ${s}`)}</p></div>${e.map(e=>Q`<professional-card .professional="${e}" .serviceId="${this.service_id??""}" .specialtyId="${this.specialty_id??""}" @show-full-schedule="${t=>{t.stopPropagation();const s=this.service_id,a=this.specialty_id;void 0!==i&&void 0!==s&&void 0!==a&&this.dispatchEvent(new ShowFullScheduleEvent({professional:e,serviceId:s,service:i,specialtyId:a,firstAvailableSlotDate:fi(e.slots)}))}}"></professional-card>`)}`}})}};e([v({context:Ie,subscribe:!0})],xi.prototype,"patient",void 0),e([R({type:String})],xi.prototype,"specialty_id",void 0),e([R({type:String})],xi.prototype,"service_id",void 0),xi=e([L(),t("professionals-list")],xi);const _i=N`.container{display:flex;flex-direction:column;gap:var(--sp-6)}.page-container{width:100%;box-sizing:border-box;display:flex;flex-direction:column;gap:var(--size-4)}.header-background{background-color:var(--color-neutrals-background-weak);display:flex;justify-content:center;width:100%}.header-container{max-width:var(--content-max-width);margin:0 auto;display:flex;flex-direction:column;gap:var(--size-4);width:100%;box-sizing:border-box}.header-nav{display:flex;align-items:center;justify-content:space-between;width:100%}.title-section{display:flex;flex-direction:column;gap:var(--size-1);align-items:center;width:100%}.title-content{display:flex;flex-direction:column;gap:var(--size-1);align-items:flex-start;padding-bottom:var(--size-2);width:100%;box-sizing:border-box}.main-title{font-family:var(--font-titles);font-size:31px;font-weight:var(--font-weight-bold);line-height:normal;color:var(--color-neutrals-text-default);margin:0;white-space:nowrap}.subtitle{font-family:var(--font-body);font-size:var(--text-base);font-weight:var(--font-weight-normal);line-height:22px;color:var(--color-neutrals-text-default);margin:0;white-space:pre-wrap;min-width:100%;width:min-content}.empty-space{height:32px;width:auto}.banner-container{align-items:flex-start;box-sizing:border-box;display:flex;gap:var(--size-2);padding:var(--size-4) var(--size-2);width:100%;background-color:var(--color-neutrals-background-disabled);color:var(--color-neutrals-text-default);font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);border-radius:var(--border-radius-sm)}.banner-icon{flex-shrink:0;display:flex;align-items:center;justify-content:center}.banner-message{margin:0;white-space:pre-wrap}@media (min-width:768px){.page-container{gap:var(--sp-8)}}`;let $i=class SuccessEvent extends Event{static{this.eventName="success"}constructor(e){super(SuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}},ki=class SelectProfessionalStep extends U{constructor(){super(...arguments),this.defaultSpecialty=void 0,this.defaultService=void 0,this.showBack=!0,this.formData=void 0,this.getScheduleServicesQuery=new m(this,()=>i(o)),this.getOrganizationSpecialtiesQuery=new m(this,()=>x(o))}static{this.styles=_i}get isScheduleFiltersReady(){const e=this.getScheduleServicesQuery.result?.isSuccess,t=this.getOrganizationSpecialtiesQuery.result?.isSuccess;return!!e&&!!t}get showSearchForm(){const e=this.getScheduleServicesQuery.result?.data,t=this.getOrganizationSpecialtiesQuery.result?.data;if(!e||!t)return!1;const i=e.length>1||t.length>1;return!(1===e.length&&1===t.length&&!this.formData)&&(i||!this.formData)}updated(){if(this.formData)return;if(this.defaultService&&this.defaultSpecialty)return void(this.formData={service_id:this.defaultService,specialty_id:this.defaultSpecialty});const e=this.getScheduleServicesQuery.result?.data,t=this.getOrganizationSpecialtiesQuery.result?.data;if(e?.length&&t?.length&&1===e.length&&1===t.length){const i=e[0],s=t[0];if(!i||!s)return;this.formData={service_id:i.id,specialty_id:String(s.id)}}}connectedCallback(){super.connectedCallback(),k.track(F(this.patient.hash))}scrollToProfessionalsList(){setTimeout(()=>{this.shadowRoot?.querySelector("professionals-list")?.scrollIntoView({behavior:"smooth"})},0)}render(){return Q`<div class="container"><new-appointment-header .showBack="${this.showBack}" @back="${()=>this.dispatchEvent(new CustomEvent("back"))}"></new-appointment-header><div class="page-container">${this.isScheduleFiltersReady?T:Q`<schedule-loading-banner></schedule-loading-banner>`} ${this.isScheduleFiltersReady&&this.showSearchForm?Q`<search-professionals-form .defaultValues="${{service:this.formData?.service_id??this.defaultService??"",specialty:this.formData?.specialty_id??this.defaultSpecialty??""}}" @success="${e=>{e.stopPropagation(),this.formData={service_id:e.detail.service,specialty_id:e.detail.specialty},this.scrollToProfessionalsList()}}"></search-professionals-form>`:T} ${this.isScheduleFiltersReady?Q`<professionals-list .specialty_id="${this.formData?.specialty_id}" .service_id="${this.formData?.service_id}" @selected-slot="${e=>{e.stopPropagation();const t=this.formData;if(!t?.service_id||!t.specialty_id)return;const i=this.getScheduleServicesQuery.result?.data?.find(e=>e.id===t.service_id);this.dispatchEvent(new $i({slot:e.detail.slot,serviceId:t.service_id,service:i,specialtyId:t.specialty_id,professional:e.detail.professional}))}}"></professionals-list>`:T}</div></div>`}};function Ei(e,t){return{queryKey:["schedule-service-professional-slots",t],queryFn:()=>e.schedules.getScheduleServiceProfessionalSlots(t)}}e([v({context:Ie,subscribe:!0})],ki.prototype,"patient",void 0),e([R({type:String})],ki.prototype,"defaultSpecialty",void 0),e([R({type:String})],ki.prototype,"defaultService",void 0),e([R({type:Boolean})],ki.prototype,"showBack",void 0),e([le()],ki.prototype,"formData",void 0),ki=e([L(),t("select-professional-step")],ki);const Ci=()=>"undefined"!=typeof window&&window.innerWidth>=ke.mobile?6:4;class SlotSelectEvent extends Event{static{this.eventName="slot-select"}constructor(e){super(SlotSelectEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class SlotUnavailableEvent extends Event{static{this.eventName="slot-unavailable"}constructor(){super(SlotUnavailableEvent.eventName,{bubbles:!0,composed:!0})}}const Mi=N`:host{display:block}.card{overflow-x:auto;padding:var(--sp-4);display:flex;flex-direction:column;gap:var(--sp-4)}.error-message{color:var(--color-error-text-default);font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);margin:0;text-align:center}@media (min-width:768px){.card{padding:var(--sp-8) var(--sp-4)}}`;let Pi=class DaysWindowView extends U{constructor(){super(...arguments),this.specialityId=void 0,this.reschedulingAppointmentId=void 0,this.windowStartDate=O(new Date),this.errorMessage=void 0,this.checkForSlotAvailabilityMutation=new f(this,{mutationFn:e=>o.schedules.getScheduleSlot({slot_id:e,service_id:this.serviceId||void 0,speciality_id:this.specialityId})}),this._visibleDays=Ci(),this.getScheduleServiceProfessionalSlotsQuery=new m(this,()=>{const e=O(Ee(this.windowStartDate,new Date)?new Date:this.windowStartDate),t=Me($e(e,this._visibleDays-1));return Ei(o,{service_id:this.serviceId,professional_hash:this.professionalId,starts_at:p(e),finishes_at:p(t),rescheduling_appointment_id:this.reschedulingAppointmentId})})}static{this.styles=Mi}connectedCallback(){super.connectedCallback(),this._resizeHandler=()=>{const e=Ci();e!==this._visibleDays&&(this._visibleDays=e,this.requestUpdate())},window.addEventListener("resize",this._resizeHandler)}disconnectedCallback(){super.disconnectedCallback(),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler)}render(){const e=new Date,t=this.getScheduleServiceProfessionalSlotsQuery.result?.isPending,i=this.getScheduleServiceProfessionalSlotsQuery.result?.data?.filter(t=>we(l(t.starts_at),e)&&t.status===c.available),s=i?.map(e=>({key:e.id,date:l(e.starts_at).toISOString()})),a=H().replace("_","-");return Q`<mq-card class="card" roundness="md"><mq-button @click="${()=>this.dispatchEvent(new CustomEvent("to-calendar-view"))}">${_e({size:24})} ${V("Elige otra fecha")}</mq-button>${this.errorMessage?Q`<p class="error-message">${this.errorMessage}</p>`:T}<mq-time-slot-picker .locale="${a}" .timezone="${this.patient.timezone}" .visibleDays="${this._visibleDays}" .slots="${s??[]}" .windowStartDate="${be(this.windowStartDate,"yyyy-MM-dd")}" ?is-loading="${t}" @window-change="${e=>{this.windowStartDate=new Date(e.detail.windowStartDate)}}" .isLoading="${this.checkForSlotAvailabilityMutation.isPending}" @slot-select="${async e=>{e.stopPropagation();const t=e.detail.slot.key,i=await this.checkForSlotAvailabilityMutation.run(t);i.status===c.available?this.dispatchEvent(new SlotSelectEvent({slot:i})):this.dispatchEvent(new SlotUnavailableEvent)}}"></mq-time-slot-picker></mq-card>`}};e([R({type:String})],Pi.prototype,"professionalId",void 0),e([R({type:String})],Pi.prototype,"serviceId",void 0),e([R({type:Number})],Pi.prototype,"specialityId",void 0),e([R({type:String})],Pi.prototype,"reschedulingAppointmentId",void 0),e([R({type:Object})],Pi.prototype,"windowStartDate",void 0),e([R({type:String,attribute:"error-message"})],Pi.prototype,"errorMessage",void 0),e([v({context:Ie,subscribe:!0})],Pi.prototype,"patient",void 0),Pi=e([L(),t("days-window-view")],Pi);const Ii=N`:host{display:block;max-width:var(--content-max-width);margin:0 auto}`;let Ai=class CalendarView extends U{constructor(){super(...arguments),this.reschedulingAppointmentId=void 0,this.initialDate=void 0,this.currentMonth=new Date,this.getScheduleServiceProfessionalSlotsQuery=new m(this,()=>{const e=Se(this.currentMonth),t=O(Ee(e,new Date)?new Date:e),i=Me(xe(t));return Ei(o,{service_id:this.serviceId,professional_hash:this.professionalId,starts_at:p(t),finishes_at:p(i),rescheduling_appointment_id:this.reschedulingAppointmentId})})}static{this.styles=Ii}connectedCallback(){super.connectedCallback(),this.initialDate&&(this.currentMonth=this.initialDate)}render(){const e=new Date,t=this.getScheduleServiceProfessionalSlotsQuery.result?.isPending,i=this.getScheduleServiceProfessionalSlotsQuery.result?.data?.filter(t=>we(l(t.starts_at),e)&&t.status===c.available),s=i&&i.length>0?Array.from(new Set(i.map(e=>{const t=l(e.starts_at);return O(t).toISOString()}))):void 0,a=H().replace("_","-");return Q`<mq-calendar locale="${a}" ?is-loading="${t}" .currentMonth="${this.currentMonth.toISOString()}" .availableDays="${s}" @prev-month="${e=>{this.currentMonth=new Date(e.detail.currentMonth)}}" @next-month="${e=>{this.currentMonth=new Date(e.detail.currentMonth)}}"></mq-calendar>`}};e([R({type:String})],Ai.prototype,"professionalId",void 0),e([R({type:String})],Ai.prototype,"serviceId",void 0),e([R({type:String})],Ai.prototype,"reschedulingAppointmentId",void 0),e([R({type:Object})],Ai.prototype,"initialDate",void 0),e([le()],Ai.prototype,"currentMonth",void 0),Ai=e([t("calendar-view")],Ai);class SuccessEvent extends Event{static{this.eventName="success"}constructor(e){super(SuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}const Fi=N`:host{display:flex;flex-direction:column;gap:var(--sp-6)}.content{display:flex;flex-direction:column;gap:var(--sp-4)}calendar-view{width:100%}days-window-view{width:100%}@media (min-width:768px){.content{flex-direction:row;gap:var(--sp-6)}new-appointment-summary{width:50%}days-window-view{width:50%}calendar-view{width:50%}}`;let Di=class SelectSlotStep extends U{constructor(){super(...arguments),this.kind="schedule",this.showBack=!0,this.reschedulingAppointmentId=void 0,this.startsAt=void 0,this.duration=void 0,this.channel=void 0,this.errorMessage=void 0,this.initialDate=void 0,this.service=void 0,this.appliedDiscount=null,this.getScheduleServiceSpecialitiesQuery=new m(this,()=>{return e=o,t=this.serviceId,i={enabled:!!this.serviceId},{queryKey:["schedule-service-specialities",t],queryFn:()=>e.schedules.getScheduleServiceSpecialities(t),...i};var e,t,i}),this.view="days-window",this.windowStartDate=O(new Date)}static{this.styles=Fi}connectedCallback(){super.connectedCallback(),this.initialDate&&(this.windowStartDate=O(this.initialDate))}renderView(){return"days-window"===this.view?Q`<days-window-view .errorMessage="${this.errorMessage}" .professionalId="${this.professionalId}" .serviceId="${this.serviceId}" .specialityId="${this.professional?.speciality?.id}" .reschedulingAppointmentId="${this.reschedulingAppointmentId}" .windowStartDate="${this.windowStartDate}" @to-calendar-view="${()=>{this.view="calendar"}}" @slot-select="${e=>{this.dispatchEvent(new SuccessEvent({slot:e.detail.slot}))}}" @slot-unavailable="${()=>{this.errorMessage=V("Este horario no está disponible. Por favor, seleccione otro."),this.queryClientContext?.invalidateQueries()}}"></days-window-view>`:Q`<calendar-view .professionalId="${this.professionalId}" .serviceId="${this.serviceId}" .reschedulingAppointmentId="${this.reschedulingAppointmentId}" .initialDate="${this.initialDate}" @date-select="${e=>{this.windowStartDate=new Date(e.detail.date),this.view="days-window"}}"></calendar-view>`}render(){const e=this.getScheduleServiceSpecialitiesQuery.result?.data?.find(e=>e.id===this.professional?.speciality?.id)?.price??null;return Q`<new-appointment-header .kind="${this.kind}" .showBack="${this.showBack}" @back="${()=>this.dispatchEvent(new CustomEvent("back"))}"></new-appointment-header><div class="content"><new-appointment-summary .professional="${this.professional}" .channel="${this.channel}" .startsAt="${this.startsAt}" .duration="${this.duration}" .serviceCode="${this.service?.code}" .serviceName="${this.service?.name}" .servicePrice="${e}" .appliedDiscount="${this.appliedDiscount}" .showPrice="${"reschedule"!==this.kind}"></new-appointment-summary>${this.renderView()}</div>`}};e([R({type:String})],Di.prototype,"kind",void 0),e([R({type:Boolean})],Di.prototype,"showBack",void 0),e([R({type:String})],Di.prototype,"serviceId",void 0),e([R({type:String})],Di.prototype,"professionalId",void 0),e([R({type:String})],Di.prototype,"reschedulingAppointmentId",void 0),e([R({type:Object})],Di.prototype,"professional",void 0),e([R({type:String})],Di.prototype,"startsAt",void 0),e([R({type:Number})],Di.prototype,"duration",void 0),e([R({type:String})],Di.prototype,"channel",void 0),e([R({type:String,attribute:"error-message"})],Di.prototype,"errorMessage",void 0),e([R({type:Object})],Di.prototype,"initialDate",void 0),e([R({type:Object})],Di.prototype,"service",void 0),e([R({type:Object})],Di.prototype,"appliedDiscount",void 0),e([v({context:fe,subscribe:!0})],Di.prototype,"queryClientContext",void 0),e([le()],Di.prototype,"view",void 0),e([le()],Di.prototype,"windowStartDate",void 0),Di=e([L(),t("select-slot-step")],Di);let qi=class SelectSlotStepSkeleton extends U{static{this.styles=N`:host{display:flex;flex-direction:column;gap:var(--sp-6)}.back-button{margin-bottom:var(--sp-4)}.header{margin-bottom:var(--sp-4);display:flex;flex-direction:column;gap:var(--sp-2)}.description{color:var(--color-gray-medium);font-size:var(--text-sm);margin-top:var(--sp-1)}.content{display:flex;flex-direction:column;gap:var(--sp-4)}.block{width:100%;display:flex;flex-direction:column;gap:var(--sp-4)}@media (min-width:768px){.content{flex-direction:row;gap:var(--sp-6)}.block{width:50%}}`}render(){return Q`<div class="header"><mq-skeleton class="back-button" width="var(--size-18)" height="var(--size-6)"></mq-skeleton><mq-skeleton width="229px" height="var(--size-10)"></mq-skeleton><mq-skeleton width="180px" height="var(--size-5)"></mq-skeleton></div><div class="content"><div class="block"><mq-skeleton width="100%" height="190px"></mq-skeleton></div><div class="block"><mq-skeleton width="100%" height="317px"></mq-skeleton></div></div>`}};function Vi(e){return{id:e.id,name:e.name,avatar:e.avatar,description:e.description,collegiate_number:e.collegiate_number,languages:e.languages,speciality:e.speciality}}qi=e([t("select-slot-step-skeleton")],qi),K();class AppointmentCreatedEvent extends Event{static{this.eventName="appointment-created"}constructor(e){super(AppointmentCreatedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}let zi=class MqSchedule extends U{constructor(){super(...arguments),this.requiresPayment=!0,this.showMediquoBranding=!0,this.showBackButton=!0,this._patient=new q(this,{context:Ie,initialValue:{hash:"",name:"",timezone:"UTC"}}),this._emittedCreated=!1,this.getAppointmentQuery=new m(this,()=>y(o,{id:this.appointmentId??""},{enabled:!!this.appointmentId})),this.getProfessionalQuery=new m(this,()=>{return e=o,t={hash:this.defaultProfessionalHash??""},i={enabled:!!this.defaultProfessionalHash},{queryKey:["professional-public-profile",t.hash],queryFn:()=>e.profile.getProfessionalPublicProfile(t),...i};var e,t,i}),this.getScheduleSlotQuery=new m(this,()=>{const e=this.getScheduleServicesQuery.result?.data,t=this.getOrganizationSpecialtiesQuery.result?.data;return i=o,s={slot_id:this.defaultSlotId??"",service_id:Fe(this.defaultService,e)?.id,speciality_id:Ae(this.defaultSpecialty,t)},a={enabled:!!(this.defaultSlotId&&this.token&&e&&t)},{queryKey:["schedules","slot",s.slot_id,s.service_id,s.speciality_id],queryFn:()=>i.schedules.getScheduleSlot(s),...a};var i,s,a}),this.getPatientProfileQuery=new m(this,()=>g(o,{enabled:!!this.token})),this.getOrganizationSpecialtiesQuery=new m(this,()=>x(o)),this.getScheduleServicesQuery=new m(this,()=>i(o)),this.getOrganizationSetupQuery=new m(this,()=>b(o,{enabled:"reschedule"===this.kind}))}static{this.styles=N`.reschedule-policy-blocked{padding:var(--sp-6);display:flex;flex-direction:column;gap:var(--sp-4);max-width:36rem;margin:0 auto}.reschedule-policy-blocked p{margin:0;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height)}`}willUpdate(e){e.has("env")&&this.env&&W(this.env),e.has("apiKey")&&this.apiKey&&o.setApiKey(this.apiKey),e.has("token")&&this.token&&o.setAuthToken(this.token),e.has("locale")&&this.locale&&G(this.locale)&&(Z(this.locale),o.setLanguage(this.locale));const t=this.getPatientProfileQuery.result?.data;this._patient.setValue({hash:t?.hash??"",name:h(t),timezone:this.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone})}_initWizard(e,t,i){return this._wizard||(this._wizard=new Pe(this,e,t),i&&this._wizard.goTo(i)),this._wizard}_stepHandlers(e){return{next:t=>e.next(t),goTo:(t,i,s)=>e.goTo(t,i,s),back:()=>{e.back()||this.dispatchEvent(new a({source:"mq-schedule"}))},update:t=>e.reconcile(t),onCreated:e=>{this._emittedCreated||(this._emittedCreated=!0,this.dispatchEvent(new AppointmentCreatedEvent({appointmentId:e})))},onAuthRequired:e=>{this.dispatchEvent(new AuthRequiredEvent(e))}}}_hostConfig(){const e=this.getPatientProfileQuery.result?.data;return{apiKey:this.apiKey,userToken:this.userToken,env:this.env,locale:this.locale,countryCode:e?.profile.billing.country_code??void 0,successUrl:this.applePaySuccessUrl}}_renderStep(e,t){const i=e.canGoBack||this.showBackButton;return function(e,t,i,s,a,r){const n=V("No se ha podido reservar este horario. Por favor, seleccione otro."),l=s?{id:s.from.hash,name:s.from.name??"",avatar:s.from.avatar,description:s.from.description,collegiate_number:s.from.collegiate_number,languages:s.from.languages,speciality:{id:s.speciality_id??0}}:void 0,d=t.professional??l,{showBack:c,isAuthenticated:p}=a;if("selectProfessional"===e)return Q`<select-professional-step .defaultSpecialty="${t.specialty}" .defaultService="${t.service?.id}" .showBack="${c}" @show-full-schedule="${e=>{i.goTo("selectSlot",{service:e.detail.service,specialty:e.detail.specialtyId,professional:Vi(e.detail.professional),firstAvailableSlotDate:e.detail.firstAvailableSlotDate,appliedDiscount:void 0,error:!1})}}" @back="${i.back}" @success="${e=>{const t=e.detail.service;t&&(p?i.goTo("completeProfile",{slot:e.detail.slot,service:t,specialty:e.detail.specialtyId,professional:Vi(e.detail.professional),appliedDiscount:void 0,error:!1}):i.onAuthRequired({professionalHash:e.detail.professional.id,slotId:e.detail.slot.id,serviceId:t.id,specialtyId:e.detail.specialtyId}))}}"></select-professional-step>`;if("selectSlot"===e){if(s){const e=s.service_id;return e&&l?Q`<select-slot-step kind="reschedule" .showBack="${c}" .errorMessage="${t.error?n:void 0}" .serviceId="${e}" .reschedulingAppointmentId="${s.id}" .professionalId="${s.from.hash}" .professional="${l}" .startsAt="${s.start_date}" .duration="${s.duration}" .channel="${s.channel}" @back="${i.back}" @success="${e=>{i.next({slot:e.detail.slot,appliedDiscount:void 0,error:!1})}}"></select-slot-step>`:T}if(!d)return T;const e=t.service;return e?Q`<select-slot-step kind="schedule" .showBack="${c}" .errorMessage="${t.error?n:void 0}" .serviceId="${e.id}" .service="${e}" .professionalId="${d.id}" .professional="${d}" .initialDate="${t.firstAvailableSlotDate}" .appliedDiscount="${t.appliedDiscount??null}" @back="${i.back}" @discount-applied="${e=>i.update({appliedDiscount:e.detail})}" @success="${s=>{p?i.next({slot:s.detail.slot,error:!1}):i.onAuthRequired({professionalHash:d.id,slotId:s.detail.slot.id,serviceId:e.id,specialtyId:t.specialty})}}"></select-slot-step>`:Q`<select-slot-step-skeleton></select-slot-step-skeleton>`}if("completeProfile"===e){const e=t.slot;return s?e&&s.service_id&&l?Q`<complete-profile-step .showBack="${c}" .serviceId="${s.service_id}" .channel="${s.channel}" .scheduleSlot="${e}" .professional="${d??l}" @back="${i.back}" @success="${()=>i.next()}"></complete-profile-step>`:T:e&&d&&t.service?Q`<complete-profile-step .showBack="${c}" .serviceId="${t.service.id}" .channel="${t.service.channel??t.slot?.channel}" .scheduleSlot="${e}" .professional="${d}" @back="${i.back}" @success="${()=>i.next()}"></complete-profile-step>`:T}if("confirm"===e){const e=t.slot;return s?e&&s.service_id&&l?Q`<confirm-step kind="reschedule" .showBack="${c}" .scheduleSlot="${e}" .professional="${l}" .serviceId="${s.service_id}" .specialityId="${s.speciality_id?.toString()??""}" .startsAt="${e.starts_at}" .duration="${s.duration}" .appointment="${s}" .requiresPayment="${!1}" @back="${i.back}" @success="${e=>i.onCreated(e.detail.appointmentId)}" @error="${()=>i.goTo("selectSlot",{error:!0},{replace:!0})}"></confirm-step>`:T:e&&d&&t.service?Q`<confirm-step kind="schedule" .showBack="${c}" .scheduleSlot="${e}" .professional="${d}" .serviceId="${t.service.id}" .specialityId="${t.specialty??""}" .service="${t.service}" .startsAt="${e.starts_at}" .duration="${e.duration}" .channel="${t.service.channel??t.slot?.channel}" .requiresPayment="${t.requiresPayment}" .appliedDiscount="${t.appliedDiscount??null}" @back="${i.back}" @success="${e=>i.onCreated(e.detail.appointmentId)}" @discount-applied="${e=>i.update({appliedDiscount:e.detail})}" @payment-started="${e=>{i.next({paymentSessionId:e.detail.sessionId,paymentUrl:e.detail.paymentUrl,paymentRequest:e.detail.request})}}" @error="${()=>i.goTo("selectSlot",{error:!0},{replace:!0})}"></confirm-step>`:T}if("payment"===e){const e=t.paymentSessionId,s=t.paymentUrl,a=d,n=t.slot;return e&&a&&n?Q`<payment-step .showBack="${c}" .sessionId="${e}" .paymentUrl="${s??""}" .professional="${a}" .startsAt="${n.starts_at}" .duration="${n.duration}" .channel="${t.service?.channel??n.channel}" .service="${t.service}" .scheduleSlot="${n}" .appliedDiscount="${t.appliedDiscount??null}" .bookingRequest="${t.paymentRequest??null}" .apiKey="${r?.apiKey}" .userToken="${r?.userToken}" .env="${r?.env??"production"}" .locale="${r?.locale??"es_ES"}" .countryCode="${r?.countryCode??"ES"}" .successUrl="${r?.successUrl}" @back="${i.back}" @success="${e=>i.onCreated(e.detail.appointmentId)}" @discount-applied="${async e=>{if(i.update({appliedDiscount:e.detail}),Be(e.detail))return;const s=t.paymentRequest;if(!s)return;const a={...s,discount_code:e.detail.code};try{const e=await o.payments.createPaymentLink(a);i.update({paymentSessionId:e.session_id,paymentUrl:e.payment_link,paymentRequest:a,error:!1})}catch{i.update({error:!0}),i.back()}}}" @payment-success="${e=>i.onCreated(e.detail.appointmentId)}" @payment-retry="${async e=>{const s=t.paymentRequest;if(!s)return i.update({error:!0}),void i.back();try{const e=await o.payments.createPaymentLink(s);i.update({paymentSessionId:e.session_id,paymentUrl:e.payment_link,error:!1})}catch{i.update({error:!0}),i.back()}}}" @error="${()=>{i.update({error:!0}),i.back()}}"></payment-step>`:T}return T}(e.current,e.ctx,this._stepHandlers(e),t,{showBack:i,isAuthenticated:!!this.token},this._hostConfig())}renderReschedulePolicyBlocked(){return Q`<div class="reschedule-policy-blocked"><p>${V("Esta cita ya no se puede modificar ni anular: no queda el tiempo mínimo requerido antes del inicio.")}</p><mq-button variant="primary" @click="${()=>this.dispatchEvent(new a({source:"mq-schedule"}))}">${V("Volver")}</mq-button></div>`}_renderLayout(e){return Q`<mq-layout variant="wide" .showMediquoBranding="${this.showMediquoBranding}">${e}</mq-layout>`}render(){const e=this._renderLayout(Q`<select-slot-step-skeleton></select-slot-step-skeleton>`);if(this.token&&this.getPatientProfileQuery.result?.isPending)return e;const t=!!this.getPatientProfileQuery.result?.data&&u(this.getPatientProfileQuery.result.data);if("reschedule"===this.kind){const i=this.getAppointmentQuery.result,a=this.getOrganizationSetupQuery.result;if(i?.isPending||a?.isPending)return e;const o=i?.data;if(!o)return e;const r=a?.data?.appointments?.seconds_before_start_to_refund_on_cancel;if(!s({startsAtIso:o.start_date,refundPolicySeconds:r}))return this._renderLayout(this.renderReschedulePolicyBlocked());const n=function(e){const{appointment:t}=e,i={id:t.from.hash,name:t.from.name??"",avatar:t.from.avatar,description:t.from.description,collegiate_number:t.from.collegiate_number,languages:t.from.languages,speciality:{id:t.speciality_id??0}};return{service:void 0,specialty:t.speciality_id?.toString(),slot:void 0,professional:i,firstAvailableSlotDate:void 0,paymentSessionId:void 0,paymentUrl:void 0,paymentRequest:void 0,appliedDiscount:void 0,profileComplete:e.profileComplete,requiresPayment:!1,error:!1}}({appointment:o,profileComplete:t}),l=this._initWizard(Le,n);return l.reconcile({profileComplete:t}),this._renderLayout(this._renderStep(l,o))}if(this.defaultProfessionalHash){const i=this.getProfessionalQuery.result;if(!i||i.isPending)return e;const s=!!this.defaultSlotId&&!!this.token,a=this.getScheduleSlotQuery.result;if(s&&(!a||a.isPending))return e;const o=s?a?.data:void 0,r="available"===o?.status,n=s&&r,l=De({defaultSpecialty:this.defaultSpecialty,defaultService:this.defaultService,defaultProfessionalHash:this.defaultProfessionalHash,specialties:this.getOrganizationSpecialtiesQuery.result?.data,services:this.getScheduleServicesQuery.result?.data,professional:i.data,profileComplete:t,requiresPayment:this.requiresPayment}),d=this._initWizard(je,{...l,slot:r?o:void 0,error:s&&!r},n?"completeProfile":void 0);return d.reconcile({profileComplete:t,service:l.service??d.ctx.service,professional:l.professional??d.ctx.professional,specialty:d.ctx.specialty??l.specialty,slot:d.ctx.slot??(r?o:void 0)}),this._renderLayout(this._renderStep(d,void 0))}const i=De({defaultSpecialty:this.defaultSpecialty,defaultService:this.defaultService,defaultProfessionalHash:void 0,specialties:this.getOrganizationSpecialtiesQuery.result?.data,services:this.getScheduleServicesQuery.result?.data,professional:void 0,profileComplete:t,requiresPayment:this.requiresPayment}),a=this._initWizard(ze,i);return a.reconcile({profileComplete:t,service:i.service??a.ctx.service,specialty:a.ctx.specialty??i.specialty}),this._renderLayout(this._renderStep(a,void 0))}};e([R({type:String,attribute:"default-specialty"})],zi.prototype,"defaultSpecialty",void 0),e([R({type:String,attribute:"default-service"})],zi.prototype,"defaultService",void 0),e([R({type:String,attribute:"default-professional-hash"})],zi.prototype,"defaultProfessionalHash",void 0),e([R({type:String,attribute:"default-slot-id"})],zi.prototype,"defaultSlotId",void 0),e([R({type:String,attribute:"kind"})],zi.prototype,"kind",void 0),e([R({type:Boolean,attribute:"requires-payment"})],zi.prototype,"requiresPayment",void 0),e([R({type:String,attribute:"appointment-id"})],zi.prototype,"appointmentId",void 0),e([R({type:Boolean,attribute:"show-mediquo-branding"})],zi.prototype,"showMediquoBranding",void 0),e([R({type:Boolean,attribute:"show-back-button",converter:{fromAttribute:e=>null===e||"false"!==e&&"0"!==e,toAttribute:e=>e?"":"false"}})],zi.prototype,"showBackButton",void 0),e([R({type:String,attribute:"api-key"})],zi.prototype,"apiKey",void 0),e([R({type:String,attribute:"token"})],zi.prototype,"token",void 0),e([R({type:String,attribute:"locale"})],zi.prototype,"locale",void 0),e([R({type:String,attribute:"env"})],zi.prototype,"env",void 0),e([R({type:String,attribute:"user-token"})],zi.prototype,"userToken",void 0),e([R({type:String,attribute:"apple-pay-success-url"})],zi.prototype,"applePaySuccessUrl",void 0),e([R({type:String,attribute:"timezone"})],zi.prototype,"timezone",void 0),zi=e([L(),t("mq-schedule")],zi);export{AppointmentCreatedEvent,AuthRequiredEvent,zi as MqSchedule};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as lit_html from 'lit-html';
|
|
2
|
+
import io from 'socket.io-client';
|
|
3
|
+
import { LitElement } from 'lit';
|
|
4
|
+
|
|
5
|
+
type BaseOptions = NonNullable<Parameters<typeof io>[0]>;
|
|
6
|
+
type Env$1 = "development" | "production";
|
|
7
|
+
type SocketOptions = Omit<BaseOptions, "query"> & {
|
|
8
|
+
env: Env$1;
|
|
9
|
+
accessToken: string;
|
|
10
|
+
};
|
|
11
|
+
declare class MediquoSocketSdkClient {
|
|
12
|
+
private readonly socket;
|
|
13
|
+
private readonly anyListeners;
|
|
14
|
+
constructor(options: SocketOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Sets up the wildcard listener for capturing all Socket.IO events.
|
|
17
|
+
*
|
|
18
|
+
* This method intercepts the internal `onevent` handler to catch all incoming
|
|
19
|
+
* Socket.IO events before they're dispatched to registered listeners. This allows
|
|
20
|
+
* the client to invoke all registered `onAny` callbacks with the event name and payload.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* The setup works by:
|
|
24
|
+
* 1. Storing a reference to the original `onevent` handler
|
|
25
|
+
* 2. Replacing it with a custom handler that:
|
|
26
|
+
* - Calls the original handler to preserve normal Socket.IO behavior
|
|
27
|
+
* - Extracts the event name and payload from the packet
|
|
28
|
+
* - Invokes all registered `onAny` callbacks
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
33
|
+
private setupWildcardListener;
|
|
34
|
+
on(event: string, callback: (...args: unknown[]) => void): void;
|
|
35
|
+
off(event: string, callback?: (...args: unknown[]) => void): void;
|
|
36
|
+
emit(event: string, ...args: unknown[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* Registers a listener that will be called for all incoming socket events.
|
|
39
|
+
*
|
|
40
|
+
* @param callback - Function that receives the event name and payload for every socket event
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* socket.onAny((eventName, payload) => {
|
|
46
|
+
* console.log(`Received event: ${eventName}`, payload);
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
onAny(callback: (eventName: string, payload: unknown) => void): void;
|
|
51
|
+
/**
|
|
52
|
+
* Removes a listener previously registered with `onAny`.
|
|
53
|
+
*
|
|
54
|
+
* @param callback - The callback function to remove. If not provided, removes all `onAny` listeners
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const handler = (eventName, payload) => {
|
|
60
|
+
* console.log(eventName, payload);
|
|
61
|
+
* };
|
|
62
|
+
* socket.onAny(handler);
|
|
63
|
+
* // Later...
|
|
64
|
+
* socket.offAny(handler);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
offAny(callback?: (eventName: string, payload: unknown) => void): void;
|
|
68
|
+
connect(): void;
|
|
69
|
+
disconnect(): void;
|
|
70
|
+
connected(): boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type Env = "development" | "production";
|
|
74
|
+
/**
|
|
75
|
+
* Socket provider component that manages socket connection and provides it to child components
|
|
76
|
+
* @fires mq-event-received when an event is received from the socket
|
|
77
|
+
*/
|
|
78
|
+
declare class SocketProvider extends LitElement {
|
|
79
|
+
/**
|
|
80
|
+
* Environment to connect to (development or production)
|
|
81
|
+
*/
|
|
82
|
+
env: Env;
|
|
83
|
+
/**
|
|
84
|
+
* JWT token for authentication
|
|
85
|
+
*/
|
|
86
|
+
token: string;
|
|
87
|
+
/**
|
|
88
|
+
* Socket client instance provided to children via context
|
|
89
|
+
*/
|
|
90
|
+
socket: MediquoSocketSdkClient | undefined;
|
|
91
|
+
disconnectedCallback(): void;
|
|
92
|
+
updated(changedProperties: Map<string, unknown>): void;
|
|
93
|
+
private initializeSocket;
|
|
94
|
+
private cleanupSocket;
|
|
95
|
+
render(): lit_html.TemplateResult<1>;
|
|
96
|
+
}
|
|
97
|
+
declare global {
|
|
98
|
+
interface HTMLElementTagNameMap {
|
|
99
|
+
"mq-socket-provider": SocketProvider;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { SocketProvider };
|