@hachther/akilio-widget 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ interface BrandLogoProps {
2
+ variant?: 'mark' | 'wordmark';
3
+ className?: string;
4
+ }
5
+ export declare function BrandLogo({ variant, className }: BrandLogoProps): import("react").JSX.Element;
6
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { AkilioResolvedCopy } from '../lib/copy';
2
+ import type { AkilioChatMessage, AkilioFeedbackRating, AkilioProduct, AkilioProductVariant } from '../types';
3
+ interface ChatPanelProps {
4
+ open: boolean;
5
+ isDesktop: boolean;
6
+ inline: boolean;
7
+ colorMode: 'light' | 'dark';
8
+ allowColorModeToggle: boolean;
9
+ copy: AkilioResolvedCopy;
10
+ locale: string;
11
+ messages: AkilioChatMessage[];
12
+ loading: boolean;
13
+ consentDecision: 'pending' | 'accepted' | 'rejected';
14
+ consentGranted: boolean;
15
+ requireConsent: boolean;
16
+ privacyNotice: string;
17
+ privacyNoticeUrl?: string;
18
+ onConsentDecision: (decision: 'pending' | 'accepted' | 'rejected') => void;
19
+ onClose: () => void;
20
+ onToggleColorMode: () => void;
21
+ onClear: () => void;
22
+ onSubmit: (query: string) => void;
23
+ onFeedback: (message: AkilioChatMessage, rating: AkilioFeedbackRating) => void;
24
+ onSuggestion: (suggestion: string) => void;
25
+ onProductClick: (message: AkilioChatMessage, product: AkilioProduct, variant?: AkilioProductVariant) => void;
26
+ }
27
+ export declare function ChatPanel(props: ChatPanelProps): import("react").JSX.Element;
28
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function SparklesIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export declare function SendIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
4
+ export declare function CloseIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
5
+ export declare function TrashIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
6
+ export declare function ThumbsUpIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
7
+ export declare function ThumbsDownIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
8
+ export declare function SunIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
9
+ export declare function MoonIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare function Launcher({ label, onClick, }: {
2
+ label: string;
3
+ onClick: () => void;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare const MarkdownAnswer: import("react").NamedExoticComponent<{
2
+ content: string;
3
+ }>;
@@ -0,0 +1,12 @@
1
+ import type { AkilioResolvedCopy } from '../lib/copy';
2
+ import type { AkilioChatMessage, AkilioFeedbackRating, AkilioProduct, AkilioProductVariant } from '../types';
3
+ interface MessageBubbleProps {
4
+ message: AkilioChatMessage;
5
+ copy: AkilioResolvedCopy;
6
+ locale: string;
7
+ onFeedback?: (message: AkilioChatMessage, rating: AkilioFeedbackRating) => void;
8
+ onSuggestion?: (suggestion: string) => void;
9
+ onProductClick?: (message: AkilioChatMessage, product: AkilioProduct, variant?: AkilioProductVariant) => void;
10
+ }
11
+ export declare const MessageBubble: import("react").NamedExoticComponent<MessageBubbleProps>;
12
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { AkilioResolvedCopy } from '../lib/copy';
2
+ import type { AkilioCommerceCapability, AkilioProduct, AkilioProductVariant } from '../types';
3
+ interface ProductCardsProps {
4
+ commerce: AkilioCommerceCapability;
5
+ copy: AkilioResolvedCopy;
6
+ locale: string;
7
+ onProductClick?: (product: AkilioProduct, variant?: AkilioProductVariant) => void;
8
+ }
9
+ export declare const ProductCards: import("react").NamedExoticComponent<ProductCardsProps>;
10
+ export {};
@@ -0,0 +1,534 @@
1
+ "use client";
2
+ var $e = globalThis.process || { env: { NODE_ENV: "production" } };
3
+ const N = ["pointerdown", "mousedown", "pointerup", "mouseup", "click"], B = /* @__PURE__ */ new WeakMap();
4
+ function R(t, e, i) {
5
+ P(t);
6
+ let n = (o) => {
7
+ let r = o.target;
8
+ t.contains(r) && ((!i || i(r)) && (o.preventDefault(), o.stopPropagation(), o.stopImmediatePropagation()), o.type === "click" && e?.(o));
9
+ };
10
+ for (let o of N) document.addEventListener(o, n, !0);
11
+ B.set(t, n);
12
+ }
13
+ function P(t) {
14
+ let e = B.get(t);
15
+ if (e) {
16
+ for (let i of N) document.removeEventListener(i, e, !0);
17
+ B.delete(t);
18
+ }
19
+ }
20
+ function Q(t, e) {
21
+ let i = t.wrapper.getBoundingClientRect();
22
+ return { width: i.width + e, height: i.height + e, realWidth: i.width, realHeight: i.height };
23
+ }
24
+ function M(t, e) {
25
+ let { elementDimensions: i, popoverDimensions: n, popoverPadding: o, popoverArrowDimensions: r } = e;
26
+ return t === "start" ? Math.max(Math.min(i.top - o, window.innerHeight - n.realHeight - r.width), r.width) : t === "end" ? Math.max(Math.min(i.top - n?.realHeight + i.height + o, window.innerHeight - n?.realHeight - r.width), r.width) : t === "center" ? Math.max(Math.min(i.top + i.height / 2 - n?.realHeight / 2, window.innerHeight - n?.realHeight - r.width), r.width) : 0;
27
+ }
28
+ function T(t, e) {
29
+ let { elementDimensions: i, popoverDimensions: n, popoverPadding: o, popoverArrowDimensions: r } = e;
30
+ return t === "start" ? Math.max(Math.min(i.left - o, window.innerWidth - n.realWidth - r.width), r.width) : t === "end" ? Math.max(Math.min(i.left - n?.realWidth + i.width + o, window.innerWidth - n?.realWidth - r.width), r.width) : t === "center" ? Math.max(Math.min(i.left + i.width / 2 - n?.realWidth / 2, window.innerWidth - n?.realWidth - r.width), r.width) : 0;
31
+ }
32
+ function $(t, e, i) {
33
+ let { align: n, side: o } = i, r = i.centered ? "over" : o, s = i.padding, p = Q(t, i.offset), v = t.arrow.getBoundingClientRect(), d = e.getBoundingClientRect(), S = d.top - p.height, y = S >= 0, f = window.innerHeight - (d.bottom + p.height), m = f >= 0, h = d.left - p.width, w = h >= 0, l = window.innerWidth - (d.right + p.width), a = l >= 0, c = !y && !m && !w && !a, g = r;
34
+ if (r === "top" && y ? a = w = m = !1 : r === "bottom" && m ? a = w = y = !1 : r === "left" && w ? a = y = m = !1 : r === "right" && a && (w = y = m = !1), r === "over") {
35
+ let u = window.innerWidth / 2 - p.realWidth / 2, C = window.innerHeight / 2 - p.realHeight / 2;
36
+ t.wrapper.style.left = `${u}px`, t.wrapper.style.right = "auto", t.wrapper.style.top = `${C}px`, t.wrapper.style.bottom = "auto";
37
+ } else if (c) {
38
+ let u = window.innerWidth / 2 - p?.realWidth / 2;
39
+ t.wrapper.style.left = `${u}px`, t.wrapper.style.right = "auto", t.wrapper.style.bottom = "10px", t.wrapper.style.top = "auto";
40
+ } else if (w) {
41
+ let u = Math.min(h, window.innerWidth - p?.realWidth - v.width), C = M(n, { elementDimensions: d, popoverDimensions: p, popoverPadding: s, popoverArrowDimensions: v });
42
+ t.wrapper.style.left = `${u}px`, t.wrapper.style.top = `${C}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.right = "auto", g = "left";
43
+ } else if (a) {
44
+ let u = Math.min(l, window.innerWidth - p?.realWidth - v.width), C = M(n, { elementDimensions: d, popoverDimensions: p, popoverPadding: s, popoverArrowDimensions: v });
45
+ t.wrapper.style.right = `${u}px`, t.wrapper.style.top = `${C}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.left = "auto", g = "right";
46
+ } else if (y) {
47
+ let u = Math.min(S, window.innerHeight - p.realHeight - v.width), C = T(n, { elementDimensions: d, popoverDimensions: p, popoverPadding: s, popoverArrowDimensions: v });
48
+ t.wrapper.style.top = `${u}px`, t.wrapper.style.left = `${C}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.right = "auto", g = "top";
49
+ } else if (m) {
50
+ let u = Math.min(f, window.innerHeight - p?.realHeight - v.width), C = T(n, { elementDimensions: d, popoverDimensions: p, popoverPadding: s, popoverArrowDimensions: v });
51
+ t.wrapper.style.left = `${C}px`, t.wrapper.style.bottom = `${u}px`, t.wrapper.style.top = "auto", t.wrapper.style.right = "auto", g = "bottom";
52
+ }
53
+ ee(t, c ? "over" : g, n, e), [...t.wrapper.classList].filter((u) => u.startsWith("driver-popover-side-") || u.startsWith("driver-popover-align-")).forEach((u) => t.wrapper.classList.remove(u)), t.wrapper.classList.add(`driver-popover-side-${g}`), t.wrapper.classList.add(`driver-popover-align-${n}`);
54
+ }
55
+ function D(t, e, i, n, o, r = 10) {
56
+ let s = n - i;
57
+ return t <= i && e >= n ? o === "start" ? 15 + r / 2 : o === "end" ? s - 15 - r / 2 : s / 2 : (Math.min(Math.max(t, i), n) + Math.min(Math.max(e, i), n)) / 2 - i;
58
+ }
59
+ function W(t, e, i = 10) {
60
+ let n = e - 15 - i;
61
+ if (n < 15) return Math.max(0, (e - i) / 2);
62
+ let o = t - i / 2;
63
+ return Math.min(Math.max(o, 15), n);
64
+ }
65
+ function U(t, e, i) {
66
+ return t === "left" || t === "right" ? e.bottom > i.top && e.top < i.bottom ? t : e.bottom <= i.top ? "bottom" : "top" : e.right > i.left && e.left < i.right ? t : e.right <= i.left ? "right" : "left";
67
+ }
68
+ function ee(t, e, i, n) {
69
+ let o = t.arrow;
70
+ if (o.className = "driver-popover-arrow", o.style.top = "", o.style.right = "", o.style.bottom = "", o.style.left = "", e === "over") {
71
+ o.classList.add("driver-popover-arrow-none");
72
+ return;
73
+ }
74
+ let r = n.getBoundingClientRect(), s = t.wrapper.getBoundingClientRect(), p = U(e, r, s);
75
+ o.classList.add(`driver-popover-arrow-side-${p}`);
76
+ let v = o.getBoundingClientRect().width || 10;
77
+ if (p === "left" || p === "right") {
78
+ let d = D(r.top, r.bottom, s.top, s.bottom, i, v);
79
+ o.style.top = `${W(d, s.height, v)}px`;
80
+ } else {
81
+ let d = D(r.left, r.right, s.left, s.right, i, v);
82
+ o.style.left = `${W(d, s.width, v)}px`;
83
+ }
84
+ }
85
+ function L(t) {
86
+ return typeof t == "function" ? t() : typeof t == "string" ? document.querySelector(t) : t;
87
+ }
88
+ function te(t) {
89
+ let e = window.getComputedStyle(t);
90
+ return [e.overflow, e.overflowX, e.overflowY].some((i) => i === "auto" || i === "scroll");
91
+ }
92
+ function _(t, e, i, n) {
93
+ return (t /= n / 2) < 1 ? i / 2 * t * t + e : -i / 2 * (--t * (t - 2) - 1) + e;
94
+ }
95
+ function z(t) {
96
+ let e = 'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])';
97
+ return t.flatMap((i) => {
98
+ let n = i.matches(e), o = Array.from(i.querySelectorAll(e));
99
+ return [...n ? [i] : [], ...o];
100
+ }).filter((i) => getComputedStyle(i).pointerEvents !== "none" && ne(i));
101
+ }
102
+ function q(t, e) {
103
+ if (!t || oe(t)) return;
104
+ let i = t.offsetHeight > window.innerHeight;
105
+ t.scrollIntoView({ behavior: !e || ie(t) ? "auto" : "smooth", inline: "center", block: i ? "start" : "center" });
106
+ }
107
+ function ie(t) {
108
+ if (!t || !t.parentElement) return;
109
+ let e = t.parentElement;
110
+ return e.scrollHeight > e.clientHeight;
111
+ }
112
+ function oe(t) {
113
+ let e = t.getBoundingClientRect();
114
+ return e.top >= 0 && e.left >= 0 && e.bottom <= (window.innerHeight || document.documentElement.clientHeight) && e.right <= (window.innerWidth || document.documentElement.clientWidth);
115
+ }
116
+ function ne(t) {
117
+ return !!(t.offsetWidth || t.offsetHeight || t.getClientRects().length);
118
+ }
119
+ function re(t) {
120
+ t && (t.wrapper.style.display = "none");
121
+ }
122
+ function le(t, e) {
123
+ let i = ae();
124
+ document.body.appendChild(i.wrapper);
125
+ let { title: n, description: o, showButtons: r, disableButtons: s, showProgress: p, nextBtnText: v, prevBtnText: d, progressText: S } = e;
126
+ i.nextButton.innerHTML = v, i.previousButton.innerHTML = d, i.progress.innerHTML = S, e.doneButton && i.nextButton.classList.add("driver-popover-done-btn"), n ? (i.title.innerHTML = n, i.title.style.display = "block") : i.title.style.display = "none", o ? (i.description.innerHTML = o, i.description.style.display = "block") : i.description.style.display = "none";
127
+ let y = r.includes("next") || r.includes("previous") || p;
128
+ i.closeButton.style.display = r.includes("close") ? "block" : "none", y ? (i.footer.style.display = "flex", i.progress.style.display = p ? "block" : "none", i.nextButton.style.display = r.includes("next") ? "block" : "none", i.previousButton.style.display = r.includes("previous") ? "block" : "none") : i.footer.style.display = "none", s.includes("next") && (i.nextButton.disabled = !0, i.nextButton.classList.add("driver-popover-btn-disabled")), s.includes("previous") && (i.previousButton.disabled = !0, i.previousButton.classList.add("driver-popover-btn-disabled")), s.includes("close") && (i.closeButton.disabled = !0, i.closeButton.classList.add("driver-popover-btn-disabled"));
129
+ let f = i.wrapper;
130
+ f.style.display = "block", f.style.left = "", f.style.top = "", f.style.bottom = "", f.style.right = "", f.id = "driver-popover-content", f.setAttribute("role", "dialog"), f.setAttribute("aria-labelledby", "driver-popover-title"), f.setAttribute("aria-describedby", "driver-popover-description");
131
+ let m = i.arrow;
132
+ m.className = "driver-popover-arrow", f.className = `driver-popover ${e.popoverClass || ""}`.trim(), R(i.wrapper, (w) => {
133
+ let l = w.target;
134
+ if (l.closest(".driver-popover-next-btn")) return e.onNextClick?.();
135
+ if (l.closest(".driver-popover-prev-btn")) return e.onPrevClick?.();
136
+ if (l.closest(".driver-popover-close-btn")) return e.onCloseClick?.();
137
+ }, (w) => i.description.contains(w) || i.title.contains(w) ? !1 : !!w.closest(".driver-popover-prev-btn, .driver-popover-next-btn, .driver-popover-close-btn")), e.onRender?.(i), $(i, t, e.position), se(i, t, e.position), q(f, e.smoothScroll);
138
+ let h = z([f, t]);
139
+ return h.length > 0 && h[0].focus(), i;
140
+ }
141
+ function se(t, e, i) {
142
+ t.wrapper.querySelectorAll("img").forEach((n) => {
143
+ if (n.complete) return;
144
+ let o = () => $(t, e, i);
145
+ n.addEventListener("load", o, { once: !0 }), n.addEventListener("error", o, { once: !0 });
146
+ });
147
+ }
148
+ function ae() {
149
+ let t = document.createElement("div");
150
+ t.classList.add("driver-popover");
151
+ let e = document.createElement("div");
152
+ e.classList.add("driver-popover-arrow");
153
+ let i = document.createElement("header");
154
+ i.id = "driver-popover-title", i.classList.add("driver-popover-title"), i.style.display = "none", i.innerText = "Popover Title";
155
+ let n = document.createElement("div");
156
+ n.id = "driver-popover-description", n.classList.add("driver-popover-description"), n.style.display = "none", n.innerText = "Popover description is here";
157
+ let o = document.createElement("button");
158
+ o.type = "button", o.classList.add("driver-popover-close-btn"), o.setAttribute("aria-label", "Close"), o.innerHTML = "&times;";
159
+ let r = document.createElement("footer");
160
+ r.classList.add("driver-popover-footer");
161
+ let s = document.createElement("span");
162
+ s.classList.add("driver-popover-progress-text"), s.innerText = "";
163
+ let p = document.createElement("span");
164
+ p.classList.add("driver-popover-navigation-btns");
165
+ let v = document.createElement("button");
166
+ v.type = "button", v.classList.add("driver-popover-prev-btn", "driver-popover-footer-btn"), v.innerHTML = "Previous";
167
+ let d = document.createElement("button");
168
+ return d.type = "button", d.classList.add("driver-popover-next-btn", "driver-popover-footer-btn"), d.innerHTML = "Next", p.appendChild(v), p.appendChild(d), r.appendChild(s), r.appendChild(p), t.appendChild(o), t.appendChild(e), t.appendChild(i), t.appendChild(n), t.appendChild(r), { wrapper: t, arrow: e, title: i, description: n, footer: r, previousButton: v, nextButton: d, closeButton: o, footerButtons: p, progress: s };
169
+ }
170
+ function F(t) {
171
+ t && (P(t.wrapper), t.wrapper.parentElement?.removeChild(t.wrapper));
172
+ }
173
+ function K(t, e) {
174
+ let i = window.innerWidth, n = window.innerHeight, o = e.padding, r = e.radius, s = t.width + o * 2, p = t.height + o * 2, v = Math.min(r, s / 2, p / 2), d = Math.floor(Math.max(v, 0)), S = t.x - o + d, y = t.y - o, f = s - d * 2, m = p - d * 2;
175
+ return `M${i},0L0,0L0,${n}L${i},${n}L${i},0Z
176
+ M${S},${y} h${f} a${d},${d} 0 0 1 ${d},${d} v${m} a${d},${d} 0 0 1 -${d},${d} h-${f} a${d},${d} 0 0 1 -${d},-${d} v-${m} a${d},${d} 0 0 1 ${d},-${d} z`;
177
+ }
178
+ function de(t, e, i, n, o) {
179
+ let r = t.getState("__activeStagePosition"), s = r || n.getBoundingClientRect(), p = o.getBoundingClientRect();
180
+ r = { x: _(e, s.x, p.x - s.x, i), y: _(e, s.y, p.y - s.y, i), width: _(e, s.width, p.width - s.width, i), height: _(e, s.height, p.height - s.height, i) }, X(t, r), t.setState("__activeStagePosition", r);
181
+ }
182
+ function V(t, e) {
183
+ if (!e) return;
184
+ let i = e.getBoundingClientRect(), n = { x: i.x, y: i.y, width: i.width, height: i.height };
185
+ t.setState("__activeStagePosition", n), X(t, n);
186
+ }
187
+ function pe(t) {
188
+ let e = t.getState("__activeStagePosition"), i = t.getState("__overlaySvg");
189
+ if (!e) return;
190
+ if (!i) {
191
+ console.warn("No stage svg found.");
192
+ return;
193
+ }
194
+ let n = window.innerWidth, o = window.innerHeight;
195
+ i.setAttribute("viewBox", `0 0 ${n} ${o}`);
196
+ }
197
+ function ce(t, e) {
198
+ let i = ge(t, e);
199
+ document.body.appendChild(i), R(i, (n) => {
200
+ n.target.tagName === "path" && t.emit("overlayClick");
201
+ }), t.setState("__overlaySvg", i);
202
+ }
203
+ function X(t, e) {
204
+ let i = t.getState("__overlaySvg");
205
+ if (!i) {
206
+ ce(t, e);
207
+ return;
208
+ }
209
+ let n = i.firstElementChild;
210
+ if (n?.tagName !== "path") throw Error("no path element found in stage svg");
211
+ n.setAttribute("d", K(e, Y(t)));
212
+ }
213
+ function Y(t) {
214
+ return { padding: t.getConfig("stagePadding") || 0, radius: t.getConfig("stageRadius") || 0 };
215
+ }
216
+ function ge(t, e) {
217
+ let i = window.innerWidth, n = window.innerHeight, o = document.createElementNS("http://www.w3.org/2000/svg", "svg");
218
+ o.classList.add("driver-overlay", "driver-overlay-animated"), o.setAttribute("viewBox", `0 0 ${i} ${n}`), o.setAttribute("xmlSpace", "preserve"), o.setAttribute("xmlnsXlink", "http://www.w3.org/1999/xlink"), o.setAttribute("version", "1.1"), o.setAttribute("preserveAspectRatio", "xMinYMin slice"), o.style.fillRule = "evenodd", o.style.clipRule = "evenodd", o.style.strokeLinejoin = "round", o.style.strokeMiterlimit = "2", o.style.zIndex = "10000", o.style.position = "fixed", o.style.top = "0", o.style.left = "0", o.style.width = "100%", o.style.height = "100%";
219
+ let r = document.createElementNS("http://www.w3.org/2000/svg", "path");
220
+ return r.setAttribute("d", K(e, Y(t))), r.style.fill = t.getConfig("overlayColor") || "rgb(0,0,0)", r.style.opacity = `${t.getConfig("overlayOpacity")}`, r.style.pointerEvents = "auto", r.style.cursor = "auto", o.appendChild(r), o;
221
+ }
222
+ function ve(t) {
223
+ let e = t.getState("__overlaySvg");
224
+ e && (P(e), e.remove());
225
+ }
226
+ const j = "{{current}} of {{total}}";
227
+ function Z(t, e) {
228
+ return !(e.skipMissingElement ?? t.getConfig("skipMissingElement")) || !e.element ? !1 : !L(e.element);
229
+ }
230
+ function b(t, e, i) {
231
+ let n = t.getConfig("steps") || [];
232
+ for (let o = e; o >= 0 && o < n.length; o += i) if (!Z(t, n[o])) return o;
233
+ }
234
+ function E(t, e) {
235
+ let i = t.getState("activeIndex"), n = i !== void 0 && b(t, i + 1, 1) === void 0, o = e?.popover?.onDoneClick || t.getConfig("onDoneClick");
236
+ return n && o ? o : e?.popover?.onNextClick || t.getConfig("onNextClick");
237
+ }
238
+ function G(t, e) {
239
+ return e?.popover?.onPrevClick || t.getConfig("onPrevClick");
240
+ }
241
+ function ue(t, e) {
242
+ return e?.popover?.onCloseClick || t.getConfig("onCloseClick");
243
+ }
244
+ function fe(t, e, i) {
245
+ let n = t.getConfig("steps") || [], o = n[e], r = o.popover || {}, s = b(t, e + 1, 1) !== void 0, p = b(t, e - 1, -1) !== void 0, v = r.doneBtnText || t.getConfig("doneBtnText") || "Done", d = t.getConfig("allowClose"), S = r.showProgress === void 0 ? t.getConfig("showProgress") : r.showProgress, y = (r.progressText || t.getConfig("progressText") || j).replace("{{current}}", `${e + 1}`).replace("{{total}}", `${n.length}`), f = r.showButtons || t.getConfig("showButtons"), m = ["next", "previous", ...d ? ["close"] : []].filter((a) => !f?.length || f.includes(a)), h = r.onNextClick || t.getConfig("onNextClick"), w = r.onPrevClick || t.getConfig("onPrevClick"), l = r.onCloseClick || t.getConfig("onCloseClick");
246
+ return { ...o, popover: { showButtons: m, nextBtnText: s ? void 0 : v, disableButtons: [...p ? [] : ["previous"]], showProgress: S, onNextClick: h || i.onNextClick, onPrevClick: w || i.onPrevClick, onCloseClick: l || i.onCloseClick, ...r, progressText: y } };
247
+ }
248
+ function J(t, e, i) {
249
+ let n = t.getConfig("stagePadding") || 0;
250
+ return { side: i.popover?.side || "bottom", align: i.popover?.align || "start", offset: n + (t.getConfig("popoverOffset") || 0), padding: n, centered: e.id === "driver-dummy-element" };
251
+ }
252
+ function me(t, e, i) {
253
+ let n = i.popover || {}, o = t.getState("activeIndex"), r = o !== void 0 && b(t, o + 1, 1) === void 0;
254
+ return { title: n.title, description: n.description, showButtons: n.showButtons || t.getConfig("showButtons"), disableButtons: n.disableButtons || t.getConfig("disableButtons") || [], showProgress: n.showProgress || t.getConfig("showProgress") || !1, progressText: n.progressText ?? (t.getConfig("progressText") || j), nextBtnText: n.nextBtnText ?? (t.getConfig("nextBtnText") || "Next"), prevBtnText: n.prevBtnText ?? (t.getConfig("prevBtnText") || "Previous"), doneButton: r, popoverClass: n.popoverClass || t.getConfig("popoverClass") || "", smoothScroll: t.getConfig("smoothScroll"), onNextClick: () => {
255
+ let s = E(t, i);
256
+ return s ? s(e, i, t.getHookOpts()) : t.emit("nextClick");
257
+ }, onPrevClick: () => {
258
+ let s = G(t, i);
259
+ return s ? s(e, i, t.getHookOpts()) : t.emit("prevClick");
260
+ }, onCloseClick: () => {
261
+ let s = ue(t, i);
262
+ return s ? s(e, i, t.getHookOpts()) : t.emit("closeClick");
263
+ }, onRender: (s) => {
264
+ t.setState("popover", s), (n.onPopoverRender || t.getConfig("onPopoverRender"))?.(s, t.getHookOpts());
265
+ }, position: J(t, e, i) };
266
+ }
267
+ function I(t, e, i) {
268
+ F(t.getState("popover")), le(e, me(t, e, i));
269
+ }
270
+ function he(t, e, i) {
271
+ let n = t.getState("popover");
272
+ n && $(n, e, J(t, e, i));
273
+ }
274
+ function we() {
275
+ let t = document.getElementById("driver-dummy-element");
276
+ if (t) return t;
277
+ let e = document.createElement("div");
278
+ return e.id = "driver-dummy-element", e.style.width = "0", e.style.height = "0", e.style.pointerEvents = "none", e.style.opacity = "0", e.style.position = "fixed", e.style.top = "50%", e.style.left = "50%", document.body.appendChild(e), e;
279
+ }
280
+ function O(t, e) {
281
+ let i = L(e.element);
282
+ i || (i = we()), Ce(t, i, e);
283
+ }
284
+ function ye(t) {
285
+ let e = t.getState("__activeElement"), i = t.getState("__activeStep");
286
+ e && (V(t, e), pe(t), he(t, e, i));
287
+ }
288
+ function Ce(t, e, i) {
289
+ let n = t.getConfig("duration") || 400, o = Date.now(), r = t.getState("__activeStep"), s = t.getState("__activeElement") || e, p = !s || s === e, v = e.id === "driver-dummy-element", d = s.id === "driver-dummy-element", S = t.getConfig("animate"), y = i.onHighlightStarted || t.getConfig("onHighlightStarted"), f = i?.onHighlighted || t.getConfig("onHighlighted"), m = r?.onDeselected || t.getConfig("onDeselected"), h = t.getHookOpts();
290
+ !p && m && m(d ? void 0 : s, r, h), y && y(v ? void 0 : e, i, h);
291
+ let w = !p && S, l = !1;
292
+ re(t.getState("popover")), t.setState("previousStep", r), t.setState("previousElement", s), t.setState("activeStep", i), t.setState("activeElement", e);
293
+ let a = () => {
294
+ if (t.getState("__transitionCallback") !== a) return;
295
+ let g = Date.now() - o, u = n - g <= n / 2;
296
+ i.popover && u && !l && w && (I(t, e, i), l = !0), t.getConfig("animate") && g < n ? de(t, g, n, s, e) : (V(t, e), f && f(v ? void 0 : e, i, t.getHookOpts()), t.setState("__transitionCallback", void 0), t.setState("__previousStep", r), t.setState("__previousElement", s), t.setState("__activeStep", i), t.setState("__activeElement", e)), window.requestAnimationFrame(a);
297
+ };
298
+ t.setState("__transitionCallback", a), window.requestAnimationFrame(a), q(e, t.getConfig("smoothScroll")), !w && i.popover && I(t, e, i), document.querySelectorAll(".driver-active-element-parent").forEach((g) => {
299
+ g.classList.remove("driver-active-element-parent", "driver-active-element-parent-no-scroll");
300
+ }), s.classList.remove("driver-active-element", "driver-no-interaction"), s.removeAttribute("aria-haspopup"), s.removeAttribute("aria-expanded"), s.removeAttribute("aria-controls"), (i.disableActiveInteraction ?? t.getConfig("disableActiveInteraction")) && e.classList.add("driver-no-interaction");
301
+ let c = e.parentElement;
302
+ c && c !== document.body && (c.classList.add("driver-active-element-parent"), te(c) && c.classList.add("driver-active-element-parent-no-scroll")), e.classList.add("driver-active-element"), e.setAttribute("aria-haspopup", "dialog"), e.setAttribute("aria-expanded", "true"), e.setAttribute("aria-controls", "driver-popover-content");
303
+ }
304
+ function Se() {
305
+ document.getElementById("driver-dummy-element")?.remove(), document.querySelectorAll(".driver-active-element").forEach((t) => {
306
+ let e = t.parentElement;
307
+ e && e !== document.body && e.classList.remove("driver-active-element-parent", "driver-active-element-parent-no-scroll"), t.classList.remove("driver-active-element", "driver-no-interaction"), t.removeAttribute("aria-haspopup"), t.removeAttribute("aria-expanded"), t.removeAttribute("aria-controls");
308
+ });
309
+ }
310
+ function H(t) {
311
+ let e = t.getState("__resizeTimeout");
312
+ e && window.cancelAnimationFrame(e), t.setState("__resizeTimeout", window.requestAnimationFrame(() => ye(t)));
313
+ }
314
+ function be(t, e) {
315
+ if (!t.getState("isInitialized") || !(e.key === "Tab" || e.keyCode === 9)) return;
316
+ let i = t.getState("__activeElement"), n = t.getState("popover")?.wrapper, o = z([...n ? [n] : [], ...i ? [i] : []]), r = o[0], s = o[o.length - 1];
317
+ e.preventDefault(), e.shiftKey ? (o[o.indexOf(document.activeElement) - 1] || s)?.focus() : (o[o.indexOf(document.activeElement) + 1] || r)?.focus();
318
+ }
319
+ function xe(t, e) {
320
+ (t.getConfig("allowKeyboardControl") ?? !0) && (e.key === "Escape" ? t.emit("escapePress") : e.key === "ArrowRight" ? t.emit("arrowRightPress") : e.key === "ArrowLeft" && t.emit("arrowLeftPress"));
321
+ }
322
+ function ke(t, e) {
323
+ let i = t.getState("__activeElement"), n = e.target;
324
+ !i || !n || !i.contains(n) || t.emit("activeElementClick");
325
+ }
326
+ function _e(t) {
327
+ let e = (s) => xe(t, s), i = (s) => be(t, s), n = () => H(t), o = () => H(t), r = (s) => ke(t, s);
328
+ t.setState("__events", { onKeyup: e, onKeydown: i, onResize: n, onScroll: o, onClick: r }), window.addEventListener("keyup", e, !1), window.addEventListener("keydown", i, !1), window.addEventListener("resize", n), window.addEventListener("scroll", o), document.addEventListener("click", r, !1);
329
+ }
330
+ function Ee(t) {
331
+ let e = t.getState("__events");
332
+ e && (window.removeEventListener("keyup", e.onKeyup), window.removeEventListener("keydown", e.onKeydown), window.removeEventListener("resize", e.onResize), window.removeEventListener("scroll", e.onScroll), document.removeEventListener("click", e.onClick, !1));
333
+ }
334
+ function Le() {
335
+ let t = {};
336
+ function e(i = {}) {
337
+ t = { animate: !0, duration: 400, allowClose: !0, allowScroll: !0, overlayClickBehavior: "close", overlayOpacity: 0.7, smoothScroll: !1, disableActiveInteraction: !1, advanceOnClick: !1, skipMissingElement: !1, waitForElement: 0, showProgress: !1, stagePadding: 10, stageRadius: 5, popoverOffset: 10, showButtons: ["next", "previous", "close"], disableButtons: [], overlayColor: "#000", ...i };
338
+ }
339
+ return e(), { getConfig: ((i) => i ? t[i] : t), configure: e };
340
+ }
341
+ function Be() {
342
+ let t = {}, e = ((o) => o ? t[o] : t), i = (o, r) => {
343
+ t[o] = r;
344
+ };
345
+ function n() {
346
+ t = {};
347
+ }
348
+ return { getState: e, setState: i, resetState: n };
349
+ }
350
+ function He() {
351
+ let t = {};
352
+ function e(o, r) {
353
+ t[o] = r;
354
+ }
355
+ function i(o) {
356
+ t[o]?.();
357
+ }
358
+ function n() {
359
+ t = {};
360
+ }
361
+ return { listen: e, emit: i, reset: n };
362
+ }
363
+ function Pe(t = {}) {
364
+ let e = Le();
365
+ e.configure(t);
366
+ let i = Be(), n = He(), o;
367
+ return { getConfig: e.getConfig, setConfig: e.configure, getState: i.getState, setState: i.setState, resetState: i.resetState, listen: n.listen, emit: n.emit, resetEmitter: n.reset, getDriver: () => o, setDriver: (r) => {
368
+ o = r;
369
+ }, getHookOpts: (r) => {
370
+ let s = r || i.getState();
371
+ return { config: e.getConfig(), state: s, driver: o, index: s.activeIndex };
372
+ } };
373
+ }
374
+ function Ae(t = {}) {
375
+ let e = Pe(t);
376
+ function i() {
377
+ e.getConfig("allowClose") && h();
378
+ }
379
+ function n() {
380
+ let l = e.getConfig("overlayClickBehavior");
381
+ if (e.getConfig("allowClose") && l === "close") {
382
+ h();
383
+ return;
384
+ }
385
+ if (typeof l == "function") {
386
+ let a = e.getState("__activeStep");
387
+ l(e.getState("__activeElement"), a, e.getHookOpts());
388
+ return;
389
+ }
390
+ if (l === "nextStep") {
391
+ let a = e.getState("activeStep"), c = e.getState("activeElement"), g = E(e, a);
392
+ if (g) {
393
+ g(c, a, e.getHookOpts());
394
+ return;
395
+ }
396
+ o();
397
+ }
398
+ }
399
+ function o() {
400
+ let l = e.getState("activeIndex"), a = e.getConfig("steps") || [];
401
+ if (l === void 0) return;
402
+ let c = l + 1;
403
+ a[c] ? m(c) : h();
404
+ }
405
+ function r() {
406
+ let l = e.getState("activeIndex"), a = e.getConfig("steps") || [];
407
+ if (l === void 0) return;
408
+ let c = l - 1;
409
+ a[c] ? m(c) : h();
410
+ }
411
+ function s(l) {
412
+ (e.getConfig("steps") || [])[l] ? m(l) : h();
413
+ }
414
+ function p() {
415
+ if (e.getState("__transitionCallback")) return;
416
+ let l = e.getState("__activeStep");
417
+ if (!l || !(l.advanceOnClick ?? e.getConfig("advanceOnClick"))) return;
418
+ let a = e.getState("__activeElement"), c = E(e, l);
419
+ if (c) {
420
+ c(a, l, e.getHookOpts());
421
+ return;
422
+ }
423
+ o();
424
+ }
425
+ function v() {
426
+ if (e.getState("__transitionCallback")) return;
427
+ let l = e.getState("activeIndex"), a = e.getState("__activeStep"), c = e.getState("__activeElement");
428
+ if (l === void 0 || a === void 0 || !(e.getConfig("steps") || [])[l - 1]) return;
429
+ let g = G(e, a);
430
+ if (g) return g(c, a, e.getHookOpts());
431
+ r();
432
+ }
433
+ function d() {
434
+ if (e.getState("__transitionCallback")) return;
435
+ let l = e.getState("activeIndex"), a = e.getState("__activeStep"), c = e.getState("__activeElement");
436
+ if (l === void 0 || a === void 0) return;
437
+ let g = E(e, a);
438
+ if (g) return g(c, a, e.getHookOpts());
439
+ o();
440
+ }
441
+ function S() {
442
+ e.getState("isInitialized") || (e.setState("isInitialized", !0), document.body.classList.add("driver-active", e.getConfig("animate") ? "driver-fade" : "driver-simple"), e.getConfig("allowScroll") || document.body.classList.add("driver-no-scroll"), document.body.style.setProperty("--driver-animation-duration", `${e.getConfig("duration") || 400}ms`), _e(e), e.listen("overlayClick", n), e.listen("activeElementClick", p), e.listen("escapePress", i), e.listen("closeClick", i), e.listen("arrowLeftPress", v), e.listen("arrowRightPress", d));
443
+ }
444
+ function y() {
445
+ let l = e.getState("__pendingWaitCancel");
446
+ l && (e.setState("__pendingWaitCancel", void 0), l());
447
+ }
448
+ function f(l, a, c) {
449
+ let g = () => {
450
+ u.disconnect(), window.clearTimeout(C), e.setState("__pendingWaitCancel", void 0), c();
451
+ }, u = new MutationObserver(() => {
452
+ L(l.element) && g();
453
+ }), C = window.setTimeout(g, a);
454
+ e.setState("__pendingWaitCancel", () => {
455
+ u.disconnect(), window.clearTimeout(C);
456
+ }), u.observe(document.documentElement, { childList: !0, subtree: !0, attributes: !0 });
457
+ }
458
+ function m(l = 0, a = !1) {
459
+ y();
460
+ let c = e.getConfig("steps");
461
+ if (!c) {
462
+ console.error("No steps to drive through"), h();
463
+ return;
464
+ }
465
+ if (!c[l]) {
466
+ h();
467
+ return;
468
+ }
469
+ let g = c[l], u = g.waitForElement ?? e.getConfig("waitForElement") ?? 0;
470
+ if (!a && u > 0 && g.element && !L(g.element)) {
471
+ f(g, u, () => m(l, !0));
472
+ return;
473
+ }
474
+ if (Z(e, g)) {
475
+ let k = e.getState("activeIndex"), x = typeof k == "number" && l < k ? -1 : 1;
476
+ c[l + x] ? m(l + x) : x === 1 && h();
477
+ return;
478
+ }
479
+ e.setState("__activeOnDestroyed", document.activeElement), e.setState("activeIndex", l);
480
+ let C = c[l + 1];
481
+ O(e, fe(e, l, { onNextClick: () => {
482
+ C ? m(l + 1) : h();
483
+ }, onPrevClick: () => {
484
+ m(l - 1);
485
+ }, onCloseClick: () => {
486
+ h();
487
+ } }));
488
+ }
489
+ function h(l = !0) {
490
+ let a = e.getState("__activeElement"), c = e.getState("__activeStep"), g = e.getState("__activeOnDestroyed"), u = e.getConfig("onDestroyStarted");
491
+ if (l && u) {
492
+ u(!a || a?.id === "driver-dummy-element" ? void 0 : a, c, e.getHookOpts());
493
+ return;
494
+ }
495
+ let C = c?.onDeselected || e.getConfig("onDeselected"), k = e.getConfig("onDestroyed");
496
+ document.body.classList.remove("driver-active", "driver-fade", "driver-simple", "driver-no-scroll"), document.body.style.removeProperty("--driver-animation-duration"), y(), Ee(e), F(e.getState("popover")), Se(), ve(e), e.resetEmitter();
497
+ let x = e.getState();
498
+ if (e.resetState(), a && c) {
499
+ let A = a.id === "driver-dummy-element";
500
+ C && C(A ? void 0 : a, c, e.getHookOpts(x)), k && k(A ? void 0 : a, c, e.getHookOpts(x));
501
+ }
502
+ g && g.focus();
503
+ }
504
+ let w = { isActive: () => e.getState("isInitialized") || !1, refresh: () => H(e), drive: (l = 0) => {
505
+ S(), m(l);
506
+ }, setConfig: e.setConfig, setSteps: (l) => {
507
+ y(), e.resetState(), e.setConfig({ ...e.getConfig(), steps: l });
508
+ }, getConfig: e.getConfig, getState: e.getState, getActiveIndex: () => e.getState("activeIndex"), isFirstStep: () => {
509
+ let l = e.getState("activeIndex");
510
+ return l !== void 0 && b(e, l - 1, -1) === void 0;
511
+ }, isLastStep: () => {
512
+ let l = e.getState("activeIndex");
513
+ return l !== void 0 && b(e, l + 1, 1) === void 0;
514
+ }, getActiveStep: () => e.getState("activeStep"), getActiveElement: () => e.getState("activeElement"), getPreviousElement: () => e.getState("previousElement"), getPreviousStep: () => e.getState("previousStep"), getNextStep: () => {
515
+ let l = e.getConfig("steps") || [], a = e.getState("activeIndex");
516
+ if (a === void 0) return;
517
+ let c = b(e, a + 1, 1);
518
+ return c === void 0 ? void 0 : l[c];
519
+ }, moveNext: o, movePrevious: r, moveTo: s, hasNextStep: () => {
520
+ let l = e.getState("activeIndex");
521
+ return l !== void 0 && b(e, l + 1, 1) !== void 0;
522
+ }, hasPreviousStep: () => {
523
+ let l = e.getState("activeIndex");
524
+ return l !== void 0 && b(e, l - 1, -1) !== void 0;
525
+ }, highlight: (l) => {
526
+ S(), O(e, { ...l, popover: l.popover ? { showButtons: [], showProgress: !1, progressText: "", ...l.popover } : void 0 });
527
+ }, destroy: () => {
528
+ h(!1);
529
+ } };
530
+ return e.setDriver(w), w;
531
+ }
532
+ export {
533
+ Ae as driver
534
+ };
@@ -0,0 +1,2 @@
1
+ export declare const AKILIO_DESKTOP_QUERY = "(min-width: 1280px)";
2
+ export declare function useIsDesktop(query?: string): boolean;
@@ -0,0 +1,18 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ import type { AkilioChatMessage } from '../types';
3
+ export declare const MAX_AKILIO_HISTORY_MESSAGES = 60;
4
+ export declare function safeJsonParse<T>(raw: string | null, fallback: T): T;
5
+ export declare function useLocalMessages(options: {
6
+ enabled: boolean;
7
+ projectKey: string;
8
+ locale: string;
9
+ }): [
10
+ AkilioChatMessage[],
11
+ Dispatch<SetStateAction<AkilioChatMessage[]>>,
12
+ string
13
+ ];
14
+ export declare function useLocalString(options: {
15
+ enabled: boolean;
16
+ key: string;
17
+ initialValue?: string;
18
+ }): [string, Dispatch<SetStateAction<string>>];
@@ -0,0 +1,3 @@
1
+ export { AkilioWidget, AkilioWidget as EjibuWidget } from './AkilioWidget';
2
+ export { AkilioClient } from './lib/client';
3
+ export type * from './types';