@askdialog/dialog-react 2.6.0 → 2.7.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.
package/dist/dialog-react.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsxs as g, jsx as n, Fragment as C } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as b, useState as v, useEffect as
|
|
3
|
-
import { registerDialogInstallation as D, addAuditCapability as
|
|
4
|
-
import { createPortal as
|
|
5
|
-
const
|
|
2
|
+
import { useRef as b, useState as v, useEffect as f, useMemo as y, useLayoutEffect as j, useCallback as P, useSyncExternalStore as q } from "react";
|
|
3
|
+
import { registerDialogInstallation as D, addAuditCapability as z, resolveTextDirection as K, SearchStatus as S, DialogSearchError as F, createSearchController as U } from "@askdialog/dialog-sdk";
|
|
4
|
+
import { createPortal as W } from "react-dom";
|
|
5
|
+
const Q = ({
|
|
6
6
|
title: e = "Your expert",
|
|
7
7
|
description: t = "A question about this product?"
|
|
8
8
|
}) => /* @__PURE__ */ g("div", { className: "dialog-block-header-container", children: [
|
|
9
9
|
/* @__PURE__ */ n("div", { className: "dialog-block-title", children: e }),
|
|
10
10
|
/* @__PURE__ */ n("div", { className: "dialog-block-description", children: t })
|
|
11
|
-
] }),
|
|
11
|
+
] }), Z = ({ color: e = "#181825" }) => /* @__PURE__ */ g(
|
|
12
12
|
"svg",
|
|
13
13
|
{
|
|
14
14
|
width: "20",
|
|
@@ -42,17 +42,17 @@ const W = ({
|
|
|
42
42
|
/* @__PURE__ */ n("defs", { children: /* @__PURE__ */ n("clipPath", { id: "clip0_466_934", children: /* @__PURE__ */ n("rect", { width: "20", height: "20", fill: "white" }) }) })
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
|
-
),
|
|
45
|
+
), X = ({
|
|
46
46
|
client: e,
|
|
47
47
|
questions: t,
|
|
48
|
-
productId:
|
|
49
|
-
productTitle:
|
|
48
|
+
productId: r,
|
|
49
|
+
productTitle: s,
|
|
50
50
|
selectedVariantId: o
|
|
51
51
|
}) => {
|
|
52
|
-
const
|
|
52
|
+
const i = (l) => {
|
|
53
53
|
e.sendProductMessage({
|
|
54
|
-
productId:
|
|
55
|
-
productTitle:
|
|
54
|
+
productId: r,
|
|
55
|
+
productTitle: s,
|
|
56
56
|
selectedVariantId: o,
|
|
57
57
|
question: l,
|
|
58
58
|
fromQuestionSuggestion: !0
|
|
@@ -62,35 +62,35 @@ const W = ({
|
|
|
62
62
|
"button",
|
|
63
63
|
{
|
|
64
64
|
className: "dialog-block-suggestions-item",
|
|
65
|
-
onClick: () =>
|
|
65
|
+
onClick: () => i(l.question),
|
|
66
66
|
children: [
|
|
67
|
-
/* @__PURE__ */ n(
|
|
67
|
+
/* @__PURE__ */ n(Z, { color: e.theme.primaryColor }),
|
|
68
68
|
/* @__PURE__ */ n("span", { className: "dialog-block-suggestions-item-label", children: l.question })
|
|
69
69
|
]
|
|
70
70
|
},
|
|
71
71
|
l.question
|
|
72
72
|
)) });
|
|
73
|
-
},
|
|
73
|
+
}, G = () => /* @__PURE__ */ g(C, { children: [
|
|
74
74
|
/* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" }),
|
|
75
75
|
/* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" }),
|
|
76
76
|
/* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" })
|
|
77
|
-
] }),
|
|
77
|
+
] }), Y = ({
|
|
78
78
|
client: e,
|
|
79
79
|
questions: t,
|
|
80
|
-
isLoading:
|
|
81
|
-
productId:
|
|
80
|
+
isLoading: r,
|
|
81
|
+
productId: s,
|
|
82
82
|
productTitle: o,
|
|
83
|
-
selectedVariantId:
|
|
84
|
-
}) => /* @__PURE__ */ n("div", { className: "dialog-block-suggestions-container", children:
|
|
85
|
-
|
|
83
|
+
selectedVariantId: i
|
|
84
|
+
}) => /* @__PURE__ */ n("div", { className: "dialog-block-suggestions-container", children: r || !t ? /* @__PURE__ */ n(G, {}) : /* @__PURE__ */ n(
|
|
85
|
+
X,
|
|
86
86
|
{
|
|
87
87
|
client: e,
|
|
88
88
|
questions: t,
|
|
89
|
-
productId:
|
|
89
|
+
productId: s,
|
|
90
90
|
productTitle: o,
|
|
91
|
-
selectedVariantId:
|
|
91
|
+
selectedVariantId: i
|
|
92
92
|
}
|
|
93
|
-
) }),
|
|
93
|
+
) }), J = ({ color: e = "#ffffff" }) => /* @__PURE__ */ n(
|
|
94
94
|
"svg",
|
|
95
95
|
{
|
|
96
96
|
width: "20",
|
|
@@ -109,67 +109,87 @@ const W = ({
|
|
|
109
109
|
}
|
|
110
110
|
)
|
|
111
111
|
}
|
|
112
|
-
),
|
|
112
|
+
), E = {
|
|
113
|
+
en: {
|
|
114
|
+
placeholder: "Ask the AI a question",
|
|
115
|
+
aiDisclosure: "You're chatting with an AI assistant. It can make mistakes, so please double-check important information"
|
|
116
|
+
},
|
|
117
|
+
fr: {
|
|
118
|
+
placeholder: "Posez une question à l'IA",
|
|
119
|
+
aiDisclosure: "Vous discutez avec un assistant IA. Il peut se tromper, pensez à vérifier les informations importantes"
|
|
120
|
+
},
|
|
121
|
+
es: {
|
|
122
|
+
placeholder: "Haz una pregunta a la IA",
|
|
123
|
+
aiDisclosure: "Estás chateando con un asistente de IA. Puede cometer errores, así que verifica la información importante"
|
|
124
|
+
}
|
|
125
|
+
}, ee = (e) => {
|
|
126
|
+
var r;
|
|
127
|
+
const t = ((r = e == null ? void 0 : e.split("-")[0]) == null ? void 0 : r.toLowerCase()) ?? "en";
|
|
128
|
+
return E[t] ?? E.en;
|
|
129
|
+
}, te = ({
|
|
113
130
|
client: e,
|
|
114
|
-
|
|
115
|
-
productId: s,
|
|
131
|
+
productId: t,
|
|
116
132
|
productTitle: r,
|
|
117
|
-
selectedVariantId:
|
|
133
|
+
selectedVariantId: s
|
|
118
134
|
}) => {
|
|
119
|
-
const
|
|
135
|
+
const o = b(null), [i, l] = v(""), a = ee(e.locale), c = () => {
|
|
120
136
|
var d;
|
|
121
|
-
(d =
|
|
137
|
+
(d = o.current) == null || d.focus();
|
|
122
138
|
}, u = () => {
|
|
123
|
-
const d =
|
|
139
|
+
const d = i;
|
|
124
140
|
d.trim() && (e.sendProductMessage({
|
|
125
|
-
productId:
|
|
141
|
+
productId: t,
|
|
126
142
|
productTitle: r,
|
|
127
|
-
selectedVariantId:
|
|
143
|
+
selectedVariantId: s,
|
|
128
144
|
question: d,
|
|
129
145
|
fromQuestionSuggestion: !0
|
|
130
|
-
}),
|
|
146
|
+
}), l(""));
|
|
147
|
+
}, p = (d) => {
|
|
148
|
+
d.key === "Enter" && u();
|
|
131
149
|
};
|
|
132
|
-
return /* @__PURE__ */ g("div", { className: "dialog-input-
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
return /* @__PURE__ */ g("div", { className: "dialog-input-container", children: [
|
|
151
|
+
/* @__PURE__ */ g("div", { className: "dialog-input-wrapper", onClick: c, children: [
|
|
152
|
+
/* @__PURE__ */ n(
|
|
153
|
+
"input",
|
|
154
|
+
{
|
|
155
|
+
id: "dialog-ask-anything-input-ai-input",
|
|
156
|
+
ref: o,
|
|
157
|
+
value: i,
|
|
158
|
+
onChange: (d) => l(d.target.value),
|
|
159
|
+
className: "dialog-ask-anything-input-ai-input",
|
|
160
|
+
placeholder: a.placeholder,
|
|
161
|
+
"aria-describedby": "dialog-input-ai-disclosure",
|
|
162
|
+
onKeyDown: p
|
|
144
163
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
)
|
|
164
|
+
),
|
|
165
|
+
/* @__PURE__ */ n(
|
|
166
|
+
"button",
|
|
167
|
+
{
|
|
168
|
+
id: "send-message-button-ai-input",
|
|
169
|
+
className: "dialog-input-submit",
|
|
170
|
+
disabled: !i.trim(),
|
|
171
|
+
onClick: u,
|
|
172
|
+
children: /* @__PURE__ */ n(J, { color: e.theme.ctaTextColor })
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ n("p", { id: "dialog-input-ai-disclosure", className: "dialog-input-ai-disclosure", children: a.aiDisclosure })
|
|
157
177
|
] });
|
|
158
|
-
},
|
|
178
|
+
}, A = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), se = (e) => {
|
|
159
179
|
if (!e) return;
|
|
160
180
|
const t = document.body;
|
|
161
|
-
Object.keys(e).forEach((
|
|
162
|
-
const
|
|
163
|
-
if (e[
|
|
164
|
-
if (typeof e[
|
|
165
|
-
Object.keys(e[
|
|
166
|
-
(
|
|
181
|
+
Object.keys(e).forEach((r) => {
|
|
182
|
+
const s = r, o = A(r);
|
|
183
|
+
if (e[s] !== void 0) {
|
|
184
|
+
if (typeof e[s] == "object") {
|
|
185
|
+
Object.keys(e[s]).forEach(
|
|
186
|
+
(i) => {
|
|
167
187
|
var a;
|
|
168
|
-
const l =
|
|
188
|
+
const l = i;
|
|
169
189
|
if (l !== void 0) {
|
|
170
|
-
const
|
|
190
|
+
const c = A(i), u = e[s];
|
|
171
191
|
t.style.setProperty(
|
|
172
|
-
`--dialog-theme-${o}-${
|
|
192
|
+
`--dialog-theme-${o}-${c}`,
|
|
173
193
|
(a = u[l]) == null ? void 0 : a.toString()
|
|
174
194
|
);
|
|
175
195
|
}
|
|
@@ -177,58 +197,58 @@ const W = ({
|
|
|
177
197
|
);
|
|
178
198
|
return;
|
|
179
199
|
}
|
|
180
|
-
if (
|
|
181
|
-
const
|
|
182
|
-
t.style.setProperty(`--dialog-theme-${o}`,
|
|
200
|
+
if (s === "ctaBorderType") {
|
|
201
|
+
const i = e[s] === "rounded" ? "24px" : "0";
|
|
202
|
+
t.style.setProperty(`--dialog-theme-${o}`, i);
|
|
183
203
|
return;
|
|
184
204
|
}
|
|
185
205
|
t.style.setProperty(
|
|
186
206
|
`--dialog-theme-${o}`,
|
|
187
|
-
e[
|
|
207
|
+
e[s].toString()
|
|
188
208
|
);
|
|
189
209
|
}
|
|
190
210
|
});
|
|
191
|
-
},
|
|
192
|
-
e &&
|
|
211
|
+
}, re = ({ theme: e, children: t }) => (f(() => {
|
|
212
|
+
e && se(e);
|
|
193
213
|
}, [e]), /* @__PURE__ */ n(C, { children: t })), Fe = ({
|
|
194
214
|
client: e,
|
|
195
215
|
productId: t,
|
|
196
|
-
productTitle:
|
|
197
|
-
selectedVariantId:
|
|
216
|
+
productTitle: r,
|
|
217
|
+
selectedVariantId: s,
|
|
198
218
|
enableInput: o = !0
|
|
199
219
|
}) => {
|
|
200
|
-
const [
|
|
220
|
+
const [i, l] = v(!0), [a, c] = v(
|
|
201
221
|
void 0
|
|
202
222
|
);
|
|
203
|
-
|
|
223
|
+
f(() => {
|
|
204
224
|
D({
|
|
205
225
|
method: "react",
|
|
206
|
-
version: "2.
|
|
207
|
-
}),
|
|
226
|
+
version: "2.7.0"
|
|
227
|
+
}), z("pdp-block");
|
|
208
228
|
}, []);
|
|
209
229
|
const u = y(
|
|
210
|
-
() =>
|
|
211
|
-
[a,
|
|
230
|
+
() => i ? "" : a == null ? void 0 : a.assistantName,
|
|
231
|
+
[a, i]
|
|
212
232
|
), p = y(
|
|
213
|
-
() =>
|
|
214
|
-
[a,
|
|
233
|
+
() => i ? "" : a == null ? void 0 : a.description,
|
|
234
|
+
[a, i]
|
|
215
235
|
), d = y(
|
|
216
|
-
() =>
|
|
217
|
-
[a,
|
|
218
|
-
),
|
|
236
|
+
() => i ? "" : a == null ? void 0 : a.inputPlaceholder,
|
|
237
|
+
[a, i]
|
|
238
|
+
), m = y(
|
|
219
239
|
() => {
|
|
220
240
|
var h;
|
|
221
|
-
return
|
|
241
|
+
return K((h = e.getLocalizationInformations()) == null ? void 0 : h.languageCode);
|
|
222
242
|
},
|
|
223
243
|
[e]
|
|
224
244
|
);
|
|
225
|
-
return
|
|
245
|
+
return f(() => {
|
|
226
246
|
let h = !0;
|
|
227
247
|
return (async () => {
|
|
228
|
-
l(!0),
|
|
248
|
+
l(!0), c(void 0);
|
|
229
249
|
try {
|
|
230
250
|
const k = await e.getSuggestions(t);
|
|
231
|
-
h &&
|
|
251
|
+
h && c(k);
|
|
232
252
|
} catch (k) {
|
|
233
253
|
console.error("error", k);
|
|
234
254
|
} finally {
|
|
@@ -237,39 +257,39 @@ const W = ({
|
|
|
237
257
|
})(), () => {
|
|
238
258
|
h = !1;
|
|
239
259
|
};
|
|
240
|
-
}, [e, t]), /* @__PURE__ */ n(
|
|
260
|
+
}, [e, t]), /* @__PURE__ */ n(re, { theme: e.theme, children: /* @__PURE__ */ g(
|
|
241
261
|
"div",
|
|
242
262
|
{
|
|
243
263
|
id: "dialog-instant",
|
|
244
264
|
className: "dialog-block-container",
|
|
245
|
-
dir:
|
|
265
|
+
dir: m,
|
|
246
266
|
children: [
|
|
247
|
-
/* @__PURE__ */ n(
|
|
267
|
+
/* @__PURE__ */ n(Q, { title: u, description: p }),
|
|
248
268
|
/* @__PURE__ */ n(
|
|
249
|
-
|
|
269
|
+
Y,
|
|
250
270
|
{
|
|
251
271
|
client: e,
|
|
252
272
|
questions: a == null ? void 0 : a.questions,
|
|
253
|
-
isLoading:
|
|
273
|
+
isLoading: i,
|
|
254
274
|
productId: t,
|
|
255
|
-
productTitle:
|
|
256
|
-
selectedVariantId:
|
|
275
|
+
productTitle: r,
|
|
276
|
+
selectedVariantId: s
|
|
257
277
|
}
|
|
258
278
|
),
|
|
259
279
|
o && /* @__PURE__ */ n(
|
|
260
|
-
|
|
280
|
+
te,
|
|
261
281
|
{
|
|
262
282
|
client: e,
|
|
263
283
|
placeholder: d,
|
|
264
284
|
productId: t,
|
|
265
|
-
productTitle:
|
|
266
|
-
selectedVariantId:
|
|
285
|
+
productTitle: r,
|
|
286
|
+
selectedVariantId: s
|
|
267
287
|
}
|
|
268
288
|
)
|
|
269
289
|
]
|
|
270
290
|
}
|
|
271
291
|
) });
|
|
272
|
-
},
|
|
292
|
+
}, ne = () => /* @__PURE__ */ n(
|
|
273
293
|
"svg",
|
|
274
294
|
{
|
|
275
295
|
width: 16,
|
|
@@ -289,7 +309,7 @@ const W = ({
|
|
|
289
309
|
}
|
|
290
310
|
)
|
|
291
311
|
}
|
|
292
|
-
),
|
|
312
|
+
), oe = "M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z", ae = ({
|
|
293
313
|
color: e = "currentColor"
|
|
294
314
|
}) => /* @__PURE__ */ n(
|
|
295
315
|
"svg",
|
|
@@ -300,20 +320,20 @@ const W = ({
|
|
|
300
320
|
fill: "none",
|
|
301
321
|
xmlns: "http://www.w3.org/2000/svg",
|
|
302
322
|
"aria-hidden": "true",
|
|
303
|
-
children: /* @__PURE__ */ n("path", { d:
|
|
323
|
+
children: /* @__PURE__ */ n("path", { d: oe, fill: e })
|
|
304
324
|
}
|
|
305
|
-
),
|
|
325
|
+
), Ue = ({
|
|
306
326
|
controller: e,
|
|
307
327
|
placeholder: t = "Search products...",
|
|
308
|
-
autoFocus:
|
|
309
|
-
submitAriaLabel:
|
|
328
|
+
autoFocus: r = !1,
|
|
329
|
+
submitAriaLabel: s = "Search"
|
|
310
330
|
}) => {
|
|
311
|
-
const [o,
|
|
331
|
+
const [o, i] = v("");
|
|
312
332
|
return /* @__PURE__ */ g("form", { className: "dialog-search-bar", role: "search", onSubmit: (a) => {
|
|
313
333
|
a.preventDefault(), e.submit(o);
|
|
314
334
|
}, children: [
|
|
315
335
|
/* @__PURE__ */ g("div", { className: "dialog-search-bar-field", children: [
|
|
316
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-bar-icon", children: /* @__PURE__ */ n(
|
|
336
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-bar-icon", children: /* @__PURE__ */ n(ae, {}) }),
|
|
317
337
|
/* @__PURE__ */ n(
|
|
318
338
|
"input",
|
|
319
339
|
{
|
|
@@ -323,9 +343,9 @@ const W = ({
|
|
|
323
343
|
value: o,
|
|
324
344
|
"aria-label": t,
|
|
325
345
|
placeholder: t,
|
|
326
|
-
autoFocus:
|
|
346
|
+
autoFocus: r,
|
|
327
347
|
onChange: (a) => {
|
|
328
|
-
|
|
348
|
+
i(a.target.value), e.setQuery(a.target.value);
|
|
329
349
|
}
|
|
330
350
|
}
|
|
331
351
|
)
|
|
@@ -335,18 +355,18 @@ const W = ({
|
|
|
335
355
|
{
|
|
336
356
|
type: "submit",
|
|
337
357
|
className: "dialog-search-bar-submit",
|
|
338
|
-
"aria-label":
|
|
339
|
-
children: /* @__PURE__ */ n(
|
|
358
|
+
"aria-label": s,
|
|
359
|
+
children: /* @__PURE__ */ n(ne, {})
|
|
340
360
|
}
|
|
341
361
|
)
|
|
342
362
|
] });
|
|
343
|
-
},
|
|
363
|
+
}, ie = (e, t) => {
|
|
344
364
|
try {
|
|
345
365
|
return new Intl.NumberFormat(t).format(e);
|
|
346
366
|
} catch {
|
|
347
367
|
return String(e);
|
|
348
368
|
}
|
|
349
|
-
},
|
|
369
|
+
}, $ = {
|
|
350
370
|
en: (e) => ({
|
|
351
371
|
searching: (t) => `Searching “${t}”…`,
|
|
352
372
|
noResults: "No matching products",
|
|
@@ -358,7 +378,7 @@ const W = ({
|
|
|
358
378
|
seeAllLabel: (t) => t === 1 ? "See the result" : `See all ${e(t)} results`,
|
|
359
379
|
previous: "Previous",
|
|
360
380
|
next: "Next",
|
|
361
|
-
pageOf: (t,
|
|
381
|
+
pageOf: (t, r) => `Page ${e(t)} / ${e(r)}`
|
|
362
382
|
}),
|
|
363
383
|
fr: (e) => ({
|
|
364
384
|
searching: (t) => `Recherche de « ${t} »…`,
|
|
@@ -371,7 +391,7 @@ const W = ({
|
|
|
371
391
|
seeAllLabel: (t) => t === 1 ? "Voir le résultat" : `Voir les ${e(t)} résultats`,
|
|
372
392
|
previous: "Précédent",
|
|
373
393
|
next: "Suivant",
|
|
374
|
-
pageOf: (t,
|
|
394
|
+
pageOf: (t, r) => `Page ${e(t)} / ${e(r)}`
|
|
375
395
|
}),
|
|
376
396
|
de: (e) => ({
|
|
377
397
|
searching: (t) => `Suche nach „${t}“…`,
|
|
@@ -384,7 +404,7 @@ const W = ({
|
|
|
384
404
|
seeAllLabel: (t) => t === 1 ? "Das Ergebnis anzeigen" : `Alle ${e(t)} Ergebnisse anzeigen`,
|
|
385
405
|
previous: "Zurück",
|
|
386
406
|
next: "Weiter",
|
|
387
|
-
pageOf: (t,
|
|
407
|
+
pageOf: (t, r) => `Seite ${e(t)} / ${e(r)}`
|
|
388
408
|
}),
|
|
389
409
|
es: (e) => ({
|
|
390
410
|
searching: (t) => `Buscando «${t}»…`,
|
|
@@ -397,7 +417,7 @@ const W = ({
|
|
|
397
417
|
seeAllLabel: (t) => t === 1 ? "Ver el resultado" : `Ver los ${e(t)} resultados`,
|
|
398
418
|
previous: "Anterior",
|
|
399
419
|
next: "Siguiente",
|
|
400
|
-
pageOf: (t,
|
|
420
|
+
pageOf: (t, r) => `Página ${e(t)} / ${e(r)}`
|
|
401
421
|
}),
|
|
402
422
|
it: (e) => ({
|
|
403
423
|
searching: (t) => `Ricerca di “${t}”…`,
|
|
@@ -410,113 +430,113 @@ const W = ({
|
|
|
410
430
|
seeAllLabel: (t) => t === 1 ? "Vedi il risultato" : `Vedi tutti i ${e(t)} risultati`,
|
|
411
431
|
previous: "Precedente",
|
|
412
432
|
next: "Successivo",
|
|
413
|
-
pageOf: (t,
|
|
433
|
+
pageOf: (t, r) => `Pagina ${e(t)} / ${e(r)}`
|
|
414
434
|
})
|
|
415
|
-
},
|
|
416
|
-
var
|
|
417
|
-
const t = ((
|
|
418
|
-
return (
|
|
419
|
-
},
|
|
435
|
+
}, M = (e) => {
|
|
436
|
+
var s;
|
|
437
|
+
const t = ((s = e == null ? void 0 : e.split("-")[0]) == null ? void 0 : s.toLowerCase()) ?? "en";
|
|
438
|
+
return ($[t] ?? $.en)((o) => ie(o, e));
|
|
439
|
+
}, T = (e) => e.status !== S.LOADING && e.response !== void 0 && e.response.nbPages > 1, ce = ({
|
|
420
440
|
controller: e,
|
|
421
441
|
state: t,
|
|
422
|
-
locale:
|
|
442
|
+
locale: r
|
|
423
443
|
}) => {
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
444
|
+
const s = t.response;
|
|
445
|
+
if (s === void 0 || !T(t))
|
|
426
446
|
return null;
|
|
427
|
-
const o =
|
|
447
|
+
const o = M(r);
|
|
428
448
|
return /* @__PURE__ */ g("nav", { "aria-label": "Search results pages", className: "dialog-search-pagination", children: [
|
|
429
449
|
/* @__PURE__ */ n(
|
|
430
450
|
"button",
|
|
431
451
|
{
|
|
432
452
|
type: "button",
|
|
433
|
-
disabled:
|
|
434
|
-
onClick: () => e.setPage(
|
|
453
|
+
disabled: s.page === 0,
|
|
454
|
+
onClick: () => e.setPage(s.page - 1),
|
|
435
455
|
children: o.previous
|
|
436
456
|
}
|
|
437
457
|
),
|
|
438
|
-
/* @__PURE__ */ n("span", { children: o.pageOf(
|
|
458
|
+
/* @__PURE__ */ n("span", { children: o.pageOf(s.page + 1, s.nbPages) }),
|
|
439
459
|
/* @__PURE__ */ n(
|
|
440
460
|
"button",
|
|
441
461
|
{
|
|
442
462
|
type: "button",
|
|
443
|
-
disabled:
|
|
444
|
-
onClick: () => e.setPage(
|
|
463
|
+
disabled: s.page >= s.nbPages - 1,
|
|
464
|
+
onClick: () => e.setPage(s.page + 1),
|
|
445
465
|
children: o.next
|
|
446
466
|
}
|
|
447
467
|
)
|
|
448
468
|
] });
|
|
449
|
-
},
|
|
450
|
-
const
|
|
451
|
-
if (
|
|
452
|
-
return
|
|
453
|
-
const o = [...e],
|
|
469
|
+
}, I = (e) => e.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").replace(/ẞ/gu, "ß").toUpperCase().toLowerCase().replace(/ς/g, "σ"), le = (e, t) => {
|
|
470
|
+
const r = { before: "", match: e, after: "" }, s = I(t.trim());
|
|
471
|
+
if (s === "")
|
|
472
|
+
return r;
|
|
473
|
+
const o = [...e], i = [];
|
|
454
474
|
let l = "";
|
|
455
475
|
o.forEach((p, d) => {
|
|
456
|
-
const
|
|
457
|
-
for (let h = 0; h <
|
|
458
|
-
|
|
459
|
-
l +=
|
|
476
|
+
const m = I(p);
|
|
477
|
+
for (let h = 0; h < m.length; h += 1)
|
|
478
|
+
i.push(d);
|
|
479
|
+
l += m;
|
|
460
480
|
});
|
|
461
|
-
const a = l.indexOf(
|
|
481
|
+
const a = l.indexOf(s);
|
|
462
482
|
if (a === -1)
|
|
463
|
-
return
|
|
464
|
-
const
|
|
483
|
+
return r;
|
|
484
|
+
const c = i[a], u = i[a + s.length - 1] + 1;
|
|
465
485
|
return {
|
|
466
|
-
before: o.slice(0,
|
|
467
|
-
match: o.slice(
|
|
486
|
+
before: o.slice(0, c).join(""),
|
|
487
|
+
match: o.slice(c, u).join(""),
|
|
468
488
|
after: o.slice(u).join("")
|
|
469
489
|
};
|
|
470
|
-
},
|
|
490
|
+
}, O = ({
|
|
471
491
|
title: e,
|
|
472
492
|
query: t
|
|
473
493
|
}) => {
|
|
474
|
-
const { before:
|
|
494
|
+
const { before: r, match: s, after: o } = le(e, t);
|
|
475
495
|
return /* @__PURE__ */ g(C, { children: [
|
|
476
|
-
|
|
477
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-match", children:
|
|
496
|
+
r !== "" && /* @__PURE__ */ n("span", { className: "dialog-search-muted", children: r }),
|
|
497
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-match", children: s }),
|
|
478
498
|
o !== "" && /* @__PURE__ */ n("span", { className: "dialog-search-muted", children: o })
|
|
479
499
|
] });
|
|
480
|
-
},
|
|
500
|
+
}, de = ({ amount: e, currencyCode: t }, r) => t === void 0 ? new Intl.NumberFormat(r).format(Number(e)) : new Intl.NumberFormat(r, {
|
|
481
501
|
style: "currency",
|
|
482
502
|
currency: t
|
|
483
|
-
}).format(Number(e)),
|
|
503
|
+
}).format(Number(e)), ue = (e, t) => {
|
|
484
504
|
if (e === void 0)
|
|
485
505
|
return "";
|
|
486
506
|
try {
|
|
487
|
-
return
|
|
507
|
+
return de(e.min, t);
|
|
488
508
|
} catch {
|
|
489
509
|
return "";
|
|
490
510
|
}
|
|
491
|
-
},
|
|
511
|
+
}, he = (e) => {
|
|
492
512
|
try {
|
|
493
513
|
const { protocol: t } = new URL(e, window.location.href);
|
|
494
514
|
return t === "http:" || t === "https:" ? e : void 0;
|
|
495
515
|
} catch {
|
|
496
516
|
return;
|
|
497
517
|
}
|
|
498
|
-
},
|
|
518
|
+
}, _ = (e) => e.url === void 0 || e.url === "" ? void 0 : he(e.url), H = (e) => e.title ?? e.handle ?? e.objectID, ge = ({
|
|
499
519
|
controller: e,
|
|
500
520
|
hit: t,
|
|
501
|
-
index:
|
|
502
|
-
locale:
|
|
521
|
+
index: r,
|
|
522
|
+
locale: s,
|
|
503
523
|
query: o = ""
|
|
504
524
|
}) => {
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}, [e, t,
|
|
525
|
+
const i = b(null);
|
|
526
|
+
f(() => {
|
|
527
|
+
i.current !== null && e.observeResult(i.current, r);
|
|
528
|
+
}, [e, t, r]);
|
|
509
529
|
const l = (d) => {
|
|
510
|
-
const
|
|
511
|
-
e.selectResult(
|
|
530
|
+
const m = d.metaKey || d.ctrlKey || d.shiftKey || d.altKey;
|
|
531
|
+
e.selectResult(r, { navigate: !m }) && d.preventDefault();
|
|
512
532
|
}, a = (d) => {
|
|
513
|
-
d.button === 1 && e.selectResult(
|
|
514
|
-
},
|
|
533
|
+
d.button === 1 && e.selectResult(r, { navigate: !1 });
|
|
534
|
+
}, c = ue(t.priceRange, s), u = _(t), p = /* @__PURE__ */ g(C, { children: [
|
|
515
535
|
/* @__PURE__ */ n("span", { className: "dialog-search-product-thumb", "aria-hidden": !0, children: t.imageUrl !== void 0 && t.imageUrl !== "" && /* @__PURE__ */ n("img", { src: t.imageUrl, alt: "", loading: "lazy" }) }),
|
|
516
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-product-title", children: /* @__PURE__ */ n(
|
|
517
|
-
|
|
536
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-product-title", children: /* @__PURE__ */ n(O, { title: H(t), query: o }) }),
|
|
537
|
+
c !== "" && /* @__PURE__ */ n("span", { className: "dialog-search-product-price", children: c })
|
|
518
538
|
] });
|
|
519
|
-
return /* @__PURE__ */ n("li", { ref:
|
|
539
|
+
return /* @__PURE__ */ n("li", { ref: i, className: "dialog-search-card", children: u === void 0 ? /* @__PURE__ */ n("div", { className: "dialog-search-product", children: p }) : /* @__PURE__ */ n(
|
|
520
540
|
"a",
|
|
521
541
|
{
|
|
522
542
|
className: "dialog-search-product",
|
|
@@ -526,7 +546,7 @@ const W = ({
|
|
|
526
546
|
children: p
|
|
527
547
|
}
|
|
528
548
|
) });
|
|
529
|
-
},
|
|
549
|
+
}, pe = () => /* @__PURE__ */ n(
|
|
530
550
|
"svg",
|
|
531
551
|
{
|
|
532
552
|
width: 16,
|
|
@@ -537,7 +557,7 @@ const W = ({
|
|
|
537
557
|
"aria-hidden": "true",
|
|
538
558
|
children: /* @__PURE__ */ n("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" })
|
|
539
559
|
}
|
|
540
|
-
),
|
|
560
|
+
), me = () => /* @__PURE__ */ n(
|
|
541
561
|
"svg",
|
|
542
562
|
{
|
|
543
563
|
width: 12,
|
|
@@ -548,98 +568,98 @@ const W = ({
|
|
|
548
568
|
"aria-hidden": "true",
|
|
549
569
|
children: /* @__PURE__ */ n("path", { d: "M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z" })
|
|
550
570
|
}
|
|
551
|
-
),
|
|
552
|
-
const
|
|
553
|
-
return
|
|
554
|
-
}),
|
|
571
|
+
), B = (e) => (e ?? []).flatMap((t) => {
|
|
572
|
+
const r = _(t);
|
|
573
|
+
return r === void 0 ? [] : [{ collection: t, href: r }];
|
|
574
|
+
}), fe = ({
|
|
555
575
|
collections: e,
|
|
556
576
|
query: t,
|
|
557
|
-
messages:
|
|
577
|
+
messages: r
|
|
558
578
|
}) => {
|
|
559
|
-
const
|
|
560
|
-
return
|
|
579
|
+
const s = B(e);
|
|
580
|
+
return s.length === 0 ? null : /* @__PURE__ */ g("aside", { className: "dialog-search-collections", children: [
|
|
561
581
|
/* @__PURE__ */ g("div", { className: "dialog-search-section-head", children: [
|
|
562
|
-
/* @__PURE__ */ n("p", { className: "dialog-search-label", children:
|
|
563
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-count", children:
|
|
582
|
+
/* @__PURE__ */ n("p", { className: "dialog-search-label", children: r.collectionsLabel }),
|
|
583
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-count", children: r.collectionsCount(s.length) })
|
|
564
584
|
] }),
|
|
565
|
-
/* @__PURE__ */ n("ul", { className: "dialog-search-collection-list", children:
|
|
585
|
+
/* @__PURE__ */ n("ul", { className: "dialog-search-collection-list", children: s.map(({ collection: o, href: i }) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ g("a", { className: "dialog-search-collection", href: i, children: [
|
|
566
586
|
/* @__PURE__ */ n("span", { className: "dialog-search-collection-thumb", "aria-hidden": !0, children: o.imageUrl !== void 0 && o.imageUrl !== "" && /* @__PURE__ */ n("img", { src: o.imageUrl, alt: "", loading: "lazy" }) }),
|
|
567
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-collection-title", children: /* @__PURE__ */ n(
|
|
568
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-caret", children: /* @__PURE__ */ n(
|
|
587
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-collection-title", children: /* @__PURE__ */ n(O, { title: H(o), query: t }) }),
|
|
588
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-caret", children: /* @__PURE__ */ n(me, {}) })
|
|
569
589
|
] }) }, o.objectID)) })
|
|
570
590
|
] });
|
|
571
|
-
},
|
|
591
|
+
}, be = ({
|
|
572
592
|
controller: e,
|
|
573
593
|
response: t,
|
|
574
|
-
locale:
|
|
575
|
-
messages:
|
|
594
|
+
locale: r,
|
|
595
|
+
messages: s
|
|
576
596
|
}) => /* @__PURE__ */ g("section", { className: "dialog-search-products", children: [
|
|
577
597
|
/* @__PURE__ */ n("div", { className: "dialog-search-section-head", children: /* @__PURE__ */ g("p", { className: "dialog-search-label", children: [
|
|
578
|
-
|
|
579
|
-
t.nbHits > 0 && /* @__PURE__ */ n("span", { className: "dialog-search-label-count", children: ` · ${
|
|
598
|
+
s.productsLabel,
|
|
599
|
+
t.nbHits > 0 && /* @__PURE__ */ n("span", { className: "dialog-search-label-count", children: ` · ${s.resultsCount(t.nbHits)}` })
|
|
580
600
|
] }) }),
|
|
581
|
-
/* @__PURE__ */ n("ul", { className: "dialog-search-results", children: t.hits.length === 0 ? /* @__PURE__ */ n("li", { className: "dialog-search-empty", role: "status", children:
|
|
582
|
-
|
|
601
|
+
/* @__PURE__ */ n("ul", { className: "dialog-search-results", children: t.hits.length === 0 ? /* @__PURE__ */ n("li", { className: "dialog-search-empty", role: "status", children: s.noResults }) : t.hits.map((o, i) => /* @__PURE__ */ n(
|
|
602
|
+
ge,
|
|
583
603
|
{
|
|
584
604
|
controller: e,
|
|
585
605
|
hit: o,
|
|
586
|
-
index:
|
|
587
|
-
locale:
|
|
606
|
+
index: i,
|
|
607
|
+
locale: r,
|
|
588
608
|
query: t.query
|
|
589
609
|
},
|
|
590
610
|
o.objectID
|
|
591
611
|
)) })
|
|
592
|
-
] }),
|
|
593
|
-
const
|
|
594
|
-
|
|
612
|
+
] }), L = 8, w = 16, ve = 200, Ce = 1440, ye = (e, t) => e.bottom > 0 && e.top < t, we = (e, t) => {
|
|
613
|
+
const r = Math.min(
|
|
614
|
+
Ce,
|
|
595
615
|
t - 2 * w
|
|
596
|
-
),
|
|
616
|
+
), s = e.left + e.width / 2 - r / 2;
|
|
597
617
|
return { left: Math.min(
|
|
598
|
-
Math.max(
|
|
599
|
-
t - w -
|
|
600
|
-
), width:
|
|
601
|
-
},
|
|
602
|
-
const
|
|
603
|
-
return
|
|
604
|
-
...
|
|
605
|
-
bottom:
|
|
618
|
+
Math.max(s, w),
|
|
619
|
+
t - w - r
|
|
620
|
+
), width: r };
|
|
621
|
+
}, Se = (e, t, r) => {
|
|
622
|
+
const s = r - e.bottom - L - w, o = e.top - L - w, i = we(e, t);
|
|
623
|
+
return s < ve && o > s ? {
|
|
624
|
+
...i,
|
|
625
|
+
bottom: r - e.top + L,
|
|
606
626
|
maxHeight: Math.max(o, 0)
|
|
607
627
|
} : {
|
|
608
|
-
...
|
|
609
|
-
top: e.bottom +
|
|
610
|
-
maxHeight: Math.max(
|
|
628
|
+
...i,
|
|
629
|
+
top: e.bottom + L,
|
|
630
|
+
maxHeight: Math.max(s, 0)
|
|
611
631
|
};
|
|
612
|
-
},
|
|
632
|
+
}, Le = (e) => {
|
|
613
633
|
const t = e.trim().replace(/^#/, "");
|
|
614
634
|
if (!/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t))
|
|
615
635
|
return;
|
|
616
|
-
const
|
|
636
|
+
const r = t.length <= 4 ? [...t].map((s) => s + s).join("") : t;
|
|
617
637
|
return [0, 2, 4].map(
|
|
618
|
-
(
|
|
638
|
+
(s) => Number.parseInt(r.slice(s, s + 2), 16)
|
|
619
639
|
);
|
|
620
|
-
},
|
|
640
|
+
}, Ne = (e) => {
|
|
621
641
|
const t = /^rgba?\((\d+), (\d+), (\d+)(?:, [\d.]+)?\)$/.exec(e);
|
|
622
642
|
if (t !== null)
|
|
623
643
|
return [t[1], t[2], t[3]].map(Number);
|
|
624
|
-
},
|
|
644
|
+
}, ke = (e) => {
|
|
625
645
|
if (typeof document > "u")
|
|
626
646
|
return;
|
|
627
647
|
const t = document.createElement("span");
|
|
628
648
|
if (t.style.color = e, t.style.color === "")
|
|
629
649
|
return;
|
|
630
650
|
document.body.appendChild(t);
|
|
631
|
-
const
|
|
632
|
-
return t.remove(),
|
|
633
|
-
},
|
|
651
|
+
const r = Ne(getComputedStyle(t).color);
|
|
652
|
+
return t.remove(), r;
|
|
653
|
+
}, Pe = (e) => Le(e) ?? ke(e), xe = (e) => {
|
|
634
654
|
const t = e / 255;
|
|
635
655
|
return t <= 0.03928 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4;
|
|
636
|
-
},
|
|
637
|
-
const t =
|
|
656
|
+
}, V = (e) => {
|
|
657
|
+
const t = Pe(e);
|
|
638
658
|
if (t === void 0)
|
|
639
659
|
return;
|
|
640
|
-
const [
|
|
641
|
-
return 0.2126 *
|
|
642
|
-
},
|
|
660
|
+
const [r, s, o] = t.map(xe);
|
|
661
|
+
return 0.2126 * r + 0.7152 * s + 0.0722 * o;
|
|
662
|
+
}, Re = "#181825", Ee = "#ffffff", Ae = "straight", x = 0.5, R = {
|
|
643
663
|
light: {
|
|
644
664
|
panel: "#ffffff",
|
|
645
665
|
side: "#fafbfc",
|
|
@@ -658,7 +678,7 @@ const W = ({
|
|
|
658
678
|
hover: "#242830",
|
|
659
679
|
thumb: "#2b2f38"
|
|
660
680
|
}
|
|
661
|
-
},
|
|
681
|
+
}, $e = {
|
|
662
682
|
rectangle: {
|
|
663
683
|
"r-panel": "4px",
|
|
664
684
|
"r-item": "4px",
|
|
@@ -671,26 +691,26 @@ const W = ({
|
|
|
671
691
|
"r-thumb": "8px",
|
|
672
692
|
"r-btn": "10px"
|
|
673
693
|
}
|
|
674
|
-
}, N = (e) => e === void 0 || e.trim() === "" ? void 0 : e.trim(),
|
|
675
|
-
const t = e === void 0 ? void 0 :
|
|
676
|
-
return t === void 0 ? "light" : t <
|
|
677
|
-
},
|
|
678
|
-
const
|
|
679
|
-
return
|
|
680
|
-
},
|
|
681
|
-
const t =
|
|
694
|
+
}, N = (e) => e === void 0 || e.trim() === "" ? void 0 : e.trim(), Ie = (e) => {
|
|
695
|
+
const t = e === void 0 ? void 0 : V(e);
|
|
696
|
+
return t === void 0 ? "light" : t < x ? "dark" : "light";
|
|
697
|
+
}, De = (e, t) => {
|
|
698
|
+
const r = V(e);
|
|
699
|
+
return r === void 0 ? R[t].text : (t === "light" ? r < x : r >= x) ? e : R[t].text;
|
|
700
|
+
}, Me = (e) => {
|
|
701
|
+
const t = Ie(N(e == null ? void 0 : e.backgroundColor)), r = (e == null ? void 0 : e.ctaBorderType) === Ae ? "rectangle" : "rectangle-rounded", s = N(e == null ? void 0 : e.primaryColor) ?? Re, o = N(e == null ? void 0 : e.fontFamily), i = {
|
|
682
702
|
...R[t],
|
|
683
|
-
|
|
684
|
-
primary:
|
|
685
|
-
accent:
|
|
686
|
-
"cta-text": N(e == null ? void 0 : e.ctaTextColor) ??
|
|
703
|
+
...$e[r],
|
|
704
|
+
primary: s,
|
|
705
|
+
accent: De(s, t),
|
|
706
|
+
"cta-text": N(e == null ? void 0 : e.ctaTextColor) ?? Ee,
|
|
687
707
|
...o === void 0 ? {} : { font: o }
|
|
688
708
|
};
|
|
689
709
|
return Object.fromEntries(
|
|
690
|
-
Object.entries(
|
|
710
|
+
Object.entries(i).map(([l, a]) => [`--dso-${l}`, a])
|
|
691
711
|
);
|
|
692
|
-
},
|
|
693
|
-
const t = b(null), [
|
|
712
|
+
}, Te = (e) => {
|
|
713
|
+
const t = b(null), [r, s] = v(void 0), [o, i] = v({ width: 0, height: 0 });
|
|
694
714
|
return j(() => {
|
|
695
715
|
if (!e)
|
|
696
716
|
return;
|
|
@@ -698,52 +718,52 @@ const W = ({
|
|
|
698
718
|
const a = t.current;
|
|
699
719
|
if (a === null)
|
|
700
720
|
return;
|
|
701
|
-
const
|
|
702
|
-
|
|
721
|
+
const c = a.previousElementSibling ?? a, { top: u, bottom: p, left: d, width: m } = c.getBoundingClientRect();
|
|
722
|
+
i(
|
|
703
723
|
(h) => h.width === window.innerWidth && h.height === window.innerHeight ? h : { width: window.innerWidth, height: window.innerHeight }
|
|
704
|
-
),
|
|
705
|
-
(h) => h !== void 0 && h.top === u && h.bottom === p && h.left === d && h.width ===
|
|
724
|
+
), s(
|
|
725
|
+
(h) => h !== void 0 && h.top === u && h.bottom === p && h.left === d && h.width === m ? h : { top: u, bottom: p, left: d, width: m }
|
|
706
726
|
);
|
|
707
727
|
};
|
|
708
728
|
return l(), window.addEventListener("scroll", l, !0), window.addEventListener("resize", l), () => {
|
|
709
729
|
window.removeEventListener("scroll", l, !0), window.removeEventListener("resize", l);
|
|
710
730
|
};
|
|
711
|
-
}, [e]), { anchorRef: t, rect:
|
|
712
|
-
},
|
|
713
|
-
const [
|
|
714
|
-
return
|
|
715
|
-
|
|
716
|
-
}, [e.query]),
|
|
717
|
-
if (!
|
|
731
|
+
}, [e]), { anchorRef: t, rect: r, viewport: o };
|
|
732
|
+
}, Oe = (e, t) => {
|
|
733
|
+
const [r, s] = v(!1), o = b(null), i = e.status !== S.IDLE && !r;
|
|
734
|
+
return f(() => {
|
|
735
|
+
s(!1);
|
|
736
|
+
}, [e.query]), f(() => {
|
|
737
|
+
if (!i)
|
|
718
738
|
return;
|
|
719
739
|
const l = (a) => {
|
|
720
|
-
var
|
|
721
|
-
const
|
|
722
|
-
if (!(
|
|
740
|
+
var m, h;
|
|
741
|
+
const c = a.target;
|
|
742
|
+
if (!(c instanceof Node))
|
|
723
743
|
return;
|
|
724
|
-
const u = (
|
|
725
|
-
!p && !d &&
|
|
744
|
+
const u = (m = t.current) == null ? void 0 : m.previousElementSibling, p = ((h = o.current) == null ? void 0 : h.contains(c)) ?? !1, d = (u == null ? void 0 : u.contains(c)) ?? !1;
|
|
745
|
+
!p && !d && s(!0);
|
|
726
746
|
};
|
|
727
747
|
return document.addEventListener("pointerdown", l), () => document.removeEventListener("pointerdown", l);
|
|
728
|
-
}, [
|
|
729
|
-
var
|
|
730
|
-
const l = (
|
|
748
|
+
}, [i, t]), f(() => {
|
|
749
|
+
var c;
|
|
750
|
+
const l = (c = t.current) == null ? void 0 : c.previousElementSibling;
|
|
731
751
|
if (l == null)
|
|
732
752
|
return;
|
|
733
|
-
const a = () =>
|
|
753
|
+
const a = () => s(!1);
|
|
734
754
|
return l.addEventListener("focusin", a), () => l.removeEventListener("focusin", a);
|
|
735
|
-
}, [t]), { isOpen:
|
|
736
|
-
},
|
|
737
|
-
var
|
|
738
|
-
const { controller:
|
|
739
|
-
if (l ===
|
|
755
|
+
}, [t]), { isOpen: i, panelRef: o };
|
|
756
|
+
}, _e = (e) => e instanceof F ? `Search failed (${e.status}${e.code ? ` ${e.code}` : ""}): ${e.message}` : "Search failed: network error. Check your connection and try again.", He = (e, t) => {
|
|
757
|
+
var m, h;
|
|
758
|
+
const { controller: r, state: s, locale: o, seeAllHref: i } = e, { status: l, response: a } = s;
|
|
759
|
+
if (l === S.ERROR)
|
|
740
760
|
return /* @__PURE__ */ g("div", { className: "dialog-search-error", children: [
|
|
741
761
|
/* @__PURE__ */ n(
|
|
742
762
|
"p",
|
|
743
763
|
{
|
|
744
764
|
role: "alert",
|
|
745
765
|
className: "dialog-search-status dialog-search-status-error",
|
|
746
|
-
children:
|
|
766
|
+
children: _e(s.error)
|
|
747
767
|
}
|
|
748
768
|
),
|
|
749
769
|
/* @__PURE__ */ n(
|
|
@@ -751,14 +771,14 @@ const W = ({
|
|
|
751
771
|
{
|
|
752
772
|
type: "button",
|
|
753
773
|
className: "dialog-search-retry",
|
|
754
|
-
onClick: () =>
|
|
774
|
+
onClick: () => r.retry(),
|
|
755
775
|
children: t.retry
|
|
756
776
|
}
|
|
757
777
|
)
|
|
758
778
|
] });
|
|
759
779
|
if (a === void 0)
|
|
760
|
-
return /* @__PURE__ */ n("p", { role: "status", className: "dialog-search-status", children: t.searching(
|
|
761
|
-
const
|
|
780
|
+
return /* @__PURE__ */ n("p", { role: "status", className: "dialog-search-status", children: t.searching(s.query) });
|
|
781
|
+
const c = ((h = (m = s.sections) == null ? void 0 : m.collections) == null ? void 0 : h.hits) ?? [], u = B(c).length > 0, p = i !== void 0 && a.nbHits > 0, d = !p && T(s);
|
|
762
782
|
return /* @__PURE__ */ g(C, { children: [
|
|
763
783
|
/* @__PURE__ */ g(
|
|
764
784
|
"div",
|
|
@@ -766,17 +786,17 @@ const W = ({
|
|
|
766
786
|
className: `dialog-search-body${u ? "" : " dialog-search-body--no-collections"}`,
|
|
767
787
|
children: [
|
|
768
788
|
/* @__PURE__ */ n(
|
|
769
|
-
|
|
789
|
+
fe,
|
|
770
790
|
{
|
|
771
|
-
collections:
|
|
791
|
+
collections: c,
|
|
772
792
|
query: a.query,
|
|
773
793
|
messages: t
|
|
774
794
|
}
|
|
775
795
|
),
|
|
776
796
|
/* @__PURE__ */ n(
|
|
777
|
-
|
|
797
|
+
be,
|
|
778
798
|
{
|
|
779
|
-
controller:
|
|
799
|
+
controller: r,
|
|
780
800
|
response: a,
|
|
781
801
|
locale: o,
|
|
782
802
|
messages: t
|
|
@@ -785,106 +805,106 @@ const W = ({
|
|
|
785
805
|
]
|
|
786
806
|
}
|
|
787
807
|
),
|
|
788
|
-
(p || d) && /* @__PURE__ */ n("div", { className: "dialog-search-footer", children: p ? /* @__PURE__ */ g("a", { className: "dialog-search-cta", href:
|
|
808
|
+
(p || d) && /* @__PURE__ */ n("div", { className: "dialog-search-footer", children: p ? /* @__PURE__ */ g("a", { className: "dialog-search-cta", href: i(a.query), children: [
|
|
789
809
|
t.seeAllLabel(a.nbHits),
|
|
790
|
-
/* @__PURE__ */ n(
|
|
810
|
+
/* @__PURE__ */ n(pe, {})
|
|
791
811
|
] }) : /* @__PURE__ */ n(
|
|
792
|
-
|
|
812
|
+
ce,
|
|
793
813
|
{
|
|
794
|
-
controller:
|
|
795
|
-
state:
|
|
814
|
+
controller: r,
|
|
815
|
+
state: s,
|
|
796
816
|
locale: o
|
|
797
817
|
}
|
|
798
818
|
) })
|
|
799
819
|
] });
|
|
800
|
-
},
|
|
801
|
-
const { state: t, locale:
|
|
802
|
-
() =>
|
|
803
|
-
[
|
|
820
|
+
}, We = (e) => {
|
|
821
|
+
const { state: t, locale: r, theme: s, layout: o = "list" } = e, i = t.status !== S.IDLE, { anchorRef: l, rect: a, viewport: c } = Te(i), { isOpen: u, panelRef: p } = Oe(t, l), d = M(r), m = y(
|
|
822
|
+
() => Me(s),
|
|
823
|
+
[s]
|
|
804
824
|
);
|
|
805
825
|
return /* @__PURE__ */ g(C, { children: [
|
|
806
826
|
/* @__PURE__ */ n("div", { ref: l }),
|
|
807
|
-
u && a !== void 0 &&
|
|
827
|
+
u && a !== void 0 && ye(a, c.height) && W(
|
|
808
828
|
/* @__PURE__ */ n(
|
|
809
829
|
"div",
|
|
810
830
|
{
|
|
811
831
|
ref: p,
|
|
812
832
|
className: `dialog-search-panel dialog-search-panel--${o}`,
|
|
813
833
|
style: {
|
|
814
|
-
...
|
|
815
|
-
...
|
|
834
|
+
...Se(a, c.width, c.height),
|
|
835
|
+
...m
|
|
816
836
|
},
|
|
817
|
-
children:
|
|
837
|
+
children: He(e, d)
|
|
818
838
|
}
|
|
819
839
|
),
|
|
820
840
|
document.body
|
|
821
841
|
)
|
|
822
842
|
] });
|
|
823
|
-
},
|
|
824
|
-
status:
|
|
843
|
+
}, Be = {
|
|
844
|
+
status: S.IDLE,
|
|
825
845
|
query: "",
|
|
826
846
|
page: 0
|
|
827
|
-
},
|
|
847
|
+
}, Qe = (e) => {
|
|
828
848
|
const t = b(e);
|
|
829
849
|
t.current = e;
|
|
830
|
-
const
|
|
831
|
-
if (
|
|
832
|
-
const { client:
|
|
833
|
-
|
|
834
|
-
search: (d,
|
|
850
|
+
const r = b(void 0), s = P(() => {
|
|
851
|
+
if (r.current === void 0) {
|
|
852
|
+
const { client: c, surface: u = "search_page", ...p } = t.current;
|
|
853
|
+
r.current = U({
|
|
854
|
+
search: (d, m) => c.search(d, m),
|
|
835
855
|
analytics: {
|
|
836
856
|
surface: u,
|
|
837
|
-
trackViewSearchResults: (d) =>
|
|
838
|
-
trackSelectSearchResult: (d) =>
|
|
857
|
+
trackViewSearchResults: (d) => c.trackViewSearchResults(d),
|
|
858
|
+
trackSelectSearchResult: (d) => c.trackSelectSearchResult(d)
|
|
839
859
|
},
|
|
840
860
|
...p
|
|
841
861
|
});
|
|
842
862
|
}
|
|
843
|
-
return
|
|
863
|
+
return r.current;
|
|
844
864
|
}, []), o = b(void 0);
|
|
845
865
|
o.current ?? (o.current = {
|
|
846
|
-
setQuery: (
|
|
847
|
-
submit: (
|
|
848
|
-
setPage: (
|
|
849
|
-
retry: () =>
|
|
850
|
-
observeResult: (
|
|
851
|
-
selectResult: (
|
|
852
|
-
subscribe: (
|
|
853
|
-
getState: () =>
|
|
866
|
+
setQuery: (c) => s().setQuery(c),
|
|
867
|
+
submit: (c) => s().submit(c),
|
|
868
|
+
setPage: (c) => s().setPage(c),
|
|
869
|
+
retry: () => s().retry(),
|
|
870
|
+
observeResult: (c, u) => s().observeResult(c, u),
|
|
871
|
+
selectResult: (c, u) => s().selectResult(c, u),
|
|
872
|
+
subscribe: (c) => s().subscribe(c),
|
|
873
|
+
getState: () => s().getState(),
|
|
854
874
|
// Create a replacement on next access after disposal.
|
|
855
875
|
dispose: () => {
|
|
856
|
-
var
|
|
857
|
-
(
|
|
876
|
+
var c;
|
|
877
|
+
(c = r.current) == null || c.dispose(), r.current = void 0;
|
|
858
878
|
}
|
|
859
|
-
}),
|
|
879
|
+
}), f(() => {
|
|
860
880
|
D({
|
|
861
881
|
method: "react",
|
|
862
|
-
version: "2.
|
|
882
|
+
version: "2.7.0"
|
|
863
883
|
});
|
|
864
|
-
const
|
|
884
|
+
const c = s();
|
|
865
885
|
return () => {
|
|
866
|
-
|
|
886
|
+
c.dispose(), r.current === c && (r.current = void 0);
|
|
867
887
|
};
|
|
868
|
-
}, [
|
|
869
|
-
const
|
|
870
|
-
(
|
|
871
|
-
[
|
|
872
|
-
), l =
|
|
873
|
-
() =>
|
|
874
|
-
[
|
|
875
|
-
), a =
|
|
876
|
-
|
|
888
|
+
}, [s]);
|
|
889
|
+
const i = P(
|
|
890
|
+
(c) => s().subscribe(c),
|
|
891
|
+
[s]
|
|
892
|
+
), l = P(
|
|
893
|
+
() => s().getState(),
|
|
894
|
+
[s]
|
|
895
|
+
), a = q(
|
|
896
|
+
i,
|
|
877
897
|
l,
|
|
878
|
-
() =>
|
|
898
|
+
() => Be
|
|
879
899
|
);
|
|
880
900
|
return { controller: o.current, state: a, theme: e.client.theme };
|
|
881
901
|
};
|
|
882
902
|
export {
|
|
883
|
-
|
|
903
|
+
te as DialogInput,
|
|
884
904
|
Fe as DialogProductBlock,
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
905
|
+
Ue as DialogSearchBar,
|
|
906
|
+
ce as DialogSearchPagination,
|
|
907
|
+
ge as DialogSearchProductCard,
|
|
908
|
+
We as DialogSearchResults,
|
|
909
|
+
Qe as useDialogSearch
|
|
890
910
|
};
|