@instockng/storefront-ui 1.0.107 → 1.0.109

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 (228) hide show
  1. package/dist/components/AssistantDrawer.d.ts +1 -3
  2. package/dist/components/AssistantDrawer.d.ts.map +1 -1
  3. package/dist/components/ProductAssistantChips.d.ts +9 -8
  4. package/dist/components/ProductAssistantChips.d.ts.map +1 -1
  5. package/dist/contexts/AssistantContext.d.ts +19 -0
  6. package/dist/contexts/AssistantContext.d.ts.map +1 -0
  7. package/dist/index.d.ts +1 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.mjs +56 -56
  10. package/dist/index10.mjs +103 -73
  11. package/dist/index100.mjs +28 -8
  12. package/dist/index101.mjs +8 -74
  13. package/dist/index102.mjs +74 -3
  14. package/dist/index103.mjs +4 -2
  15. package/dist/index104.mjs +2 -83
  16. package/dist/index105.mjs +81 -52
  17. package/dist/index106.mjs +53 -5
  18. package/dist/index107.mjs +5 -4
  19. package/dist/index108.mjs +4 -178
  20. package/dist/index109.mjs +174 -48
  21. package/dist/index11.mjs +73 -189
  22. package/dist/index110.mjs +51 -67
  23. package/dist/index111.mjs +69 -2
  24. package/dist/index112.mjs +2 -37
  25. package/dist/index113.mjs +25 -40
  26. package/dist/index114.mjs +18 -2
  27. package/dist/index115.mjs +213 -26
  28. package/dist/index116.mjs +175 -13
  29. package/dist/index117.mjs +17 -210
  30. package/dist/index118.mjs +17 -174
  31. package/dist/index119.mjs +25 -14
  32. package/dist/index12.mjs +171 -106
  33. package/dist/index120.mjs +150 -17
  34. package/dist/index121.mjs +13 -26
  35. package/dist/index122.mjs +24 -149
  36. package/dist/index123.mjs +77 -13
  37. package/dist/index124.mjs +27 -20
  38. package/dist/index125.mjs +137 -76
  39. package/dist/index126.mjs +50 -33
  40. package/dist/index127.mjs +19 -141
  41. package/dist/index128.mjs +22 -50
  42. package/dist/index129.mjs +14 -14
  43. package/dist/index13.mjs +127 -98
  44. package/dist/index130.mjs +18 -20
  45. package/dist/index131.mjs +14 -16
  46. package/dist/index132.mjs +14 -17
  47. package/dist/index133.mjs +12 -12
  48. package/dist/index134.mjs +58 -15
  49. package/dist/index135.mjs +11 -14
  50. package/dist/index136.mjs +30 -56
  51. package/dist/index137.mjs +15 -9
  52. package/dist/index138.mjs +26 -31
  53. package/dist/index139.mjs +16 -13
  54. package/dist/index14.mjs +94 -90
  55. package/dist/index140.mjs +11 -26
  56. package/dist/index141.mjs +12 -18
  57. package/dist/index142.mjs +40 -12
  58. package/dist/index143.mjs +16 -14
  59. package/dist/index144.mjs +263 -42
  60. package/dist/index145.mjs +62 -15
  61. package/dist/index146.mjs +7 -267
  62. package/dist/index147.mjs +2 -70
  63. package/dist/index148.mjs +2 -8
  64. package/dist/index149.mjs +33 -2
  65. package/dist/index15.mjs +84 -149
  66. package/dist/index150.mjs +2 -2
  67. package/dist/index151.mjs +37 -33
  68. package/dist/index152.mjs +43 -2
  69. package/dist/index153.mjs +2 -21
  70. package/dist/index154.mjs +19 -54
  71. package/dist/index155.mjs +55 -28
  72. package/dist/index156.mjs +28 -6
  73. package/dist/index157.mjs +6 -51
  74. package/dist/index158.mjs +51 -5
  75. package/dist/index159.mjs +6 -12
  76. package/dist/index16.mjs +157 -203
  77. package/dist/index160.mjs +12 -7
  78. package/dist/index161.mjs +6 -27
  79. package/dist/index162.mjs +28 -2
  80. package/dist/index163.mjs +2 -70
  81. package/dist/index164.mjs +67 -164
  82. package/dist/index165.mjs +167 -2
  83. package/dist/index167.mjs +2 -2
  84. package/dist/index168.mjs +2 -18
  85. package/dist/index169.mjs +11 -25
  86. package/dist/index17.mjs +197 -106
  87. package/dist/index170.mjs +26 -32
  88. package/dist/index171.mjs +32 -12
  89. package/dist/index172.mjs +9 -9
  90. package/dist/index173.mjs +18 -2
  91. package/dist/index174.mjs +2 -20
  92. package/dist/index175.mjs +13 -39
  93. package/dist/index176.mjs +46 -2
  94. package/dist/index177.mjs +2 -30
  95. package/dist/index178.mjs +24 -12
  96. package/dist/index179.mjs +18 -2
  97. package/dist/index18.mjs +96 -129
  98. package/dist/index180.mjs +2 -2
  99. package/dist/index181.mjs +2 -2
  100. package/dist/index182.mjs +2 -2
  101. package/dist/index183.mjs +2 -72
  102. package/dist/index184.mjs +72 -2
  103. package/dist/index185.mjs +2 -53
  104. package/dist/index186.mjs +53 -2
  105. package/dist/index187.mjs +2 -36
  106. package/dist/index188.mjs +30 -146
  107. package/dist/index189.mjs +152 -2
  108. package/dist/index19.mjs +140 -87
  109. package/dist/index190.mjs +2 -2
  110. package/dist/index191.mjs +2 -19
  111. package/dist/index192.mjs +19 -2
  112. package/dist/index193.mjs +2 -2
  113. package/dist/index194.mjs +2 -26
  114. package/dist/index195.mjs +26 -2
  115. package/dist/index196.mjs +2 -2
  116. package/dist/index197.mjs +2 -24
  117. package/dist/index198.mjs +17 -16
  118. package/dist/index199.mjs +23 -2
  119. package/dist/index2.mjs +29 -15
  120. package/dist/index20.mjs +82 -708
  121. package/dist/index201.mjs +2 -2
  122. package/dist/index202.mjs +2 -23
  123. package/dist/index203.mjs +23 -2
  124. package/dist/index204.mjs +2 -23
  125. package/dist/index205.mjs +23 -2
  126. package/dist/index206.mjs +2 -2
  127. package/dist/index208.mjs +2 -23
  128. package/dist/index209.mjs +23 -2
  129. package/dist/index21.mjs +688 -229
  130. package/dist/index210.mjs +2 -23
  131. package/dist/index211.mjs +23 -2
  132. package/dist/index212.mjs +2 -2
  133. package/dist/index213.mjs +2 -2
  134. package/dist/index215.mjs +2 -2
  135. package/dist/index216.mjs +2 -2
  136. package/dist/index217.mjs +2 -2
  137. package/dist/index218.mjs +2 -2
  138. package/dist/index219.mjs +2 -127
  139. package/dist/index22.mjs +260 -42
  140. package/dist/index220.mjs +127 -2
  141. package/dist/index221.mjs +2 -74
  142. package/dist/index222.mjs +59 -59
  143. package/dist/index223.mjs +74 -2
  144. package/dist/index224.mjs +2 -13
  145. package/dist/index225.mjs +108 -7
  146. package/dist/index226.mjs +2 -12
  147. package/dist/index227.mjs +2 -5
  148. package/dist/index228.mjs +2 -33
  149. package/dist/index229.mjs +2 -31
  150. package/dist/index23.mjs +44 -22
  151. package/dist/index230.mjs +2 -28
  152. package/dist/index231.mjs +2 -61
  153. package/dist/index232.mjs +2 -31
  154. package/dist/index233.mjs +2 -11
  155. package/dist/index234.mjs +2 -4
  156. package/dist/index235.mjs +36 -3
  157. package/dist/index236.mjs +2 -2
  158. package/dist/index237.mjs +244 -2
  159. package/dist/index238.mjs +2 -2
  160. package/dist/index239.mjs +33 -2
  161. package/dist/index240.mjs +65 -2
  162. package/dist/index241.mjs +25 -2
  163. package/dist/index242.mjs +2 -2
  164. package/dist/index244.mjs +2 -108
  165. package/dist/index245.mjs +2 -2
  166. package/dist/index246.mjs +2 -2
  167. package/dist/index247.mjs +2 -37
  168. package/dist/index248.mjs +2 -2
  169. package/dist/index249.mjs +2 -2
  170. package/dist/index250.mjs +2 -244
  171. package/dist/index251.mjs +13 -2
  172. package/dist/index252.mjs +7 -33
  173. package/dist/index253.mjs +30 -64
  174. package/dist/index254.mjs +10 -24
  175. package/dist/index255.mjs +4 -2
  176. package/dist/index256.mjs +4 -2
  177. package/dist/index257.mjs +2 -2
  178. package/dist/index258.mjs +4 -2
  179. package/dist/index259.mjs +12 -2
  180. package/dist/index260.mjs +5 -2
  181. package/dist/index261.mjs +33 -2
  182. package/dist/index262.mjs +31 -2
  183. package/dist/index263.mjs +28 -4
  184. package/dist/index264.mjs +61 -2
  185. package/dist/index265.mjs +2 -2
  186. package/dist/index266.mjs +2 -2
  187. package/dist/index277.mjs +1 -1
  188. package/dist/index282.mjs +1 -1
  189. package/dist/index283.mjs +2 -2
  190. package/dist/index3.mjs +3 -3
  191. package/dist/index4.mjs +34 -101
  192. package/dist/index5.mjs +92 -102
  193. package/dist/index50.mjs +1 -1
  194. package/dist/index58.mjs +1 -1
  195. package/dist/index6.mjs +111 -15
  196. package/dist/index63.mjs +17 -17
  197. package/dist/index64.mjs +2 -2
  198. package/dist/index7.mjs +15 -195
  199. package/dist/index8.mjs +135 -189
  200. package/dist/index81.mjs +19 -149
  201. package/dist/index82.mjs +149 -19
  202. package/dist/index85.mjs +1 -1
  203. package/dist/index89.mjs +35 -35
  204. package/dist/index9.mjs +240 -99
  205. package/dist/index90.mjs +1 -1
  206. package/dist/index91.mjs +2 -2
  207. package/dist/index92.mjs +2 -2
  208. package/dist/index94.mjs +2 -235
  209. package/dist/index95.mjs +233 -4
  210. package/dist/index96.mjs +5 -133
  211. package/dist/index97.mjs +129 -63
  212. package/dist/index98.mjs +67 -86
  213. package/dist/index99.mjs +85 -27
  214. package/dist/providers/StorefrontProvider.d.ts +3 -1
  215. package/dist/providers/StorefrontProvider.d.ts.map +1 -1
  216. package/dist/styles.css +1 -1
  217. package/package.json +2 -2
  218. package/src/components/AssistantDrawer.stories.tsx +20 -91
  219. package/src/components/AssistantDrawer.tsx +5 -9
  220. package/src/components/ProductAssistantChips.stories.tsx +11 -6
  221. package/src/components/ProductAssistantChips.tsx +13 -8
  222. package/src/contexts/AssistantContext.tsx +62 -0
  223. package/src/index.ts +3 -2
  224. package/src/providers/StorefrontProvider.tsx +17 -2
  225. package/dist/components/SearchAssistantTrigger.d.ts +0 -12
  226. package/dist/components/SearchAssistantTrigger.d.ts.map +0 -1
  227. package/src/components/SearchAssistantTrigger.stories.tsx +0 -35
  228. package/src/components/SearchAssistantTrigger.tsx +0 -41
package/dist/index21.mjs CHANGED
@@ -1,268 +1,727 @@
1
1
  'use client';
2
- import { jsxs as l, jsx as r } from "react/jsx-runtime";
3
- import { useState as m, useRef as p, useCallback as G, useEffect as N } from "react";
4
- import { createPortal as Q } from "react-dom";
5
- import { Sparkles as ee, X as te, Loader2 as re, Send as se } from "lucide-react";
6
- import { cn as k, formatCurrency as ne } from "./index30.mjs";
7
- import { useHideBodyOverflow as ae } from "./index53.mjs";
8
- function ue({
9
- isOpen: c,
10
- onClose: y,
11
- apiUrl: I,
12
- brandSlug: D,
13
- productSlug: J,
14
- initialQuestion: x,
15
- assistantName: L = "AI Assistant",
16
- onProductClick: S,
17
- className: K,
18
- disablePortal: Y = !1
2
+ import { jsxs as a, jsx as e, Fragment as O } from "react/jsx-runtime";
3
+ import { useState as C, useEffect as Z, useMemo as V, useCallback as qe } from "react";
4
+ import { object as Q, string as S, ValidationError as _e } from "./index54.mjs";
5
+ import "./index31.mjs";
6
+ import "@tanstack/react-query";
7
+ import { useGetDeliveryZones as Le } from "./index47.mjs";
8
+ import { useCart as Ze } from "./index3.mjs";
9
+ import { Modal as fe } from "./index27.mjs";
10
+ import { FormInput as W } from "./index28.mjs";
11
+ import { FormSelect as ve } from "./index29.mjs";
12
+ import { Button as $ } from "./index24.mjs";
13
+ import { Loader2 as R, ChevronLeft as ze, ChevronRight as Fe, Package as ge, Banknote as Ne, Phone as Te, ChevronDown as Ae, Zap as Be } from "lucide-react";
14
+ import { PostPurchaseUpsell as We } from "./index55.mjs";
15
+ import { formatCurrency as _, cn as M, getFbCookies as Y, getTikTokCookies as J } from "./index30.mjs";
16
+ import $e from "./index56.mjs";
17
+ import { usePaystackPayment as Re } from "./index57.mjs";
18
+ const Ue = "2348125648668", He = `https://wa.me/${Ue}`, Ke = (d) => d.replace(/\D/g, ""), U = (d) => {
19
+ const x = d.trim().split(/\s+/), i = x[0] || "", b = x.slice(1).join(" ") || "-";
20
+ return { firstName: i, lastName: b };
21
+ }, Ge = Q({
22
+ fullName: S().required("Name is required").min(2, "Name must be at least 2 characters").max(100, "Name must be less than 100 characters"),
23
+ phone: S().required("Phone number is required").test("nigerian-phone", "Please enter a valid Nigerian phone number (e.g. 0812 564 8668)", (d) => {
24
+ if (!d) return !1;
25
+ const x = Ke(d);
26
+ return [
27
+ /^0[789]\d{9}$/
28
+ // 0xxxxxxxxx (11 digits total)
29
+ ].some((b) => b.test(x));
30
+ })
31
+ }), Oe = Q({
32
+ address: S().required("Street address is required").min(10, "Please provide a complete address"),
33
+ city: S().required("City is required").min(3, "City name must be at least 3 characters"),
34
+ state: S().required("State is required").test("not-empty", "State is required", (d) => !!d && d.trim() !== ""),
35
+ deliveryZoneId: S().required("Delivery zone is required").test("not-empty", "Delivery zone is required", (d) => !!d && d.trim() !== "")
36
+ }), Ve = Q({
37
+ paymentMethod: S().oneOf(["cod", "online"], "Please select a payment method").required("Payment method is required")
38
+ });
39
+ function mt({
40
+ isOpen: d,
41
+ onClose: x,
42
+ initialData: i,
43
+ onSuccess: b,
44
+ onError: c,
45
+ submitButtonText: be = "Place Order",
46
+ refundPolicy: z
19
47
  }) {
20
- const [u, d] = m([]), [w, E] = m(""), [f, W] = m(!1), [$, h] = m(null), [q, C] = m(!1), [Z, F] = m(!1), M = p(null), z = p(null), A = p(!1), B = p([]);
21
- B.current = u, ae(c);
22
- const H = G((e, a) => {
23
- if (e === "token")
24
- d((s) => {
25
- const o = [...s], t = o[o.length - 1];
26
- return (t == null ? void 0 : t.role) === "assistant" && (o[o.length - 1] = { ...t, content: t.content + a }), o;
27
- });
28
- else if (e === "done")
48
+ var ie, de, oe, ce, me, he, ue, pe, ye;
49
+ const [m, w] = C("customer"), [F, xe] = C(void 0), [y, X] = C(void 0), [f, H] = C(null), { refetch: E, isLoading: D, cart: t, updateCartMutation: P, checkoutMutation: we, clearAndCreateNewCart: ee } = Ze(), te = (ie = t == null ? void 0 : t.brand) == null ? void 0 : ie.paystackPublicKey, ae = Re({
50
+ isOpen: d,
51
+ publicKey: te || "",
52
+ onSuccess: async (n) => {
29
53
  try {
30
- const s = JSON.parse(a);
31
- d((o) => {
32
- var i;
33
- const t = [...o], n = t[t.length - 1];
34
- return (n == null ? void 0 : n.role) === "assistant" && (t[t.length - 1] = {
35
- ...n,
36
- content: s.answer || n.content,
37
- products: ((i = s.products) == null ? void 0 : i.length) > 0 ? s.products : void 0
38
- }), t;
54
+ const { fbc: r, fbp: l } = Y(), { ttp: o, ttclid: g } = J(), { firstName: p, lastName: L } = U(s.fullName), N = await j.mutateAsync({
55
+ firstName: p,
56
+ lastName: L,
57
+ phone: s.phone,
58
+ address: s.address,
59
+ city: s.city,
60
+ deliveryZoneId: y || s.deliveryZoneId,
61
+ paymentMethod: s.paymentMethod,
62
+ paystackReference: n.reference,
63
+ fbc: r,
64
+ fbp: l,
65
+ ttp: o,
66
+ ttclid: g
39
67
  });
40
- } catch {
41
- }
42
- else if (e === "error")
43
- try {
44
- const s = JSON.parse(a);
45
- h(s.message || "An error occurred");
46
- } catch {
47
- h("An error occurred");
68
+ if ("error" in N) {
69
+ const I = N.error;
70
+ c == null || c(new Error((I == null ? void 0 : I.message) || "Checkout failed"));
71
+ return;
72
+ }
73
+ H(N), ee(), b == null || b(N);
74
+ } catch (r) {
75
+ c == null || c(r);
48
76
  }
49
- }, []), v = p(), U = G(
50
- async (e) => {
51
- var o;
52
- if (!e.trim()) return;
53
- h(null);
54
- const a = { role: "user", content: e }, s = B.current.map((t) => ({
55
- role: t.role,
56
- content: t.content
77
+ },
78
+ onClose: () => {
79
+ console.log("Payment popup closed by user");
80
+ }
81
+ });
82
+ Z(() => {
83
+ d && E();
84
+ }, [d, E]);
85
+ const { data: k } = Le(((de = t == null ? void 0 : t.brand) == null ? void 0 : de.id) || "", {
86
+ enabled: !!((oe = t == null ? void 0 : t.brand) != null && oe.id)
87
+ }), u = V(() => k == null ? void 0 : k.find((n) => n.id === F), [k, F]), h = V(() => u == null ? void 0 : u.zones.find((n) => n.id === y), [u, y]), j = we;
88
+ Z(() => {
89
+ d || (H(null), w("customer"), j.reset());
90
+ }, [d]);
91
+ const [s, K] = C({
92
+ fullName: (i == null ? void 0 : i.fullName) || "",
93
+ phone: (i == null ? void 0 : i.phone) || "",
94
+ address: (i == null ? void 0 : i.address) || "",
95
+ city: (i == null ? void 0 : i.city) || "",
96
+ deliveryZoneId: (i == null ? void 0 : i.deliveryZoneId) || "",
97
+ paymentMethod: (i == null ? void 0 : i.paymentMethod) || "online",
98
+ notes: (i == null ? void 0 : i.notes) || ""
99
+ });
100
+ Z(() => {
101
+ d && w("customer");
102
+ }, [d]);
103
+ const [se, re] = C(!1);
104
+ Z(() => {
105
+ if (d && t && !i && !se) {
106
+ const n = [t.customerFirstName, t.customerLastName].filter(Boolean).join(" ");
107
+ K((r) => {
108
+ var l;
109
+ return {
110
+ ...r,
111
+ fullName: n || r.fullName,
112
+ phone: t.customerPhone || r.phone,
113
+ deliveryZoneId: ((l = t.deliveryZone) == null ? void 0 : l.id) || r.deliveryZoneId
114
+ };
115
+ }), re(!0);
116
+ }
117
+ d || re(!1);
118
+ }, [d, t, i, se]), Z(() => {
119
+ if (y) {
120
+ const n = u == null ? void 0 : u.zones.find((r) => r.id === y);
121
+ n && K((r) => ({
122
+ ...r,
123
+ paymentMethod: n.allowOnline ? "online" : "cod"
57
124
  }));
58
- d((t) => [...t, a]), E(""), W(!0), d((t) => [...t, { role: "assistant", content: "" }]);
59
- try {
60
- const t = await fetch(`${I}/v1/assistant/ask`, {
61
- method: "POST",
62
- headers: { "Content-Type": "application/json" },
63
- body: JSON.stringify({
64
- question: e,
65
- brandSlug: D,
66
- productSlug: J,
67
- history: s
68
- })
69
- });
70
- if (!t.ok) {
71
- const g = await t.json().catch(() => ({}));
72
- throw new Error(
73
- ((o = g == null ? void 0 : g.error) == null ? void 0 : o.message) || `Request failed (${t.status})`
74
- );
125
+ }
126
+ }, [y, u]);
127
+ const [v, T] = C({}), [G, Ce] = C(!1), q = (n) => {
128
+ const { name: r, value: l } = n.target;
129
+ K((o) => ({ ...o, [r]: l })), v[r] && T((o) => ({ ...o, [r]: void 0 }));
130
+ }, ne = qe(
131
+ (n) => {
132
+ const r = s[n];
133
+ if (r)
134
+ if (n === "fullName") {
135
+ const { firstName: l, lastName: o } = U(r);
136
+ P.mutate({ customerFirstName: l, customerLastName: o });
137
+ } else n === "phone" && P.mutate({ customerPhone: r });
138
+ },
139
+ [s, P]
140
+ ), A = (n) => {
141
+ const r = {};
142
+ try {
143
+ if (n === "customer")
144
+ Ge.validateSync(s, { abortEarly: !1 });
145
+ else if (n === "delivery") {
146
+ const l = {
147
+ address: s.address,
148
+ city: s.city,
149
+ state: F || s.state || "",
150
+ deliveryZoneId: y || s.deliveryZoneId || ""
151
+ };
152
+ Oe.validateSync(l, { abortEarly: !1 });
153
+ } else n === "payment" && Ve.validateSync(s, { abortEarly: !1 });
154
+ } catch (l) {
155
+ l instanceof _e && l.inner.forEach((o) => {
156
+ o.path && (r[o.path] = o.message);
157
+ });
158
+ }
159
+ return T(r), Object.keys(r).length === 0;
160
+ }, Pe = () => {
161
+ A(m) && (m === "customer" ? w("delivery") : m === "delivery" && w("payment"));
162
+ }, ke = () => {
163
+ m === "payment" ? w("delivery") : m === "delivery" && w("customer");
164
+ }, Ie = async () => {
165
+ var n;
166
+ if (!A("customer")) {
167
+ w("customer");
168
+ return;
169
+ }
170
+ if (!A("delivery")) {
171
+ w("delivery");
172
+ return;
173
+ }
174
+ if (A("payment")) {
175
+ if (s.paymentMethod === "online") {
176
+ if (!te) {
177
+ c == null || c(new Error("Paystack is not configured. Please contact support."));
178
+ return;
75
179
  }
76
- if (!t.body) throw new Error("No response body");
77
- const n = t.body.getReader(), i = new TextDecoder();
78
- let j = "", R = "";
79
- for (; ; ) {
80
- const { done: g, value: P } = await n.read();
81
- if (g) break;
82
- j += i.decode(P, { stream: !0 });
83
- const X = j.split(`
84
- `);
85
- j = X.pop() || "";
86
- for (const b of X) {
87
- if (b.trim() === "") {
88
- R = "";
89
- continue;
90
- }
91
- if (b.trimStart().startsWith("event:"))
92
- R = b.trimStart().slice(6).trim();
93
- else if (b.trimStart().startsWith("data:")) {
94
- const T = b.trimStart().slice(5), O = T.startsWith(" ") ? T.slice(1) : T;
95
- H(R || "token", O);
96
- }
97
- }
180
+ if (!ae.isLoaded) {
181
+ c == null || c(new Error("Payment system is loading. Please try again."));
182
+ return;
98
183
  }
99
- } catch (t) {
100
- h(t.message || "Something went wrong"), d((n) => {
101
- const i = n[n.length - 1];
102
- return (i == null ? void 0 : i.role) === "assistant" && !i.content ? n.slice(0, -1) : n;
184
+ const r = Math.round(t.pricing.total * 100), { fbc: l, fbp: o } = Y(), { ttp: g, ttclid: p } = J(), { firstName: L, lastName: N } = U(s.fullName);
185
+ ae.initializePayment({
186
+ email: (t == null ? void 0 : t.customerEmail) || `${s.phone.replace(/\D/g, "")}@customer.instock.ng`,
187
+ phone: s.phone,
188
+ amount: r,
189
+ currency: "NGN",
190
+ metadata: {
191
+ cartId: t == null ? void 0 : t.id,
192
+ brandSlug: (n = t == null ? void 0 : t.brand) == null ? void 0 : n.slug,
193
+ address: s.address,
194
+ city: s.city,
195
+ delivery_zone_id: y || s.deliveryZoneId,
196
+ firstName: L,
197
+ lastName: N,
198
+ phone: s.phone,
199
+ fbc: l,
200
+ fbp: o,
201
+ ttp: g,
202
+ ttclid: p,
203
+ custom_fields: [
204
+ {
205
+ display_name: "Customer Name",
206
+ variable_name: "customer_name",
207
+ value: s.fullName
208
+ },
209
+ {
210
+ display_name: "Phone Number",
211
+ variable_name: "phone_number",
212
+ value: s.phone
213
+ },
214
+ {
215
+ display_name: "Address",
216
+ variable_name: "address",
217
+ value: s.address
218
+ },
219
+ {
220
+ display_name: "City",
221
+ variable_name: "city",
222
+ value: s.city
223
+ },
224
+ {
225
+ display_name: "Delivery Zone ID",
226
+ variable_name: "delivery_zone_id",
227
+ value: y || s.deliveryZoneId
228
+ }
229
+ ]
230
+ }
103
231
  });
104
- } finally {
105
- W(!1);
232
+ return;
106
233
  }
107
- },
108
- [I, D, J, H]
109
- );
110
- v.current = U, N(() => {
111
- if (c)
112
- F(!0), requestAnimationFrame(() => {
113
- requestAnimationFrame(() => {
114
- C(!0);
234
+ try {
235
+ const { fbc: r, fbp: l } = Y(), { ttp: o, ttclid: g } = J(), { firstName: p, lastName: L } = U(s.fullName), N = await j.mutateAsync({
236
+ firstName: p,
237
+ lastName: L,
238
+ phone: s.phone,
239
+ address: s.address,
240
+ city: s.city,
241
+ deliveryZoneId: y || s.deliveryZoneId,
242
+ paymentMethod: s.paymentMethod,
243
+ fbc: r,
244
+ fbp: l,
245
+ ttp: o,
246
+ ttclid: g
115
247
  });
116
- });
117
- else {
118
- C(!1);
119
- const e = setTimeout(() => {
120
- F(!1), d([]), E(""), h(null), A.current = !1;
121
- }, 300);
122
- return () => clearTimeout(e);
248
+ if ("error" in N) {
249
+ const I = N.error;
250
+ c == null || c(new Error((I == null ? void 0 : I.message) || "Checkout failed"));
251
+ return;
252
+ }
253
+ H(N), ee(), b == null || b(N);
254
+ } catch (r) {
255
+ c == null || c(r);
256
+ }
123
257
  }
124
- }, [c]), N(() => {
125
- c && x && !A.current && (A.current = !0, x.trim() ? setTimeout(() => {
126
- var e;
127
- return (e = v.current) == null ? void 0 : e.call(v, x);
128
- }, 100) : setTimeout(() => {
129
- var e;
130
- return (e = z.current) == null ? void 0 : e.focus();
131
- }, 350));
132
- }, [c, x]), N(() => {
133
- var e;
134
- (e = M.current) == null || e.scrollIntoView({ behavior: "smooth" });
135
- }, [u]), N(() => {
136
- const e = (a) => {
137
- a.key === "Escape" && c && y();
138
- };
139
- if (c)
140
- return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
141
- }, [c, y]);
142
- const _ = (e) => {
143
- e.preventDefault(), w.trim() && U(w.trim());
144
- };
145
- if (!Z) return null;
146
- const V = /* @__PURE__ */ l(
147
- "div",
148
- {
149
- className: k(
150
- "fixed inset-0 z-50 transition-opacity duration-300",
151
- q ? "opacity-100" : "opacity-0"
258
+ }, Me = {
259
+ customer: "Customer Information",
260
+ delivery: "Delivery Address",
261
+ payment: "Payment Method"
262
+ }, Se = V(() => Me[m], [m]), je = /* @__PURE__ */ a("div", { className: "space-y-3", children: [
263
+ (m === "payment" || m === "delivery") && ((ce = t == null ? void 0 : t.pricing) == null ? void 0 : ce.total) && /* @__PURE__ */ a("div", { className: "text-sm text-black relative", children: [
264
+ D && /* @__PURE__ */ e("div", { className: "absolute flex items-center justify-center inset-0 bg-white opacity-50", children: /* @__PURE__ */ e(R, { className: "animate-spin text-accent-500" }) }),
265
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
266
+ /* @__PURE__ */ e("span", { children: "Subtotal" }),
267
+ /* @__PURE__ */ e("span", { children: _(((me = t == null ? void 0 : t.pricing) == null ? void 0 : me.subtotal) ?? 0) })
268
+ ] }),
269
+ t.pricing.discount && /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
270
+ /* @__PURE__ */ e("span", { children: "Discount" }),
271
+ /* @__PURE__ */ a("span", { className: "text-green-600", children: [
272
+ "-",
273
+ _(((ue = (he = t == null ? void 0 : t.pricing) == null ? void 0 : he.discount) == null ? void 0 : ue.amount) ?? 0)
274
+ ] })
275
+ ] }),
276
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
277
+ /* @__PURE__ */ e("span", { children: "Delivery Fee" }),
278
+ /* @__PURE__ */ e("span", { children: (() => {
279
+ var o, g, p;
280
+ if (!y)
281
+ return /* @__PURE__ */ e("span", { className: "text-gray-400 text-xs", children: "Select zone first" });
282
+ const n = (o = t == null ? void 0 : t.brand) == null ? void 0 : o.freeShippingThreshold, r = ((g = t == null ? void 0 : t.pricing) == null ? void 0 : g.subtotal) ?? 0;
283
+ if (n && r >= n)
284
+ return /* @__PURE__ */ e("span", { className: "text-green-600", children: "Free" });
285
+ const l = P.isPending ? (h == null ? void 0 : h.deliveryCost) ?? 0 : ((p = t == null ? void 0 : t.pricing) == null ? void 0 : p.deliveryCharge) ?? 0;
286
+ return l === 0 ? /* @__PURE__ */ e("span", { className: "text-green-600", children: "Free" }) : _(l);
287
+ })() })
288
+ ] }),
289
+ /* @__PURE__ */ e("hr", { className: "border-gray-200 my-2" }),
290
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
291
+ /* @__PURE__ */ e("span", { children: "Total" }),
292
+ /* @__PURE__ */ e("span", { children: _(((pe = t == null ? void 0 : t.pricing) == null ? void 0 : pe.total) ?? 0) })
293
+ ] })
294
+ ] }),
295
+ /* @__PURE__ */ a("div", { className: "flex gap-3", children: [
296
+ m !== "customer" && /* @__PURE__ */ a(
297
+ $,
298
+ {
299
+ type: "button",
300
+ variant: "outline",
301
+ onClick: ke,
302
+ className: "flex-1 border-gray-400",
303
+ size: "lg",
304
+ children: [
305
+ /* @__PURE__ */ e(ze, { className: "mr-2 h-4 w-4" }),
306
+ "Back"
307
+ ]
308
+ }
152
309
  ),
153
- children: [
154
- /* @__PURE__ */ r(
155
- "div",
310
+ m !== "payment" ? /* @__PURE__ */ e(
311
+ $,
312
+ {
313
+ type: "button",
314
+ onClick: Pe,
315
+ disabled: m === "delivery" && P.isPending,
316
+ className: "flex-1 bg-accent-500 text-white hover:bg-accent-600",
317
+ size: "lg",
318
+ children: m === "delivery" && P.isPending ? /* @__PURE__ */ a(O, { children: [
319
+ /* @__PURE__ */ e(R, { className: "mr-2 h-4 w-4 animate-spin" }),
320
+ "Updating..."
321
+ ] }) : /* @__PURE__ */ a(O, { children: [
322
+ "Next",
323
+ /* @__PURE__ */ e(Fe, { className: "ml-2 h-4 w-4" })
324
+ ] })
325
+ }
326
+ ) : /* @__PURE__ */ e(
327
+ $,
328
+ {
329
+ type: "button",
330
+ onClick: Ie,
331
+ disabled: j.isPending,
332
+ className: "flex-1 bg-accent-500 text-white hover:bg-accent-600",
333
+ size: "lg",
334
+ children: j.isPending ? /* @__PURE__ */ a(O, { children: [
335
+ /* @__PURE__ */ e(R, { className: "mr-2 h-4 w-4 animate-spin" }),
336
+ "Processing..."
337
+ ] }) : be
338
+ }
339
+ )
340
+ ] }),
341
+ j.isError && /* @__PURE__ */ e("div", { className: "rounded-lg bg-red-50 p-3 text-sm text-red-600", children: "Failed to place order. Please check your information and try again." })
342
+ ] }), B = (n) => !(t != null && t.availablePaymentMethods.includes(n));
343
+ if (f)
344
+ return /* @__PURE__ */ e(
345
+ fe,
346
+ {
347
+ isOpen: d,
348
+ onClose: x,
349
+ title: /* @__PURE__ */ a("span", { className: "flex items-center gap-3", children: [
350
+ /* @__PURE__ */ e("span", { className: "w-10 h-10 bg-green-100 rounded-full flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ e("svg", { className: "h-6 w-6 text-green-600", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }) }),
351
+ /* @__PURE__ */ a("span", { children: [
352
+ "Thank You!",
353
+ /* @__PURE__ */ e("br", {}),
354
+ "We'll contact you shortly"
355
+ ] })
356
+ ] }),
357
+ footer: /* @__PURE__ */ e(
358
+ $,
156
359
  {
157
- className: "absolute inset-0 bg-black/40 backdrop-blur-sm",
158
- onClick: y
360
+ onClick: x,
361
+ className: "w-full bg-accent-500 text-white hover:bg-accent-600",
362
+ size: "lg",
363
+ children: "Close"
159
364
  }
160
365
  ),
161
- /* @__PURE__ */ l(
366
+ size: "lg",
367
+ contentClassName: "p-4",
368
+ children: /* @__PURE__ */ a("div", { className: "space-y-4", children: [
369
+ /* @__PURE__ */ a("div", { className: "bg-gray-50 rounded-lg p-4 space-y-2", children: [
370
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-center space-x-2 text-gray-700", children: [
371
+ /* @__PURE__ */ e(ge, { className: "h-4 w-4" }),
372
+ /* @__PURE__ */ a("span", { className: "text-sm font-medium", children: [
373
+ "Order #",
374
+ f.orderNumber
375
+ ] })
376
+ ] }),
377
+ /* @__PURE__ */ a("div", { className: "border-t border-gray-200 pt-2 space-y-1.5", children: [
378
+ /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
379
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Customer" }),
380
+ /* @__PURE__ */ a("span", { className: "font-medium text-gray-900", children: [
381
+ f.firstName,
382
+ " ",
383
+ f.lastName
384
+ ] })
385
+ ] }),
386
+ /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
387
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Phone" }),
388
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: f.phone })
389
+ ] }),
390
+ f.email && /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
391
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Email" }),
392
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: f.email })
393
+ ] }),
394
+ /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
395
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Payment" }),
396
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: f.paymentMethod === "cod" ? "Cash on Delivery" : "Online" })
397
+ ] }),
398
+ /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
399
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Total" }),
400
+ /* @__PURE__ */ e("span", { className: "font-bold text-gray-900", children: _(f.totalPrice) })
401
+ ] })
402
+ ] })
403
+ ] }),
404
+ /* @__PURE__ */ e(
405
+ We,
406
+ {
407
+ orderId: f.id,
408
+ token: f.userActionToken,
409
+ limit: 4,
410
+ brandSiteUrl: (ye = f.brand) == null ? void 0 : ye.siteUrl
411
+ }
412
+ )
413
+ ] })
414
+ }
415
+ );
416
+ const le = h && (m === "delivery" || m === "payment") && (h.waybillOnly || !(h != null && h.allowCOD));
417
+ return /* @__PURE__ */ e(
418
+ fe,
419
+ {
420
+ isOpen: d,
421
+ onClose: x,
422
+ title: Se,
423
+ footer: je,
424
+ size: "lg",
425
+ contentClassName: "p-0",
426
+ children: D ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center min-h-[300px]", children: /* @__PURE__ */ e(R, { className: "h-8 w-8 animate-spin text-gray-600" }) }) : /* @__PURE__ */ e("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
427
+ le && /* @__PURE__ */ a("div", { className: "space-y-3 p-4 pb-0", children: [
428
+ h.noteTitle && h.noteContent && /* @__PURE__ */ e("div", { className: "bg-amber-50 border border-amber-200 rounded-lg p-4", children: /* @__PURE__ */ a("div", { className: "flex items-start gap-3", children: [
429
+ /* @__PURE__ */ e(ge, { className: "h-5 w-5 text-amber-600 flex-shrink-0 mt-0.5" }),
430
+ /* @__PURE__ */ a("div", { className: "space-y-1", children: [
431
+ /* @__PURE__ */ e("p", { className: "text-sm font-semibold text-amber-900 whitespace-pre-wrap", children: h.noteTitle }),
432
+ /* @__PURE__ */ e("p", { className: "text-sm text-amber-800 whitespace-pre-wrap", children: h.noteContent })
433
+ ] })
434
+ ] }) }),
435
+ !(h != null && h.allowCOD) && /* @__PURE__ */ e("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: /* @__PURE__ */ a("div", { className: "flex items-start gap-3", children: [
436
+ /* @__PURE__ */ e(Ne, { className: "h-5 w-5 text-blue-600 flex-shrink-0 mt-0.5" }),
437
+ /* @__PURE__ */ a("div", { className: "space-y-1", children: [
438
+ /* @__PURE__ */ e("p", { className: "text-sm font-semibold text-blue-900", children: "Cash on Delivery Unavailable" }),
439
+ /* @__PURE__ */ e("p", { className: "text-sm text-blue-800", children: "We're unable to offer cash on delivery to this location. Please use online payment to complete your order." })
440
+ ] })
441
+ ] }) })
442
+ ] }),
443
+ /* @__PURE__ */ e("div", { className: "p-4", children: /* @__PURE__ */ a(
444
+ "a",
445
+ {
446
+ href: He,
447
+ target: "_blank",
448
+ rel: "noopener noreferrer",
449
+ className: "flex items-center justify-center gap-2 p-3 bg-green-500 hover:bg-green-600 rounded-lg transition-colors",
450
+ children: [
451
+ /* @__PURE__ */ e(
452
+ "img",
453
+ {
454
+ src: "https://toyland.ng/icon-whatsapp.svg",
455
+ alt: "WhatsApp",
456
+ className: "h-5 w-5"
457
+ }
458
+ ),
459
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium text-white", children: "Need help with your order? Click to Contact us on WhatsApp" })
460
+ ]
461
+ }
462
+ ) }),
463
+ /* @__PURE__ */ a(
162
464
  "div",
163
465
  {
164
- className: k(
165
- "absolute bg-white flex flex-col transition-transform duration-300 ease-out",
166
- // Mobile: bottom sheet
167
- "inset-x-0 bottom-0 top-[10vh] rounded-t-2xl",
168
- // Desktop: right side drawer
169
- "sm:inset-y-0 sm:right-0 sm:left-auto sm:w-[420px] sm:max-w-full sm:rounded-t-none sm:rounded-l-2xl",
170
- // Animation
171
- q ? "translate-y-0 sm:translate-x-0" : "translate-y-full sm:translate-y-0 sm:translate-x-full",
172
- K
466
+ className: M(
467
+ "flex transition-transform duration-300 ease-in-out w-full",
468
+ m === "customer" && "translate-x-0",
469
+ m === "delivery" && "-translate-x-full",
470
+ m === "payment" && "-translate-x-[200%]"
173
471
  ),
174
472
  children: [
175
- /* @__PURE__ */ l("div", { className: "flex items-center justify-between border-b border-gray-200 px-4 py-3 flex-shrink-0", children: [
176
- /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
177
- /* @__PURE__ */ r(ee, { className: "h-5 w-5 text-orange-500" }),
178
- /* @__PURE__ */ r("span", { className: "font-semibold text-gray-900", children: L }),
179
- /* @__PURE__ */ r("span", { className: "text-xs text-gray-400 bg-gray-100 rounded px-1.5 py-0.5", children: "beta" })
180
- ] }),
181
- /* @__PURE__ */ r(
182
- "button",
473
+ /* @__PURE__ */ e("div", { className: "w-full min-w-full flex-shrink-0 p-4", children: /* @__PURE__ */ a("div", { className: "space-y-4", children: [
474
+ /* @__PURE__ */ e(
475
+ W,
476
+ {
477
+ label: "Full Name",
478
+ type: "text",
479
+ name: "fullName",
480
+ value: s.fullName,
481
+ onChange: q,
482
+ onBlur: () => ne("fullName"),
483
+ error: v.fullName,
484
+ autoCorrect: "off",
485
+ required: !0
486
+ }
487
+ ),
488
+ /* @__PURE__ */ e(
489
+ W,
183
490
  {
184
- type: "button",
185
- onClick: y,
186
- className: "p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors",
187
- "aria-label": "Close",
188
- children: /* @__PURE__ */ r(te, { className: "h-5 w-5" })
491
+ label: "Phone Number",
492
+ type: "tel",
493
+ name: "phone",
494
+ value: s.phone,
495
+ onChange: q,
496
+ onBlur: () => ne("phone"),
497
+ placeholder: "e.g. 08012345678",
498
+ maxLength: 18,
499
+ error: v.phone,
500
+ icon: /* @__PURE__ */ e(Te, { size: 16 }),
501
+ autoCorrect: "off",
502
+ required: !0,
503
+ className: "font-semibold"
189
504
  }
190
505
  )
191
- ] }),
192
- /* @__PURE__ */ l("div", { className: "flex-1 overflow-y-auto p-4 space-y-4 min-h-0", children: [
193
- u.length === 0 && !f && /* @__PURE__ */ r("div", { className: "text-center text-gray-400 text-sm py-8", children: "Ask me anything about our products!" }),
194
- u.map((e, a) => /* @__PURE__ */ r("div", { children: e.role === "user" ? /* @__PURE__ */ r("div", { className: "flex justify-end", children: /* @__PURE__ */ r("div", { className: "bg-gray-800 text-white rounded-2xl rounded-br-sm px-4 py-2 max-w-[80%] text-sm", children: e.content }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: [
195
- /* @__PURE__ */ l("div", { className: "text-sm text-gray-800 leading-relaxed whitespace-pre-wrap", children: [
196
- e.content,
197
- f && a === u.length - 1 && /* @__PURE__ */ r("span", { className: "inline-block w-1.5 h-4 bg-gray-400 animate-pulse ml-0.5 align-text-bottom" })
198
- ] }),
199
- e.products && e.products.length > 0 && /* @__PURE__ */ r("div", { className: "space-y-2", children: e.products.map((s) => /* @__PURE__ */ l(
506
+ ] }) }),
507
+ /* @__PURE__ */ e("div", { className: "w-full min-w-full flex-shrink-0 p-4", children: /* @__PURE__ */ a("div", { className: "space-y-4", children: [
508
+ /* @__PURE__ */ e(
509
+ W,
510
+ {
511
+ label: "Street Address",
512
+ type: "text",
513
+ name: "address",
514
+ value: s.address,
515
+ onChange: q,
516
+ error: v.address,
517
+ autoCorrect: "off",
518
+ required: !0
519
+ }
520
+ ),
521
+ /* @__PURE__ */ a("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
522
+ /* @__PURE__ */ e(
523
+ W,
524
+ {
525
+ label: "Area",
526
+ type: "text",
527
+ name: "city",
528
+ value: s.city,
529
+ onChange: q,
530
+ error: v.city,
531
+ autoCorrect: "off",
532
+ required: !0
533
+ }
534
+ ),
535
+ /* @__PURE__ */ a(
536
+ ve,
537
+ {
538
+ label: "State",
539
+ name: "state",
540
+ value: F || "",
541
+ onChange: (n) => {
542
+ X("");
543
+ const r = n.target.value;
544
+ xe(r || void 0), v.state && T((l) => ({ ...l, state: void 0 }));
545
+ },
546
+ error: v.state,
547
+ required: !0,
548
+ children: [
549
+ /* @__PURE__ */ e("option", { disabled: !0, value: "", children: "Select State" }),
550
+ k == null ? void 0 : k.slice().sort((n, r) => {
551
+ const l = n.name.toLowerCase() === "lagos" ? 0 : 1, o = r.name.toLowerCase() === "lagos" ? 0 : 1;
552
+ return l - o;
553
+ }).map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.name }, n.id))
554
+ ]
555
+ }
556
+ ),
557
+ /* @__PURE__ */ a(
558
+ ve,
559
+ {
560
+ label: "Delivery Zone",
561
+ value: y || "",
562
+ onChange: (n) => {
563
+ const r = n.target.value;
564
+ X(r || void 0), v.deliveryZoneId && T((l) => ({ ...l, deliveryZoneId: void 0 })), r && P.mutate({ deliveryZoneId: r });
565
+ },
566
+ disabled: !u,
567
+ error: v.deliveryZoneId,
568
+ required: !0,
569
+ children: [
570
+ /* @__PURE__ */ e("option", { disabled: !0, value: "", children: u ? "Select Delivery Zone" : "Select State First" }),
571
+ (() => {
572
+ var o, g;
573
+ const n = ((o = t == null ? void 0 : t.pricing) == null ? void 0 : o.subtotal) ?? 0, r = (g = t == null ? void 0 : t.brand) == null ? void 0 : g.freeShippingThreshold, l = r && n >= r;
574
+ return u == null ? void 0 : u.zones.map((p) => /* @__PURE__ */ a("option", { value: p.id, children: [
575
+ p.name,
576
+ l ? "" : ` (${_(p.deliveryCost)})`
577
+ ] }, p.id));
578
+ })()
579
+ ]
580
+ }
581
+ )
582
+ ] })
583
+ ] }) }),
584
+ /* @__PURE__ */ e("div", { className: "w-full min-w-full flex-shrink-0 p-4", children: /* @__PURE__ */ a("div", { className: "space-y-6", children: [
585
+ z && /* @__PURE__ */ a("div", { className: `border border-gray-200 rounded-lg ${le ? "mt-4" : ""}`, children: [
586
+ /* @__PURE__ */ a(
200
587
  "button",
201
588
  {
202
589
  type: "button",
203
- onClick: () => S == null ? void 0 : S(s.slug),
204
- className: "flex items-center gap-3 w-full rounded-xl border border-gray-200 p-2 hover:bg-gray-50 transition-colors text-left",
590
+ onClick: () => Ce(!G),
591
+ className: "overflow-hidden w-full flex items-center overflow-hidden rounded-lg rounded-b-none justify-between p-4 text-left hover:bg-gray-50 transition-colors",
205
592
  children: [
206
- s.thumbnailUrl ? /* @__PURE__ */ r(
207
- "img",
593
+ /* @__PURE__ */ e("span", { className: "text-sm font-bold text-accent-700", children: z.title || "Yes, we offer refunds!" }),
594
+ /* @__PURE__ */ e(
595
+ Ae,
208
596
  {
209
- src: s.thumbnailUrl,
210
- alt: s.name,
211
- className: "h-16 w-16 rounded-lg object-cover flex-shrink-0"
597
+ size: 16,
598
+ className: M(
599
+ "transform transition-transform duration-200 text-gray-500",
600
+ G && "rotate-180"
601
+ )
212
602
  }
213
- ) : /* @__PURE__ */ r("div", { className: "h-16 w-16 rounded-lg bg-gray-100 flex-shrink-0" }),
214
- /* @__PURE__ */ l("div", { className: "min-w-0", children: [
215
- /* @__PURE__ */ r("p", { className: "text-sm font-medium text-gray-900 line-clamp-2", children: s.name }),
216
- /* @__PURE__ */ r("p", { className: "text-sm font-semibold text-blue-600", children: ne(s.price) })
217
- ] })
603
+ )
218
604
  ]
219
- },
220
- s.slug
221
- )) })
222
- ] }) }, a)),
223
- $ && /* @__PURE__ */ r("div", { className: "rounded-lg bg-red-50 border border-red-200 p-3 text-sm text-red-700", children: $ }),
224
- /* @__PURE__ */ r("div", { ref: M })
225
- ] }),
226
- /* @__PURE__ */ r("div", { className: "border-t border-gray-200 p-3 flex-shrink-0", children: /* @__PURE__ */ l("form", { onSubmit: _, className: "flex items-center gap-2", children: [
227
- /* @__PURE__ */ r(
228
- "input",
229
- {
230
- ref: z,
231
- type: "text",
232
- value: w,
233
- onChange: (e) => E(e.target.value),
234
- placeholder: `Ask ${L} a question`,
235
- disabled: f,
236
- className: k(
237
- "flex-1 rounded-full border border-gray-300 px-4 py-2.5 text-sm",
238
- "focus:border-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-400/30",
239
- "disabled:opacity-50"
240
- )
241
- }
242
- ),
243
- /* @__PURE__ */ r(
244
- "button",
245
- {
246
- type: "submit",
247
- disabled: !w.trim() || f,
248
- className: k(
249
- "flex h-10 w-10 items-center justify-center rounded-full",
250
- "bg-gray-800 text-white",
251
- "hover:bg-gray-700 transition-colors",
252
- "disabled:opacity-40 disabled:cursor-not-allowed"
253
- ),
254
- children: f ? /* @__PURE__ */ r(re, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ r(se, { className: "h-4 w-4" })
255
- }
256
- )
605
+ }
606
+ ),
607
+ /* @__PURE__ */ e(
608
+ "div",
609
+ {
610
+ className: M(
611
+ "overflow-hidden transition-all duration-300 ease-in-out",
612
+ G ? "max-h-96 opacity-100" : "max-h-0 opacity-0"
613
+ ),
614
+ children: /* @__PURE__ */ e("div", { className: "px-4 pb-4 border-t border-gray-100", children: /* @__PURE__ */ e("div", { className: "text-sm text-gray-600 space-y-3 pt-4", children: z.policies && /* @__PURE__ */ a("div", { children: [
615
+ /* @__PURE__ */ e("h4", { className: "font-bold text-gray-800 mb-2", children: "Our Refund Policy" }),
616
+ /* @__PURE__ */ e("ul", { className: "space-y-1", children: z.policies.map((n, r) => /* @__PURE__ */ a("li", { className: "flex items-start", children: [
617
+ /* @__PURE__ */ e("span", { className: "text-green-600 mr-2", children: "✓" }),
618
+ /* @__PURE__ */ e("span", { children: n })
619
+ ] }, r)) })
620
+ ] }) }) })
621
+ }
622
+ )
623
+ ] }),
624
+ /* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-4", children: [
625
+ /* @__PURE__ */ e("div", { className: "relative", children: /* @__PURE__ */ a(
626
+ "label",
627
+ {
628
+ className: M(
629
+ "flex items-center justify-center relative p-4 border-2 rounded-xl cursor-pointer transition-all duration-200",
630
+ s.paymentMethod === "online" ? "border-accent-500 bg-accent-50" : "border-gray-200 hover:border-gray-300",
631
+ B("online") && "opacity-50 cursor-not-allowed"
632
+ ),
633
+ children: [
634
+ /* @__PURE__ */ e(
635
+ "input",
636
+ {
637
+ type: "radio",
638
+ name: "paymentMethod",
639
+ value: "online",
640
+ disabled: B("online"),
641
+ checked: s.paymentMethod === "online",
642
+ onChange: q,
643
+ className: "sr-only"
644
+ }
645
+ ),
646
+ /* @__PURE__ */ a("div", { className: "flex flex-col items-center text-center space-y-3", children: [
647
+ /* @__PURE__ */ e(
648
+ "div",
649
+ {
650
+ className: M(
651
+ "p-3 rounded-full",
652
+ s.paymentMethod === "online" ? "bg-accent-100 text-accent-600" : "bg-gray-100 text-gray-600"
653
+ ),
654
+ children: /* @__PURE__ */ e(Be, { size: 24 })
655
+ }
656
+ ),
657
+ /* @__PURE__ */ a("div", { children: [
658
+ /* @__PURE__ */ e("div", { className: "font-semibold text-gray-900", children: "Pay Online" }),
659
+ /* @__PURE__ */ e("div", { className: "text-sm text-gray-500 mt-1", children: "Bank transfer" }),
660
+ /* @__PURE__ */ e(
661
+ "img",
662
+ {
663
+ src: $e,
664
+ alt: "Paystack",
665
+ className: "h-4 w-auto mt-2 mx-auto"
666
+ }
667
+ )
668
+ ] })
669
+ ] }),
670
+ s.paymentMethod === "online" && /* @__PURE__ */ e("div", { className: "absolute top-2 right-2", children: /* @__PURE__ */ e("div", { className: "w-5 h-5 bg-accent-600 rounded-full flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "w-2 h-2 bg-white rounded-full" }) }) })
671
+ ]
672
+ }
673
+ ) }),
674
+ /* @__PURE__ */ a(
675
+ "label",
676
+ {
677
+ className: M(
678
+ "flex items-center justify-center relative p-4 border-2 rounded-xl cursor-pointer transition-all duration-200",
679
+ s.paymentMethod === "cod" ? "border-accent-500 bg-accent-50" : "border-gray-200 hover:border-gray-300",
680
+ B("cod") && "opacity-50 cursor-not-allowed"
681
+ ),
682
+ children: [
683
+ /* @__PURE__ */ e(
684
+ "input",
685
+ {
686
+ type: "radio",
687
+ name: "paymentMethod",
688
+ value: "cod",
689
+ disabled: B("cod"),
690
+ checked: s.paymentMethod === "cod",
691
+ onChange: q,
692
+ className: "sr-only"
693
+ }
694
+ ),
695
+ /* @__PURE__ */ a("div", { className: "flex flex-col items-center text-center space-y-3", children: [
696
+ /* @__PURE__ */ e(
697
+ "div",
698
+ {
699
+ className: M(
700
+ "p-3 rounded-full",
701
+ s.paymentMethod === "cod" ? "bg-accent-100 text-accent-600" : "bg-gray-100 text-gray-600"
702
+ ),
703
+ children: /* @__PURE__ */ e(Ne, { size: 24 })
704
+ }
705
+ ),
706
+ /* @__PURE__ */ a("div", { children: [
707
+ /* @__PURE__ */ e("div", { className: "font-semibold text-gray-900", children: "Pay on Delivery" }),
708
+ /* @__PURE__ */ e("div", { className: "text-sm text-gray-500 mt-1", children: "Pay when item arrives" })
709
+ ] })
710
+ ] }),
711
+ s.paymentMethod === "cod" && /* @__PURE__ */ e("div", { className: "absolute top-2 right-2", children: /* @__PURE__ */ e("div", { className: "w-5 h-5 bg-accent-600 rounded-full flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "w-2 h-2 bg-white rounded-full" }) }) })
712
+ ]
713
+ }
714
+ )
715
+ ] }),
716
+ v.paymentMethod && /* @__PURE__ */ e("p", { className: "text-red-600 text-sm", children: v.paymentMethod })
257
717
  ] }) })
258
718
  ]
259
719
  }
260
720
  )
261
- ]
721
+ ] }) })
262
722
  }
263
723
  );
264
- return Y ? V : Q(V, document.body);
265
724
  }
266
725
  export {
267
- ue as AssistantDrawer
726
+ mt as Checkout
268
727
  };