@fayz-ai/plugin-agenda 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/chunk-DRZF6CV2.js +421 -0
  2. package/dist/chunk-DRZF6CV2.js.map +1 -0
  3. package/dist/chunk-LFUELUIT.cjs +423 -0
  4. package/dist/chunk-LFUELUIT.cjs.map +1 -0
  5. package/dist/index.cjs +741 -10
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +741 -10
  9. package/dist/index.js.map +1 -1
  10. package/dist/migrations/index.d.ts +2 -0
  11. package/dist/migrations/index.d.ts.map +1 -0
  12. package/dist/public/BookingWidget.d.ts +4 -2
  13. package/dist/public/BookingWidget.d.ts.map +1 -1
  14. package/dist/public/components/BrandHeader.d.ts +6 -0
  15. package/dist/public/components/BrandHeader.d.ts.map +1 -0
  16. package/dist/public/components/ServiceCard.d.ts +5 -0
  17. package/dist/public/components/ServiceCard.d.ts.map +1 -0
  18. package/dist/public/components/SidebarExtras.d.ts +4 -0
  19. package/dist/public/components/SidebarExtras.d.ts.map +1 -0
  20. package/dist/public/components/StepRailItem.d.ts +4 -0
  21. package/dist/public/components/StepRailItem.d.ts.map +1 -0
  22. package/dist/public/components/SuccessPanel.d.ts +4 -0
  23. package/dist/public/components/SuccessPanel.d.ts.map +1 -0
  24. package/dist/public/components/SummaryRail.d.ts +27 -0
  25. package/dist/public/components/SummaryRail.d.ts.map +1 -0
  26. package/dist/public/components/defaults.d.ts +3 -0
  27. package/dist/public/components/defaults.d.ts.map +1 -0
  28. package/dist/public/context.d.ts +22 -8
  29. package/dist/public/context.d.ts.map +1 -1
  30. package/dist/public/createPublicBookingPlugin.d.ts +27 -10
  31. package/dist/public/createPublicBookingPlugin.d.ts.map +1 -1
  32. package/dist/public/data.d.ts +37 -0
  33. package/dist/public/data.d.ts.map +1 -0
  34. package/dist/public/data.supabase.d.ts +7 -0
  35. package/dist/public/data.supabase.d.ts.map +1 -0
  36. package/dist/public/format.d.ts +18 -0
  37. package/dist/public/format.d.ts.map +1 -0
  38. package/dist/public/hooks.d.ts +13 -11
  39. package/dist/public/hooks.d.ts.map +1 -1
  40. package/dist/public/index.cjs +1016 -613
  41. package/dist/public/index.cjs.map +1 -1
  42. package/dist/public/index.d.ts +15 -4
  43. package/dist/public/index.d.ts.map +1 -1
  44. package/dist/public/index.js +1006 -616
  45. package/dist/public/index.js.map +1 -1
  46. package/dist/public/steps/ContactStep.d.ts +30 -0
  47. package/dist/public/steps/ContactStep.d.ts.map +1 -0
  48. package/dist/public/steps/DateTimeStep.d.ts +23 -0
  49. package/dist/public/steps/DateTimeStep.d.ts.map +1 -0
  50. package/dist/public/steps/OverviewStep.d.ts +16 -0
  51. package/dist/public/steps/OverviewStep.d.ts.map +1 -0
  52. package/dist/public/steps/PaymentStep.d.ts +20 -0
  53. package/dist/public/steps/PaymentStep.d.ts.map +1 -0
  54. package/dist/public/types.d.ts +134 -0
  55. package/dist/public/types.d.ts.map +1 -1
  56. package/package.json +12 -12
  57. package/src/index.ts +11 -0
  58. package/src/migrations/001_public_booking.sql +278 -0
  59. package/src/migrations/index.ts +282 -0
  60. package/src/public/BookingWidget.tsx +136 -713
  61. package/src/public/components/BrandHeader.tsx +27 -0
  62. package/src/public/components/ServiceCard.tsx +39 -0
  63. package/src/public/components/SidebarExtras.tsx +30 -0
  64. package/src/public/components/StepRailItem.tsx +27 -0
  65. package/src/public/components/SuccessPanel.tsx +27 -0
  66. package/src/public/components/SummaryRail.tsx +90 -0
  67. package/src/public/components/defaults.ts +14 -0
  68. package/src/public/context.tsx +64 -7
  69. package/src/public/createPublicBookingPlugin.ts +131 -21
  70. package/src/public/data.supabase.ts +94 -0
  71. package/src/public/data.ts +99 -0
  72. package/src/public/format.ts +61 -0
  73. package/src/public/hooks.ts +22 -34
  74. package/src/public/index.ts +57 -4
  75. package/src/public/steps/ContactStep.tsx +179 -0
  76. package/src/public/steps/DateTimeStep.tsx +138 -0
  77. package/src/public/steps/OverviewStep.tsx +81 -0
  78. package/src/public/steps/PaymentStep.tsx +180 -0
  79. package/src/public/types.ts +169 -3
  80. package/dist/chunk-GAJVIEXM.cjs +0 -870
  81. package/dist/chunk-GAJVIEXM.cjs.map +0 -1
  82. package/dist/chunk-U6VTLOHN.js +0 -867
  83. package/dist/chunk-U6VTLOHN.js.map +0 -1
@@ -1,12 +1,130 @@
1
- import { createSupabaseAgendaProvider, createMockAgendaProvider } from '../chunk-U6VTLOHN.js';
2
- import '../chunk-3LJKZQK4.js';
3
- import { createContext, useContext, useState, useEffect, useMemo, useRef, createElement } from 'react';
4
- import { DEFAULT_COUNTRY, getCountry, COUNTRIES, maskPhone, unmaskPhone, createSafeDataProvider } from '@fayz-ai/core';
1
+ import { createMockAgendaProvider } from '../chunk-DRZF6CV2.js';
2
+ import { createContext, useState, useEffect, useMemo, useContext, useRef, createElement } from 'react';
3
+ import { ChevronLeft, ShieldCheck, Clock, ChevronRight, User, Check, Calendar, ChevronDown, Loader2, CreditCard, Plus, QrCode, CalendarCheck, Copy, Video } from 'lucide-react';
4
+ import { DEFAULT_COUNTRY, getCountry, maskPhone, unmaskPhone, createSafeDataProvider, getSupabaseClientOptional, COUNTRIES } from '@fayz-ai/core';
5
5
  import { jsx, jsxs } from 'react/jsx-runtime';
6
- import { Clock, Video, MapPin, CreditCard, User, ChevronLeft, ChevronRight, ChevronDown, ShieldCheck, Loader2, Check, Plus, QrCode, CalendarCheck, Copy, Calendar } from 'lucide-react';
7
6
 
7
+ // src/public/data.ts
8
+ function createMockPublicBookingProvider(options) {
9
+ const inner = createMockAgendaProvider({ seed: options.seed });
10
+ const { services, professionalId } = options;
11
+ return {
12
+ async getServices() {
13
+ return services;
14
+ },
15
+ async getAvailableSlots(query) {
16
+ return inner.getAvailableSlots({
17
+ assigneeId: query.assigneeId ?? professionalId,
18
+ date: query.date,
19
+ durationMinutes: query.durationMinutes,
20
+ slotInterval: query.slotInterval
21
+ });
22
+ },
23
+ async createBooking(input) {
24
+ const service = services.find((s) => s.id === input.serviceId);
25
+ if (!service) throw new Error("Servi\xE7o inv\xE1lido");
26
+ const booking = await inner.createBooking({
27
+ kind: "appointment",
28
+ // Mock: the customer is captured as the booking title; the Supabase
29
+ // path upserts a person record server-side instead.
30
+ clientId: "public-guest",
31
+ professionalId,
32
+ startsAt: input.startsAt,
33
+ title: input.contact.name,
34
+ notes: [input.contact.phone, input.contact.email, input.contact.notes].filter(Boolean).join(" \xB7 ") || void 0,
35
+ services: [
36
+ {
37
+ serviceId: service.id,
38
+ name: service.name,
39
+ durationMinutes: service.durationMinutes,
40
+ price: service.price,
41
+ assigneeId: professionalId
42
+ }
43
+ ]
44
+ });
45
+ const endsAt = booking.endsAt ?? new Date(new Date(input.startsAt).getTime() + service.durationMinutes * 6e4).toISOString();
46
+ return { bookingId: booking.id, startsAt: booking.startsAt, endsAt };
47
+ }
48
+ };
49
+ }
50
+ function getClient() {
51
+ const client = getSupabaseClientOptional();
52
+ if (!client) throw new Error("[plugin-agenda/public] Supabase client not initialized");
53
+ return client;
54
+ }
55
+ function toPhoneDigits(phone) {
56
+ return (phone ?? "").replace(/\D/g, "");
57
+ }
58
+ function createSupabasePublicBookingProvider(options) {
59
+ const { tenantId } = options;
60
+ return {
61
+ async getServices() {
62
+ const { data, error } = await getClient().from("v_public_services").select("id, name, description, price, currency, duration_minutes, sort_order").eq("tenant_id", tenantId).order("sort_order", { ascending: true });
63
+ if (error) throw new Error(`[plugin-agenda/public] getServices: ${error.message}`);
64
+ return (data ?? []).map((row) => ({
65
+ id: String(row.id),
66
+ name: String(row.name),
67
+ description: row.description ?? void 0,
68
+ price: Number(row.price ?? 0),
69
+ durationMinutes: Number(row.duration_minutes ?? 30)
70
+ }));
71
+ },
72
+ async getAvailableSlots(query) {
73
+ const { data, error } = await getClient().rpc("get_available_slots", {
74
+ p_tenant_id: tenantId,
75
+ p_assignee_id: query.assigneeId,
76
+ p_date: query.date,
77
+ p_duration_minutes: query.durationMinutes,
78
+ p_slot_interval: query.slotInterval
79
+ });
80
+ if (error) throw new Error(`[plugin-agenda/public] getAvailableSlots: ${error.message}`);
81
+ return (data ?? []).map((row) => ({
82
+ start: row.slot_start,
83
+ end: row.slot_end
84
+ }));
85
+ },
86
+ async createBooking(input) {
87
+ const phone = toPhoneDigits(input.contact.phone);
88
+ const { data, error } = await getClient().rpc("create_public_booking", {
89
+ p_tenant_id: tenantId,
90
+ p_service_id: input.serviceId,
91
+ p_starts_at: input.startsAt,
92
+ p_name: input.contact.name.trim(),
93
+ p_phone: phone,
94
+ p_email: input.contact.email?.trim() || null,
95
+ p_notes: input.contact.notes?.trim() || null
96
+ });
97
+ if (error) throw new Error(`[plugin-agenda/public] createBooking: ${error.message}`);
98
+ const row = Array.isArray(data) ? data[0] : data;
99
+ if (!row) throw new Error("[plugin-agenda/public] createBooking: empty RPC response");
100
+ return { bookingId: row.booking_id, startsAt: row.starts_at, endsAt: row.ends_at };
101
+ }
102
+ };
103
+ }
8
104
  var PublicBookingContext = createContext(null);
9
- function BookingProvider({ value, children }) {
105
+ function BookingProvider({ base, staticServices, children }) {
106
+ const [fetched, setFetched] = useState(null);
107
+ const [loading, setLoading] = useState(staticServices === null);
108
+ useEffect(() => {
109
+ if (staticServices !== null) return;
110
+ let active = true;
111
+ setLoading(true);
112
+ base.provider.getServices().then((result) => {
113
+ if (active) setFetched(result);
114
+ }).catch((err) => {
115
+ console.error("[plugin-agenda/public] failed to load services:", err);
116
+ if (active) setFetched([]);
117
+ }).finally(() => {
118
+ if (active) setLoading(false);
119
+ });
120
+ return () => {
121
+ active = false;
122
+ };
123
+ }, [base.provider, staticServices]);
124
+ const value = useMemo(
125
+ () => ({ ...base, services: staticServices ?? fetched ?? [], servicesLoading: loading }),
126
+ [base, staticServices, fetched, loading]
127
+ );
10
128
  return /* @__PURE__ */ jsx(PublicBookingContext.Provider, { value, children });
11
129
  }
12
130
  function useBooking() {
@@ -19,6 +137,10 @@ function useBooking() {
19
137
  function useServices() {
20
138
  return useBooking().services;
21
139
  }
140
+ function usePublicServices() {
141
+ const { services, servicesLoading } = useBooking();
142
+ return { services, loading: servicesLoading };
143
+ }
22
144
  function useAvailableSlots(params) {
23
145
  const { provider, professionalId, services, window: window2 } = useBooking();
24
146
  const [slots, setSlots] = useState([]);
@@ -51,36 +173,17 @@ function useAvailableSlots(params) {
51
173
  return { slots, loading, error };
52
174
  }
53
175
  function useCreateBooking() {
54
- const { provider, professionalId, services } = useBooking();
176
+ const { provider } = useBooking();
55
177
  const [submitting, setSubmitting] = useState(false);
56
178
  const [error, setError] = useState(null);
57
179
  const [done, setDone] = useState(false);
58
180
  async function submit(input) {
59
- const service = services.find((s) => s.id === input.serviceId);
60
- if (!service) throw new Error("Servi\xE7o inv\xE1lido");
61
181
  setSubmitting(true);
62
182
  setError(null);
63
183
  try {
64
- await provider.createBooking({
65
- kind: "appointment",
66
- // POC: the customer is captured as the booking title; a real flow would
67
- // upsert a client/person record and pass its id here.
68
- clientId: "public-guest",
69
- professionalId,
70
- startsAt: input.startsAt,
71
- title: input.contact.name,
72
- notes: [input.contact.phone, input.contact.email, input.contact.notes].filter(Boolean).join(" \xB7 ") || void 0,
73
- services: [
74
- {
75
- serviceId: service.id,
76
- name: service.name,
77
- durationMinutes: service.durationMinutes,
78
- price: service.price,
79
- assigneeId: professionalId
80
- }
81
- ]
82
- });
184
+ const result = await provider.createBooking(input);
83
185
  setDone(true);
186
+ return result;
84
187
  } catch (err) {
85
188
  const e = err instanceof Error ? err : new Error(String(err));
86
189
  setError(e);
@@ -129,7 +232,368 @@ function formatSlotRange(startIso, durationMin, fmt) {
129
232
  const end = new Date(start.getTime() + durationMin * 6e4);
130
233
  return `${fmt.dateShort.format(start)} \u2013 ${fmt.time.format(start)} at\xE9 ${fmt.time.format(end)} (${durationMin}min)`;
131
234
  }
132
- var PIX_PAYLOAD = "00020126840014br.gov.bcb.pix2562qrcode.hempdent.com.br/pix/v2/9d8f7a6b-consulta-canabica5204000053039865802BR5913HEMPDENT6009SAO PAULO62070503***6304AB12";
235
+ function OverviewStep({
236
+ services,
237
+ servicesLoading,
238
+ businessHours,
239
+ professionalName,
240
+ labels,
241
+ brand,
242
+ fmt,
243
+ components: C,
244
+ onStartBooking
245
+ }) {
246
+ const openDays = new Set(businessHours.daysOfWeek);
247
+ return /* @__PURE__ */ jsxs("div", { className: "grid gap-6 lg:grid-cols-[1fr_18rem]", children: [
248
+ /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
249
+ /* @__PURE__ */ jsxs("section", { className: "rounded-2xl border border-border bg-card p-6 shadow-sm", children: [
250
+ /* @__PURE__ */ jsx("h3", { className: "mb-4 font-heading text-lg font-bold text-foreground", children: labels.servicesHeading }),
251
+ /* @__PURE__ */ jsx("div", { className: "space-y-3", children: servicesLoading ? Array.from({ length: 2 }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "h-24 animate-pulse rounded-2xl bg-muted" }, i)) : services.map((s, i) => /* @__PURE__ */ jsx(
252
+ C.ServiceCard,
253
+ {
254
+ service: s,
255
+ featured: i === 0,
256
+ onSelect: () => onStartBooking(s.id),
257
+ fmt,
258
+ brand
259
+ },
260
+ s.id
261
+ )) })
262
+ ] }),
263
+ /* @__PURE__ */ jsxs("section", { className: "rounded-2xl border border-border bg-card p-6 shadow-sm", children: [
264
+ /* @__PURE__ */ jsx("h3", { className: "font-heading text-lg font-bold text-foreground", children: labels.aboutHeading }),
265
+ /* @__PURE__ */ jsxs("p", { className: "mt-3 mb-2 flex items-center gap-1.5 text-sm font-medium text-muted-foreground", children: [
266
+ /* @__PURE__ */ jsx(Clock, { className: "h-4 w-4" }),
267
+ " ",
268
+ labels.openingHoursHeading
269
+ ] }),
270
+ /* @__PURE__ */ jsx("ul", { className: "divide-y divide-border border-l-2 border-primary/20 pl-4", children: WEEK_ORDER.map((day) => {
271
+ const open = openDays.has(day);
272
+ return /* @__PURE__ */ jsxs("li", { className: "flex items-center justify-between py-2 text-sm", children: [
273
+ /* @__PURE__ */ jsx("span", { className: "text-foreground", children: DAY_NAMES[day] }),
274
+ /* @__PURE__ */ jsx("span", { className: open ? "tabular-nums text-foreground" : "text-muted-foreground", children: open ? `${businessHours.start} \u2013 ${businessHours.end}` : labels.closedLabel })
275
+ ] }, day);
276
+ }) })
277
+ ] })
278
+ ] }),
279
+ /* @__PURE__ */ jsx("aside", { className: "lg:sticky lg:top-24 lg:self-start", children: /* @__PURE__ */ jsx(
280
+ C.SidebarExtras,
281
+ {
282
+ professionalName,
283
+ brand,
284
+ labels,
285
+ onStartBooking: () => onStartBooking()
286
+ }
287
+ ) })
288
+ ] });
289
+ }
290
+ function DateTimeStep({
291
+ labels,
292
+ fmt,
293
+ week,
294
+ weekOffset,
295
+ maxWeekOffset,
296
+ onWeekOffset,
297
+ businessHours,
298
+ date,
299
+ onSelectDate,
300
+ slots,
301
+ slotsLoading,
302
+ slotStart,
303
+ onSelectSlot,
304
+ onContinue
305
+ }) {
306
+ const openDays = new Set(businessHours.daysOfWeek);
307
+ return /* @__PURE__ */ jsxs("div", { children: [
308
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-baseline justify-between gap-2", children: [
309
+ /* @__PURE__ */ jsx("h3", { className: "font-heading text-xl font-bold text-foreground", children: labels.dateStep }),
310
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
311
+ /* @__PURE__ */ jsx(Clock, { className: "h-3.5 w-3.5" }),
312
+ " ",
313
+ labels.timezoneNote
314
+ ] })
315
+ ] }),
316
+ /* @__PURE__ */ jsxs("div", { className: "mt-5 flex items-center justify-between", children: [
317
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold capitalize text-foreground", children: fmt.month.format(week[0].date) }),
318
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
319
+ /* @__PURE__ */ jsx(
320
+ "button",
321
+ {
322
+ type: "button",
323
+ disabled: weekOffset === 0,
324
+ onClick: () => onWeekOffset((w) => Math.max(0, w - 1)),
325
+ className: "flex h-9 w-9 items-center justify-center rounded-lg border border-border text-foreground transition-colors hover:bg-accent disabled:opacity-40 disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
326
+ "aria-label": labels.prevWeek,
327
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
328
+ }
329
+ ),
330
+ /* @__PURE__ */ jsx(
331
+ "button",
332
+ {
333
+ type: "button",
334
+ disabled: weekOffset >= maxWeekOffset,
335
+ onClick: () => onWeekOffset((w) => Math.min(maxWeekOffset, w + 1)),
336
+ className: "flex h-9 w-9 items-center justify-center rounded-lg border border-border text-foreground transition-colors hover:bg-accent disabled:opacity-40 disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
337
+ "aria-label": labels.nextWeek,
338
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
339
+ }
340
+ )
341
+ ] })
342
+ ] }),
343
+ /* @__PURE__ */ jsx("div", { className: "mt-3 grid grid-cols-7 gap-1.5", children: week.map((d) => {
344
+ const selected = date === d.iso;
345
+ const closed = !openDays.has(d.date.getDay());
346
+ return /* @__PURE__ */ jsxs(
347
+ "button",
348
+ {
349
+ type: "button",
350
+ disabled: closed,
351
+ onClick: () => onSelectDate(d.iso),
352
+ className: [
353
+ "flex flex-col items-center gap-0.5 rounded-xl border py-2.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
354
+ closed ? "cursor-not-allowed border-transparent text-muted-foreground/40" : selected ? "border-primary bg-primary text-primary-foreground" : "border-border text-foreground hover:border-primary/60 hover:bg-accent/40"
355
+ ].join(" "),
356
+ children: [
357
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium capitalize opacity-80", children: fmt.weekday.format(d.date).replace(".", "") }),
358
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-bold tabular-nums", children: fmt.dayNum.format(d.date) })
359
+ ]
360
+ },
361
+ d.iso
362
+ );
363
+ }) }),
364
+ date ? /* @__PURE__ */ jsxs("div", { className: "mt-6", children: [
365
+ /* @__PURE__ */ jsx("p", { className: "mb-2 text-sm font-semibold text-foreground", children: labels.slotsHeading }),
366
+ slotsLoading ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-2 sm:grid-cols-4", children: Array.from({ length: 8 }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "h-10 animate-pulse rounded-lg bg-muted" }, i)) }) : slots.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-dashed border-border p-6 text-center text-sm text-muted-foreground", children: labels.noSlots }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-2 sm:grid-cols-4", children: slots.map((s) => {
367
+ const selected = slotStart === s.start;
368
+ return /* @__PURE__ */ jsx(
369
+ "button",
370
+ {
371
+ type: "button",
372
+ onClick: () => onSelectSlot(s.start),
373
+ className: [
374
+ "rounded-lg border py-2.5 text-sm font-semibold tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
375
+ selected ? "border-primary bg-primary text-primary-foreground" : "border-border text-foreground hover:border-primary/60 hover:bg-accent/40"
376
+ ].join(" "),
377
+ children: fmt.time.format(new Date(s.start))
378
+ },
379
+ s.start
380
+ );
381
+ }) })
382
+ ] }) : null,
383
+ /* @__PURE__ */ jsx(
384
+ "button",
385
+ {
386
+ type: "button",
387
+ disabled: !slotStart,
388
+ onClick: onContinue,
389
+ className: "mt-6 w-full rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
390
+ children: labels.continueCta
391
+ }
392
+ )
393
+ ] });
394
+ }
395
+ function ContactStep({
396
+ labels,
397
+ contact,
398
+ onContactChange,
399
+ contactStep,
400
+ country,
401
+ onCountryChange,
402
+ code,
403
+ onCodeChange,
404
+ codeError,
405
+ onSendCode,
406
+ onConfirmCode,
407
+ onBackToPhone,
408
+ onSubmitDetails,
409
+ payment,
410
+ submitting,
411
+ error
412
+ }) {
413
+ return /* @__PURE__ */ jsxs("div", { children: [
414
+ /* @__PURE__ */ jsx("h3", { className: "font-heading text-xl font-bold text-foreground", children: labels.contactStep }),
415
+ contactStep === "phone" ? /* @__PURE__ */ jsxs("form", { onSubmit: (e) => {
416
+ e.preventDefault();
417
+ onSendCode();
418
+ }, children: [
419
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: labels.contactIntro }),
420
+ /* @__PURE__ */ jsxs("div", { className: "mt-5", children: [
421
+ /* @__PURE__ */ jsx("label", { htmlFor: "bk-phone", className: "mb-1 block text-sm font-medium text-foreground", children: labels.phoneLabel }),
422
+ /* @__PURE__ */ jsxs("div", { className: "flex", children: [
423
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
424
+ /* @__PURE__ */ jsx(
425
+ "select",
426
+ {
427
+ "aria-label": "Pa\xEDs",
428
+ value: country.iso2,
429
+ onChange: (e) => onCountryChange(e.target.value),
430
+ className: "h-full appearance-none rounded-l-xl border border-r-0 border-border bg-muted py-3 pl-3 pr-8 text-sm font-medium text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
431
+ children: COUNTRIES.map((c) => /* @__PURE__ */ jsxs("option", { value: c.iso2, children: [
432
+ c.flag,
433
+ " ",
434
+ c.dial
435
+ ] }, c.iso2))
436
+ }
437
+ ),
438
+ /* @__PURE__ */ jsx(ChevronDown, { className: "pointer-events-none absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" })
439
+ ] }),
440
+ /* @__PURE__ */ jsx(
441
+ "input",
442
+ {
443
+ id: "bk-phone",
444
+ type: "tel",
445
+ autoComplete: "tel",
446
+ inputMode: "tel",
447
+ value: contact.phone,
448
+ onChange: (e) => onContactChange({ ...contact, phone: maskPhone(e.target.value, country.mask) }),
449
+ className: "w-full rounded-r-xl border border-border bg-background px-4 py-3 text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring",
450
+ placeholder: `Ex.: ${maskPhone("11987654321", country.mask)}`
451
+ }
452
+ )
453
+ ] }),
454
+ /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: labels.phoneHint })
455
+ ] }),
456
+ /* @__PURE__ */ jsx(
457
+ "button",
458
+ {
459
+ type: "submit",
460
+ disabled: unmaskPhone(contact.phone).length < 8,
461
+ className: "mt-5 w-full rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
462
+ children: labels.sendCodeCta
463
+ }
464
+ )
465
+ ] }) : null,
466
+ contactStep === "details" ? /* @__PURE__ */ jsxs("form", { onSubmit: (e) => {
467
+ e.preventDefault();
468
+ onSubmitDetails();
469
+ }, children: [
470
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: labels.contactIntro }),
471
+ /* @__PURE__ */ jsxs("div", { className: "mt-4 flex items-center justify-between rounded-xl border border-border bg-muted/40 px-4 py-3", children: [
472
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-sm text-foreground", children: [
473
+ /* @__PURE__ */ jsx(ShieldCheck, { className: "h-4 w-4 text-primary" }),
474
+ " ",
475
+ labels.phoneVerified,
476
+ " \xB7 ",
477
+ country.flag,
478
+ " ",
479
+ country.dial,
480
+ " ",
481
+ contact.phone
482
+ ] }),
483
+ /* @__PURE__ */ jsx(
484
+ "button",
485
+ {
486
+ type: "button",
487
+ onClick: onBackToPhone,
488
+ className: "rounded text-sm font-medium text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
489
+ children: labels.changePhone
490
+ }
491
+ )
492
+ ] }),
493
+ /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-3", children: [
494
+ /* @__PURE__ */ jsxs("div", { children: [
495
+ /* @__PURE__ */ jsx("label", { htmlFor: "bk-name", className: "mb-1 block text-sm font-medium text-foreground", children: labels.nameLabel }),
496
+ /* @__PURE__ */ jsx(
497
+ "input",
498
+ {
499
+ id: "bk-name",
500
+ type: "text",
501
+ autoComplete: "name",
502
+ value: contact.name,
503
+ onChange: (e) => onContactChange({ ...contact, name: e.target.value }),
504
+ className: "w-full rounded-xl border border-border bg-background px-4 py-3 text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring",
505
+ placeholder: labels.namePlaceholder
506
+ }
507
+ )
508
+ ] }),
509
+ /* @__PURE__ */ jsxs("div", { children: [
510
+ /* @__PURE__ */ jsx("label", { htmlFor: "bk-email", className: "mb-1 block text-sm font-medium text-foreground", children: labels.emailLabel }),
511
+ /* @__PURE__ */ jsx(
512
+ "input",
513
+ {
514
+ id: "bk-email",
515
+ type: "email",
516
+ autoComplete: "email",
517
+ inputMode: "email",
518
+ value: contact.email,
519
+ onChange: (e) => onContactChange({ ...contact, email: e.target.value }),
520
+ className: "w-full rounded-xl border border-border bg-background px-4 py-3 text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring",
521
+ placeholder: labels.emailPlaceholder
522
+ }
523
+ ),
524
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: labels.emailHint })
525
+ ] }),
526
+ /* @__PURE__ */ jsxs("div", { children: [
527
+ /* @__PURE__ */ jsx("label", { htmlFor: "bk-notes", className: "mb-1 block text-sm font-medium text-foreground", children: labels.notesLabel }),
528
+ /* @__PURE__ */ jsx(
529
+ "textarea",
530
+ {
531
+ id: "bk-notes",
532
+ rows: 3,
533
+ value: contact.notes,
534
+ onChange: (e) => onContactChange({ ...contact, notes: e.target.value }),
535
+ className: "w-full resize-none rounded-xl border border-border bg-background px-4 py-3 text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring",
536
+ placeholder: labels.notesPlaceholder
537
+ }
538
+ )
539
+ ] })
540
+ ] }),
541
+ error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "mt-3 text-sm text-destructive", children: labels.submitError }) : null,
542
+ /* @__PURE__ */ jsxs(
543
+ "button",
544
+ {
545
+ type: "submit",
546
+ disabled: !contact.name.trim() || submitting,
547
+ className: "mt-5 flex w-full items-center justify-center gap-2 rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
548
+ children: [
549
+ submitting ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }),
550
+ payment ? labels.saveAndContinueCta : labels.confirmCta
551
+ ]
552
+ }
553
+ ),
554
+ !payment ? /* @__PURE__ */ jsxs("p", { className: "mt-3 flex items-center justify-center gap-1.5 text-xs text-muted-foreground", children: [
555
+ /* @__PURE__ */ jsx(CreditCard, { className: "h-3.5 w-3.5" }),
556
+ " ",
557
+ labels.noChargeNote
558
+ ] }) : null
559
+ ] }) : null,
560
+ contactStep === "code" ? /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-foreground/40 p-4", role: "dialog", "aria-modal": "true", "aria-label": labels.codeTitle, children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-xl", children: [
561
+ /* @__PURE__ */ jsx("h4", { className: "font-heading text-lg font-bold text-foreground", children: labels.codeTitle }),
562
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: labels.codeBody }),
563
+ /* @__PURE__ */ jsxs("form", { onSubmit: (e) => {
564
+ e.preventDefault();
565
+ onConfirmCode();
566
+ }, children: [
567
+ /* @__PURE__ */ jsx(
568
+ "input",
569
+ {
570
+ type: "text",
571
+ inputMode: "numeric",
572
+ value: code,
573
+ autoFocus: true,
574
+ onChange: (e) => onCodeChange(e.target.value),
575
+ className: "mt-4 w-full rounded-xl border border-border bg-background px-4 py-3 text-center text-lg tracking-[0.4em] text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring placeholder:text-sm placeholder:tracking-normal",
576
+ placeholder: "Digite o c\xF3digo"
577
+ }
578
+ ),
579
+ codeError ? /* @__PURE__ */ jsx("p", { role: "alert", className: "mt-2 text-sm text-destructive", children: labels.codeInvalid }) : null,
580
+ /* @__PURE__ */ jsx(
581
+ "button",
582
+ {
583
+ type: "submit",
584
+ className: "mt-4 w-full rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
585
+ children: labels.codeConfirmCta
586
+ }
587
+ )
588
+ ] }),
589
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between text-xs text-muted-foreground", children: [
590
+ /* @__PURE__ */ jsx("span", { children: labels.codeResendHint }),
591
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onBackToPhone, className: "font-medium text-primary hover:underline", children: labels.back })
592
+ ] })
593
+ ] }) }) : null
594
+ ] });
595
+ }
596
+ var PIX_PAYLOAD = "00020126840014br.gov.bcb.pix2562qrcode.fayz.ai/pix/v2/9d8f7a6b-agendamento5204000053039865802BR5904FAYZ6009SAO PAULO62070503***6304AB12";
133
597
  function QrPlaceholder({ data }) {
134
598
  const size = 25;
135
599
  let seed = 0;
@@ -142,9 +606,9 @@ function QrPlaceholder({ data }) {
142
606
  for (let y = 0; y < size; y++) {
143
607
  for (let x = 0; x < size; x++) {
144
608
  if (isFinder(x, y)) {
145
- const local = (bx, by) => ({ lx: x - bx, ly: y - by });
146
609
  const corner = x < 7 && y < 7 ? { bx: 0, by: 0 } : x >= size - 7 && y < 7 ? { bx: size - 7, by: 0 } : { bx: 0, by: size - 7 };
147
- const { lx, ly } = local(corner.bx, corner.by);
610
+ const lx = x - corner.bx;
611
+ const ly = y - corner.by;
148
612
  const outer = lx === 0 || lx === 6 || ly === 0 || ly === 6;
149
613
  const inner = lx >= 2 && lx <= 4 && ly >= 2 && ly <= 4;
150
614
  if (outer || inner) cells.push({ x, y });
@@ -158,84 +622,197 @@ function QrPlaceholder({ data }) {
158
622
  cells.map((c, i) => /* @__PURE__ */ jsx("rect", { x: c.x, y: c.y, width: 1, height: 1, fill: "currentColor", className: "text-foreground" }, i))
159
623
  ] });
160
624
  }
161
- function BrandHeader() {
162
- return /* @__PURE__ */ jsxs("div", { className: "mb-5 flex items-center gap-3 rounded-2xl border border-border bg-card px-5 py-4 shadow-sm", children: [
163
- /* @__PURE__ */ jsx("span", { className: "flex h-11 w-11 items-center justify-center rounded-xl bg-primary text-lg font-bold text-primary-foreground", children: "H" }),
164
- /* @__PURE__ */ jsxs("div", { children: [
165
- /* @__PURE__ */ jsx("p", { className: "font-heading text-base font-bold text-foreground", children: "HempDent \xB7 Consulta Can\xE1bica" }),
166
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-xs text-muted-foreground", children: [
167
- /* @__PURE__ */ jsx(ShieldCheck, { className: "h-3.5 w-3.5 text-primary" }),
168
- " Agendamento online seguro \xB7 CRO-SP 166513"
169
- ] })
170
- ] })
171
- ] });
172
- }
173
- function ServiceRow({
625
+ function PaymentStep({
174
626
  service,
175
- featured,
176
- onSelect,
177
- fmt
627
+ payment,
628
+ paymentStep,
629
+ charge,
630
+ busy,
631
+ error,
632
+ copied,
633
+ fmt,
634
+ onPayWithPix,
635
+ onCopy,
636
+ onSimulatePaid
178
637
  }) {
179
- return /* @__PURE__ */ jsxs(
180
- "button",
181
- {
182
- type: "button",
183
- onClick: onSelect,
184
- className: "group flex w-full items-center gap-4 rounded-2xl border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
185
- children: [
186
- /* @__PURE__ */ jsx("span", { className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-accent text-primary", children: /* @__PURE__ */ jsx(Video, { className: "h-5 w-5" }) }),
187
- /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
188
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
189
- /* @__PURE__ */ jsx("span", { className: "font-semibold text-foreground", children: service.name }),
190
- featured ? /* @__PURE__ */ jsx("span", { className: "rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-primary", children: "Mais procurado" }) : null
638
+ const feePct = payment.reservationFeePercent;
639
+ const fee = Math.round(service.price * feePct) / 100;
640
+ const remaining = Math.round((service.price - fee) * 100) / 100;
641
+ if (paymentStep === "choose") {
642
+ return /* @__PURE__ */ jsxs("div", { children: [
643
+ /* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-border p-4", children: [
644
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between font-semibold text-foreground", children: [
645
+ /* @__PURE__ */ jsx("span", { children: service.name }),
646
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: fmt.price.format(service.price) })
647
+ ] }),
648
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 space-y-2 text-sm", children: [
649
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-foreground", children: [
650
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
651
+ /* @__PURE__ */ jsx("span", { className: "flex h-4 w-4 items-center justify-center rounded bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }) }),
652
+ "Taxa de reserva ",
653
+ /* @__PURE__ */ jsxs("span", { className: "rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground", children: [
654
+ feePct,
655
+ "%"
656
+ ] })
657
+ ] }),
658
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: fmt.price.format(fee) })
191
659
  ] }),
192
- /* @__PURE__ */ jsxs("span", { className: "mt-0.5 flex items-center gap-1 text-xs text-muted-foreground", children: [
193
- /* @__PURE__ */ jsx(Clock, { className: "h-3 w-3" }),
194
- " ",
195
- service.durationMinutes,
196
- " min \xB7 Online"
660
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-muted-foreground", children: [
661
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
662
+ /* @__PURE__ */ jsx("span", { className: "h-4 w-4 rounded border border-border" }),
663
+ " Valor restante"
664
+ ] }),
665
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: remaining <= 0 ? "Gr\xE1tis" : fmt.price.format(remaining) })
197
666
  ] }),
198
- service.description ? /* @__PURE__ */ jsx("span", { className: "mt-1 block text-sm text-muted-foreground", children: service.description }) : null
667
+ /* @__PURE__ */ jsxs("button", { type: "button", className: "flex items-center gap-1 text-sm font-medium text-primary hover:underline", children: [
668
+ /* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5" }),
669
+ " Adicionar cupom"
670
+ ] })
199
671
  ] }),
200
- /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-right", children: [
201
- /* @__PURE__ */ jsx("span", { className: "block font-semibold tabular-nums text-primary", children: fmt.price.format(service.price) }),
202
- /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto mt-1 h-4 w-4 text-muted-foreground transition-transform group-hover:translate-x-0.5" })
672
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between border-t border-dashed border-border pt-3 font-semibold text-foreground", children: [
673
+ /* @__PURE__ */ jsx("span", { children: "Valor total" }),
674
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: fmt.price.format(service.price) })
203
675
  ] })
204
- ]
205
- }
206
- );
207
- }
208
- function StepRail({
209
- n,
210
- label,
211
- state,
212
- children
213
- }) {
214
- return /* @__PURE__ */ jsxs("li", { className: "relative pl-11", children: [
215
- /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "absolute left-[15px] top-8 bottom-[-18px] w-px bg-border last:hidden" }),
676
+ ] }),
677
+ /* @__PURE__ */ jsxs("div", { className: "mt-6 flex items-center justify-between", children: [
678
+ /* @__PURE__ */ jsx("h3", { className: "font-heading text-lg font-bold text-foreground", children: "Escolha como pagar" }),
679
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
680
+ /* @__PURE__ */ jsx(ShieldCheck, { className: "h-3.5 w-3.5 text-primary" }),
681
+ " Pagamento seguro"
682
+ ] })
683
+ ] }),
684
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 rounded-2xl border-2 border-primary bg-accent/20 p-4", children: [
685
+ /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 font-semibold text-foreground", children: [
686
+ /* @__PURE__ */ jsx("span", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" }) }),
687
+ "Pix"
688
+ ] }),
689
+ /* @__PURE__ */ jsx("div", { className: "mt-4 grid grid-cols-1 gap-4 sm:grid-cols-3", children: [
690
+ { icon: Check, t: 'Finalize o agendamento clicando em "Pagar com Pix".' },
691
+ { icon: QrCode, t: "Mostraremos um QR Code e o Pix copia-e-cola." },
692
+ { icon: CalendarCheck, t: "Ap\xF3s o pagamento, seu agendamento \xE9 reservado." }
693
+ ].map((s, i) => /* @__PURE__ */ jsxs("div", { className: "text-sm text-muted-foreground", children: [
694
+ /* @__PURE__ */ jsx("span", { className: "mb-2 flex h-8 w-8 items-center justify-center rounded-lg bg-accent text-primary", children: /* @__PURE__ */ jsx(s.icon, { className: "h-4 w-4" }) }),
695
+ /* @__PURE__ */ jsxs("span", { className: "font-semibold text-foreground", children: [
696
+ i + 1,
697
+ "."
698
+ ] }),
699
+ " ",
700
+ s.t
701
+ ] }, i)) })
702
+ ] }),
703
+ error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "mt-3 text-sm text-destructive", children: "N\xE3o foi poss\xEDvel iniciar o pagamento. Tente novamente." }) : null,
704
+ /* @__PURE__ */ jsxs(
705
+ "button",
706
+ {
707
+ type: "button",
708
+ disabled: busy,
709
+ onClick: () => onPayWithPix(fee),
710
+ className: "mt-6 flex w-full items-center justify-center gap-2 rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
711
+ children: [
712
+ busy ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(CreditCard, { className: "h-4 w-4" }),
713
+ "Pagar ",
714
+ fmt.price.format(fee),
715
+ " com Pix"
716
+ ]
717
+ }
718
+ )
719
+ ] });
720
+ }
721
+ return /* @__PURE__ */ jsxs("div", { children: [
722
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-amber-300/60 bg-amber-50 p-4 dark:border-amber-400/30 dark:bg-amber-950/30", children: [
723
+ /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 text-sm font-semibold text-foreground", children: [
724
+ /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }),
725
+ " Realize o pagamento para finalizar"
726
+ ] }),
727
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Este c\xF3digo Pix \xE9 v\xE1lido por somente 5 minutos. N\xE3o feche esta p\xE1gina at\xE9 receber a confirma\xE7\xE3o do pagamento." })
728
+ ] }),
729
+ /* @__PURE__ */ jsx("h3", { className: "mt-6 font-heading text-lg font-bold text-foreground", children: "Escaneie ou copie este c\xF3digo para pagar" }),
730
+ /* @__PURE__ */ jsxs("ol", { className: "mt-2 space-y-1 text-sm text-muted-foreground", children: [
731
+ /* @__PURE__ */ jsx("li", { children: "1. Acesse o app do seu banco, pagamentos ou Internet Banking." }),
732
+ /* @__PURE__ */ jsx("li", { children: "2. Escolha pagar via Pix." }),
733
+ /* @__PURE__ */ jsx("li", { children: "3. Escaneie o QR Code ou use o Pix copia-e-cola:" })
734
+ ] }),
735
+ /* @__PURE__ */ jsx("div", { className: "mt-4 w-fit rounded-xl border border-border bg-white p-3", children: /* @__PURE__ */ jsx(QrPlaceholder, { data: charge?.pixQrCode ?? PIX_PAYLOAD }) }),
736
+ /* @__PURE__ */ jsxs("div", { className: "mt-4 flex max-w-md items-center gap-2", children: [
737
+ /* @__PURE__ */ jsx("code", { className: "flex-1 truncate rounded-lg border border-border bg-muted px-3 py-2 text-xs text-muted-foreground", children: charge?.pixCopyPaste ?? PIX_PAYLOAD }),
738
+ /* @__PURE__ */ jsxs(
739
+ "button",
740
+ {
741
+ type: "button",
742
+ onClick: onCopy,
743
+ className: "inline-flex shrink-0 items-center gap-1.5 rounded-lg bg-foreground px-3 py-2 text-xs font-medium text-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
744
+ children: [
745
+ copied ? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" }),
746
+ " ",
747
+ copied ? "Copiado" : "Copiar"
748
+ ]
749
+ }
750
+ )
751
+ ] }),
216
752
  /* @__PURE__ */ jsx(
217
- "span",
753
+ "button",
218
754
  {
219
- className: [
220
- "absolute left-0 top-0 flex h-8 w-8 items-center justify-center rounded-full text-sm font-semibold transition-colors",
221
- state === "done" ? "bg-primary text-primary-foreground" : state === "active" ? "bg-accent text-primary ring-2 ring-primary" : "bg-muted text-muted-foreground"
222
- ].join(" "),
223
- children: state === "done" ? /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) : n
755
+ type: "button",
756
+ onClick: onSimulatePaid,
757
+ className: "mt-6 w-full rounded-xl border border-primary py-3 font-semibold text-primary transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
758
+ children: "J\xE1 paguei \u2014 confirmar (simula\xE7\xE3o)"
224
759
  }
225
- ),
226
- /* @__PURE__ */ jsx("p", { className: `pt-1 text-sm font-semibold ${state === "todo" ? "text-muted-foreground" : "text-foreground"}`, children: label }),
227
- children ? /* @__PURE__ */ jsx("div", { className: "mt-2", children }) : null
760
+ )
761
+ ] });
762
+ }
763
+ function SummaryRail({
764
+ title,
765
+ railState,
766
+ service,
767
+ professionalName,
768
+ slotStart,
769
+ contactSummary,
770
+ payment,
771
+ paymentReached,
772
+ labels,
773
+ fmt,
774
+ components: C,
775
+ serviceMeta
776
+ }) {
777
+ return /* @__PURE__ */ jsxs("div", { className: "sticky top-24 rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
778
+ /* @__PURE__ */ jsx("p", { className: "mb-5 font-heading text-sm font-bold uppercase tracking-wide text-muted-foreground", children: title }),
779
+ /* @__PURE__ */ jsxs("ol", { className: "space-y-6", children: [
780
+ /* @__PURE__ */ jsx(C.StepRailItem, { n: 1, label: labels.railService, state: railState.service, children: service ? /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-border bg-background p-3", children: [
781
+ /* @__PURE__ */ jsx("p", { className: "truncate text-sm font-semibold text-foreground", children: service.name }),
782
+ /* @__PURE__ */ jsxs("p", { className: "mt-0.5 flex items-center justify-between text-xs text-muted-foreground", children: [
783
+ /* @__PURE__ */ jsxs("span", { children: [
784
+ serviceMeta ? `${serviceMeta} \xB7 ` : "",
785
+ service.durationMinutes,
786
+ " min"
787
+ ] }),
788
+ /* @__PURE__ */ jsx("span", { className: "font-semibold tabular-nums text-primary", children: fmt.price.format(service.price) })
789
+ ] })
790
+ ] }) : null }),
791
+ /* @__PURE__ */ jsx(C.StepRailItem, { n: 2, label: labels.railProfessional, state: railState.professional, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
792
+ /* @__PURE__ */ jsx("span", { className: "flex h-7 w-7 items-center justify-center rounded-full bg-primary text-xs font-semibold text-primary-foreground", children: professionalName.charAt(0) }),
793
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground", children: professionalName })
794
+ ] }) }),
795
+ /* @__PURE__ */ jsx(C.StepRailItem, { n: 3, label: labels.railDatetime, state: railState.datetime, children: slotStart && service ? /* @__PURE__ */ jsx("p", { className: "text-sm tabular-nums text-foreground", children: formatSlotRange(slotStart, service.durationMinutes, fmt) }) : null }),
796
+ /* @__PURE__ */ jsx(C.StepRailItem, { n: 4, label: labels.railContact, state: railState.contact, children: contactSummary ? /* @__PURE__ */ jsx("p", { className: "text-sm text-foreground", children: contactSummary }) : null }),
797
+ payment ? /* @__PURE__ */ jsx(C.StepRailItem, { n: 5, label: labels.railPayment, state: railState.payment, children: paymentReached ? /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-sm text-foreground", children: [
798
+ /* @__PURE__ */ jsx(CreditCard, { className: "h-3.5 w-3.5 text-primary" }),
799
+ " Pix \xE0 vista"
800
+ ] }) : null }) : null
801
+ ] })
228
802
  ] });
229
803
  }
230
804
  function BookingWidget() {
231
805
  const {
232
806
  services,
807
+ servicesLoading,
233
808
  professionalName,
234
809
  businessHours,
235
810
  payment,
236
811
  paymentProvider,
237
812
  onIdentityVerified,
238
813
  labels,
814
+ brand,
815
+ components: C,
239
816
  window: bookingWindow,
240
817
  locale,
241
818
  currency
@@ -263,6 +840,12 @@ function BookingWidget() {
263
840
  const [charge, setCharge] = useState(null);
264
841
  const [charging, setCharging] = useState(false);
265
842
  const pollRef = useRef(null);
843
+ useEffect(() => {
844
+ if (preselected && step === "overview") {
845
+ setServiceId(preselected);
846
+ setStep("datetime");
847
+ }
848
+ }, [preselected]);
266
849
  useEffect(() => {
267
850
  if (!(step === "payment" && paymentStep === "pix" && charge && paymentProvider)) return;
268
851
  let active = true;
@@ -296,7 +879,9 @@ function BookingWidget() {
296
879
  const bookableSlots = slots.filter((s) => new Date(s.start).getTime() >= minTime);
297
880
  const service = services.find((s) => s.id === serviceId) ?? null;
298
881
  const maxWeekOffset = Math.floor(bookingWindow.maxAdvanceDays / 7);
299
- const openDays = new Set(businessHours.daysOfWeek);
882
+ function contactForSubmit() {
883
+ return { ...contact, phone: `${country.dial} ${contact.phone}` };
884
+ }
300
885
  function startBooking(id) {
301
886
  setServiceId(id ?? serviceId ?? services[0]?.id ?? null);
302
887
  setDate(todayIso);
@@ -306,7 +891,7 @@ function BookingWidget() {
306
891
  async function handleConfirm() {
307
892
  if (!serviceId || !slotStart || !contact.name.trim()) return;
308
893
  try {
309
- await submit({ serviceId, startsAt: slotStart, contact });
894
+ await submit({ serviceId, startsAt: slotStart, contact: contactForSubmit() });
310
895
  setStep("success");
311
896
  } catch {
312
897
  }
@@ -341,17 +926,17 @@ function BookingWidget() {
341
926
  setStep("payment");
342
927
  } else void handleConfirm();
343
928
  }
344
- async function payWithPix(fee, svcId, svcName) {
345
- if (charging) return;
929
+ async function payWithPix(fee) {
930
+ if (charging || !service || !slotStart) return;
346
931
  setCharging(true);
347
932
  try {
348
- await submit({ serviceId: svcId, startsAt: slotStart, contact });
933
+ await submit({ serviceId: service.id, startsAt: slotStart, contact: contactForSubmit() });
349
934
  if (paymentProvider) {
350
935
  const c = await paymentProvider.createCharge({
351
936
  amount: fee,
352
937
  currency,
353
938
  method: "pix",
354
- description: svcName,
939
+ description: service.name,
355
940
  customer: { name: contact.name, email: contact.email || void 0, phone: contact.phone || void 0 }
356
941
  });
357
942
  setCharge(c);
@@ -362,61 +947,32 @@ function BookingWidget() {
362
947
  setCharging(false);
363
948
  }
364
949
  }
950
+ function copyPixPayload() {
951
+ const payload = charge?.pixCopyPaste ?? PIX_PAYLOAD;
952
+ try {
953
+ void navigator.clipboard?.writeText(payload);
954
+ setCopied(true);
955
+ } catch {
956
+ setCopied(true);
957
+ }
958
+ }
365
959
  if (step === "overview") {
366
960
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-4xl", children: [
367
- /* @__PURE__ */ jsx(BrandHeader, {}),
368
- /* @__PURE__ */ jsxs("div", { className: "grid gap-6 lg:grid-cols-[1fr_18rem]", children: [
369
- /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
370
- /* @__PURE__ */ jsxs("section", { className: "rounded-2xl border border-border bg-card p-6 shadow-sm", children: [
371
- /* @__PURE__ */ jsx("h3", { className: "mb-4 font-heading text-lg font-bold text-foreground", children: "Servi\xE7os" }),
372
- /* @__PURE__ */ jsx("div", { className: "space-y-3", children: services.map((s, i) => /* @__PURE__ */ jsx(ServiceRow, { service: s, featured: i === 0, onSelect: () => startBooking(s.id), fmt }, s.id)) })
373
- ] }),
374
- /* @__PURE__ */ jsxs("section", { className: "rounded-2xl border border-border bg-card p-6 shadow-sm", children: [
375
- /* @__PURE__ */ jsx("h3", { className: "font-heading text-lg font-bold text-foreground", children: "Sobre" }),
376
- /* @__PURE__ */ jsxs("p", { className: "mt-3 mb-2 flex items-center gap-1.5 text-sm font-medium text-muted-foreground", children: [
377
- /* @__PURE__ */ jsx(Clock, { className: "h-4 w-4" }),
378
- " Hor\xE1rio de funcionamento"
379
- ] }),
380
- /* @__PURE__ */ jsx("ul", { className: "divide-y divide-border border-l-2 border-primary/20 pl-4", children: WEEK_ORDER.map((day) => {
381
- const open = openDays.has(day);
382
- return /* @__PURE__ */ jsxs("li", { className: "flex items-center justify-between py-2 text-sm", children: [
383
- /* @__PURE__ */ jsx("span", { className: "text-foreground", children: DAY_NAMES[day] }),
384
- /* @__PURE__ */ jsx("span", { className: open ? "tabular-nums text-foreground" : "text-muted-foreground", children: open ? `${businessHours.start} \u2013 ${businessHours.end}` : "Fechado" })
385
- ] }, day);
386
- }) })
387
- ] })
388
- ] }),
389
- /* @__PURE__ */ jsx("aside", { className: "lg:sticky lg:top-24 lg:self-start", children: /* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
390
- /* @__PURE__ */ jsx(
391
- "button",
392
- {
393
- type: "button",
394
- onClick: () => startBooking(),
395
- className: "w-full rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
396
- children: "Agendar agora"
397
- }
398
- ),
399
- /* @__PURE__ */ jsxs("div", { className: "mt-5 space-y-2 border-t border-border pt-4 text-xs text-muted-foreground", children: [
400
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2", children: [
401
- /* @__PURE__ */ jsx(Video, { className: "h-3.5 w-3.5 text-primary" }),
402
- " Consulta 100% online"
403
- ] }),
404
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2", children: [
405
- /* @__PURE__ */ jsx(MapPin, { className: "h-3.5 w-3.5 text-primary" }),
406
- " Atende todo o Brasil"
407
- ] }),
408
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2", children: [
409
- /* @__PURE__ */ jsx(CreditCard, { className: "h-3.5 w-3.5 text-primary" }),
410
- " Aceitamos Pix"
411
- ] }),
412
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2", children: [
413
- /* @__PURE__ */ jsx(User, { className: "h-3.5 w-3.5 text-primary" }),
414
- " ",
415
- professionalName
416
- ] })
417
- ] })
418
- ] }) })
419
- ] })
961
+ /* @__PURE__ */ jsx(C.BrandHeader, { brand }),
962
+ /* @__PURE__ */ jsx(
963
+ OverviewStep,
964
+ {
965
+ services,
966
+ servicesLoading,
967
+ businessHours,
968
+ professionalName,
969
+ labels,
970
+ brand,
971
+ fmt,
972
+ components: C,
973
+ onStartBooking: startBooking
974
+ }
975
+ )
420
976
  ] });
421
977
  }
422
978
  const railState = {
@@ -426,9 +982,10 @@ function BookingWidget() {
426
982
  contact: step === "payment" || step === "success" ? "done" : step === "contact" ? "active" : "todo",
427
983
  payment: step === "success" ? "done" : step === "payment" ? "active" : "todo"
428
984
  };
429
- const railTitle = step === "payment" && paymentStep === "pix" ? "Aguardando pagamento" : "Passos para agendar";
985
+ const railTitle = step === "payment" && paymentStep === "pix" ? labels.railWaitingPayment : labels.railTitle;
986
+ const contactSummary = (contact.name || contact.phone) && (step === "payment" || step === "success" || contactStep === "details") ? `${contact.name || "Contato"}${contact.phone ? ` \xB7 ${country.dial} ${contact.phone}` : ""}` : null;
430
987
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-4xl", children: [
431
- /* @__PURE__ */ jsx(BrandHeader, {}),
988
+ /* @__PURE__ */ jsx(C.BrandHeader, { brand }),
432
989
  /* @__PURE__ */ jsxs("div", { className: "grid gap-6 lg:grid-cols-[1fr_18rem]", children: [
433
990
  /* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-border bg-card p-6 md:p-7 shadow-sm", children: [
434
991
  /* @__PURE__ */ jsx("div", { className: "mb-5 flex items-center gap-1.5 lg:hidden", children: ["datetime", "contact"].map((s) => /* @__PURE__ */ jsx("span", { className: `h-1.5 flex-1 rounded-full ${railState[s] !== "todo" ? "bg-primary" : "bg-muted"}` }, s)) }),
@@ -441,470 +998,226 @@ function BookingWidget() {
441
998
  children: [
442
999
  /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }),
443
1000
  " ",
444
- step === "datetime" ? "Servi\xE7os" : "Voltar"
1001
+ step === "datetime" ? labels.backToServices : labels.back
445
1002
  ]
446
1003
  }
447
1004
  ) : null,
448
- step === "datetime" ? /* @__PURE__ */ jsxs("div", { children: [
449
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-baseline justify-between gap-2", children: [
450
- /* @__PURE__ */ jsx("h3", { className: "font-heading text-xl font-bold text-foreground", children: labels.dateStep }),
451
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
452
- /* @__PURE__ */ jsx(Clock, { className: "h-3.5 w-3.5" }),
453
- " Fuso: Hor\xE1rio de Bras\xEDlia"
454
- ] })
455
- ] }),
456
- /* @__PURE__ */ jsxs("div", { className: "mt-5 flex items-center justify-between", children: [
457
- /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold capitalize text-foreground", children: fmt.month.format(week[0].date) }),
458
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
459
- /* @__PURE__ */ jsx(
460
- "button",
461
- {
462
- type: "button",
463
- disabled: weekOffset === 0,
464
- onClick: () => setWeekOffset((w) => Math.max(0, w - 1)),
465
- className: "flex h-9 w-9 items-center justify-center rounded-lg border border-border text-foreground transition-colors hover:bg-accent disabled:opacity-40 disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
466
- "aria-label": "Semana anterior",
467
- children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
468
- }
469
- ),
470
- /* @__PURE__ */ jsx(
471
- "button",
472
- {
473
- type: "button",
474
- disabled: weekOffset >= maxWeekOffset,
475
- onClick: () => setWeekOffset((w) => Math.min(maxWeekOffset, w + 1)),
476
- className: "flex h-9 w-9 items-center justify-center rounded-lg border border-border text-foreground transition-colors hover:bg-accent disabled:opacity-40 disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
477
- "aria-label": "Pr\xF3xima semana",
478
- children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
479
- }
480
- )
481
- ] })
1005
+ step === "datetime" ? /* @__PURE__ */ jsx(
1006
+ DateTimeStep,
1007
+ {
1008
+ labels,
1009
+ fmt,
1010
+ week,
1011
+ weekOffset,
1012
+ maxWeekOffset,
1013
+ onWeekOffset: setWeekOffset,
1014
+ businessHours,
1015
+ date,
1016
+ onSelectDate: (iso) => {
1017
+ setDate(iso);
1018
+ setSlotStart(null);
1019
+ },
1020
+ slots: bookableSlots,
1021
+ slotsLoading,
1022
+ slotStart,
1023
+ onSelectSlot: setSlotStart,
1024
+ onContinue: () => setStep("contact")
1025
+ }
1026
+ ) : null,
1027
+ step === "contact" ? /* @__PURE__ */ jsx(
1028
+ ContactStep,
1029
+ {
1030
+ labels,
1031
+ contact,
1032
+ onContactChange: setContact,
1033
+ contactStep,
1034
+ country,
1035
+ onCountryChange: (iso2) => {
1036
+ const c = getCountry(iso2);
1037
+ setCountryIso(c.iso2);
1038
+ setContact((prev) => ({ ...prev, phone: maskPhone(unmaskPhone(prev.phone), c.mask) }));
1039
+ },
1040
+ code,
1041
+ onCodeChange: (v) => {
1042
+ setCode(v);
1043
+ setCodeError(false);
1044
+ },
1045
+ codeError,
1046
+ onSendCode: sendCode,
1047
+ onConfirmCode: confirmCode,
1048
+ onBackToPhone: () => setContactStep("phone"),
1049
+ onSubmitDetails: submitDetails,
1050
+ payment,
1051
+ submitting,
1052
+ error
1053
+ }
1054
+ ) : null,
1055
+ step === "payment" && service && payment ? /* @__PURE__ */ jsx(
1056
+ PaymentStep,
1057
+ {
1058
+ service,
1059
+ payment,
1060
+ paymentStep,
1061
+ charge,
1062
+ busy: submitting || charging,
1063
+ error,
1064
+ copied,
1065
+ fmt,
1066
+ onPayWithPix: (fee) => void payWithPix(fee),
1067
+ onCopy: copyPixPayload,
1068
+ onSimulatePaid: () => setStep("success")
1069
+ }
1070
+ ) : null,
1071
+ step === "success" ? /* @__PURE__ */ jsx(
1072
+ C.SuccessPanel,
1073
+ {
1074
+ service,
1075
+ slotStart,
1076
+ professionalName,
1077
+ labels,
1078
+ fmt
1079
+ }
1080
+ ) : null
1081
+ ] }),
1082
+ /* @__PURE__ */ jsx("aside", { className: "hidden lg:block", children: /* @__PURE__ */ jsx(
1083
+ SummaryRail,
1084
+ {
1085
+ title: railTitle,
1086
+ railState,
1087
+ service,
1088
+ professionalName,
1089
+ slotStart,
1090
+ contactSummary,
1091
+ payment,
1092
+ paymentReached: step === "payment" || step === "success",
1093
+ labels,
1094
+ fmt,
1095
+ components: C,
1096
+ serviceMeta: brand.serviceMeta
1097
+ }
1098
+ ) })
1099
+ ] })
1100
+ ] });
1101
+ }
1102
+ function DefaultBrandHeader({ brand }) {
1103
+ return /* @__PURE__ */ jsxs("div", { className: "mb-5 flex items-center gap-3 rounded-2xl border border-border bg-card px-5 py-4 shadow-sm", children: [
1104
+ brand.logoUrl ? /* @__PURE__ */ jsx("img", { src: brand.logoUrl, alt: brand.name, className: "h-11 w-11 rounded-xl object-cover" }) : /* @__PURE__ */ jsx("span", { className: "flex h-11 w-11 items-center justify-center rounded-xl bg-primary text-lg font-bold text-primary-foreground", children: brand.initials }),
1105
+ /* @__PURE__ */ jsxs("div", { children: [
1106
+ /* @__PURE__ */ jsx("p", { className: "font-heading text-base font-bold text-foreground", children: brand.name }),
1107
+ brand.tagline ? /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-xs text-muted-foreground", children: [
1108
+ /* @__PURE__ */ jsx(ShieldCheck, { className: "h-3.5 w-3.5 text-primary" }),
1109
+ " ",
1110
+ brand.tagline
1111
+ ] }) : null
1112
+ ] })
1113
+ ] });
1114
+ }
1115
+ function DefaultServiceCard({ service, featured, onSelect, fmt, brand }) {
1116
+ const Icon = brand.serviceIcon;
1117
+ return /* @__PURE__ */ jsxs(
1118
+ "button",
1119
+ {
1120
+ type: "button",
1121
+ onClick: onSelect,
1122
+ className: "group flex w-full items-center gap-4 rounded-2xl border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1123
+ children: [
1124
+ /* @__PURE__ */ jsx("span", { className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-accent text-primary", children: /* @__PURE__ */ jsx(Icon, { className: "h-5 w-5" }) }),
1125
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
1126
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
1127
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-foreground", children: service.name }),
1128
+ featured && brand.featuredBadge ? /* @__PURE__ */ jsx("span", { className: "rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-primary", children: brand.featuredBadge }) : null
482
1129
  ] }),
483
- /* @__PURE__ */ jsx("div", { className: "mt-3 grid grid-cols-7 gap-1.5", children: week.map((d) => {
484
- const selected = date === d.iso;
485
- const closed = !openDays.has(d.date.getDay());
486
- return /* @__PURE__ */ jsxs(
487
- "button",
488
- {
489
- type: "button",
490
- disabled: closed,
491
- onClick: () => {
492
- setDate(d.iso);
493
- setSlotStart(null);
494
- },
495
- className: [
496
- "flex flex-col items-center gap-0.5 rounded-xl border py-2.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
497
- closed ? "cursor-not-allowed border-transparent text-muted-foreground/40" : selected ? "border-primary bg-primary text-primary-foreground" : "border-border text-foreground hover:border-primary/60 hover:bg-accent/40"
498
- ].join(" "),
499
- children: [
500
- /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium capitalize opacity-80", children: fmt.weekday.format(d.date).replace(".", "") }),
501
- /* @__PURE__ */ jsx("span", { className: "text-sm font-bold tabular-nums", children: fmt.dayNum.format(d.date) })
502
- ]
503
- },
504
- d.iso
505
- );
506
- }) }),
507
- date ? /* @__PURE__ */ jsxs("div", { className: "mt-6", children: [
508
- /* @__PURE__ */ jsx("p", { className: "mb-2 text-sm font-semibold text-foreground", children: "Hor\xE1rios dispon\xEDveis" }),
509
- slotsLoading ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-2 sm:grid-cols-4", children: Array.from({ length: 8 }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "h-10 animate-pulse rounded-lg bg-muted" }, i)) }) : bookableSlots.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-dashed border-border p-6 text-center text-sm text-muted-foreground", children: "Nenhum hor\xE1rio dispon\xEDvel neste dia. Tente outra data." }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-2 sm:grid-cols-4", children: bookableSlots.map((s) => {
510
- const selected = slotStart === s.start;
511
- return /* @__PURE__ */ jsx(
512
- "button",
513
- {
514
- type: "button",
515
- onClick: () => setSlotStart(s.start),
516
- className: [
517
- "rounded-lg border py-2.5 text-sm font-semibold tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
518
- selected ? "border-primary bg-primary text-primary-foreground" : "border-border text-foreground hover:border-primary/60 hover:bg-accent/40"
519
- ].join(" "),
520
- children: fmt.time.format(new Date(s.start))
521
- },
522
- s.start
523
- );
524
- }) })
525
- ] }) : null,
526
- /* @__PURE__ */ jsx(
527
- "button",
528
- {
529
- type: "button",
530
- disabled: !slotStart,
531
- onClick: () => setStep("contact"),
532
- className: "mt-6 w-full rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
533
- children: "Continuar"
534
- }
535
- )
536
- ] }) : null,
537
- step === "contact" ? /* @__PURE__ */ jsxs("div", { children: [
538
- /* @__PURE__ */ jsx("h3", { className: "font-heading text-xl font-bold text-foreground", children: labels.contactStep }),
539
- contactStep === "phone" ? /* @__PURE__ */ jsxs("form", { onSubmit: (e) => {
540
- e.preventDefault();
541
- sendCode();
542
- }, children: [
543
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Preencha as informa\xE7\xF5es abaixo para que seu agendamento seja identificado." }),
544
- /* @__PURE__ */ jsxs("div", { className: "mt-5", children: [
545
- /* @__PURE__ */ jsx("label", { htmlFor: "bk-phone", className: "mb-1 block text-sm font-medium text-foreground", children: "Celular" }),
546
- /* @__PURE__ */ jsxs("div", { className: "flex", children: [
547
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
548
- /* @__PURE__ */ jsx(
549
- "select",
550
- {
551
- "aria-label": "Pa\xEDs",
552
- value: countryIso,
553
- onChange: (e) => {
554
- const c = getCountry(e.target.value);
555
- setCountryIso(c.iso2);
556
- setContact({ ...contact, phone: maskPhone(unmaskPhone(contact.phone), c.mask) });
557
- },
558
- className: "h-full appearance-none rounded-l-xl border border-r-0 border-border bg-muted py-3 pl-3 pr-8 text-sm font-medium text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
559
- children: COUNTRIES.map((c) => /* @__PURE__ */ jsxs("option", { value: c.iso2, children: [
560
- c.flag,
561
- " ",
562
- c.dial
563
- ] }, c.iso2))
564
- }
565
- ),
566
- /* @__PURE__ */ jsx(ChevronDown, { className: "pointer-events-none absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" })
567
- ] }),
568
- /* @__PURE__ */ jsx(
569
- "input",
570
- {
571
- id: "bk-phone",
572
- type: "tel",
573
- autoComplete: "tel",
574
- inputMode: "tel",
575
- value: contact.phone,
576
- onChange: (e) => setContact({ ...contact, phone: maskPhone(e.target.value, country.mask) }),
577
- className: "w-full rounded-r-xl border border-border bg-background px-4 py-3 text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring",
578
- placeholder: `Ex.: ${maskPhone("11987654321", country.mask)}`
579
- }
580
- )
581
- ] }),
582
- /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: "Enviaremos um c\xF3digo para confirmar que o n\xFAmero de telefone \xE9 seu. Usaremos este n\xFAmero para associar as suas informa\xE7\xF5es \xE0 sua conta." })
583
- ] }),
584
- /* @__PURE__ */ jsx(
585
- "button",
586
- {
587
- type: "submit",
588
- disabled: unmaskPhone(contact.phone).length < 8,
589
- className: "mt-5 w-full rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
590
- children: "Enviar c\xF3digo via WhatsApp"
591
- }
592
- )
593
- ] }) : null,
594
- contactStep === "details" ? /* @__PURE__ */ jsxs("form", { onSubmit: (e) => {
595
- e.preventDefault();
596
- submitDetails();
597
- }, children: [
598
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Preencha as informa\xE7\xF5es abaixo para que seu agendamento seja identificado." }),
599
- /* @__PURE__ */ jsxs("div", { className: "mt-4 flex items-center justify-between rounded-xl border border-border bg-muted/40 px-4 py-3", children: [
600
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-sm text-foreground", children: [
601
- /* @__PURE__ */ jsx(ShieldCheck, { className: "h-4 w-4 text-primary" }),
602
- " Celular verificado \xB7 ",
603
- country.flag,
604
- " ",
605
- country.dial,
606
- " ",
607
- contact.phone
608
- ] }),
609
- /* @__PURE__ */ jsx(
610
- "button",
611
- {
612
- type: "button",
613
- onClick: () => setContactStep("phone"),
614
- className: "rounded text-sm font-medium text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
615
- children: "Trocar telefone"
616
- }
617
- )
618
- ] }),
619
- /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-3", children: [
620
- /* @__PURE__ */ jsxs("div", { children: [
621
- /* @__PURE__ */ jsx("label", { htmlFor: "bk-name", className: "mb-1 block text-sm font-medium text-foreground", children: "Nome completo *" }),
622
- /* @__PURE__ */ jsx(
623
- "input",
624
- {
625
- id: "bk-name",
626
- type: "text",
627
- autoComplete: "name",
628
- value: contact.name,
629
- onChange: (e) => setContact({ ...contact, name: e.target.value }),
630
- className: "w-full rounded-xl border border-border bg-background px-4 py-3 text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring",
631
- placeholder: "Seu nome"
632
- }
633
- )
634
- ] }),
635
- /* @__PURE__ */ jsxs("div", { children: [
636
- /* @__PURE__ */ jsx("label", { htmlFor: "bk-email", className: "mb-1 block text-sm font-medium text-foreground", children: "E-mail" }),
637
- /* @__PURE__ */ jsx(
638
- "input",
639
- {
640
- id: "bk-email",
641
- type: "email",
642
- autoComplete: "email",
643
- inputMode: "email",
644
- value: contact.email,
645
- onChange: (e) => setContact({ ...contact, email: e.target.value }),
646
- className: "w-full rounded-xl border border-border bg-background px-4 py-3 text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring",
647
- placeholder: "voce@email.com"
648
- }
649
- ),
650
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Enviaremos uma confirma\xE7\xE3o e um lembrete antes do agendamento." })
651
- ] }),
652
- /* @__PURE__ */ jsxs("div", { children: [
653
- /* @__PURE__ */ jsx("label", { htmlFor: "bk-notes", className: "mb-1 block text-sm font-medium text-foreground", children: "Observa\xE7\xE3o" }),
654
- /* @__PURE__ */ jsx(
655
- "textarea",
656
- {
657
- id: "bk-notes",
658
- rows: 3,
659
- value: contact.notes,
660
- onChange: (e) => setContact({ ...contact, notes: e.target.value }),
661
- className: "w-full resize-none rounded-xl border border-border bg-background px-4 py-3 text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring",
662
- placeholder: "Use esse espa\xE7o para deixar uma observa\xE7\xE3o sobre este agendamento"
663
- }
664
- )
665
- ] })
666
- ] }),
667
- error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "mt-3 text-sm text-destructive", children: "N\xE3o foi poss\xEDvel concluir o agendamento. Tente novamente." }) : null,
668
- /* @__PURE__ */ jsxs(
669
- "button",
670
- {
671
- type: "submit",
672
- disabled: !contact.name.trim() || submitting,
673
- className: "mt-5 flex w-full items-center justify-center gap-2 rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
674
- children: [
675
- submitting ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }),
676
- payment ? "Salvar e continuar" : labels.confirmCta
677
- ]
678
- }
679
- ),
680
- !payment ? /* @__PURE__ */ jsxs("p", { className: "mt-3 flex items-center justify-center gap-1.5 text-xs text-muted-foreground", children: [
681
- /* @__PURE__ */ jsx(CreditCard, { className: "h-3.5 w-3.5" }),
682
- " Pagamento via Pix \xB7 Sem cobran\xE7a agora"
683
- ] }) : null
684
- ] }) : null
685
- ] }) : null,
686
- step === "contact" && contactStep === "code" ? /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-foreground/40 p-4", role: "dialog", "aria-modal": "true", "aria-label": "Verifica\xE7\xE3o de c\xF3digo", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-xl", children: [
687
- /* @__PURE__ */ jsx("h4", { className: "font-heading text-lg font-bold text-foreground", children: "Insira o c\xF3digo" }),
688
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Enviamos um c\xF3digo via WhatsApp para voc\xEA confirmar seu n\xFAmero." }),
689
- /* @__PURE__ */ jsxs("form", { onSubmit: (e) => {
690
- e.preventDefault();
691
- confirmCode();
692
- }, children: [
693
- /* @__PURE__ */ jsx(
694
- "input",
695
- {
696
- type: "text",
697
- inputMode: "numeric",
698
- value: code,
699
- autoFocus: true,
700
- onChange: (e) => {
701
- setCode(e.target.value);
702
- setCodeError(false);
703
- },
704
- className: "mt-4 w-full rounded-xl border border-border bg-background px-4 py-3 text-center text-lg tracking-[0.4em] text-foreground outline-none transition-colors focus:border-primary focus-visible:ring-2 focus-visible:ring-ring placeholder:text-sm placeholder:tracking-normal",
705
- placeholder: "Digite o c\xF3digo"
706
- }
707
- ),
708
- codeError ? /* @__PURE__ */ jsx("p", { role: "alert", className: "mt-2 text-sm text-destructive", children: "C\xF3digo inv\xE1lido. Para testar, use 0000." }) : null,
709
- /* @__PURE__ */ jsx(
710
- "button",
711
- {
712
- type: "submit",
713
- className: "mt-4 w-full rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
714
- children: "Confirmar"
715
- }
716
- )
1130
+ /* @__PURE__ */ jsxs("span", { className: "mt-0.5 flex items-center gap-1 text-xs text-muted-foreground", children: [
1131
+ /* @__PURE__ */ jsx(Clock, { className: "h-3 w-3" }),
1132
+ " ",
1133
+ service.durationMinutes,
1134
+ " min",
1135
+ brand.serviceMeta ? ` \xB7 ${brand.serviceMeta}` : ""
717
1136
  ] }),
718
- /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between text-xs text-muted-foreground", children: [
719
- /* @__PURE__ */ jsx("span", { children: "Reenviar c\xF3digo via WhatsApp em 28 segundos." }),
720
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setContactStep("phone"), className: "font-medium text-primary hover:underline", children: "Voltar" })
721
- ] })
722
- ] }) }) : null,
723
- step === "payment" && service ? (() => {
724
- const feePct = payment?.reservationFeePercent ?? 100;
725
- const fee = Math.round(service.price * feePct) / 100;
726
- const remaining = Math.round((service.price - fee) * 100) / 100;
727
- return /* @__PURE__ */ jsx("div", { children: paymentStep === "choose" ? /* @__PURE__ */ jsxs("div", { children: [
728
- /* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-border p-4", children: [
729
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between font-semibold text-foreground", children: [
730
- /* @__PURE__ */ jsx("span", { children: service.name }),
731
- /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: fmt.price.format(service.price) })
732
- ] }),
733
- /* @__PURE__ */ jsxs("div", { className: "mt-3 space-y-2 text-sm", children: [
734
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-foreground", children: [
735
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
736
- /* @__PURE__ */ jsx("span", { className: "flex h-4 w-4 items-center justify-center rounded bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }) }),
737
- "Taxa de reserva ",
738
- /* @__PURE__ */ jsxs("span", { className: "rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground", children: [
739
- feePct,
740
- "%"
741
- ] })
742
- ] }),
743
- /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: fmt.price.format(fee) })
744
- ] }),
745
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-muted-foreground", children: [
746
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
747
- /* @__PURE__ */ jsx("span", { className: "h-4 w-4 rounded border border-border" }),
748
- " Valor restante"
749
- ] }),
750
- /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: remaining <= 0 ? "Gr\xE1tis" : fmt.price.format(remaining) })
751
- ] }),
752
- /* @__PURE__ */ jsxs("button", { type: "button", className: "flex items-center gap-1 text-sm font-medium text-primary hover:underline", children: [
753
- /* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5" }),
754
- " Adicionar cupom"
755
- ] })
756
- ] }),
757
- /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between border-t border-dashed border-border pt-3 font-semibold text-foreground", children: [
758
- /* @__PURE__ */ jsx("span", { children: "Valor total" }),
759
- /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: fmt.price.format(service.price) })
760
- ] })
761
- ] }),
762
- /* @__PURE__ */ jsxs("div", { className: "mt-6 flex items-center justify-between", children: [
763
- /* @__PURE__ */ jsx("h3", { className: "font-heading text-lg font-bold text-foreground", children: "Escolha como pagar" }),
764
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
765
- /* @__PURE__ */ jsx(ShieldCheck, { className: "h-3.5 w-3.5 text-primary" }),
766
- " Pagamento seguro"
767
- ] })
768
- ] }),
769
- /* @__PURE__ */ jsxs("div", { className: "mt-3 rounded-2xl border-2 border-primary bg-accent/20 p-4", children: [
770
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 font-semibold text-foreground", children: [
771
- /* @__PURE__ */ jsx("span", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" }) }),
772
- "Pix"
773
- ] }),
774
- /* @__PURE__ */ jsx("div", { className: "mt-4 grid grid-cols-1 gap-4 sm:grid-cols-3", children: [
775
- { icon: Check, t: 'Finalize o agendamento clicando em "Pagar com Pix".' },
776
- { icon: QrCode, t: "Mostraremos um QR Code e o Pix copia-e-cola." },
777
- { icon: CalendarCheck, t: "Ap\xF3s o pagamento, seu agendamento \xE9 reservado." }
778
- ].map((s, i) => /* @__PURE__ */ jsxs("div", { className: "text-sm text-muted-foreground", children: [
779
- /* @__PURE__ */ jsx("span", { className: "mb-2 flex h-8 w-8 items-center justify-center rounded-lg bg-accent text-primary", children: /* @__PURE__ */ jsx(s.icon, { className: "h-4 w-4" }) }),
780
- /* @__PURE__ */ jsxs("span", { className: "font-semibold text-foreground", children: [
781
- i + 1,
782
- "."
783
- ] }),
784
- " ",
785
- s.t
786
- ] }, i)) })
787
- ] }),
788
- error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "mt-3 text-sm text-destructive", children: "N\xE3o foi poss\xEDvel iniciar o pagamento. Tente novamente." }) : null,
789
- /* @__PURE__ */ jsxs(
790
- "button",
791
- {
792
- type: "button",
793
- disabled: submitting || charging,
794
- onClick: () => void payWithPix(fee, service.id, service.name),
795
- className: "mt-6 flex w-full items-center justify-center gap-2 rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
796
- children: [
797
- submitting || charging ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(CreditCard, { className: "h-4 w-4" }),
798
- "Pagar ",
799
- fmt.price.format(fee),
800
- " com Pix"
801
- ]
802
- }
803
- )
804
- ] }) : (
805
- /* Pix QR — aguardando pagamento */
806
- /* @__PURE__ */ jsxs("div", { children: [
807
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-amber-300/60 bg-amber-50 p-4 dark:border-amber-400/30 dark:bg-amber-950/30", children: [
808
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 text-sm font-semibold text-foreground", children: [
809
- /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }),
810
- " Realize o pagamento para finalizar"
811
- ] }),
812
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Este c\xF3digo Pix \xE9 v\xE1lido por somente 5 minutos. N\xE3o feche esta p\xE1gina at\xE9 receber a confirma\xE7\xE3o do pagamento." })
813
- ] }),
814
- /* @__PURE__ */ jsx("h3", { className: "mt-6 font-heading text-lg font-bold text-foreground", children: "Escaneie ou copie este c\xF3digo para pagar" }),
815
- /* @__PURE__ */ jsxs("ol", { className: "mt-2 space-y-1 text-sm text-muted-foreground", children: [
816
- /* @__PURE__ */ jsx("li", { children: "1. Acesse o app do seu banco, pagamentos ou Internet Banking." }),
817
- /* @__PURE__ */ jsx("li", { children: "2. Escolha pagar via Pix." }),
818
- /* @__PURE__ */ jsx("li", { children: "3. Escaneie o QR Code ou use o Pix copia-e-cola:" })
819
- ] }),
820
- /* @__PURE__ */ jsx("div", { className: "mt-4 w-fit rounded-xl border border-border bg-white p-3", children: /* @__PURE__ */ jsx(QrPlaceholder, { data: charge?.pixQrCode ?? PIX_PAYLOAD }) }),
821
- /* @__PURE__ */ jsxs("div", { className: "mt-4 flex max-w-md items-center gap-2", children: [
822
- /* @__PURE__ */ jsx("code", { className: "flex-1 truncate rounded-lg border border-border bg-muted px-3 py-2 text-xs text-muted-foreground", children: charge?.pixCopyPaste ?? PIX_PAYLOAD }),
823
- /* @__PURE__ */ jsxs(
824
- "button",
825
- {
826
- type: "button",
827
- onClick: () => {
828
- const payload = charge?.pixCopyPaste ?? PIX_PAYLOAD;
829
- try {
830
- void navigator.clipboard?.writeText(payload);
831
- setCopied(true);
832
- } catch {
833
- setCopied(true);
834
- }
835
- },
836
- className: "inline-flex shrink-0 items-center gap-1.5 rounded-lg bg-foreground px-3 py-2 text-xs font-medium text-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
837
- children: [
838
- copied ? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" }),
839
- " ",
840
- copied ? "Copiado" : "Copiar"
841
- ]
842
- }
843
- )
844
- ] }),
845
- /* @__PURE__ */ jsx(
846
- "button",
847
- {
848
- type: "button",
849
- onClick: () => setStep("success"),
850
- className: "mt-6 w-full rounded-xl border border-primary py-3 font-semibold text-primary transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
851
- children: "J\xE1 paguei \u2014 confirmar (simula\xE7\xE3o)"
852
- }
853
- )
854
- ] })
855
- ) });
856
- })() : null,
857
- step === "success" ? /* @__PURE__ */ jsxs("div", { className: "py-8 text-center", children: [
858
- /* @__PURE__ */ jsx("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-accent text-primary", children: /* @__PURE__ */ jsx(Check, { className: "h-8 w-8" }) }),
859
- /* @__PURE__ */ jsx("h3", { className: "font-heading text-2xl font-bold text-foreground", children: labels.successTitle }),
860
- /* @__PURE__ */ jsx("p", { className: "mx-auto mt-2 max-w-sm text-muted-foreground", children: labels.successBody }),
861
- service && slotStart ? /* @__PURE__ */ jsxs("div", { className: "mx-auto mt-6 max-w-sm rounded-2xl border border-border bg-muted/50 p-4 text-left", children: [
862
- /* @__PURE__ */ jsx("p", { className: "font-semibold text-foreground", children: service.name }),
863
- /* @__PURE__ */ jsxs("p", { className: "mt-1 flex items-center gap-1.5 text-sm tabular-nums text-muted-foreground", children: [
864
- /* @__PURE__ */ jsx(Calendar, { className: "h-4 w-4 text-primary" }),
865
- " ",
866
- formatSlotRange(slotStart, service.durationMinutes, fmt)
867
- ] }),
868
- /* @__PURE__ */ jsxs("p", { className: "mt-1 flex items-center gap-1.5 text-sm text-muted-foreground", children: [
869
- /* @__PURE__ */ jsx(User, { className: "h-4 w-4 text-primary" }),
870
- " ",
871
- professionalName
872
- ] })
873
- ] }) : null
874
- ] }) : null
875
- ] }),
876
- /* @__PURE__ */ jsx("aside", { className: "hidden lg:block", children: /* @__PURE__ */ jsxs("div", { className: "sticky top-24 rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
877
- /* @__PURE__ */ jsx("p", { className: "mb-5 font-heading text-sm font-bold uppercase tracking-wide text-muted-foreground", children: railTitle }),
878
- /* @__PURE__ */ jsxs("ol", { className: "space-y-6", children: [
879
- /* @__PURE__ */ jsx(StepRail, { n: 1, label: "Servi\xE7o", state: railState.service, children: service ? /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-border bg-background p-3", children: [
880
- /* @__PURE__ */ jsx("p", { className: "truncate text-sm font-semibold text-foreground", children: service.name }),
881
- /* @__PURE__ */ jsxs("p", { className: "mt-0.5 flex items-center justify-between text-xs text-muted-foreground", children: [
882
- /* @__PURE__ */ jsxs("span", { children: [
883
- "Online \xB7 ",
884
- service.durationMinutes,
885
- " min"
886
- ] }),
887
- /* @__PURE__ */ jsx("span", { className: "font-semibold tabular-nums text-primary", children: fmt.price.format(service.price) })
888
- ] })
889
- ] }) : null }),
890
- /* @__PURE__ */ jsx(StepRail, { n: 2, label: "Profissional", state: railState.professional, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
891
- /* @__PURE__ */ jsx("span", { className: "flex h-7 w-7 items-center justify-center rounded-full bg-primary text-xs font-semibold text-primary-foreground", children: professionalName.charAt(0) }),
892
- /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground", children: professionalName })
893
- ] }) }),
894
- /* @__PURE__ */ jsx(StepRail, { n: 3, label: "Data e hor\xE1rio", state: railState.datetime, children: slotStart && service ? /* @__PURE__ */ jsx("p", { className: "text-sm tabular-nums text-foreground", children: formatSlotRange(slotStart, service.durationMinutes, fmt) }) : null }),
895
- /* @__PURE__ */ jsx(StepRail, { n: 4, label: "Informa\xE7\xF5es pessoais", state: railState.contact, children: (contact.name || contact.phone) && (step === "payment" || step === "success" || contactStep === "details") ? /* @__PURE__ */ jsxs("p", { className: "text-sm text-foreground", children: [
896
- contact.name || "Contato",
897
- contact.phone ? ` \xB7 ${country.dial} ${contact.phone}` : ""
898
- ] }) : null }),
899
- payment ? /* @__PURE__ */ jsx(StepRail, { n: 5, label: "Pagamento", state: railState.payment, children: step === "payment" || step === "success" ? /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-sm text-foreground", children: [
900
- /* @__PURE__ */ jsx(CreditCard, { className: "h-3.5 w-3.5 text-primary" }),
901
- " Pix \xE0 vista"
902
- ] }) : null }) : null
1137
+ service.description ? /* @__PURE__ */ jsx("span", { className: "mt-1 block text-sm text-muted-foreground", children: service.description }) : null
1138
+ ] }),
1139
+ /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-right", children: [
1140
+ /* @__PURE__ */ jsx("span", { className: "block font-semibold tabular-nums text-primary", children: fmt.price.format(service.price) }),
1141
+ /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto mt-1 h-4 w-4 text-muted-foreground transition-transform group-hover:translate-x-0.5" })
903
1142
  ] })
904
- ] }) })
1143
+ ]
1144
+ }
1145
+ );
1146
+ }
1147
+ function DefaultSidebarExtras({ professionalName, brand, onStartBooking, labels }) {
1148
+ return /* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
1149
+ /* @__PURE__ */ jsx(
1150
+ "button",
1151
+ {
1152
+ type: "button",
1153
+ onClick: onStartBooking,
1154
+ className: "w-full rounded-xl bg-primary py-3 font-semibold text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1155
+ children: labels.bookNowCta
1156
+ }
1157
+ ),
1158
+ /* @__PURE__ */ jsxs("div", { className: "mt-5 space-y-2 border-t border-border pt-4 text-xs text-muted-foreground", children: [
1159
+ brand.highlights.map((h, i) => {
1160
+ const Icon = h.icon ?? User;
1161
+ return /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2", children: [
1162
+ /* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5 text-primary" }),
1163
+ " ",
1164
+ h.text
1165
+ ] }, i);
1166
+ }),
1167
+ /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2", children: [
1168
+ /* @__PURE__ */ jsx(User, { className: "h-3.5 w-3.5 text-primary" }),
1169
+ " ",
1170
+ professionalName
1171
+ ] })
905
1172
  ] })
906
1173
  ] });
907
1174
  }
1175
+ function DefaultStepRailItem({ n, label, state, children }) {
1176
+ return /* @__PURE__ */ jsxs("li", { className: "relative pl-11", children: [
1177
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "absolute left-[15px] top-8 bottom-[-18px] w-px bg-border last:hidden" }),
1178
+ /* @__PURE__ */ jsx(
1179
+ "span",
1180
+ {
1181
+ className: [
1182
+ "absolute left-0 top-0 flex h-8 w-8 items-center justify-center rounded-full text-sm font-semibold transition-colors",
1183
+ state === "done" ? "bg-primary text-primary-foreground" : state === "active" ? "bg-accent text-primary ring-2 ring-primary" : "bg-muted text-muted-foreground"
1184
+ ].join(" "),
1185
+ children: state === "done" ? /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) : n
1186
+ }
1187
+ ),
1188
+ /* @__PURE__ */ jsx("p", { className: `pt-1 text-sm font-semibold ${state === "todo" ? "text-muted-foreground" : "text-foreground"}`, children: label }),
1189
+ children ? /* @__PURE__ */ jsx("div", { className: "mt-2", children }) : null
1190
+ ] });
1191
+ }
1192
+ function DefaultSuccessPanel({ service, slotStart, professionalName, labels, fmt }) {
1193
+ return /* @__PURE__ */ jsxs("div", { className: "py-8 text-center", children: [
1194
+ /* @__PURE__ */ jsx("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-accent text-primary", children: /* @__PURE__ */ jsx(Check, { className: "h-8 w-8" }) }),
1195
+ /* @__PURE__ */ jsx("h3", { className: "font-heading text-2xl font-bold text-foreground", children: labels.successTitle }),
1196
+ /* @__PURE__ */ jsx("p", { className: "mx-auto mt-2 max-w-sm text-muted-foreground", children: labels.successBody }),
1197
+ service && slotStart ? /* @__PURE__ */ jsxs("div", { className: "mx-auto mt-6 max-w-sm rounded-2xl border border-border bg-muted/50 p-4 text-left", children: [
1198
+ /* @__PURE__ */ jsx("p", { className: "font-semibold text-foreground", children: service.name }),
1199
+ /* @__PURE__ */ jsxs("p", { className: "mt-1 flex items-center gap-1.5 text-sm tabular-nums text-muted-foreground", children: [
1200
+ /* @__PURE__ */ jsx(Calendar, { className: "h-4 w-4 text-primary" }),
1201
+ " ",
1202
+ formatSlotRange(slotStart, service.durationMinutes, fmt)
1203
+ ] }),
1204
+ /* @__PURE__ */ jsxs("p", { className: "mt-1 flex items-center gap-1.5 text-sm text-muted-foreground", children: [
1205
+ /* @__PURE__ */ jsx(User, { className: "h-4 w-4 text-primary" }),
1206
+ " ",
1207
+ professionalName
1208
+ ] })
1209
+ ] }) : null
1210
+ ] });
1211
+ }
1212
+
1213
+ // src/public/components/defaults.ts
1214
+ var DEFAULT_BOOKING_COMPONENTS = {
1215
+ BrandHeader: DefaultBrandHeader,
1216
+ ServiceCard: DefaultServiceCard,
1217
+ SidebarExtras: DefaultSidebarExtras,
1218
+ StepRailItem: DefaultStepRailItem,
1219
+ SuccessPanel: DefaultSuccessPanel
1220
+ };
908
1221
 
909
1222
  // src/public/createPublicBookingPlugin.ts
910
1223
  var DEFAULT_LABELS = {
@@ -914,10 +1227,71 @@ var DEFAULT_LABELS = {
914
1227
  contactStep: "Seus dados",
915
1228
  confirmCta: "Confirmar agendamento",
916
1229
  successTitle: "Agendamento confirmado!",
917
- successBody: "Voc\xEA receber\xE1 os detalhes em breve. At\xE9 logo!"
1230
+ successBody: "Voc\xEA receber\xE1 os detalhes em breve. At\xE9 logo!",
1231
+ // overview
1232
+ servicesHeading: "Servi\xE7os",
1233
+ aboutHeading: "Sobre",
1234
+ openingHoursHeading: "Hor\xE1rio de funcionamento",
1235
+ closedLabel: "Fechado",
1236
+ bookNowCta: "Agendar agora",
1237
+ // datetime
1238
+ timezoneNote: "Fuso: Hor\xE1rio de Bras\xEDlia",
1239
+ slotsHeading: "Hor\xE1rios dispon\xEDveis",
1240
+ noSlots: "Nenhum hor\xE1rio dispon\xEDvel neste dia. Tente outra data.",
1241
+ continueCta: "Continuar",
1242
+ backToServices: "Servi\xE7os",
1243
+ back: "Voltar",
1244
+ prevWeek: "Semana anterior",
1245
+ nextWeek: "Pr\xF3xima semana",
1246
+ // contact
1247
+ contactIntro: "Preencha as informa\xE7\xF5es abaixo para que seu agendamento seja identificado.",
1248
+ phoneLabel: "Celular",
1249
+ phoneHint: "Enviaremos um c\xF3digo para confirmar que o n\xFAmero de telefone \xE9 seu. Usaremos este n\xFAmero para associar as suas informa\xE7\xF5es \xE0 sua conta.",
1250
+ sendCodeCta: "Enviar c\xF3digo via WhatsApp",
1251
+ codeTitle: "Insira o c\xF3digo",
1252
+ codeBody: "Enviamos um c\xF3digo via WhatsApp para voc\xEA confirmar seu n\xFAmero.",
1253
+ codeInvalid: "C\xF3digo inv\xE1lido. Para testar, use 0000.",
1254
+ codeConfirmCta: "Confirmar",
1255
+ codeResendHint: "Reenviar c\xF3digo via WhatsApp em 28 segundos.",
1256
+ phoneVerified: "Celular verificado",
1257
+ changePhone: "Trocar telefone",
1258
+ nameLabel: "Nome completo *",
1259
+ namePlaceholder: "Seu nome",
1260
+ emailLabel: "E-mail",
1261
+ emailPlaceholder: "voce@email.com",
1262
+ emailHint: "Enviaremos uma confirma\xE7\xE3o e um lembrete antes do agendamento.",
1263
+ notesLabel: "Observa\xE7\xE3o",
1264
+ notesPlaceholder: "Use esse espa\xE7o para deixar uma observa\xE7\xE3o sobre este agendamento",
1265
+ saveAndContinueCta: "Salvar e continuar",
1266
+ submitError: "N\xE3o foi poss\xEDvel concluir o agendamento. Tente novamente.",
1267
+ noChargeNote: "Pagamento via Pix \xB7 Sem cobran\xE7a agora",
1268
+ // right rail
1269
+ railTitle: "Passos para agendar",
1270
+ railWaitingPayment: "Aguardando pagamento",
1271
+ railService: "Servi\xE7o",
1272
+ railProfessional: "Profissional",
1273
+ railDatetime: "Data e hor\xE1rio",
1274
+ railContact: "Informa\xE7\xF5es pessoais",
1275
+ railPayment: "Pagamento"
918
1276
  };
919
1277
  var DEFAULT_WINDOW = { minAdvanceHours: 2, maxAdvanceDays: 21, slotInterval: 30 };
920
1278
  var DEFAULT_HOURS = { daysOfWeek: [1, 2, 3, 4, 5, 6], start: "09:00", end: "18:00" };
1279
+ function resolveBrand(brand, labels) {
1280
+ const name = brand?.name ?? labels.title;
1281
+ return {
1282
+ name,
1283
+ initials: brand?.initials ?? name.charAt(0).toUpperCase(),
1284
+ logoUrl: brand?.logoUrl,
1285
+ tagline: brand?.tagline === void 0 ? "Agendamento online seguro" : brand.tagline,
1286
+ serviceIcon: brand?.serviceIcon ?? Video,
1287
+ serviceMeta: brand?.serviceMeta === void 0 ? "Online" : brand.serviceMeta,
1288
+ featuredBadge: brand?.featuredBadge === void 0 ? "Mais procurado" : brand.featuredBadge,
1289
+ highlights: brand?.highlights ?? [
1290
+ { icon: CalendarCheck, text: "Confirma\xE7\xE3o imediata" },
1291
+ { icon: ShieldCheck, text: "Agendamento seguro" }
1292
+ ]
1293
+ };
1294
+ }
921
1295
  var scheduleId = 0;
922
1296
  function buildSchedules(professionalId, hours) {
923
1297
  return hours.daysOfWeek.map((day) => ({
@@ -936,19 +1310,23 @@ function buildSchedules(professionalId, hours) {
936
1310
  }
937
1311
  function createPublicBookingPlugin(options) {
938
1312
  const basePath = options.basePath ?? "/agendar";
939
- const professionalId = options.professional?.id ?? "dr-hiago";
1313
+ const mockProfessionalId = options.professional?.id ?? "pro-1";
1314
+ const professionalId = options.professional?.id ?? null;
940
1315
  const professionalName = options.professional?.name ?? "Especialista";
941
1316
  const window2 = { ...DEFAULT_WINDOW, ...options.window };
942
1317
  const labels = { ...DEFAULT_LABELS, ...options.labels };
1318
+ const brand = resolveBrand(options.brand, labels);
1319
+ const components = { ...DEFAULT_BOOKING_COMPONENTS, ...options.components };
943
1320
  const currency = options.currency ?? "BRL";
944
1321
  const locale = options.locale ?? "pt-BR";
945
1322
  const hours = options.workingHours ?? DEFAULT_HOURS;
1323
+ const staticServices = options.services ?? null;
946
1324
  const payment = options.payment?.enabled ? {
947
1325
  reservationFeePercent: options.payment.reservationFeePercent ?? 100,
948
1326
  method: options.payment.method ?? "pix"
949
1327
  } : null;
950
1328
  const professional = {
951
- id: professionalId,
1329
+ id: mockProfessionalId,
952
1330
  name: professionalName,
953
1331
  avatarUrl: null,
954
1332
  locationId: null,
@@ -957,28 +1335,40 @@ function createPublicBookingPlugin(options) {
957
1335
  };
958
1336
  const mockSeed = options.seed ?? {
959
1337
  professionals: [professional],
960
- schedules: buildSchedules(professionalId, hours),
1338
+ schedules: buildSchedules(mockProfessionalId, hours),
961
1339
  bookings: []
962
1340
  };
963
1341
  const provider = options.dataProvider ?? createSafeDataProvider(
964
- () => createSupabaseAgendaProvider(),
965
- () => createMockAgendaProvider({ seed: mockSeed })
1342
+ () => {
1343
+ if (!options.tenantId) {
1344
+ throw new Error(
1345
+ "[plugin-agenda/public] `tenantId` is required when a Supabase client is configured (setGlobalSupabaseClient)."
1346
+ );
1347
+ }
1348
+ return createSupabasePublicBookingProvider({ tenantId: options.tenantId });
1349
+ },
1350
+ () => createMockPublicBookingProvider({
1351
+ seed: mockSeed,
1352
+ services: staticServices ?? [],
1353
+ professionalId: mockProfessionalId
1354
+ })
966
1355
  );
967
- const value = {
1356
+ const base = {
968
1357
  provider,
969
1358
  professionalId,
970
1359
  professionalName,
971
- services: options.services,
972
1360
  businessHours: hours,
973
1361
  payment,
974
1362
  paymentProvider: options.paymentProvider ?? null,
975
1363
  onIdentityVerified: options.onIdentityVerified ?? null,
976
1364
  window: window2,
977
1365
  labels,
1366
+ brand,
1367
+ components,
978
1368
  currency,
979
1369
  locale
980
1370
  };
981
- const Provider = ({ children }) => createElement(BookingProvider, { value, children });
1371
+ const Provider = ({ children }) => createElement(BookingProvider, { base, staticServices, children });
982
1372
  Provider.displayName = "PublicBookingProvider";
983
1373
  const BookingScreen = () => createElement(
984
1374
  "section",
@@ -994,7 +1384,7 @@ function createPublicBookingPlugin(options) {
994
1384
  id: "booking",
995
1385
  name: "Agendamento",
996
1386
  icon: "CalendarCheck",
997
- version: "0.1.0",
1387
+ version: "0.3.0",
998
1388
  scope: options.scope ?? "universal",
999
1389
  verticalId: options.verticalId,
1000
1390
  scaffolds: ["website", "landing_page"],
@@ -1007,6 +1397,6 @@ function createPublicBookingPlugin(options) {
1007
1397
  return { manifest, Provider, dataProvider: provider };
1008
1398
  }
1009
1399
 
1010
- export { BookingProvider, BookingWidget, createPublicBookingPlugin, useAvailableSlots, useBooking, useCreateBooking, useServices };
1400
+ export { BookingProvider, BookingWidget, DAY_NAMES, DEFAULT_BOOKING_COMPONENTS, DefaultBrandHeader, DefaultServiceCard, DefaultSidebarExtras, DefaultStepRailItem, DefaultSuccessPanel, WEEK_ORDER, createMockPublicBookingProvider, createPublicBookingPlugin, createSupabasePublicBookingProvider, formatSlotRange, useAvailableSlots, useBooking, useCreateBooking, useFormatters, usePublicServices, useServices };
1011
1401
  //# sourceMappingURL=index.js.map
1012
1402
  //# sourceMappingURL=index.js.map