@ecomid/modules 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js ADDED
@@ -0,0 +1,4532 @@
1
+ "use client";
2
+ import { B as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, R as d, S as f, T as p, V as m, _ as h, a as g, b as _, c as v, d as y, f as b, g as x, h as S, i as C, j as w, k as T, l as E, m as D, n as O, o as k, p as A, t as j, u as ee, v as te, x as M, y as N, z as P } from "./chunks/resultsStore-DuG3wQlt.js";
3
+ import { Component as F, createContext as I, useCallback as L, useContext as R, useEffect as z, useId as ne, useLayoutEffect as re, useMemo as B, useRef as V, useState as H, useSyncExternalStore as ie } from "react";
4
+ import { Fragment as U, jsx as W, jsxs as G } from "react/jsx-runtime";
5
+ import { createPortal as K } from "react-dom";
6
+ // src/html/pixel/types.ts
7
+ var q = {
8
+ REQUEST: "search_request",
9
+ ABORT: "search_abort",
10
+ RESPONSE: "search_response",
11
+ CHUNK: "search_chunk",
12
+ END: "search_end",
13
+ ERROR: "search_error"
14
+ }, ae = 1e4, oe = () => `search-${crypto.randomUUID()}`, se = new TextEncoder();
15
+ function J() {
16
+ return Object.assign(/* @__PURE__ */ Error("The operation was aborted"), { name: "AbortError" });
17
+ }
18
+ function ce({ cgwUrls: e, isLoggedIn: t, timeoutMs: n = ae }) {
19
+ return {
20
+ isSignedIn: () => t() && u() !== null,
21
+ canRelay: (t) => e.some((e) => !!e && t.startsWith(`${e}/v0/search/`)),
22
+ fetch: (e, t) => new Promise((r, a) => {
23
+ let o = u();
24
+ if (!o) {
25
+ a(new s());
26
+ return;
27
+ }
28
+ let c = t.signal;
29
+ if (c?.aborted) {
30
+ a(J());
31
+ return;
32
+ }
33
+ let l = oe(), d = new URL(e), f = null, p = !1, m, h = () => {
34
+ clearTimeout(m), window.removeEventListener("message", v), c?.removeEventListener("abort", _);
35
+ }, g = () => {
36
+ o.postMessage({
37
+ type: q.ABORT,
38
+ id: l
39
+ }, "*");
40
+ };
41
+ function _() {
42
+ h(), g(), p ? f?.error(J()) : a(J());
43
+ }
44
+ function v(e) {
45
+ let t = e.data;
46
+ if (t && t.id === l && e.source === o && i(e)) {
47
+ if (t.type === q.RESPONSE) {
48
+ h();
49
+ let e = Number(t.status), n = e === 204 ? null : typeof t.body == "string" ? t.body : JSON.stringify(t.body);
50
+ try {
51
+ r(new Response(n, {
52
+ status: e,
53
+ headers: { "Content-Type": "application/json" }
54
+ }));
55
+ } catch (e) {
56
+ a(e);
57
+ }
58
+ } else if (t.type === q.CHUNK && typeof t.chunk == "string") {
59
+ clearTimeout(m);
60
+ let e = se.encode(t.chunk);
61
+ if (p) {
62
+ f?.enqueue(e);
63
+ return;
64
+ }
65
+ p = !0, r(new Response(new ReadableStream({
66
+ start(t) {
67
+ f = t, t.enqueue(e);
68
+ },
69
+ cancel() {
70
+ h(), g();
71
+ }
72
+ }), {
73
+ status: 200,
74
+ headers: { "Content-Type": "text/event-stream" }
75
+ }));
76
+ } else if (t.type === q.END) h(), p ? f?.close() : r(new Response(null, { status: 200 }));
77
+ else if (t.type === q.ERROR) {
78
+ h();
79
+ let e = Number(t.status);
80
+ p ? f?.error(/* @__PURE__ */ Error("relay stream failed")) : e >= 400 && e <= 599 ? r(new Response(null, { status: e })) : a(/* @__PURE__ */ Error("relay request failed"));
81
+ }
82
+ }
83
+ }
84
+ window.addEventListener("message", v), c?.addEventListener("abort", _, { once: !0 }), m = setTimeout(() => {
85
+ h(), g(), a(/* @__PURE__ */ Error("relay timeout"));
86
+ }, n), o.postMessage({
87
+ type: q.REQUEST,
88
+ id: l,
89
+ origin: d.origin,
90
+ path: d.pathname,
91
+ method: (t.method ?? "GET").toUpperCase(),
92
+ ...d.search ? { query: d.search.slice(1) } : {},
93
+ ...typeof t.body == "string" ? { body: t.body } : {}
94
+ }, "*");
95
+ })
96
+ };
97
+ }
98
+ // src/search/react/relay.ts
99
+ function le() {
100
+ c(ce({
101
+ cgwUrls: Object.values(P).map((e) => e.cgw),
102
+ isLoggedIn: () => typeof window < "u" && m().ecomid?.auth?.getState().loggedIn === !0
103
+ }));
104
+ }
105
+ // src/react/EcomidContext.ts
106
+ var ue = I(null), de = !1;
107
+ function fe({ clientId: t, locale: n, environment: r, active: i }) {
108
+ let o = R(ue), s = e(r ?? o?.environment), c = B(() => (e, t) => {
109
+ a(e, t, { eventsBaseUrl: s.events });
110
+ }, [s.events]);
111
+ return z(() => {
112
+ if (!i || de) return;
113
+ let e = () => {
114
+ de || m().ecomid?.version || (de = !0, c(/* @__PURE__ */ Error("ecomid loader not found")));
115
+ };
116
+ if (document.readyState === "complete") e();
117
+ else return window.addEventListener("load", e, { once: !0 }), () => window.removeEventListener("load", e);
118
+ }, [i, c]), {
119
+ clientId: t ?? o?.clientId,
120
+ locale: n ?? o?.locale,
121
+ urls: s,
122
+ report: c
123
+ };
124
+ }
125
+ var pe = I((e, t) => {
126
+ a(e, t);
127
+ }), me = () => R(pe), he = class extends F {
128
+ static contextType = pe;
129
+ state = { hasError: !1 };
130
+ static getDerivedStateFromError() {
131
+ return { hasError: !0 };
132
+ }
133
+ componentDidCatch(e, t) {
134
+ this.context(e, { context: t.componentStack ?? void 0 });
135
+ }
136
+ render() {
137
+ return this.state.hasError ? null : this.props.children;
138
+ }
139
+ };
140
+ function Y({ message: e }) {
141
+ let t = me();
142
+ return z(() => {
143
+ t(Error(e));
144
+ }, [e, t]), null;
145
+ }
146
+ // src/search/components/SearchBoundary.tsx
147
+ function ge({ clientId: e, locale: t, children: n }) {
148
+ let r;
149
+ try {
150
+ r = w({
151
+ clientId: e,
152
+ locale: t
153
+ });
154
+ } catch (e) {
155
+ return /* @__PURE__ */ W(Y, { message: e instanceof Error ? e.message : String(e) });
156
+ }
157
+ return /* @__PURE__ */ W(he, { children: n(r) });
158
+ }
159
+ // src/search/components/hooks/useGuard.ts
160
+ function _e() {
161
+ let e = me();
162
+ return L((t) => {
163
+ try {
164
+ t();
165
+ } catch (t) {
166
+ t instanceof Error && e(t);
167
+ }
168
+ }, [e]);
169
+ }
170
+ // src/search/components/hooks/useSyncExternalStoreSsr.ts
171
+ var ve = ie, X = {
172
+ INIT: "init",
173
+ VISIBLE: "visible",
174
+ OPEN: "open",
175
+ CLOSE: "close",
176
+ ADD_TO_CART: "add_to_cart",
177
+ KEEP_SIZE: "keep_size",
178
+ ADD_SIZE_ANYWAY: "add_size_anyway",
179
+ CHANGE_TO_RECOMMENDED_SIZE: "change_to_recommended_size",
180
+ FIND_MY_SIZE: "find_my_size",
181
+ RECOMMENDATION: "recommendation",
182
+ YOUR_SIZE_RECOMMENDATION: "your_size_recommendation",
183
+ STEP: "step",
184
+ RESET: "reset",
185
+ SELECT_SIZE: "select_size",
186
+ FEEDBACK_SUBMIT: "feedback_submit",
187
+ FEEDBACK_SIZE_SUBMIT: "feedback_size_submit",
188
+ SHOW_NO_SIZE_PAGE: "show_no_size_page",
189
+ SHOW_ERROR_PAGE: "show_error_page",
190
+ SHOW_RESET_PAGE: "show_reset_page",
191
+ SHOW_INFO_PAGE: "show_info_page",
192
+ FEEDBACK_VISIBLE: "feedback_visible",
193
+ CURIOSITY_SUBMIT: "curiosity_submit",
194
+ CURIOSITY_VISIBLE: "curiosity_visible",
195
+ SIZE_GUIDE_BUTTON_VISIBLE: "size_guide_button_visible",
196
+ SIZE_GUIDE_OPEN: "size_guide_open",
197
+ FORM_SUBMIT: "form_submit",
198
+ EXPAND: "expand",
199
+ PROMPT_SUBMIT: "prompt_submit",
200
+ SIDEBAR_OPEN: "sidebar_open",
201
+ SIDEBAR_CLOSE: "sidebar_close",
202
+ PRODUCT_CLICK: "product_click",
203
+ PRODUCT_VISIBLE: "product_visible",
204
+ PRODUCT_MENU_OPEN: "product_menu_open",
205
+ PRODUCT_MENU_CLICK_ITEM: "product_menu_click_item",
206
+ PRODUCT_CAROUSEL_LAYOUT_CHANGE: "product_carousel_layout_change",
207
+ PRODUCT_CAROUSEL_PREV_CLICK: "product_carousel_prev_click",
208
+ PRODUCT_CAROUSEL_NEXT_CLICK: "product_carousel_next_click",
209
+ PRE_PROMPT_CLICK: "pre_prompt_click",
210
+ CREATE_MESSAGE: "create_message",
211
+ NEW_CHAT_CLICK: "new_chat_click",
212
+ CREATE_CHAT: "create_chat",
213
+ STOP: "stop",
214
+ SIGNUP: "signup",
215
+ SIGNUP_COMPLETE: "signup_complete",
216
+ LOGIN: "login",
217
+ LOGOUT: "logout",
218
+ USER_EDIT: "user_edit",
219
+ USER_DELETE: "user_delete",
220
+ PROFILE_ADD: "profile_add",
221
+ PROFILE_EDIT: "profile_edit",
222
+ PROFILE_DELETE: "profile_delete",
223
+ PROFILE_SWITCH: "profile_switch",
224
+ PROFILE_PHOTO_UPLOAD: "profile_photo_upload",
225
+ PROFILE_PHOTO_REMOVE: "profile_photo_remove",
226
+ AUTH_OTP_START: "auth_otp_start",
227
+ AUTH_OTP_RESEND: "auth_otp_resend",
228
+ AUTH_OTP_VERIFY: "auth_otp_verify",
229
+ AUTH_OTP_VERIFY_FAIL: "auth_otp_verify_fail",
230
+ AUTH_OTP_ACCOUNT_LOCK: "auth_otp_account_lock",
231
+ ACCOUNT_DETAILS_OPEN: "account_details_open",
232
+ ACCOUNT_DETAILS_PAGE_OPEN: "account_details_page_open",
233
+ ACCOUNT_DETAILS_UPDATE: "account_details_update",
234
+ ACCOUNT_PHOTO_UPLOAD: "account_photo_upload",
235
+ ACCOUNT_PHOTO_REMOVE: "account_photo_remove",
236
+ MEASUREMENTS_OPEN: "measurements_open",
237
+ MEASUREMENTS_PAGE_OPEN: "measurements_page_open",
238
+ MEASUREMENTS_UPDATE: "measurements_update",
239
+ PROFILE_SWITCHER_OPEN: "profile_switcher_open",
240
+ MANAGE_SIZE_PROFILES_OPEN: "manage_size_profiles_open",
241
+ SEARCH_SUBMIT: "search_submit",
242
+ SUGGESTION_CLICK: "suggestion_click",
243
+ FAVORITE_BRANDS_EDIT: "favorite_brands_edit",
244
+ FAVORITE_BRANDS_ADD: "favorite_brands_add",
245
+ FAVORITE_BRANDS_QUICK_ADD: "favorite_brands_quick_add",
246
+ FAVORITE_BRANDS_REMOVE: "favorite_brands_remove",
247
+ FAVORITE_BRANDS_MORE: "favorite_brands_more",
248
+ FAVORITE_BRANDS_SAVE: "favorite_brands_save",
249
+ ACTIVITY_OPEN: "activity_open",
250
+ ACTIVITY_VIEW_ALL: "activity_view_all",
251
+ ACTIVITY_FILTER: "activity_filter",
252
+ ACTIVITY_LOAD_MORE: "activity_load_more",
253
+ ACTIVITY_ROW_EXPAND: "activity_row_expand",
254
+ ACTIVITY_MENU_ACTION: "activity_menu_action"
255
+ }, ye = {
256
+ INFO_MODULE: "info_module",
257
+ USER_INFO_MODULE: "user_info_module",
258
+ SIZE_FINDER_MODULE: "size_finder_module",
259
+ ACCOUNT_MODULE: "account_module",
260
+ BRACKETING_ALERT_MODULE: "bracketing_alert_module",
261
+ AGENT_MODULE: "agent_module",
262
+ SCORE_MODULE: "score_module",
263
+ SMART_PROMPTS_MODULE: "smart_prompts_module",
264
+ SEARCH_MODULE: "search_module"
265
+ };
266
+ // src/search/components/Backdrop.tsx
267
+ function be({ onDismiss: e, ...t }) {
268
+ return /* @__PURE__ */ W("div", {
269
+ ...t,
270
+ onClick: (t) => {
271
+ t.stopPropagation(), t.target === t.currentTarget && e();
272
+ }
273
+ });
274
+ }
275
+ // src/helpers/bodyScrollLock.ts
276
+ var Z = 0, xe = null;
277
+ function Se() {
278
+ let { body: e } = document;
279
+ if (Z === 0) {
280
+ xe = {
281
+ overflowY: e.style.overflowY,
282
+ position: e.style.position,
283
+ top: e.style.top,
284
+ width: e.style.width,
285
+ scrollY: window.scrollY
286
+ };
287
+ let t = window.innerWidth - document.documentElement.clientWidth > 0;
288
+ e.style.overflowY = t ? "scroll" : "hidden", e.style.position = "fixed", e.style.top = `-${xe.scrollY}px`, e.style.width = "100%";
289
+ }
290
+ Z++;
291
+ let t = !1;
292
+ return () => {
293
+ if (t || (t = !0, Z--, Z > 0 || !xe)) return;
294
+ let n = xe;
295
+ xe = null, e.style.overflowY = n.overflowY, e.style.position = n.position, e.style.top = n.top, e.style.width = n.width, window.scrollTo({
296
+ top: n.scrollY,
297
+ behavior: "instant"
298
+ });
299
+ };
300
+ }
301
+ // src/search/components/hooks/useBodyScrollLock.ts
302
+ function Ce(e) {
303
+ z(() => {
304
+ if (e) return Se();
305
+ }, [e]);
306
+ }
307
+ // src/helpers/focusTrap.ts
308
+ var we = "a[href], area[href], input:not([disabled]):not([type=hidden]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex]:not([data-focus-guard]), [contenteditable]", Te = (e, t) => {
309
+ for (let n = e; n && n !== t.parentElement; n = n.parentElement) if (n.hidden || getComputedStyle(n).display === "none") return !0;
310
+ return !1;
311
+ }, Ee = (e) => [...e.querySelectorAll(we)].filter((t) => t.getAttribute("tabindex") !== "-1" && !t.closest("[inert]") && !Te(t, e)), De = () => {
312
+ let e = document.createElement("span");
313
+ return e.tabIndex = 0, e.dataset.focusGuard = "", e.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;overflow:hidden;opacity:0;pointer-events:none", e;
314
+ };
315
+ function Oe(e, t) {
316
+ e.contains(document.activeElement) || (e.querySelector("[data-autofocus]") ?? Ee(e)[0] ?? e).focus({ preventScroll: !0 });
317
+ let n = (n) => {
318
+ if (n.key === "Escape") {
319
+ n.stopPropagation(), t();
320
+ return;
321
+ }
322
+ if (n.key !== "Tab") return;
323
+ let r = Ee(e), i = r[0], a = r[r.length - 1];
324
+ i && a && (n.shiftKey && document.activeElement === i ? (n.preventDefault(), a.focus()) : !n.shiftKey && document.activeElement === a && (n.preventDefault(), i.focus()), n.stopPropagation());
325
+ };
326
+ e.addEventListener("keydown", n);
327
+ let r = De(), i = De(), a = () => {
328
+ e.firstChild !== r && e.prepend(r), e.lastChild !== i && e.append(i);
329
+ };
330
+ a();
331
+ let o = (t) => {
332
+ let n = Ee(e);
333
+ ((t === "first" ? n[0] : n[n.length - 1]) ?? e).focus({ preventScroll: !0 });
334
+ }, s = (t) => t.relatedTarget instanceof Node && e.contains(t.relatedTarget);
335
+ r.addEventListener("focus", (e) => o(s(e) ? "last" : "first")), i.addEventListener("focus", (e) => o(s(e) ? "first" : "last"));
336
+ let c = new MutationObserver(a);
337
+ return c.observe(e, { childList: !0 }), () => {
338
+ e.removeEventListener("keydown", n), c.disconnect(), r.remove(), i.remove();
339
+ };
340
+ }
341
+ // src/search/components/hooks/useFocusTrap.ts
342
+ var ke = (e, t = !0) => {
343
+ let [n, r] = H(null), i = V(e);
344
+ return i.current = e, z(() => {
345
+ if (n && t) return Oe(n, () => i.current());
346
+ }, [n, t]), r;
347
+ }, Ae = (e, t) => {
348
+ let [n, r] = H(null);
349
+ return z(() => {
350
+ if (!n || !t || typeof ResizeObserver > "u") return;
351
+ let r = new ResizeObserver((t) => {
352
+ let r = t[t.length - 1].borderBoxSize?.[0]?.blockSize ?? n.getBoundingClientRect().height;
353
+ n.style.setProperty(e, `${r}px`);
354
+ });
355
+ return r.observe(n), () => r.disconnect();
356
+ }, [
357
+ n,
358
+ e,
359
+ t
360
+ ]), r;
361
+ }, je = (e, t) => {
362
+ z(() => {
363
+ if (!e) return;
364
+ let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
365
+ return () => {
366
+ (!t || t()) && n?.focus();
367
+ };
368
+ }, [e, t]);
369
+ }, Me = class {
370
+ subject;
371
+ meta;
372
+ enabled = !0;
373
+ flushTimeout = null;
374
+ topWindow = d(window);
375
+ constructor(e, t) {
376
+ this.subject = e, this.meta = t || {};
377
+ }
378
+ track = (e, t) => {
379
+ if (!this.topWindow) {
380
+ this.enabled = !1;
381
+ return;
382
+ }
383
+ if (!this.enabled) return;
384
+ let n = {
385
+ type: "ecomid_event",
386
+ event: {
387
+ action: e,
388
+ subject: this.subject,
389
+ clientId: t?.clientId || this.meta.clientId,
390
+ attrs: {
391
+ ...this.meta.attrs,
392
+ ...o(),
393
+ version: "dev_2026-11-18T15:08:45.602Z",
394
+ ...t?.attrs
395
+ },
396
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleString("sv")
397
+ }
398
+ };
399
+ this.topWindow.postMessage(n, "*");
400
+ };
401
+ setMeta = (e) => {
402
+ this.meta = {
403
+ ...this.meta,
404
+ ...e,
405
+ attrs: {
406
+ ...this.meta.attrs,
407
+ ...e.attrs
408
+ }
409
+ };
410
+ };
411
+ };
412
+ // src/search/core/tracking.ts
413
+ function Ne(e) {
414
+ let t;
415
+ return (n, r) => {
416
+ t ??= new Me(ye.SEARCH_MODULE, e).track, t(n, r);
417
+ };
418
+ }
419
+ // src/search/components/hooks/useSearchSession.ts
420
+ function Pe({ clientId: e, lang: t, market: n }) {
421
+ let r = me(), i = B(() => Ne({
422
+ clientId: e,
423
+ attrs: {
424
+ lang: t,
425
+ market: n
426
+ }
427
+ }), [
428
+ e,
429
+ t,
430
+ n
431
+ ]), a = V(!1), o = L((e, t) => {
432
+ a.current || (a.current = !0, r(e, { context: t.componentStack ?? void 0 }));
433
+ }, [r]);
434
+ return z(() => {
435
+ i(X.INIT);
436
+ }, []), {
437
+ track: i,
438
+ onRenderError: o
439
+ };
440
+ }
441
+ // src/helpers/deepMerge.ts
442
+ function Fe(e, ...t) {
443
+ if (!t.length) return e;
444
+ let n = t.shift();
445
+ if (Ie(e) && Ie(n)) for (let t in n) Ie(n[t]) ? (e[t] || Object.assign(e, { [t]: {} }), [
446
+ "__proto__",
447
+ "constructor",
448
+ "prototype"
449
+ ].includes(t) || Fe(e[t], n[t])) : Object.assign(e, { [t]: n[t] });
450
+ return Fe(e, ...t);
451
+ }
452
+ function Ie(e) {
453
+ return e && typeof e == "object" && !Array.isArray(e);
454
+ }
455
+ // src/translations/translate.ts
456
+ function Le(e, t, n) {
457
+ let r = e;
458
+ for (let e of t.split(".")) if (r = r?.[e], !r) return "";
459
+ return typeof r == "string" && n ? r.replace(/{(.*?)}/g, (e, t) => n[t] || e) : r;
460
+ }
461
+ function Re(e, t) {
462
+ return t ? Fe({}, e, t) : e;
463
+ }
464
+ // src/search/components/hooks/useSearchTranslations.ts
465
+ var ze = /* #__PURE__ */ Object.assign({
466
+ "/translations/search/widget/cs.json": () => import("./chunks/cs-Dqb_rREp.js"),
467
+ "/translations/search/widget/da.json": () => import("./chunks/da-WYTDtjgg.js"),
468
+ "/translations/search/widget/de.json": () => import("./chunks/de-D6tbcZ82.js"),
469
+ "/translations/search/widget/en.json": () => import("./chunks/en-BJsf6vvY.js"),
470
+ "/translations/search/widget/es.json": () => import("./chunks/es-UCU6bjwJ.js"),
471
+ "/translations/search/widget/fi.json": () => import("./chunks/fi-BZ1TBPKK.js"),
472
+ "/translations/search/widget/fr.json": () => import("./chunks/fr-Bh4svI2n.js"),
473
+ "/translations/search/widget/it.json": () => import("./chunks/it-S3zZ2XyN.js"),
474
+ "/translations/search/widget/nl.json": () => import("./chunks/nl-BskWxJtL.js"),
475
+ "/translations/search/widget/no.json": () => import("./chunks/no-fPEJ7LXi.js"),
476
+ "/translations/search/widget/pl.json": () => import("./chunks/pl-DgFibWpI.js"),
477
+ "/translations/search/widget/pt.json": () => import("./chunks/pt-CZ1aBAcy.js"),
478
+ "/translations/search/widget/sk.json": () => import("./chunks/sk-BVkd-dpe.js"),
479
+ "/translations/search/widget/sv.json": () => import("./chunks/sv-CoiCABF8.js")
480
+ }), Be = /* @__PURE__ */ new Map(), Ve = "en.json", He = (e, t) => Object.entries(e).find(([e]) => e.endsWith(`/${t}`))?.[1], Ue = (e, t) => {
481
+ a(new We(`Error loading translations for ${e}: ${t instanceof Error ? t.message : String(t)}`));
482
+ }, We = class extends Error {
483
+ constructor(e) {
484
+ super(e), this.name = "MissingTranslationError";
485
+ }
486
+ }, Ge = (e) => e.default ?? e, Ke = async (e, t, n) => {
487
+ try {
488
+ let n = await He(e, t)?.();
489
+ return n ? Ge(n) : void 0;
490
+ } catch (e) {
491
+ n() || Ue(t, e);
492
+ return;
493
+ }
494
+ };
495
+ async function qe(e, { loaders: t = ze, store: n = Be, isCancelled: r = () => !1 } = {}) {
496
+ let i = `${e}.json`, a = n.get(i);
497
+ if (a) return a;
498
+ let [o, s] = await Promise.all([Ke(t, Ve, r), i === Ve ? void 0 : Ke(t, i, r)]);
499
+ if (!o) return;
500
+ let c = Re(o, s);
501
+ return n.set(i, c), c;
502
+ }
503
+ function Q(e) {
504
+ let [t, n] = H(() => Be.get(`${e}.json`) ?? Be.get("en.json"));
505
+ return z(() => {
506
+ let t = !1;
507
+ return qe(e, { isCancelled: () => t }).then((e) => {
508
+ !t && e && n(e);
509
+ }), () => {
510
+ t = !0;
511
+ };
512
+ }, [e]), {
513
+ t: (e, n) => Le(t, e, n),
514
+ isLoading: !t
515
+ };
516
+ }
517
+ // src/search/components/PortalTarget.tsx
518
+ var Je = I(null);
519
+ function Ye() {
520
+ return R(Je) ?? document.body;
521
+ }
522
+ // node_modules/clsx/dist/clsx.mjs
523
+ function Xe(e) {
524
+ var t, n, r = "";
525
+ if (typeof e == "string" || typeof e == "number") r += e;
526
+ else if (typeof e == "object") {
527
+ if (Array.isArray(e)) {
528
+ var i = e.length;
529
+ for (t = 0; t < i; t++) e[t] && (n = Xe(e[t])) && (r && (r += " "), r += n);
530
+ } else for (n in e) e[n] && (r && (r += " "), r += n);
531
+ }
532
+ return r;
533
+ }
534
+ function Ze() {
535
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = Xe(e)) && (r && (r += " "), r += t);
536
+ return r;
537
+ }
538
+ // src/components/Wordmark/index.tsx
539
+ var Qe = 288 / 55;
540
+ function $e({ height: e = 12, color: t, className: n, standardAttribution: r = !1 }) {
541
+ return /* @__PURE__ */ G("svg", {
542
+ xmlns: "http://www.w3.org/2000/svg",
543
+ viewBox: "0 0 55 12",
544
+ fill: "none",
545
+ style: {
546
+ height: r ? Math.min(e, Qe) : e,
547
+ color: t,
548
+ overflow: r ? "visible" : void 0
549
+ },
550
+ role: "img",
551
+ "aria-label": "eComID logo",
552
+ "aria-hidden": "true",
553
+ className: Ze("js-ecomid-logo", n),
554
+ children: [
555
+ /* @__PURE__ */ W("path", {
556
+ d: "M0.0224609 7.65191C0.0224609 5.43252 1.39553 3.41919 3.98386 3.41919C6.52482 3.41919 7.86632 5.32153 7.85054 7.36656C7.85054 7.6836 7.81898 8.06407 7.81898 8.06407H1.72696C1.88479 9.57009 2.78439 10.4261 4.11011 10.4261C5.1202 10.4261 5.92509 9.95056 6.11448 9.11036H7.80321C7.51912 10.9017 6.01979 11.9004 4.06276 11.9004C1.47445 11.9004 0.0224609 9.88714 0.0224609 7.65191ZM1.80588 6.70074H6.00401C5.92509 5.59103 5.21489 4.78255 3.98386 4.78255C2.83172 4.78255 2.0584 5.49591 1.80588 6.70074Z",
557
+ fill: "currentColor"
558
+ }),
559
+ /* @__PURE__ */ W("path", {
560
+ d: "M14.3155 11.9004C11.3642 11.9004 8.72852 9.9664 8.72852 6.05076C8.72852 2.15096 11.4115 0.216919 14.3155 0.216919C16.9038 0.216919 18.9555 1.65953 19.287 4.22768H17.3615C17.1248 2.76923 15.8937 1.83391 14.2997 1.83391C12.1849 1.83391 10.5908 3.33993 10.5908 6.05076C10.5908 8.77745 12.1849 10.2676 14.2997 10.2676C15.9095 10.2676 17.0932 9.3957 17.3615 7.88968H19.3027C18.8766 10.5371 16.8249 11.9004 14.3155 11.9004Z",
561
+ fill: "currentColor"
562
+ }),
563
+ /* @__PURE__ */ W("path", {
564
+ d: "M24.3604 11.9004C21.9457 11.9004 20.2412 10.1091 20.2412 7.65191C20.2412 5.21056 21.9457 3.41919 24.3604 3.41919C26.7279 3.41919 28.4797 5.19471 28.4797 7.65191C28.4797 10.1249 26.7279 11.9004 24.3604 11.9004ZM24.3604 10.3944C25.7493 10.3944 26.7121 9.25305 26.7121 7.65191C26.7121 6.05077 25.7336 4.92521 24.3604 4.92521C22.9243 4.92521 21.9931 6.06662 21.9931 7.65191C21.9931 9.25305 22.9243 10.3944 24.3604 10.3944Z",
565
+ fill: "currentColor"
566
+ }),
567
+ /* @__PURE__ */ W("path", {
568
+ d: "M29.4429 11.7736V3.54603H31.1632V4.95693C31.5892 4.03746 32.4099 3.41919 33.5778 3.41919C34.9037 3.41919 35.8506 3.98989 36.1977 5.05205C36.6395 4.13258 37.618 3.41919 38.8808 3.41919C40.6327 3.41919 41.769 4.54474 41.769 6.22515V11.7736H40.0486V6.65317C40.0486 5.60688 39.4488 4.90936 38.4072 4.90936C37.1605 4.90936 36.466 6.01907 36.466 7.62021V11.7736H34.7456V6.65317C34.7456 5.60688 34.1618 4.90936 33.1202 4.90936C31.8732 4.90936 31.1632 6.03492 31.1632 7.62021V11.7736H29.4429Z",
569
+ fill: "currentColor"
570
+ }),
571
+ /* @__PURE__ */ W("path", {
572
+ d: "M42.7407 11.7736V0.34375H44.5715V11.7736H42.7407Z",
573
+ fill: "currentColor"
574
+ }),
575
+ /* @__PURE__ */ W("path", {
576
+ d: "M45.5483 11.7736V0.34375H49.0994C52.2559 0.34375 54.8758 2.29365 54.8758 6.05076C54.8758 9.82375 52.2559 11.7736 49.0994 11.7736H45.5483ZM48.989 10.1408C51.0407 10.1408 52.9977 8.99939 52.9977 6.05076C52.9977 3.11799 51.0407 1.97659 48.989 1.97659H47.3791V10.1408H48.989Z",
577
+ fill: "currentColor"
578
+ })
579
+ ]
580
+ });
581
+ }
582
+ // src/search/components/PoweredBy/index.tsx
583
+ function et() {
584
+ return /* @__PURE__ */ G("div", {
585
+ className: "ecomid-search-powered",
586
+ children: [
587
+ /* @__PURE__ */ W("span", {
588
+ className: "ecomid-search-powered__label",
589
+ children: "Powered by"
590
+ }),
591
+ /* @__PURE__ */ W($e, {
592
+ className: "ecomid-search-powered__logo",
593
+ height: 7.93
594
+ }),
595
+ /* @__PURE__ */ W("span", {
596
+ className: "ecomid-search-sr-only",
597
+ children: "eComID"
598
+ })
599
+ ]
600
+ });
601
+ }
602
+ // src/search/components/ComingSoonTab/follower.ts
603
+ var tt = 10, nt = 16, rt = .07, it = 250;
604
+ function at(e, t) {
605
+ let n = 0, r = 0, i = 0, a = 0, o = !1, s = 0, c, l = () => {
606
+ let t = e();
607
+ t && (t.style.transform = `translate(${i.toFixed(1)}px, ${a.toFixed(1)}px)`);
608
+ }, u = () => {
609
+ s && cancelAnimationFrame(s), s = 0;
610
+ }, d = () => {
611
+ i += (n + tt - i) * rt, a += (r + nt - a) * rt, l(), s = requestAnimationFrame(d);
612
+ };
613
+ return {
614
+ enter(u, f) {
615
+ n = u, r = f, clearTimeout(c), o || (i = u + tt, a = f + nt), o = !0;
616
+ let p = e();
617
+ p && (p.style.transition = "opacity 0.12s linear", p.style.opacity = "1"), l(), !t() && !s && (s = requestAnimationFrame(d));
618
+ },
619
+ move(e, s) {
620
+ n = e, r = s, o && t() && (i = e + tt, a = s + nt, l());
621
+ },
622
+ leave() {
623
+ o = !1;
624
+ let t = e();
625
+ t && (t.style.transition = "opacity 0.1s linear 0.03s", t.style.opacity = "0"), clearTimeout(c), c = setTimeout(() => {
626
+ o || u();
627
+ }, it);
628
+ },
629
+ destroy() {
630
+ clearTimeout(c), u(), o = !1;
631
+ }
632
+ };
633
+ }
634
+ // src/search/components/ComingSoonTab/index.tsx
635
+ var ot = 44, st = 3e3, ct = () => typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, lt = () => typeof window.matchMedia == "function" && window.matchMedia("(hover: hover) and (pointer: fine)").matches;
636
+ function ut({ lang: e, label: t }) {
637
+ let { t: n } = Q(e), r = ne(), i = V(null), a = V(null), o = V(null), s = V([]), c = V(0), [l, u] = H(null), [d, f] = H(null);
638
+ z(() => {
639
+ f(document.body);
640
+ }, []);
641
+ let p = () => (o.current ||= at(() => a.current, ct), o.current), m = () => {
642
+ for (let e of s.current) clearTimeout(e);
643
+ s.current = [];
644
+ };
645
+ z(() => () => {
646
+ o.current?.destroy();
647
+ for (let e of s.current) clearTimeout(e);
648
+ }, []);
649
+ let h = (e) => {
650
+ e.pointerType !== "touch" && p().enter(e.clientX, e.clientY);
651
+ }, g = (e) => {
652
+ e.pointerType !== "touch" && p().move(e.clientX, e.clientY);
653
+ }, _ = (e) => {
654
+ e.pointerType !== "touch" && p().leave();
655
+ }, v = (e) => {
656
+ let { pointerType: t } = e;
657
+ if (!(t ? t === "touch" : !lt())) return;
658
+ let n = (i.current?.closest(".ecomid-search-shell, .ecomid-search-modal__title-row") ?? i.current)?.getBoundingClientRect();
659
+ n && (m(), c.current += 1, u({
660
+ key: c.current,
661
+ left: n.left + n.width / 2,
662
+ top: n.top + ot,
663
+ leaving: !1
664
+ }), s.current = [setTimeout(() => {
665
+ u((e) => e && {
666
+ ...e,
667
+ leaving: !0
668
+ });
669
+ }, st), setTimeout(() => u(null), 3450)]);
670
+ }, y = n("coming_soon");
671
+ return /* @__PURE__ */ G(U, { children: [
672
+ /* @__PURE__ */ W("button", {
673
+ ref: i,
674
+ type: "button",
675
+ className: "ecomid-search-shell__tab ecomid-search-shell__tab--soon",
676
+ "aria-disabled": "true",
677
+ "aria-describedby": r,
678
+ onPointerEnter: h,
679
+ onPointerMove: g,
680
+ onPointerLeave: _,
681
+ onClick: v,
682
+ children: t
683
+ }),
684
+ /* @__PURE__ */ W("span", {
685
+ id: r,
686
+ className: "ecomid-search-sr-only",
687
+ children: y
688
+ }),
689
+ d && K(/* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("div", {
690
+ ref: a,
691
+ className: "ecomid-search-soon ecomid-search-soon--follow",
692
+ "aria-hidden": "true",
693
+ children: y
694
+ }), l && /* @__PURE__ */ W("div", {
695
+ className: "ecomid-search-soon ecomid-search-soon--toast",
696
+ "data-leaving": l.leaving || void 0,
697
+ style: {
698
+ left: l.left,
699
+ top: l.top
700
+ },
701
+ "aria-hidden": "true",
702
+ children: y
703
+ }, l.key)] }), d)
704
+ ] });
705
+ }
706
+ // src/search/components/HeaderTabs/index.tsx
707
+ function dt({ lang: e }) {
708
+ let { t } = Q(e);
709
+ return /* @__PURE__ */ G("div", {
710
+ className: "ecomid-search-shell__tabs",
711
+ children: [/* @__PURE__ */ W("span", {
712
+ className: "ecomid-search-shell__tab",
713
+ "aria-current": "page",
714
+ children: t("shell.search")
715
+ }), /* @__PURE__ */ W(ut, {
716
+ lang: e,
717
+ label: t("shell.for_you")
718
+ })]
719
+ });
720
+ }
721
+ // src/search/components/icons.tsx
722
+ function ft() {
723
+ return /* @__PURE__ */ G("svg", {
724
+ className: "ecomid-search-icon",
725
+ "aria-hidden": "true",
726
+ focusable: "false",
727
+ width: "16",
728
+ height: "16",
729
+ viewBox: "0 0 16 16",
730
+ fill: "none",
731
+ children: [/* @__PURE__ */ W("path", {
732
+ d: "M7 12.5C10.038 12.5 12.5 10.038 12.5 7C12.5 3.962 10.038 1.5 7 1.5C3.962 1.5 1.5 3.962 1.5 7C1.5 10.038 3.962 12.5 7 12.5Z",
733
+ stroke: "currentColor",
734
+ strokeWidth: "1.5",
735
+ strokeLinecap: "round",
736
+ strokeLinejoin: "round"
737
+ }), /* @__PURE__ */ W("path", {
738
+ d: "M14.5 14.5L11 11",
739
+ stroke: "currentColor",
740
+ strokeWidth: "1.5",
741
+ strokeLinecap: "round",
742
+ strokeLinejoin: "round"
743
+ })]
744
+ });
745
+ }
746
+ function pt() {
747
+ return /* @__PURE__ */ G("svg", {
748
+ className: "ecomid-search-icon",
749
+ "aria-hidden": "true",
750
+ focusable: "false",
751
+ width: "20",
752
+ height: "20",
753
+ viewBox: "0 0 20 20",
754
+ fill: "none",
755
+ children: [/* @__PURE__ */ W("path", {
756
+ d: "M17.266 2.74L2.732 17.274",
757
+ stroke: "currentColor",
758
+ strokeWidth: "1.5",
759
+ strokeLinecap: "round",
760
+ strokeLinejoin: "round"
761
+ }), /* @__PURE__ */ W("path", {
762
+ d: "M2.732 2.74L17.266 17.274",
763
+ stroke: "currentColor",
764
+ strokeWidth: "1.5",
765
+ strokeLinecap: "round",
766
+ strokeLinejoin: "round"
767
+ })]
768
+ });
769
+ }
770
+ function mt() {
771
+ return /* @__PURE__ */ G("svg", {
772
+ className: "ecomid-search-icon",
773
+ "aria-hidden": "true",
774
+ focusable: "false",
775
+ width: "16",
776
+ height: "16",
777
+ viewBox: "0 0 16 16",
778
+ fill: "none",
779
+ children: [/* @__PURE__ */ W("path", {
780
+ d: "M12.5 7.672L2 7.672",
781
+ stroke: "currentColor",
782
+ strokeWidth: "1.5",
783
+ strokeLinecap: "round"
784
+ }), /* @__PURE__ */ W("path", {
785
+ d: "M7.414 2L13 7.586L7.414 13.172",
786
+ stroke: "currentColor",
787
+ strokeWidth: "1.5",
788
+ strokeMiterlimit: "16",
789
+ strokeLinecap: "round"
790
+ })]
791
+ });
792
+ }
793
+ function ht() {
794
+ return /* @__PURE__ */ G("svg", {
795
+ className: "ecomid-search-icon",
796
+ "aria-hidden": "true",
797
+ focusable: "false",
798
+ width: "16",
799
+ height: "16",
800
+ viewBox: "0 0 16 16",
801
+ fill: "none",
802
+ children: [/* @__PURE__ */ W("path", {
803
+ d: "M8 3L8 14",
804
+ stroke: "currentColor",
805
+ strokeWidth: "1.5",
806
+ strokeLinecap: "round"
807
+ }), /* @__PURE__ */ W("path", {
808
+ d: "M2 8L8 2L14 8",
809
+ stroke: "currentColor",
810
+ strokeWidth: "1.5",
811
+ strokeMiterlimit: "16",
812
+ strokeLinecap: "round"
813
+ })]
814
+ });
815
+ }
816
+ function gt() {
817
+ return /* @__PURE__ */ W("svg", {
818
+ className: "ecomid-search-icon",
819
+ "aria-hidden": "true",
820
+ focusable: "false",
821
+ width: "16",
822
+ height: "16",
823
+ viewBox: "0 0 16 16",
824
+ fill: "none",
825
+ children: /* @__PURE__ */ W("path", {
826
+ d: "M6 2L12 8L6 14",
827
+ stroke: "currentColor",
828
+ strokeWidth: "1.5",
829
+ strokeMiterlimit: "16",
830
+ strokeLinecap: "round"
831
+ })
832
+ });
833
+ }
834
+ function _t() {
835
+ return /* @__PURE__ */ W("svg", {
836
+ className: "ecomid-search-icon",
837
+ "aria-hidden": "true",
838
+ focusable: "false",
839
+ width: "20",
840
+ height: "20",
841
+ viewBox: "0 0 20 20",
842
+ fill: "none",
843
+ children: /* @__PURE__ */ W("path", {
844
+ d: "M12 16L6 10L12 4",
845
+ stroke: "currentColor",
846
+ strokeWidth: "1.5",
847
+ strokeMiterlimit: "16",
848
+ strokeLinecap: "round"
849
+ })
850
+ });
851
+ }
852
+ function vt() {
853
+ return /* @__PURE__ */ G("svg", {
854
+ className: "ecomid-search-icon ecomid-search-icon--16",
855
+ "aria-hidden": "true",
856
+ focusable: "false",
857
+ width: "16",
858
+ height: "16",
859
+ viewBox: "0 0 16 16",
860
+ fill: "none",
861
+ children: [
862
+ /* @__PURE__ */ W("path", {
863
+ d: "M1.5 5H10.86",
864
+ stroke: "currentColor",
865
+ strokeWidth: "1.5",
866
+ strokeLinecap: "round",
867
+ strokeLinejoin: "round"
868
+ }),
869
+ /* @__PURE__ */ W("path", {
870
+ d: "M12.68 6.64C13.685 6.64 14.5 5.825 14.5 4.82C14.5 3.815 13.685 3 12.68 3C11.675 3 10.86 3.815 10.86 4.82C10.86 5.825 11.675 6.64 12.68 6.64Z",
871
+ stroke: "currentColor",
872
+ strokeWidth: "1.5",
873
+ strokeLinecap: "round",
874
+ strokeLinejoin: "round"
875
+ }),
876
+ /* @__PURE__ */ W("path", {
877
+ d: "M14.499 11.552L9.299 11.552",
878
+ stroke: "currentColor",
879
+ strokeWidth: "1.5",
880
+ strokeLinecap: "round",
881
+ strokeLinejoin: "round"
882
+ }),
883
+ /* @__PURE__ */ W("path", {
884
+ d: "M4.62 11.552H1.5",
885
+ stroke: "currentColor",
886
+ strokeWidth: "1.5",
887
+ strokeLinecap: "round",
888
+ strokeLinejoin: "round"
889
+ }),
890
+ /* @__PURE__ */ W("path", {
891
+ d: "M7.183 13.442C8.188 13.442 9.003 12.627 9.003 11.622C9.003 10.617 8.188 9.802 7.183 9.802C6.178 9.802 5.363 10.617 5.363 11.622C5.363 12.627 6.178 13.442 7.183 13.442Z",
892
+ stroke: "currentColor",
893
+ strokeWidth: "1.5",
894
+ strokeLinecap: "round",
895
+ strokeLinejoin: "round"
896
+ })
897
+ ]
898
+ });
899
+ }
900
+ var yt = {
901
+ 12: [{
902
+ d: "M10.19 3.75L6 7.939L1.811 3.75",
903
+ strokeWidth: 1.2,
904
+ strokeMiterlimit: 16
905
+ }],
906
+ 16: [{
907
+ d: "M13.586 6L8 11.586L2.414 6",
908
+ strokeWidth: 1.5,
909
+ strokeMiterlimit: 16
910
+ }]
911
+ };
912
+ function bt({ size: e = 12 }) {
913
+ return /* @__PURE__ */ W("svg", {
914
+ className: `ecomid-search-icon ecomid-search-icon--${e}`,
915
+ "aria-hidden": "true",
916
+ focusable: "false",
917
+ width: e,
918
+ height: e,
919
+ viewBox: `0 0 ${e} ${e}`,
920
+ fill: "none",
921
+ children: yt[e].map((e) => /* @__PURE__ */ W("path", {
922
+ d: e.d,
923
+ stroke: "currentColor",
924
+ strokeWidth: e.strokeWidth,
925
+ strokeMiterlimit: e.strokeMiterlimit,
926
+ strokeLinecap: "round"
927
+ }, e.d))
928
+ });
929
+ }
930
+ function xt() {
931
+ return /* @__PURE__ */ G("svg", {
932
+ className: "ecomid-search-icon ecomid-search-icon--12",
933
+ "aria-hidden": "true",
934
+ focusable: "false",
935
+ width: "12",
936
+ height: "12",
937
+ viewBox: "0 0 12 12",
938
+ fill: "none",
939
+ children: [/* @__PURE__ */ W("path", {
940
+ d: "M9.607 2.379L2.395 9.591",
941
+ stroke: "currentColor",
942
+ strokeWidth: "1.2",
943
+ strokeLinecap: "round",
944
+ strokeLinejoin: "round"
945
+ }), /* @__PURE__ */ W("path", {
946
+ d: "M2.395 2.379L9.607 9.591",
947
+ stroke: "currentColor",
948
+ strokeWidth: "1.2",
949
+ strokeLinecap: "round",
950
+ strokeLinejoin: "round"
951
+ })]
952
+ });
953
+ }
954
+ function St({ size: e = 16 }) {
955
+ return /* @__PURE__ */ W("svg", {
956
+ className: `ecomid-search-icon ecomid-search-icon--${e}`,
957
+ "aria-hidden": "true",
958
+ focusable: "false",
959
+ width: e,
960
+ height: e,
961
+ viewBox: "0 0 16 16",
962
+ fill: "none",
963
+ children: /* @__PURE__ */ W("path", {
964
+ d: "M13.24 4.301L5.842 11.699L2.76 8.617",
965
+ stroke: "currentColor",
966
+ strokeWidth: "1.5",
967
+ strokeLinecap: "round",
968
+ strokeLinejoin: "round"
969
+ })
970
+ });
971
+ }
972
+ function Ct() {
973
+ return /* @__PURE__ */ G("svg", {
974
+ className: "ecomid-search-icon ecomid-search-icon--12",
975
+ "aria-hidden": "true",
976
+ focusable: "false",
977
+ width: "12",
978
+ height: "12",
979
+ viewBox: "0 0 12 12",
980
+ fill: "none",
981
+ children: [/* @__PURE__ */ W("path", {
982
+ d: "M5.999 5.191C7.182 5.191 8.141 4.232 8.141 3.05C8.141 1.867 7.182 0.908 5.999 0.908C4.816 0.908 3.857 1.867 3.857 3.05C3.857 4.232 4.816 5.191 5.999 5.191Z",
983
+ stroke: "currentColor",
984
+ strokeWidth: "1.2",
985
+ strokeLinecap: "round",
986
+ strokeLinejoin: "round"
987
+ }), /* @__PURE__ */ W("path", {
988
+ d: "M1.716 11.092H6H10.283V10.628C10.276 9.976 10.084 9.336 9.727 8.768C9.37 8.2 8.858 7.723 8.24 7.381C7.622 7.039 6.918 6.844 6.193 6.813C6.129 6.81 6.064 6.809 6 6.809C5.935 6.809 5.87 6.81 5.806 6.813C5.081 6.844 4.377 7.039 3.759 7.381C3.141 7.723 2.629 8.2 2.272 8.768C1.915 9.336 1.723 9.976 1.716 10.628V11.092Z",
989
+ stroke: "currentColor",
990
+ strokeWidth: "1.2",
991
+ strokeLinecap: "round",
992
+ strokeLinejoin: "round"
993
+ })]
994
+ });
995
+ }
996
+ function wt() {
997
+ return /* @__PURE__ */ G("svg", {
998
+ className: "ecomid-search-icon",
999
+ "aria-hidden": "true",
1000
+ focusable: "false",
1001
+ width: "20",
1002
+ height: "20",
1003
+ viewBox: "0 0 20 20",
1004
+ fill: "none",
1005
+ children: [/* @__PURE__ */ W("path", {
1006
+ d: "M10.25 9.167C12.321 9.167 14 7.488 14 5.417C14 3.346 12.321 1.667 10.25 1.667C8.179 1.667 6.5 3.346 6.5 5.417C6.5 7.488 8.179 9.167 10.25 9.167Z",
1007
+ stroke: "currentColor",
1008
+ strokeWidth: "1.5",
1009
+ strokeLinecap: "round",
1010
+ strokeLinejoin: "round"
1011
+ }), /* @__PURE__ */ W("path", {
1012
+ d: "M4 18.334H10.25H16.5V17.612C16.489 16.596 16.21 15.6 15.688 14.717C15.167 13.833 14.421 13.09 13.519 12.558C12.618 12.026 11.59 11.722 10.533 11.674C10.438 11.669 10.344 11.667 10.25 11.667C10.156 11.667 10.062 11.669 9.967 11.674C8.91 11.722 7.882 12.026 6.981 12.558C6.079 13.09 5.333 13.833 4.811 14.717C4.29 15.6 4.011 16.596 4 17.612V18.334Z",
1013
+ stroke: "currentColor",
1014
+ strokeWidth: "1.5",
1015
+ strokeLinecap: "round",
1016
+ strokeLinejoin: "round"
1017
+ })]
1018
+ });
1019
+ }
1020
+ // src/search/components/PersonalizeButton/index.tsx
1021
+ function Tt({ lang: e, onClick: t, buttonRef: n }) {
1022
+ let { t: r } = Q(e);
1023
+ return /* @__PURE__ */ G("button", {
1024
+ type: "button",
1025
+ ref: n,
1026
+ className: "ecomid-search-modal__personalize",
1027
+ title: r("personalize"),
1028
+ "aria-label": r("personalize"),
1029
+ onClick: t,
1030
+ children: [
1031
+ /* @__PURE__ */ W("span", {
1032
+ className: "ecomid-search-modal__personalize-chip",
1033
+ children: /* @__PURE__ */ W(Ct, {})
1034
+ }),
1035
+ /* @__PURE__ */ W("span", {
1036
+ className: "ecomid-search-modal__personalize-button",
1037
+ children: /* @__PURE__ */ W(wt, {})
1038
+ }),
1039
+ /* @__PURE__ */ W("span", {
1040
+ className: "ecomid-search-modal__personalize-label",
1041
+ children: r("personalize")
1042
+ })
1043
+ ]
1044
+ });
1045
+ }
1046
+ // src/search/components/SearchHeader/index.tsx
1047
+ function Et({ lang: e, onClose: t, onPersonalize: n, personalizeRef: r }) {
1048
+ let { t: i } = Q(e);
1049
+ return /* @__PURE__ */ G("div", {
1050
+ className: "ecomid-search-modal__title-row",
1051
+ children: [
1052
+ /* @__PURE__ */ W("div", {
1053
+ className: "ecomid-search-modal__start",
1054
+ children: /* @__PURE__ */ W(Tt, {
1055
+ lang: e,
1056
+ onClick: n,
1057
+ buttonRef: r
1058
+ })
1059
+ }),
1060
+ /* @__PURE__ */ W(dt, { lang: e }),
1061
+ /* @__PURE__ */ W("div", {
1062
+ className: "ecomid-search-modal__end",
1063
+ children: /* @__PURE__ */ W("button", {
1064
+ type: "button",
1065
+ className: "ecomid-search-modal__close",
1066
+ title: i("actions.close"),
1067
+ "aria-label": i("actions.close"),
1068
+ onClick: t,
1069
+ children: /* @__PURE__ */ W(pt, {})
1070
+ })
1071
+ })
1072
+ ]
1073
+ });
1074
+ }
1075
+ // node_modules/@ecomid/web-ui/dist/clsx-m_fIYDAy.js
1076
+ function Dt(e) {
1077
+ var t, n, r = "";
1078
+ if (typeof e == "string" || typeof e == "number") r += e;
1079
+ else if (typeof e == "object") {
1080
+ if (Array.isArray(e)) {
1081
+ var i = e.length;
1082
+ for (t = 0; t < i; t++) e[t] && (n = Dt(e[t])) && (r && (r += " "), r += n);
1083
+ } else for (n in e) e[n] && (r && (r += " "), r += n);
1084
+ }
1085
+ return r;
1086
+ }
1087
+ function Ot() {
1088
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = Dt(e)) && (r && (r += " "), r += t);
1089
+ return r;
1090
+ }
1091
+ // node_modules/@ecomid/web-ui/dist/components/Icons/helpers.js
1092
+ var kt = ({ color: e, rotate: t, className: n, ...r }) => ({
1093
+ "aria-hidden": r.title || r["aria-label"] || r["aria-labelledby"] ? void 0 : !0,
1094
+ ...r,
1095
+ className: Ot("transition-transform duration-150 ease-out", n)
1096
+ }), At = (e) => {
1097
+ let t = kt(e);
1098
+ return /* @__PURE__ */ G("svg", {
1099
+ xmlns: "http://www.w3.org/2000/svg",
1100
+ width: 16,
1101
+ height: 16,
1102
+ fill: "none",
1103
+ role: "img",
1104
+ "aria-label": t.title,
1105
+ ...t,
1106
+ children: [
1107
+ /* @__PURE__ */ W("path", {
1108
+ fill: "currentColor",
1109
+ d: "M13.25 7c0-.19891-.079-.38968-.2197-.53033-.1406-.14065-.3314-.21967-.5303-.21967s-.3897.07902-.5303.21967c-.1407.14065-.2197.33142-.2197.53033.0001.37463-.0435.7476-.1302 1.10999-.4374 1.93071-2.21179 3.46981-4.1873 3.62061-.14356.0129-.28728.0194-.4325.0194-.77107.0009-1.5354-.1871-2.21431-.5464C3.25243 10.4091 2.23144 8.72925 2.25 7c-.03726-2.13475 1.56198-4.15368 3.64001-4.61978C6.2524 2.29346 6.62537 2.24995 7 2.25c.19891 0 .38968-.07902.53033-.21967S7.75 1.69891 7.75 1.5s-.07902-.38968-.21967-.53033C7.38968.829018 7.19891.75 7 .75c-.49002-.000104-.9813.056992-1.45902.17139C2.79984 1.53721.703717 4.1908.75 7c-.02416 2.27239 1.31952 4.4871 3.33528 5.53.89341.4733 1.90572.7216 2.91472.72.18995 0 .37844-.0084.56706-.0254 2.60604-.2022 4.93214-2.2179 5.51154-4.76558.1144-.47772.1715-.969.1714-1.45902"
1110
+ }),
1111
+ /* @__PURE__ */ W("path", {
1112
+ stroke: "currentColor",
1113
+ strokeLinecap: "round",
1114
+ strokeLinejoin: "round",
1115
+ strokeWidth: 1.5,
1116
+ d: "M14.5 14.5 11 11"
1117
+ }),
1118
+ /* @__PURE__ */ W("path", {
1119
+ fill: "currentColor",
1120
+ d: "M12.5476 3.90403s-.8675.2737-1.2285.63467-.6347 1.22849-.6347 1.22849c-.1847.50791-.5271.50791-.7118 0 0 0-.2737-.86752-.63467-1.22849s-1.22849-.63467-1.22849-.63467c-.5079-.1847-.5079-.52713 0-.71181 0 0 .86752-.27371 1.22849-.63468s.63467-1.22848.63467-1.22848c.1847-.507918.5271-.507918.7118 0 0 0 .2737.86751.6347 1.22848s1.2285.63468 1.2285.63468c.5079.18468.5079.52711 0 .71181"
1121
+ })
1122
+ ]
1123
+ });
1124
+ }, jt = (e) => {
1125
+ let t = kt(e);
1126
+ return /* @__PURE__ */ G("svg", {
1127
+ xmlns: "http://www.w3.org/2000/svg",
1128
+ width: 20,
1129
+ height: 20,
1130
+ fill: "none",
1131
+ role: "img",
1132
+ "aria-label": t.title,
1133
+ ...t,
1134
+ children: [
1135
+ /* @__PURE__ */ W("path", {
1136
+ stroke: "currentColor",
1137
+ strokeLinecap: "round",
1138
+ strokeLinejoin: "round",
1139
+ strokeWidth: 1.5,
1140
+ d: "M9.99996 5.62518v4.99992L6.75 12.2501"
1141
+ }),
1142
+ /* @__PURE__ */ W("path", {
1143
+ stroke: "currentColor",
1144
+ strokeLinecap: "round",
1145
+ strokeWidth: 1.5,
1146
+ d: "M2.09253 11.8749C2.93898 15.4582 6.15809 18.1248 10 18.1248c4.4873 0 8.1249-3.6376 8.1249-8.12491C18.1249 5.51264 14.4873 1.875 10 1.875c-3.1346 0-5.85461 1.77511-7.20963 4.37494"
1147
+ }),
1148
+ /* @__PURE__ */ W("path", {
1149
+ stroke: "currentColor",
1150
+ strokeLinecap: "round",
1151
+ strokeLinejoin: "round",
1152
+ strokeWidth: 1.5,
1153
+ d: "M1.875 3.75012v3.12496h3.12496"
1154
+ })
1155
+ ]
1156
+ });
1157
+ }, Mt = (e) => {
1158
+ let t = kt(e);
1159
+ return /* @__PURE__ */ W("svg", {
1160
+ xmlns: "http://www.w3.org/2000/svg",
1161
+ width: 12,
1162
+ height: 12,
1163
+ fill: "none",
1164
+ role: "img",
1165
+ "aria-label": t.title,
1166
+ ...t,
1167
+ children: /* @__PURE__ */ W("path", {
1168
+ stroke: "currentColor",
1169
+ strokeLinecap: "round",
1170
+ strokeLinejoin: "round",
1171
+ strokeWidth: 1.2,
1172
+ d: "M5.25 9.375c2.27818 0 4.125-1.84682 4.125-4.125S7.52818 1.125 5.25 1.125 1.125 2.97182 1.125 5.25 2.97182 9.375 5.25 9.375M10.875 10.875 8.25 8.25"
1173
+ })
1174
+ });
1175
+ };
1176
+ // src/search/components/hooks/useMediaQuery.ts
1177
+ function Nt(e) {
1178
+ return ve(L((t) => {
1179
+ if (typeof window.matchMedia != "function") return () => {};
1180
+ let n = window.matchMedia(e);
1181
+ return n.addEventListener("change", t), () => n.removeEventListener("change", t);
1182
+ }, [e]), L(() => typeof window.matchMedia == "function" && window.matchMedia(e).matches, [e]), () => !1);
1183
+ }
1184
+ // src/search/components/Panel.tsx
1185
+ var Pt = 8, Ft = 8;
1186
+ function It(e, t, n, r) {
1187
+ let i = t.getBoundingClientRect(), a = e.offsetWidth, o = document.documentElement.clientWidth, s = n === "end" ? i.right - a : i.left, c = Math.max(Ft, Math.min(s, o - a - Ft)), l = i.bottom + Pt, u = i.top - Pt - e.offsetHeight, d = r && l + e.offsetHeight > window.innerHeight && u >= 0;
1188
+ e.dataset.placement = d ? "top" : "bottom", e.style.top = `${d ? u : l}px`, e.style.left = `${c}px`;
1189
+ }
1190
+ function Lt({ kind: e, label: t, onClose: n, anchor: r, align: i = "start", flip: a = !1, semantics: o = "dialog", children: s }) {
1191
+ let c = e !== "popover", l = Ye(), u = ke(n), d = V(null), f = V(!1), p = V(null);
1192
+ je(!0, L(() => {
1193
+ let e = document.activeElement;
1194
+ return !f.current || e === null || e === document.body || !!p.current?.contains(e);
1195
+ }, [])), Ce(c), z(() => {
1196
+ if (c) return;
1197
+ let e = (e) => {
1198
+ e.target instanceof Node && !r?.contains(e.target) && !d.current?.contains(e.target) && n();
1199
+ };
1200
+ return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
1201
+ }, [
1202
+ c,
1203
+ r,
1204
+ n
1205
+ ]), z(() => {
1206
+ if (c) return;
1207
+ let e = {
1208
+ x: window.scrollX,
1209
+ y: window.scrollY
1210
+ }, t = (t) => {
1211
+ let i = d.current, a = t.target;
1212
+ a instanceof Node && i?.contains(a) || a instanceof Element && r && !a.contains(r) || (a instanceof Element || window.scrollX !== e.x || window.scrollY !== e.y) && (f.current = !0, n());
1213
+ };
1214
+ return window.addEventListener("scroll", t, !0), () => window.removeEventListener("scroll", t, !0);
1215
+ }, [
1216
+ c,
1217
+ r,
1218
+ n
1219
+ ]), re(() => {
1220
+ let e = d.current;
1221
+ if (c || !e || !r) return;
1222
+ let t = 0, n = () => {
1223
+ t = 0, It(e, r, i, a);
1224
+ }, o = () => {
1225
+ t ||= requestAnimationFrame(n);
1226
+ };
1227
+ return It(e, r, i, a), window.addEventListener("resize", o), () => {
1228
+ cancelAnimationFrame(t), window.removeEventListener("resize", o);
1229
+ };
1230
+ }, [
1231
+ c,
1232
+ r,
1233
+ i,
1234
+ a
1235
+ ]);
1236
+ let m = L((e) => {
1237
+ d.current = e, e && (p.current = e), u(e);
1238
+ }, [u]), h = /* @__PURE__ */ W("div", {
1239
+ ref: m,
1240
+ ...o === "dialog" ? {
1241
+ role: "dialog",
1242
+ "aria-modal": c ? "true" : void 0,
1243
+ "aria-label": t
1244
+ } : { role: "none" },
1245
+ tabIndex: -1,
1246
+ className: `ecomid-search-overlay ecomid-search-overlay--${e}`,
1247
+ children: s
1248
+ });
1249
+ return K(c ? /* @__PURE__ */ W(be, {
1250
+ className: "ecomid-search-overlay-layer",
1251
+ onDismiss: n,
1252
+ children: h
1253
+ }) : h, l);
1254
+ }
1255
+ // src/search/components/SheetFrame.tsx
1256
+ function Rt({ title: e, allLabel: t, closeLabel: n, onAll: r, onClose: i, children: a }) {
1257
+ return /* @__PURE__ */ G(U, { children: [
1258
+ /* @__PURE__ */ W("div", {
1259
+ className: "ecomid-search-sheet__grabber",
1260
+ "aria-hidden": "true"
1261
+ }),
1262
+ /* @__PURE__ */ G("div", {
1263
+ className: "ecomid-search-sheet__header",
1264
+ children: [
1265
+ r && /* @__PURE__ */ W("button", {
1266
+ type: "button",
1267
+ className: "ecomid-search-sheet__action ecomid-search-sheet__action--start",
1268
+ title: t,
1269
+ "aria-label": t,
1270
+ onClick: r,
1271
+ children: /* @__PURE__ */ W(vt, {})
1272
+ }),
1273
+ /* @__PURE__ */ W("h2", {
1274
+ className: "ecomid-search-sheet__title",
1275
+ children: e
1276
+ }),
1277
+ /* @__PURE__ */ W("button", {
1278
+ type: "button",
1279
+ className: "ecomid-search-sheet__action ecomid-search-sheet__action--end",
1280
+ title: n,
1281
+ "aria-label": n,
1282
+ onClick: i,
1283
+ children: /* @__PURE__ */ W(pt, {})
1284
+ })
1285
+ ]
1286
+ }),
1287
+ /* @__PURE__ */ W("div", {
1288
+ className: "ecomid-search-sheet__body",
1289
+ children: a
1290
+ })
1291
+ ] });
1292
+ }
1293
+ // src/search/components/ProductCard/Menu.tsx
1294
+ var zt = I(null), Bt = (e) => {
1295
+ e.stopPropagation(), e.preventDefault();
1296
+ }, Vt = "[role=\"menuitem\"]";
1297
+ function Ht(e) {
1298
+ let t = R(zt);
1299
+ return t ? /* @__PURE__ */ W(Ut, {
1300
+ ...e,
1301
+ onMoreLikeThis: t
1302
+ }) : null;
1303
+ }
1304
+ function Ut({ product: e, lang: t, onMoreLikeThis: n }) {
1305
+ let { t: r, isLoading: i } = Q(t), a = Nt("(min-width: 768px)"), [o, s] = H(!1), c = V(null), l = L(() => s(!1), []);
1306
+ if (i) return null;
1307
+ let u = r("card_menu.open", { name: e.name }), d = (e) => {
1308
+ Bt(e), e.currentTarget.focus({ preventScroll: !0 }), s((e) => !e);
1309
+ }, f = (e) => {
1310
+ Bt(e), l();
1311
+ }, p = /* @__PURE__ */ W("div", {
1312
+ role: "menu",
1313
+ "aria-label": e.name,
1314
+ className: "ecomid-search-card-menu__list",
1315
+ onKeyDown: (e) => {
1316
+ if (![
1317
+ "ArrowDown",
1318
+ "ArrowUp",
1319
+ "Home",
1320
+ "End"
1321
+ ].includes(e.key)) return;
1322
+ let t = Array.from(e.currentTarget.querySelectorAll(Vt));
1323
+ if (t.length === 0) return;
1324
+ e.preventDefault();
1325
+ let n = t.indexOf(document.activeElement);
1326
+ t[e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : e.key === "ArrowDown" ? (n + 1) % t.length : (n - 1 + t.length) % t.length]?.focus();
1327
+ },
1328
+ onClick: Bt,
1329
+ children: /* @__PURE__ */ G("button", {
1330
+ type: "button",
1331
+ role: "menuitem",
1332
+ className: "ecomid-search-card-menu__item",
1333
+ onClick: () => {
1334
+ s(!1), n(r("card_menu.similar_to", { name: e.name }));
1335
+ },
1336
+ children: [/* @__PURE__ */ W(At, {
1337
+ "aria-hidden": "true",
1338
+ focusable: "false"
1339
+ }), /* @__PURE__ */ W("span", { children: r("card_menu.more_like_this") })]
1340
+ })
1341
+ });
1342
+ return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("button", {
1343
+ ref: c,
1344
+ type: "button",
1345
+ className: "ecomid-search-card-menu__button",
1346
+ title: u,
1347
+ "aria-label": u,
1348
+ "aria-haspopup": a ? "menu" : "dialog",
1349
+ "aria-expanded": o,
1350
+ onClick: d,
1351
+ children: /* @__PURE__ */ W(At, {
1352
+ "aria-hidden": "true",
1353
+ focusable: "false"
1354
+ })
1355
+ }), o && /* @__PURE__ */ W(Lt, {
1356
+ kind: a ? "popover" : "sheet",
1357
+ label: e.name,
1358
+ semantics: a ? "none" : "dialog",
1359
+ onClose: l,
1360
+ anchor: c.current,
1361
+ align: "end",
1362
+ flip: !0,
1363
+ children: a ? p : /* @__PURE__ */ W(Rt, {
1364
+ title: e.name,
1365
+ closeLabel: r("actions.close"),
1366
+ onClose: f,
1367
+ children: p
1368
+ })
1369
+ })] });
1370
+ }
1371
+ // src/search/components/RollingPlaceholder/index.tsx
1372
+ var Wt = 2200, Gt = 4e3;
1373
+ function Kt({ texts: e }) {
1374
+ let [t, n] = H(0), r = e.length;
1375
+ z(() => {
1376
+ if (n(0), r < 2) return;
1377
+ let e = Date.now() + Gt, t = setInterval(() => {
1378
+ Date.now() < e || n((e) => e + 1);
1379
+ }, Wt);
1380
+ return () => clearInterval(t);
1381
+ }, [r]);
1382
+ let i = e[t % e.length], a = t > 0 ? e[(t - 1) % e.length] : void 0;
1383
+ return /* @__PURE__ */ G("span", {
1384
+ className: "ecomid-search-roll",
1385
+ "aria-hidden": "true",
1386
+ children: [a !== void 0 && /* @__PURE__ */ W("span", {
1387
+ className: "ecomid-search-roll__line ecomid-search-roll__line--out",
1388
+ children: a
1389
+ }, `out-${t}`), /* @__PURE__ */ W("span", {
1390
+ className: "ecomid-search-roll__line",
1391
+ "data-rolling": t > 0 || void 0,
1392
+ children: i
1393
+ }, `in-${t}`)]
1394
+ });
1395
+ }
1396
+ // src/search/core/reveal.ts
1397
+ var qt = 6, Jt = 60, Yt = 300, Xt = 10, Zt = 140, Qt = 70, $t = 30, en = 6, tn = 60, nn = 40, rn = 440;
1398
+ function an(e) {
1399
+ let t = e.trim();
1400
+ return t ? t.split(/\s+/).length : 0;
1401
+ }
1402
+ function on(e, t) {
1403
+ let n = Jt + (an(e) + Xt) * qt + Yt, r = n + 150, i = t ? r + 250 : n + 200;
1404
+ return {
1405
+ question: r,
1406
+ chips: t ? r + 120 : n + 100,
1407
+ picks: i,
1408
+ browse: i + 200
1409
+ };
1410
+ }
1411
+ function sn(e, t, n = 0, r = 0) {
1412
+ return r + Zt + e * Qt + Math.min(Math.max(t - n, 0), en) * $t;
1413
+ }
1414
+ function cn(e, t = 0) {
1415
+ return tn + Math.min(Math.max(e - t, 0) * nn, rn);
1416
+ }
1417
+ function ln(e, t = !1) {
1418
+ return (t ? Jt : 0) + e * qt;
1419
+ }
1420
+ function un(e, t) {
1421
+ return Math.max(e - t, 0);
1422
+ }
1423
+ // src/helpers/productUrl.ts
1424
+ var dn = (e, t) => {
1425
+ let n = e.indexOf("#"), r = n === -1 ? e : e.slice(0, n), i = n === -1 ? "" : e.slice(n), a = r.includes("?") ? r : r.replace(/%3F(?=variant=)/i, "?");
1426
+ return new URL(`${a}${i}`.replace(/^\/+/, ""), t);
1427
+ }, fn = "http://relative.invalid";
1428
+ function pn(e) {
1429
+ if (e) try {
1430
+ let t = dn(e, fn);
1431
+ return t.origin === fn ? `${t.pathname}${t.search}${t.hash}` : t.toString();
1432
+ } catch {
1433
+ return e;
1434
+ }
1435
+ }
1436
+ // src/search/components/ProductCard/index.tsx
1437
+ var mn = /* @__PURE__ */ new Set(["cdn.ecomid.com", "images.ecomid.com"]), hn = "ec_white_background";
1438
+ function gn(e) {
1439
+ try {
1440
+ return mn.has(new URL(e).hostname);
1441
+ } catch {
1442
+ return !1;
1443
+ }
1444
+ }
1445
+ function _n({ price: e, baselinePrice: t }) {
1446
+ return e === void 0 || t === void 0 || t <= e ? 0 : Math.round((1 - e / t) * 100);
1447
+ }
1448
+ function vn(e) {
1449
+ if (e) return gn(e) ? `${e}-0x600` : e;
1450
+ }
1451
+ function yn(e, t) {
1452
+ return t ? `${e}-${t}` : e;
1453
+ }
1454
+ function bn(e, t) {
1455
+ try {
1456
+ return new Intl.NumberFormat(t, {
1457
+ style: "percent",
1458
+ signDisplay: "always"
1459
+ }).format(-e / 100);
1460
+ } catch (e) {
1461
+ e instanceof Error && a(e);
1462
+ return;
1463
+ }
1464
+ }
1465
+ function xn({ product: e, lang: t, market: n, onClick: r, revealDelay: i }) {
1466
+ let [a, o] = H(!1), s = L((e) => {
1467
+ e?.complete && e.naturalWidth > 0 && o(!0);
1468
+ }, []), c = _n(e), l = c > 0 ? bn(c, yn(t, n)) : void 0, u = e.imageTags?.includes(hn), { t: d } = Q(t), f = e.variantCount !== void 0 && e.variantCount > 1 ? e.variantCount - 1 : 0, p = f ? d(f === 1 ? "more_colors.singular" : "more_colors.plural", { count: String(f) }) : "", m = Nt("(hover: hover)"), h = vn(e.imageUrl), g = m ? vn(e.hoverImageUrl) : void 0, _ = e.hoverImageTags?.includes(hn), v = /* @__PURE__ */ G(U, { children: [
1469
+ /* @__PURE__ */ G("span", {
1470
+ className: "ecomid-search-product__image",
1471
+ "data-white-bg": u || void 0,
1472
+ children: [
1473
+ h && /* @__PURE__ */ W("img", {
1474
+ ref: s,
1475
+ className: "ecomid-search-product__img",
1476
+ "data-white-bg": u || void 0,
1477
+ "data-loaded": a || void 0,
1478
+ src: h,
1479
+ alt: "",
1480
+ loading: "lazy",
1481
+ draggable: !1,
1482
+ onLoad: () => o(!0)
1483
+ }),
1484
+ g && /* @__PURE__ */ W("span", {
1485
+ className: "ecomid-search-product__hover",
1486
+ "data-white-bg": _ || void 0,
1487
+ children: /* @__PURE__ */ W("img", {
1488
+ className: "ecomid-search-product__hover-img",
1489
+ "data-white-bg": _ || void 0,
1490
+ src: g,
1491
+ alt: "",
1492
+ "aria-hidden": "true",
1493
+ loading: "lazy",
1494
+ draggable: !1
1495
+ })
1496
+ }),
1497
+ l && /* @__PURE__ */ W("span", {
1498
+ className: "ecomid-search-product__badge",
1499
+ "aria-hidden": "true",
1500
+ children: l
1501
+ })
1502
+ ]
1503
+ }),
1504
+ /* @__PURE__ */ W("span", {
1505
+ className: "ecomid-search-product__name",
1506
+ children: e.name
1507
+ }),
1508
+ /* @__PURE__ */ W(Sn, {
1509
+ product: e,
1510
+ lang: t,
1511
+ market: n
1512
+ }),
1513
+ p && /* @__PURE__ */ W("span", {
1514
+ className: "ecomid-search-product__colors",
1515
+ children: p
1516
+ }),
1517
+ e.reason && /* @__PURE__ */ W("span", {
1518
+ className: "ecomid-search-product__reason",
1519
+ children: e.reason
1520
+ })
1521
+ ] }), y = pn(e.url), b = i === void 0 ? "ecomid-search-product" : "ecomid-search-product ecomid-search-tile-enter", x = i === void 0 ? void 0 : { animationDelay: `${i}ms` };
1522
+ return /* @__PURE__ */ G("div", {
1523
+ className: b,
1524
+ style: x,
1525
+ children: [y ? /* @__PURE__ */ W("a", {
1526
+ className: "ecomid-search-product__link",
1527
+ href: y,
1528
+ onClick: r,
1529
+ children: v
1530
+ }) : /* @__PURE__ */ W("div", {
1531
+ className: "ecomid-search-product__link",
1532
+ children: v
1533
+ }), /* @__PURE__ */ W("div", {
1534
+ className: "ecomid-search-product__actions",
1535
+ children: /* @__PURE__ */ W(Ht, {
1536
+ product: e,
1537
+ lang: t
1538
+ })
1539
+ })]
1540
+ });
1541
+ }
1542
+ function Sn({ product: e, lang: t, market: n }) {
1543
+ if (e.price === void 0 || !e.currency) return null;
1544
+ try {
1545
+ let r = new Intl.NumberFormat(yn(t, n), {
1546
+ style: "currency",
1547
+ currency: e.currency,
1548
+ currencyDisplay: "narrowSymbol",
1549
+ minimumFractionDigits: 0,
1550
+ maximumFractionDigits: 2
1551
+ });
1552
+ return e.baselinePrice !== void 0 && e.price < e.baselinePrice ? /* @__PURE__ */ W(Cn, {
1553
+ lang: t,
1554
+ price: r.format(e.price),
1555
+ baselinePrice: r.format(e.baselinePrice)
1556
+ }) : /* @__PURE__ */ W("span", {
1557
+ className: "ecomid-search-product__price",
1558
+ children: r.format(e.price)
1559
+ });
1560
+ } catch (e) {
1561
+ return e instanceof Error && a(e), null;
1562
+ }
1563
+ }
1564
+ function Cn({ lang: e, price: t, baselinePrice: n }) {
1565
+ let { t: r, isLoading: i } = Q(e), a = !i || void 0;
1566
+ return /* @__PURE__ */ G("span", {
1567
+ className: "ecomid-search-product__price",
1568
+ "data-on-sale": "true",
1569
+ children: [
1570
+ !i && /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("span", {
1571
+ className: "ecomid-search-sr-only",
1572
+ children: r("price.sale", { price: t })
1573
+ }), /* @__PURE__ */ W("span", {
1574
+ className: "ecomid-search-sr-only",
1575
+ children: r("price.original", { price: n })
1576
+ })] }),
1577
+ /* @__PURE__ */ W("span", {
1578
+ className: "ecomid-search-product__price-current",
1579
+ "aria-hidden": a,
1580
+ children: t
1581
+ }),
1582
+ /* @__PURE__ */ W("span", {
1583
+ className: "ecomid-search-product__price-baseline",
1584
+ "aria-hidden": a,
1585
+ children: n
1586
+ })
1587
+ ]
1588
+ });
1589
+ }
1590
+ // src/search/components/ProductGrid/index.tsx
1591
+ var wn = class extends F {
1592
+ state = { hasError: !1 };
1593
+ static getDerivedStateFromError() {
1594
+ return { hasError: !0 };
1595
+ }
1596
+ componentDidCatch(e, t) {
1597
+ this.props.onError?.(e, t);
1598
+ }
1599
+ render() {
1600
+ return this.state.hasError ? this.props.fallback : this.props.children;
1601
+ }
1602
+ };
1603
+ function Tn(e, t, n) {
1604
+ if (typeof window < "u") return e(t, n);
1605
+ try {
1606
+ return e(t, n);
1607
+ } catch {
1608
+ return null;
1609
+ }
1610
+ }
1611
+ function En({ product: e, position: t, onProductClick: n, renderProduct: r, fallback: i, revealDelay: a, lang: o }) {
1612
+ let s = Tn(r, e, {
1613
+ position: t,
1614
+ menuButton: /* @__PURE__ */ W(Ht, {
1615
+ product: e,
1616
+ lang: o
1617
+ })
1618
+ });
1619
+ return s == null ? i : /* @__PURE__ */ W("div", {
1620
+ className: a === void 0 ? "ecomid-search-grid__item" : "ecomid-search-grid__item ecomid-search-tile-enter",
1621
+ style: a === void 0 ? void 0 : { animationDelay: `${a}ms` },
1622
+ onClickCapture: (r) => {
1623
+ let i = r.target;
1624
+ if (!(i instanceof Element)) return;
1625
+ let a = i.closest("a[href]");
1626
+ i.closest(".ecomid-search-card-menu__button") || a && r.currentTarget.contains(a) && n(e, t)(r, (e) => {
1627
+ setTimeout(e, 0);
1628
+ });
1629
+ },
1630
+ children: s
1631
+ });
1632
+ }
1633
+ function Dn({ products: e, lang: t, market: n, variant: r = "panel", reveal: i, onProductClick: a, renderProduct: o, onRenderError: s }) {
1634
+ let c = V(/* @__PURE__ */ new Map());
1635
+ return /* @__PURE__ */ W("div", {
1636
+ className: r === "results" ? "ecomid-search-grid ecomid-search-grid--results" : r === "carousel" ? "ecomid-search-carousel__track" : r === "picks" ? "ecomid-search-grid ecomid-search-grid--picks" : r === "wide" ? "ecomid-search-grid ecomid-search-grid--wide" : "ecomid-search-grid",
1637
+ children: e.map((e, l) => {
1638
+ let u = `${e.id}:${l}`, d;
1639
+ i && (d = c.current.get(u) ?? (r === "results" ? cn(l, i.from) : sn(i.section, l, i.from, i.base)), c.current.set(u, d));
1640
+ let f = /* @__PURE__ */ W(xn, {
1641
+ product: e,
1642
+ lang: t,
1643
+ market: n,
1644
+ onClick: a(e, l),
1645
+ revealDelay: d
1646
+ }, u);
1647
+ return o ? /* @__PURE__ */ W(wn, {
1648
+ fallback: f,
1649
+ onError: s,
1650
+ children: /* @__PURE__ */ W(En, {
1651
+ lang: t,
1652
+ product: e,
1653
+ position: l,
1654
+ onProductClick: a,
1655
+ renderProduct: o,
1656
+ fallback: f,
1657
+ revealDelay: d
1658
+ })
1659
+ }, u) : f;
1660
+ })
1661
+ });
1662
+ }
1663
+ // src/search/components/ProductCarousel/pageTarget.ts
1664
+ var On = 1;
1665
+ function kn({ direction: e, cards: t, scrollLeft: n, clientWidth: r, scrollWidth: i, padding: a }) {
1666
+ let o = Math.max(0, i - r), s = (e) => Math.min(o, Math.max(0, e));
1667
+ if (e === 1) {
1668
+ let e = n + r - a + On, i = t.find(({ left: t, width: n }) => t + n > e);
1669
+ return s(i ? i.left - a : n + r);
1670
+ }
1671
+ let c = n + a - On, l = t.findLast(({ left: e }) => e < c);
1672
+ if (!l) return s(n - r);
1673
+ let u = l.left + l.width + a - r, d = t.find(({ left: e }) => e - a >= u - On);
1674
+ return s(d ? d.left - a : u);
1675
+ }
1676
+ // src/search/components/ProductCarousel/index.tsx
1677
+ var An = 1;
1678
+ function jn({ products: e, lang: t, market: n, previousLabel: r, nextLabel: i, onProductClick: a, renderProduct: o, reveal: s, onRenderError: c }) {
1679
+ let l = V(null), u = V(null), d = V(null), [f, p] = H(!1), [m, h] = H(!1), g = L(() => {
1680
+ let e = l.current;
1681
+ if (!e) return;
1682
+ let { scrollLeft: t, scrollWidth: n, clientWidth: r } = e, i = t > An, a = t + r < n - An, o = document.activeElement;
1683
+ o === u.current && !i ? (a ? d.current : e)?.focus({ preventScroll: !0 }) : o === d.current && !a && (i ? u.current : e)?.focus({ preventScroll: !0 }), p(i), h(a);
1684
+ }, []);
1685
+ z(() => {
1686
+ g();
1687
+ let e = l.current;
1688
+ if (!e || typeof ResizeObserver > "u") return;
1689
+ let t = new ResizeObserver(g);
1690
+ return t.observe(e), e.firstElementChild && t.observe(e.firstElementChild), () => t.disconnect();
1691
+ }, [g]);
1692
+ let _ = (e) => {
1693
+ let t = l.current;
1694
+ if (!t) return;
1695
+ let n = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, r = Number.parseFloat(getComputedStyle(t).scrollPaddingLeft) || 0, i = t.getBoundingClientRect().left, a = Array.from(t.querySelectorAll(".ecomid-search-carousel__track > *")).map((e) => {
1696
+ let n = e.getBoundingClientRect();
1697
+ return {
1698
+ left: n.left - i + t.scrollLeft,
1699
+ width: n.width
1700
+ };
1701
+ });
1702
+ t.scrollTo({
1703
+ left: kn({
1704
+ direction: e,
1705
+ cards: a,
1706
+ scrollLeft: t.scrollLeft,
1707
+ clientWidth: t.clientWidth,
1708
+ scrollWidth: t.scrollWidth,
1709
+ padding: r
1710
+ }),
1711
+ behavior: n ? "auto" : "smooth"
1712
+ });
1713
+ };
1714
+ return /* @__PURE__ */ G("div", {
1715
+ className: "ecomid-search-carousel",
1716
+ children: [/* @__PURE__ */ W("div", {
1717
+ ref: l,
1718
+ className: "ecomid-search-carousel__scroller",
1719
+ tabIndex: -1,
1720
+ onScroll: g,
1721
+ children: /* @__PURE__ */ W(Dn, {
1722
+ variant: "carousel",
1723
+ reveal: s,
1724
+ products: e,
1725
+ lang: t,
1726
+ market: n,
1727
+ onProductClick: a,
1728
+ renderProduct: o,
1729
+ onRenderError: c
1730
+ })
1731
+ }), (f || m) && /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("button", {
1732
+ ref: u,
1733
+ type: "button",
1734
+ className: "ecomid-search-carousel__button ecomid-search-carousel__button--previous",
1735
+ title: r,
1736
+ "aria-label": r,
1737
+ disabled: !f,
1738
+ onClick: () => _(-1),
1739
+ children: /* @__PURE__ */ W(_t, {})
1740
+ }), /* @__PURE__ */ W("button", {
1741
+ ref: d,
1742
+ type: "button",
1743
+ className: "ecomid-search-carousel__button ecomid-search-carousel__button--next",
1744
+ title: i,
1745
+ "aria-label": i,
1746
+ disabled: !m,
1747
+ onClick: () => _(1),
1748
+ children: /* @__PURE__ */ W(gt, {})
1749
+ })] })]
1750
+ });
1751
+ }
1752
+ // src/search/components/Skeletons/index.tsx
1753
+ var Mn = [
1754
+ "88px",
1755
+ "112px",
1756
+ "96px",
1757
+ "128px",
1758
+ "72px"
1759
+ ];
1760
+ function Nn() {
1761
+ return /* @__PURE__ */ W("div", {
1762
+ className: "ecomid-search-starters",
1763
+ "aria-hidden": "true",
1764
+ "data-loading": "true",
1765
+ children: Mn.map((e) => /* @__PURE__ */ W("span", {
1766
+ className: "ecomid-search-skeleton ecomid-search-skeleton--pill",
1767
+ style: { width: e }
1768
+ }, e))
1769
+ });
1770
+ }
1771
+ function Pn({ variant: e, count: t = 4 }) {
1772
+ return /* @__PURE__ */ W("div", {
1773
+ className: e ? `ecomid-search-grid ecomid-search-grid--${e}` : "ecomid-search-grid",
1774
+ "aria-hidden": "true",
1775
+ "data-loading": "true",
1776
+ children: Array.from({ length: t }, (e, t) => `card-${t}`).map((e) => /* @__PURE__ */ G("div", {
1777
+ className: "ecomid-search-product",
1778
+ children: [/* @__PURE__ */ W("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--image" }), /* @__PURE__ */ W("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--text" })]
1779
+ }, e))
1780
+ });
1781
+ }
1782
+ var Fn = [
1783
+ "a",
1784
+ "b",
1785
+ "c",
1786
+ "d",
1787
+ "e",
1788
+ "f"
1789
+ ];
1790
+ function In() {
1791
+ return /* @__PURE__ */ W("div", {
1792
+ className: "ecomid-search-carousel",
1793
+ "aria-hidden": "true",
1794
+ "data-loading": "true",
1795
+ children: /* @__PURE__ */ W("div", {
1796
+ className: "ecomid-search-carousel__scroller",
1797
+ children: /* @__PURE__ */ W("div", {
1798
+ className: "ecomid-search-carousel__track",
1799
+ children: Fn.map((e) => /* @__PURE__ */ G("div", {
1800
+ className: "ecomid-search-product",
1801
+ children: [
1802
+ /* @__PURE__ */ W("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--image" }),
1803
+ /* @__PURE__ */ W("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--text" }),
1804
+ /* @__PURE__ */ W("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--text ecomid-search-skeleton--short" })
1805
+ ]
1806
+ }, e))
1807
+ })
1808
+ })
1809
+ });
1810
+ }
1811
+ function Ln({ widths: e, className: t }) {
1812
+ return /* @__PURE__ */ W("div", {
1813
+ className: t ? `ecomid-search-skeleton-lines ${t}` : "ecomid-search-skeleton-lines",
1814
+ "aria-hidden": "true",
1815
+ "data-loading": "true",
1816
+ children: e.map((e, t) => /* @__PURE__ */ W("span", {
1817
+ className: "ecomid-search-skeleton-line",
1818
+ children: /* @__PURE__ */ W("span", {
1819
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar",
1820
+ style: {
1821
+ width: e,
1822
+ animationDelay: `${t * .15}s`
1823
+ }
1824
+ })
1825
+ }, e))
1826
+ });
1827
+ }
1828
+ var Rn = [
1829
+ "40px",
1830
+ "112px",
1831
+ "96px",
1832
+ "120px",
1833
+ "84px"
1834
+ ];
1835
+ function zn() {
1836
+ return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("div", {
1837
+ className: "ecomid-search-toolbar__pills",
1838
+ "aria-hidden": "true",
1839
+ "data-loading": "true",
1840
+ children: Rn.map((e, t) => /* @__PURE__ */ W("span", {
1841
+ className: "ecomid-search-skeleton ecomid-search-skeleton--pill",
1842
+ style: {
1843
+ width: e,
1844
+ animationDelay: `${t * .08}s`
1845
+ }
1846
+ }, e))
1847
+ }), /* @__PURE__ */ G("div", {
1848
+ className: "ecomid-search-toolbar__meta",
1849
+ "aria-hidden": "true",
1850
+ "data-loading": "true",
1851
+ children: [/* @__PURE__ */ W("span", {
1852
+ className: "ecomid-search-skeleton-line",
1853
+ children: /* @__PURE__ */ W("span", {
1854
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar",
1855
+ style: { width: "72px" }
1856
+ })
1857
+ }), /* @__PURE__ */ W("span", {
1858
+ className: "ecomid-search-skeleton-line",
1859
+ children: /* @__PURE__ */ W("span", {
1860
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar",
1861
+ style: { width: "56px" }
1862
+ })
1863
+ })]
1864
+ })] });
1865
+ }
1866
+ function Bn({ count: e = 4 }) {
1867
+ return /* @__PURE__ */ G("section", {
1868
+ className: "ecomid-search-section ecomid-search-compose__section ecomid-search-compose__section--picks",
1869
+ "aria-hidden": "true",
1870
+ "data-loading": "true",
1871
+ children: [/* @__PURE__ */ G("div", {
1872
+ className: "ecomid-search-compose__section-header",
1873
+ children: [/* @__PURE__ */ W("span", {
1874
+ className: "ecomid-search-compose__section-title ecomid-search-skeleton-line",
1875
+ children: /* @__PURE__ */ W("span", {
1876
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar ecomid-search-skeleton--title",
1877
+ style: { width: "180px" }
1878
+ })
1879
+ }), /* @__PURE__ */ W("span", {
1880
+ className: "ecomid-search-compose__count ecomid-search-skeleton-line",
1881
+ children: /* @__PURE__ */ W("span", {
1882
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar",
1883
+ style: { width: "72px" }
1884
+ })
1885
+ })]
1886
+ }), /* @__PURE__ */ W(Pn, {
1887
+ variant: "picks",
1888
+ count: e
1889
+ })]
1890
+ });
1891
+ }
1892
+ // src/helpers/dragScroll.ts
1893
+ var Vn = 5;
1894
+ function Hn(e, t = "grab") {
1895
+ let n = {
1896
+ isPointerDown: !1,
1897
+ isDragging: !1,
1898
+ startX: 0,
1899
+ startScrollLeft: 0,
1900
+ suppressNextClick: !1
1901
+ }, r = () => {
1902
+ e.style.cursor = t, e.style.userSelect = "";
1903
+ }, i = (t) => {
1904
+ t.pointerType === "mouse" && (n.isPointerDown = !0, n.isDragging = !1, n.startX = t.clientX, n.startScrollLeft = e.scrollLeft);
1905
+ }, a = (t) => {
1906
+ if (!n.isPointerDown) return;
1907
+ let r = t.clientX - n.startX;
1908
+ if (!n.isDragging) {
1909
+ if (Math.abs(r) <= Vn) return;
1910
+ n.isDragging = !0, e.style.cursor = "grabbing", e.style.userSelect = "none";
1911
+ }
1912
+ e.scrollLeft = n.startScrollLeft - r;
1913
+ }, o = (e) => {
1914
+ n.isPointerDown && (n.isPointerDown = !1, n.isDragging && (n.isDragging = !1, e && (n.suppressNextClick = !0), r()));
1915
+ }, s = () => o(!0), c = () => o(!1), l = (e) => {
1916
+ n.suppressNextClick && (n.suppressNextClick = !1, e.stopPropagation(), e.preventDefault());
1917
+ };
1918
+ return e.style.cursor = t, e.addEventListener("pointerdown", i), window.addEventListener("pointermove", a), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", c), e.addEventListener("click", l, { capture: !0 }), () => {
1919
+ e.style.cursor = "", e.style.userSelect = "", e.removeEventListener("pointerdown", i), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", s), window.removeEventListener("pointercancel", c), e.removeEventListener("click", l, { capture: !0 });
1920
+ };
1921
+ }
1922
+ // src/search/components/hooks/useDragScroll.ts
1923
+ function Un(e, t = !0) {
1924
+ z(() => {
1925
+ let n = e.current;
1926
+ if (t && n) return Hn(n, "");
1927
+ }, [e, t]);
1928
+ }
1929
+ // src/helpers/cssProperties.ts
1930
+ var Wn = /* @__PURE__ */ new Set(), Gn = (e) => {
1931
+ if (typeof CSS > "u" || typeof CSS.registerProperty != "function") return !1;
1932
+ for (let t of e) if (!Wn.has(t.name)) {
1933
+ try {
1934
+ CSS.registerProperty(t);
1935
+ } catch {}
1936
+ Wn.add(t.name);
1937
+ }
1938
+ return !0;
1939
+ }, Kn = "--ecomid-fade-start", qn = "--ecomid-fade-end", Jn = [{
1940
+ name: Kn,
1941
+ syntax: "<color>",
1942
+ inherits: !1,
1943
+ initialValue: "black"
1944
+ }, {
1945
+ name: qn,
1946
+ syntax: "<color>",
1947
+ inherits: !1,
1948
+ initialValue: "black"
1949
+ }];
1950
+ function Yn(e, t) {
1951
+ Gn(Jn);
1952
+ let n = 0, r = (t, n) => {
1953
+ n ? e.style.removeProperty(t) : e.style.setProperty(t, "transparent");
1954
+ }, i = () => {
1955
+ cancelAnimationFrame(n), n = requestAnimationFrame(() => {
1956
+ let n = t === "horizontal", i = n ? e.scrollLeft : e.scrollTop, a = n ? e.scrollWidth - e.clientWidth : e.scrollHeight - e.clientHeight;
1957
+ r(Kn, i <= 1), r(qn, i >= a - 1);
1958
+ });
1959
+ };
1960
+ i(), e.addEventListener("scroll", i, { passive: !0 });
1961
+ let a = typeof ResizeObserver > "u" ? null : new ResizeObserver(i);
1962
+ return a?.observe(e), () => {
1963
+ cancelAnimationFrame(n), e.removeEventListener("scroll", i), a?.disconnect(), e.style.removeProperty(Kn), e.style.removeProperty(qn);
1964
+ };
1965
+ }
1966
+ // src/search/components/hooks/useScrollFade.ts
1967
+ function Xn(e, t = "horizontal", n = !0) {
1968
+ z(() => {
1969
+ let r = e.current;
1970
+ if (n && r) return Yn(r, t);
1971
+ }, [
1972
+ e,
1973
+ t,
1974
+ n
1975
+ ]);
1976
+ }
1977
+ // src/search/components/hooks/useVisibleCount.ts
1978
+ var Zn = "[data-more]";
1979
+ function Qn(e) {
1980
+ let t = Array.from(e.children).filter((e) => e instanceof HTMLElement && !e.matches(Zn)), n = e.querySelector(Zn);
1981
+ for (let e of t) e.hidden = !1;
1982
+ n && (n.hidden = !0);
1983
+ let r = e.clientWidth;
1984
+ if (e.scrollWidth <= r || t.length < (n ? 2 : 1)) return 0;
1985
+ let i = 0;
1986
+ n && (n.hidden = !1, i = n.offsetWidth, n.hidden = !0);
1987
+ let a = Number.parseFloat(getComputedStyle(e).columnGap) || 0, o = t.map((e) => e.offsetWidth), s = 0, c = 0;
1988
+ for (let e = 0; e < t.length; e++) {
1989
+ let l = c === 0 ? o[0] : s + a + o[e];
1990
+ if (l + (n && e < t.length - 1 ? a + i : 0) > r && (!n || c > 0)) break;
1991
+ s = l, c++;
1992
+ }
1993
+ return t.length - c;
1994
+ }
1995
+ function $n(e, t) {
1996
+ let n = Array.from(e.children).filter((e) => e instanceof HTMLElement && !e.matches(Zn));
1997
+ n.forEach((e, r) => {
1998
+ e.hidden = r >= n.length - t;
1999
+ });
2000
+ let r = e.querySelector(Zn);
2001
+ r && (r.hidden = t === 0);
2002
+ }
2003
+ function er(e, t) {
2004
+ let [n, r] = H(0), i = V(() => {});
2005
+ return i.current = () => {
2006
+ let i = e.current;
2007
+ if (!i) return;
2008
+ let a = t ? Qn(i) : 0;
2009
+ $n(i, a), a !== n && r(a);
2010
+ }, re(() => {
2011
+ i.current();
2012
+ }), re(() => {
2013
+ let n = e.current;
2014
+ if (!t || !n || typeof ResizeObserver > "u") return;
2015
+ let r = new ResizeObserver(() => i.current());
2016
+ return r.observe(n.parentElement ?? n), () => r.disconnect();
2017
+ }, [e, t]), n;
2018
+ }
2019
+ // src/search/components/SearchPanel/StarterPills/index.tsx
2020
+ function tr({ starters: e, onSelect: t, fit: n = !1 }) {
2021
+ let r = V(null), i = Nt("(min-width: 768px)"), a = n && i;
2022
+ return er(r, a), Un(r, !a), Xn(r, "horizontal", !a), /* @__PURE__ */ W("div", {
2023
+ ref: r,
2024
+ className: "ecomid-search-starters",
2025
+ children: e.map((e) => /* @__PURE__ */ W("button", {
2026
+ type: "button",
2027
+ className: "ecomid-search-starters__pill",
2028
+ onClick: () => t(e.text),
2029
+ children: e.text
2030
+ }, e.text))
2031
+ });
2032
+ }
2033
+ // src/search/components/SearchPanel/EmptyState/index.tsx
2034
+ function nr({ status: e, starters: t, products: n, lang: r, market: i, recommendedLabel: a, countLabel: o, fitStarters: s, previousLabel: c, nextLabel: l, onPillSelect: u, onProductClick: d, renderProduct: f, onRenderError: p }) {
2035
+ return e === "error" ? null : e === "loading" || e === "idle" ? /* @__PURE__ */ G("div", {
2036
+ className: "ecomid-search-panel__empty",
2037
+ children: [/* @__PURE__ */ W(Nn, {}), /* @__PURE__ */ G("section", {
2038
+ className: "ecomid-search-section",
2039
+ "aria-hidden": "true",
2040
+ children: [/* @__PURE__ */ W("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--heading ecomid-search-section__heading" }), /* @__PURE__ */ W(In, {})]
2041
+ })]
2042
+ }) : /* @__PURE__ */ G("div", {
2043
+ className: "ecomid-search-panel__empty",
2044
+ children: [t.length > 0 && /* @__PURE__ */ W(tr, {
2045
+ starters: t,
2046
+ onSelect: u,
2047
+ fit: s
2048
+ }), n.length > 0 && /* @__PURE__ */ G("section", {
2049
+ className: "ecomid-search-section",
2050
+ children: [o ? /* @__PURE__ */ G("div", {
2051
+ className: "ecomid-search-section__header",
2052
+ children: [/* @__PURE__ */ W("h3", {
2053
+ className: "ecomid-search-section__heading",
2054
+ children: a
2055
+ }), /* @__PURE__ */ W("span", {
2056
+ className: "ecomid-search-section__count",
2057
+ children: o
2058
+ })]
2059
+ }) : /* @__PURE__ */ W("h3", {
2060
+ className: "ecomid-search-section__heading",
2061
+ children: a
2062
+ }), /* @__PURE__ */ W(jn, {
2063
+ products: n,
2064
+ lang: r,
2065
+ market: i,
2066
+ previousLabel: c,
2067
+ nextLabel: l,
2068
+ onProductClick: d,
2069
+ renderProduct: f,
2070
+ onRenderError: p
2071
+ })]
2072
+ })]
2073
+ });
2074
+ }
2075
+ // src/search/components/SearchPanel/Suggestions/index.tsx
2076
+ function rr({ suggestions: e, askLabel: t, query: n, activeIndex: r, listboxId: i, labelledBy: a, getOptionId: o, onSelect: s, leading: c }) {
2077
+ return /* @__PURE__ */ W("div", {
2078
+ id: i,
2079
+ role: "listbox",
2080
+ "aria-labelledby": a,
2081
+ className: "ecomid-search-listbox",
2082
+ children: e.map((e, i) => /* @__PURE__ */ G("button", {
2083
+ type: "button",
2084
+ id: o(i),
2085
+ role: "option",
2086
+ tabIndex: -1,
2087
+ "aria-selected": r === i,
2088
+ "data-active": r === i || void 0,
2089
+ className: "ecomid-search-option",
2090
+ onMouseDown: (e) => e.preventDefault(),
2091
+ onClick: () => s(e.text),
2092
+ children: [c, /* @__PURE__ */ W("span", {
2093
+ className: "ecomid-search-option__text",
2094
+ children: e.ask ? /* @__PURE__ */ W(ar, {
2095
+ template: t,
2096
+ text: e.text
2097
+ }) : /* @__PURE__ */ W(or, {
2098
+ text: e.text,
2099
+ query: n
2100
+ })
2101
+ })]
2102
+ }, e.text))
2103
+ });
2104
+ }
2105
+ var ir = "{query}";
2106
+ function ar({ template: e, text: t }) {
2107
+ let n = e.indexOf(ir);
2108
+ return n === -1 ? /* @__PURE__ */ W(U, { children: t }) : /* @__PURE__ */ G(U, { children: [
2109
+ e.slice(0, n),
2110
+ /* @__PURE__ */ W("span", {
2111
+ className: "ecomid-search-highlight",
2112
+ children: t
2113
+ }),
2114
+ e.slice(n + 7)
2115
+ ] });
2116
+ }
2117
+ function or({ text: e, query: t }) {
2118
+ if (!t) return /* @__PURE__ */ W(U, { children: e });
2119
+ let n = e.toLowerCase().indexOf(t.toLowerCase());
2120
+ return n === -1 ? /* @__PURE__ */ W(U, { children: e }) : /* @__PURE__ */ G(U, { children: [
2121
+ e.slice(0, n),
2122
+ /* @__PURE__ */ W("span", {
2123
+ className: "ecomid-search-highlight",
2124
+ children: e.slice(n, n + t.length)
2125
+ }),
2126
+ e.slice(n + t.length)
2127
+ ] });
2128
+ }
2129
+ // src/search/components/SearchPanel/TypingState/index.tsx
2130
+ function sr({ suggestions: e, starters: t, carousel: n, previousLabel: r, nextLabel: i, onPillSelect: a, products: o, query: s, activeIndex: c, showListbox: l, showNoResults: u, noResultsLabel: d, suggestionsLabel: f, askLabel: p, productsLabel: m, listboxId: h, suggestionsHeadingId: g, getOptionId: _, lang: v, market: y, onSuggestionSelect: b, onProductClick: x, renderProduct: S, onRenderError: C }) {
2131
+ return /* @__PURE__ */ G("div", {
2132
+ className: "ecomid-search-panel__typing",
2133
+ children: [
2134
+ t.length > 0 && /* @__PURE__ */ W(tr, {
2135
+ starters: t,
2136
+ onSelect: a
2137
+ }),
2138
+ l && /* @__PURE__ */ G("section", {
2139
+ className: "ecomid-search-section",
2140
+ children: [/* @__PURE__ */ W("h3", {
2141
+ id: g,
2142
+ className: "ecomid-search-section__heading",
2143
+ children: f
2144
+ }), /* @__PURE__ */ W(rr, {
2145
+ suggestions: e,
2146
+ askLabel: p,
2147
+ query: s,
2148
+ activeIndex: c,
2149
+ listboxId: h,
2150
+ labelledBy: g,
2151
+ getOptionId: _,
2152
+ onSelect: b
2153
+ })]
2154
+ }),
2155
+ u ? /* @__PURE__ */ W("p", {
2156
+ className: "ecomid-search-no-results",
2157
+ children: d
2158
+ }) : o.length > 0 && /* @__PURE__ */ G("section", {
2159
+ className: "ecomid-search-section",
2160
+ children: [/* @__PURE__ */ W("h3", {
2161
+ className: "ecomid-search-section__heading",
2162
+ children: m
2163
+ }), n ? /* @__PURE__ */ W(jn, {
2164
+ products: o,
2165
+ lang: v,
2166
+ market: y,
2167
+ previousLabel: r,
2168
+ nextLabel: i,
2169
+ onProductClick: x,
2170
+ renderProduct: S,
2171
+ onRenderError: C
2172
+ }) : /* @__PURE__ */ W(Dn, {
2173
+ products: o,
2174
+ lang: v,
2175
+ market: y,
2176
+ onProductClick: x,
2177
+ renderProduct: S,
2178
+ onRenderError: C
2179
+ })]
2180
+ })
2181
+ ]
2182
+ });
2183
+ }
2184
+ // src/search/components/SearchPanel/index.tsx
2185
+ var cr = (e) => e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey;
2186
+ function lr({ store: e, track: t, onDone: n, headerEnd: r, footer: i, onSubmit: a, onProductClick: o, renderProduct: s, onRenderError: c, lang: l, market: u, autoFocus: d = !0, showCount: f = !1, floatingSuggestions: p = !1 }) {
2187
+ let m = ne(), h = ve(e.subscribe, e.getState, e.getState), { t: g } = Q(l), v = V(null), y = V(null), [b, x] = H(-1), [S, C] = H(!1), w = Nt("(min-width: 768px)"), T = p && w;
2188
+ z(() => {
2189
+ e.loadEmptyState(), e.resumeSearch();
2190
+ }, [e]), z(() => {
2191
+ h.query || x(-1);
2192
+ }, [h.query]), z(() => {
2193
+ if (!T) return;
2194
+ let e = (e) => {
2195
+ e.target instanceof Node && !y.current?.contains(e.target) && C(!0);
2196
+ };
2197
+ return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
2198
+ }, [T]);
2199
+ let E = L(() => {
2200
+ let r = e.submit();
2201
+ r && (t(X.SEARCH_SUBMIT, { attrs: { query: r } }), a?.(r), n?.());
2202
+ }, [
2203
+ e,
2204
+ t,
2205
+ a,
2206
+ n
2207
+ ]), D = L((n) => {
2208
+ t(X.SUGGESTION_CLICK, { attrs: { text: n } }), e.setQuery(n), x(-1), E();
2209
+ }, [
2210
+ e,
2211
+ t,
2212
+ E
2213
+ ]), O = L((t) => {
2214
+ e.setQuery(t), x(-1), E();
2215
+ }, [e, E]), k = L((n) => {
2216
+ t(X.PRE_PROMPT_CLICK, { attrs: { text: n } }), e.setQuery(n), x(-1), E();
2217
+ }, [
2218
+ e,
2219
+ t,
2220
+ E
2221
+ ]), A = L((e, r) => (i, a) => {
2222
+ t(X.PRODUCT_CLICK, { attrs: {
2223
+ variant_id: e.id,
2224
+ name: e.name,
2225
+ url: e.url,
2226
+ position: String(r)
2227
+ } }), o?.(e, i), cr(i) && (a && n ? a(n) : n?.());
2228
+ }, [
2229
+ t,
2230
+ o,
2231
+ n
2232
+ ]), j = () => {
2233
+ let e = P[b];
2234
+ e ? D(e.text) : E();
2235
+ }, ee = (e) => {
2236
+ e.preventDefault(), j();
2237
+ }, te = (e) => {
2238
+ e.key === "Escape" && T && U ? (e.preventDefault(), C(!0), x(-1)) : e.key === "ArrowDown" ? (e.preventDefault(), P.length > 0 && (C(!1), x((e) => Math.min(e + 1, P.length - 1)))) : e.key === "ArrowUp" && (e.preventDefault(), x((e) => Math.max(e - 1, -1)));
2239
+ }, M = h.query.trim(), N = M.length < e.minQueryLength, P = T || h.instant ? [..._(h.query), ...h.instant?.suggestions ?? []] : [], F = h.instant?.products ?? [], I = h.emptyState?.starters ?? [], R = h.emptyState?.recommendedProducts ?? [], re = Nt("(prefers-reduced-motion: reduce)"), B = [g("placeholder"), ...I.map((e) => e.text)].filter(Boolean), ie = !re && B.length > 1 && !h.query, U = !N && P.length > 0 && !(T && S), K = F.length === 0 && R.length > 0, q = K ? R : F, ae = !N && !T && P.length === 0 && I.length > 0, oe = !N && h.status === "success" && !ae && P.length === 0 && q.length === 0, se = N || T ? "" : h.status === "success" ? oe ? g("no_results") : g(F.length === 1 ? "results_status.title_singular" : "results_status.title_plural", {
2240
+ count: String(F.length),
2241
+ query: M
2242
+ }) : "", J = `${m}-listbox`, ce = b >= 0 ? `${m}-option-${b}` : void 0, le = `${m}-suggestions`, ue = /* @__PURE__ */ G("div", {
2243
+ className: "ecomid-search-panel__header",
2244
+ children: [
2245
+ /* @__PURE__ */ W("span", {
2246
+ className: "ecomid-search-panel__search-icon",
2247
+ children: /* @__PURE__ */ W(ft, {})
2248
+ }),
2249
+ /* @__PURE__ */ G("form", {
2250
+ className: "ecomid-search-panel__form",
2251
+ onSubmit: ee,
2252
+ children: [ie && /* @__PURE__ */ W(Kt, { texts: B }), /* @__PURE__ */ W("input", {
2253
+ ref: v,
2254
+ className: "ecomid-search-panel__input",
2255
+ type: "text",
2256
+ role: "combobox",
2257
+ "data-autofocus": d ? "" : void 0,
2258
+ value: h.query,
2259
+ placeholder: g("placeholder"),
2260
+ "data-rolling": ie || void 0,
2261
+ "aria-label": g("placeholder"),
2262
+ "aria-autocomplete": "list",
2263
+ "aria-haspopup": "listbox",
2264
+ "aria-expanded": U,
2265
+ "aria-controls": U ? J : void 0,
2266
+ "aria-activedescendant": ce,
2267
+ enterKeyHint: "search",
2268
+ onChange: (t) => {
2269
+ e.setQuery(t.currentTarget.value), x(-1), C(!1);
2270
+ },
2271
+ onKeyDown: te,
2272
+ autoComplete: "off"
2273
+ })]
2274
+ }),
2275
+ /* @__PURE__ */ W("button", {
2276
+ type: "button",
2277
+ className: "ecomid-search-panel__submit",
2278
+ title: g("actions.submit"),
2279
+ "aria-label": g("actions.submit"),
2280
+ disabled: !M,
2281
+ onClick: j,
2282
+ children: /* @__PURE__ */ W(mt, {})
2283
+ }),
2284
+ r
2285
+ ]
2286
+ });
2287
+ return /* @__PURE__ */ G(zt.Provider, {
2288
+ value: O,
2289
+ children: [T ? /* @__PURE__ */ W("div", {
2290
+ ref: y,
2291
+ className: "ecomid-search-panel__field",
2292
+ children: /* @__PURE__ */ G("div", {
2293
+ className: "ecomid-search-panel__box",
2294
+ "data-open": U || void 0,
2295
+ children: [ue, U && /* @__PURE__ */ G("div", {
2296
+ className: "ecomid-search-panel__dropdown",
2297
+ children: [/* @__PURE__ */ W("p", {
2298
+ id: le,
2299
+ className: "ecomid-search-panel__dropdown-title",
2300
+ children: g("suggestions")
2301
+ }), /* @__PURE__ */ W(rr, {
2302
+ suggestions: P,
2303
+ askLabel: g("ask_suggestion", { query: "{query}" }),
2304
+ query: M,
2305
+ activeIndex: b,
2306
+ listboxId: J,
2307
+ labelledBy: le,
2308
+ getOptionId: (e) => `${m}-option-${e}`,
2309
+ onSelect: D,
2310
+ leading: /* @__PURE__ */ W(Mt, {
2311
+ className: "ecomid-search-icon",
2312
+ "aria-hidden": "true"
2313
+ })
2314
+ })]
2315
+ })]
2316
+ })
2317
+ }) : ue, /* @__PURE__ */ G("div", {
2318
+ className: "ecomid-search-panel__body",
2319
+ children: [
2320
+ N || T || h.instant === null ? /* @__PURE__ */ W(nr, {
2321
+ status: h.emptyStateStatus,
2322
+ starters: I,
2323
+ products: R,
2324
+ lang: l,
2325
+ market: u,
2326
+ recommendedLabel: g("empty.popular"),
2327
+ countLabel: f ? g(R.length === 1 ? "results_count.singular" : "results_count.plural", { count: String(R.length) }) : void 0,
2328
+ fitStarters: f,
2329
+ previousLabel: g("actions.previous"),
2330
+ nextLabel: g("actions.next"),
2331
+ onPillSelect: k,
2332
+ onProductClick: A,
2333
+ renderProduct: s,
2334
+ onRenderError: c
2335
+ }) : /* @__PURE__ */ W(sr, {
2336
+ suggestions: P,
2337
+ starters: ae ? I : [],
2338
+ carousel: ae && K,
2339
+ previousLabel: g("actions.previous"),
2340
+ nextLabel: g("actions.next"),
2341
+ onPillSelect: k,
2342
+ products: q,
2343
+ query: M,
2344
+ activeIndex: b,
2345
+ showListbox: U,
2346
+ showNoResults: oe,
2347
+ noResultsLabel: g("no_results"),
2348
+ suggestionsLabel: g("suggestions"),
2349
+ askLabel: g("ask_suggestion", { query: "{query}" }),
2350
+ productsLabel: g(K ? "empty.popular" : "products"),
2351
+ listboxId: J,
2352
+ suggestionsHeadingId: le,
2353
+ getOptionId: (e) => `${m}-option-${e}`,
2354
+ lang: l,
2355
+ market: u,
2356
+ onSuggestionSelect: D,
2357
+ onProductClick: A,
2358
+ renderProduct: s,
2359
+ onRenderError: c
2360
+ }),
2361
+ /* @__PURE__ */ W("p", {
2362
+ role: "status",
2363
+ className: "ecomid-search-sr-only",
2364
+ children: se
2365
+ }),
2366
+ i
2367
+ ]
2368
+ })]
2369
+ });
2370
+ }
2371
+ // src/search/components/SearchDialog/index.tsx
2372
+ var ur = 1e5;
2373
+ function dr({ store: e, open: t, onClose: n, onSubmit: r, onProductClick: i, renderProduct: a, lang: o, market: s, clientId: c }) {
2374
+ let l = ve(e.subscribe, e.getState, e.getState), { t: u } = Q(o), { track: d, onRenderError: f } = Pe({
2375
+ clientId: c,
2376
+ lang: o,
2377
+ market: s
2378
+ }), [p, m] = H(!1), [h, g] = H(!1), _ = V(null), v = V(!1);
2379
+ z(() => {
2380
+ if (t) return d(X.OPEN), () => d(X.CLOSE);
2381
+ }, [t, d]);
2382
+ let y = ke(L(() => {
2383
+ l.query ? e.setQuery("") : n();
2384
+ }, [
2385
+ l.query,
2386
+ e,
2387
+ n
2388
+ ]), !h), b = Ae("--ecomid-search-modal-height", !(l.query.trim().length >= e.minQueryLength)), [x, S] = H(null), C = L((e) => {
2389
+ y(e), b(e), S(e?.parentElement ?? null);
2390
+ }, [y, b]);
2391
+ return je(t), Ce(t), z(() => {
2392
+ h ? v.current = !0 : v.current && (v.current = !1, _.current?.focus());
2393
+ }, [h]), z(() => {
2394
+ if (!t) {
2395
+ m(!1), g(!1);
2396
+ return;
2397
+ }
2398
+ let e = 0, n = requestAnimationFrame(() => {
2399
+ e = requestAnimationFrame(() => m(!0));
2400
+ });
2401
+ return () => {
2402
+ cancelAnimationFrame(n), cancelAnimationFrame(e);
2403
+ };
2404
+ }, [t]), t ? K(/* @__PURE__ */ W(be, {
2405
+ className: "ecomid-search-backdrop",
2406
+ "data-visible": p || void 0,
2407
+ onDismiss: n,
2408
+ children: /* @__PURE__ */ W(Je.Provider, {
2409
+ value: x,
2410
+ children: /* @__PURE__ */ G("div", {
2411
+ ref: C,
2412
+ role: "dialog",
2413
+ "aria-modal": "true",
2414
+ "aria-label": u("dialog_label"),
2415
+ className: "ecomid-search-modal",
2416
+ "data-visible": p || void 0,
2417
+ "data-receded": h || void 0,
2418
+ inert: h || void 0,
2419
+ children: [/* @__PURE__ */ W(Et, {
2420
+ lang: o,
2421
+ onClose: n,
2422
+ onPersonalize: (e) => {
2423
+ let t = window.ecomid?.widgets?.account;
2424
+ if (!t) return;
2425
+ let r = e.currentTarget.closest(".ecomid-search-backdrop"), i = r ? Number.parseInt(getComputedStyle(r).zIndex, 10) : NaN, a = !window.matchMedia("(min-width: 768px)").matches;
2426
+ g(!0), t.init({
2427
+ clientId: c,
2428
+ locale: `${o}-${s}`,
2429
+ opts: {
2430
+ stacked: !0,
2431
+ source: "search",
2432
+ callbacks: { onClose: () => {
2433
+ g(!1), a && n();
2434
+ } }
2435
+ },
2436
+ styles: { overlay: { zIndex: (Number.isNaN(i) ? ur : i) + 1 } }
2437
+ });
2438
+ },
2439
+ personalizeRef: _
2440
+ }), /* @__PURE__ */ W(lr, {
2441
+ store: e,
2442
+ track: d,
2443
+ onDone: n,
2444
+ onSubmit: r,
2445
+ onProductClick: i,
2446
+ renderProduct: a,
2447
+ onRenderError: f,
2448
+ lang: o,
2449
+ market: s,
2450
+ footer: /* @__PURE__ */ W("div", {
2451
+ className: "ecomid-search-modal__footer",
2452
+ children: /* @__PURE__ */ W(et, {})
2453
+ })
2454
+ })]
2455
+ })
2456
+ })
2457
+ }), document.body) : null;
2458
+ }
2459
+ // src/search/components/SearchRoot.tsx
2460
+ var fr = () => () => {}, pr = () => !0, mr = () => !1;
2461
+ function hr(e, t) {
2462
+ let n = new URL(e, window.location.href);
2463
+ return n.search = T(n.search, {
2464
+ kind: "compose",
2465
+ text: t
2466
+ }), n.href;
2467
+ }
2468
+ function gr({ clientId: e, lang: t, market: n, baseUrl: r, open: i, onClose: a, onSubmit: o, resultsUrl: s, onProductClick: c, renderProduct: l, onOpen: u }) {
2469
+ let d = ve(fr, pr, mr), p = B(() => f({
2470
+ clientId: e,
2471
+ market: n,
2472
+ lang: t,
2473
+ baseUrl: r
2474
+ }), [
2475
+ e,
2476
+ n,
2477
+ t,
2478
+ r
2479
+ ]);
2480
+ z(() => () => p.destroy(), [p]);
2481
+ let m = _e(), h = V(u);
2482
+ h.current = u;
2483
+ let g = V(a);
2484
+ g.current = a, z(() => {
2485
+ i && m(() => h.current?.());
2486
+ }, [i, m]);
2487
+ let _ = L(() => m(() => g.current()), [m]), v = L((e) => {
2488
+ o ? m(() => o(e)) : s && window.location.assign(hr(s, e));
2489
+ }, [
2490
+ o,
2491
+ s,
2492
+ m
2493
+ ]), y = L((e, t) => {
2494
+ m(() => c?.(e, t));
2495
+ }, [c, m]);
2496
+ return /* @__PURE__ */ W(dr, {
2497
+ store: p,
2498
+ open: i && d,
2499
+ onClose: _,
2500
+ onSubmit: v,
2501
+ onProductClick: y,
2502
+ renderProduct: l,
2503
+ lang: t,
2504
+ market: n,
2505
+ clientId: e
2506
+ });
2507
+ }
2508
+ function _r(e) {
2509
+ return /* @__PURE__ */ W(he, { children: /* @__PURE__ */ W(gr, { ...e }) });
2510
+ }
2511
+ // src/search/react/SearchModal.tsx
2512
+ function vr({ clientId: e, locale: t, environment: n, ...r }) {
2513
+ let i = fe({
2514
+ clientId: e,
2515
+ locale: t,
2516
+ environment: n,
2517
+ active: r.open
2518
+ });
2519
+ return /* @__PURE__ */ W(pe.Provider, {
2520
+ value: i.report,
2521
+ children: /* @__PURE__ */ W(ge, {
2522
+ clientId: i.clientId,
2523
+ locale: i.locale,
2524
+ children: (e) => /* @__PURE__ */ W(_r, {
2525
+ ...r,
2526
+ clientId: e.clientId,
2527
+ lang: e.lang,
2528
+ market: e.market,
2529
+ baseUrl: i.urls.cgw
2530
+ })
2531
+ })
2532
+ });
2533
+ }
2534
+ // src/search/components/hooks/useAccountOverlay.ts
2535
+ function yr({ clientId: e, lang: t, market: n }) {
2536
+ return L(() => {
2537
+ window.ecomid?.widgets?.account?.init({
2538
+ clientId: e,
2539
+ locale: `${t}-${n}`,
2540
+ opts: { source: "search" }
2541
+ });
2542
+ }, [
2543
+ e,
2544
+ t,
2545
+ n
2546
+ ]);
2547
+ }
2548
+ // src/search/components/ResultsShell/index.tsx
2549
+ function br({ lang: e, onNewSearch: t, onPersonalize: n, history: r, children: i }) {
2550
+ let { t: a } = Q(e);
2551
+ return /* @__PURE__ */ G("div", {
2552
+ className: "ecomid-search-shell",
2553
+ children: [
2554
+ /* @__PURE__ */ W("div", {
2555
+ className: "ecomid-search-shell__start",
2556
+ children: r ?? (n && /* @__PURE__ */ W(Tt, {
2557
+ lang: e,
2558
+ onClick: n
2559
+ }))
2560
+ }),
2561
+ /* @__PURE__ */ W(dt, { lang: e }),
2562
+ /* @__PURE__ */ G("div", {
2563
+ className: "ecomid-search-shell__end",
2564
+ children: [t && /* @__PURE__ */ G("button", {
2565
+ type: "button",
2566
+ className: "ecomid-search-shell__new",
2567
+ title: a("shell.new_search"),
2568
+ "aria-label": a("shell.new_search"),
2569
+ onClick: t,
2570
+ children: [/* @__PURE__ */ W(ft, {}), /* @__PURE__ */ W("span", {
2571
+ className: "ecomid-search-shell__new-label",
2572
+ children: a("shell.new_search")
2573
+ })]
2574
+ }), i]
2575
+ })
2576
+ ]
2577
+ });
2578
+ }
2579
+ // src/search/components/FilterOptions/model.ts
2580
+ function xr(e, t = []) {
2581
+ return e.values.filter((e) => e.available || t.includes(e.value));
2582
+ }
2583
+ function Sr(e, t = {}) {
2584
+ return v.filter((n) => n === "price" || e.some((e) => e.key === n && xr(e, t[n]).length > 0));
2585
+ }
2586
+ var Cr = [
2587
+ "category",
2588
+ "color",
2589
+ "size",
2590
+ "material",
2591
+ "gender",
2592
+ "price"
2593
+ ], wr = [
2594
+ "material",
2595
+ "price",
2596
+ "color",
2597
+ "category"
2598
+ ], Tr = 3;
2599
+ function Er(e, t, n) {
2600
+ let r = (e) => e === "price" ? b(n) : (n[e] ?? []).length > 0, i = Cr.filter((t) => e.includes(t) && r(t)), a = (e) => e === "price" || (t.find((t) => t.key === e)?.values.filter((e) => e.available).length ?? 0) >= 2, o = wr.filter((t) => e.includes(t) && !r(t) && a(t)).slice(0, Tr);
2601
+ return [...i, ...o];
2602
+ }
2603
+ function Dr(e) {
2604
+ let t = /* @__PURE__ */ new Map();
2605
+ for (let n of e?.appliedFilters ?? []) n.values.forEach((e, r) => {
2606
+ t.set(`${n.key}:${e}`, n.labels[r] ?? e);
2607
+ });
2608
+ for (let n of e?.facets ?? []) for (let e of n.values) t.set(`${n.key}:${e.value}`, e.label);
2609
+ for (let n of e?.state?.filters ?? []) n.labels?.forEach((e, r) => {
2610
+ t.set(`${n.key}:${n.values[r]}`, e);
2611
+ });
2612
+ return (e, n) => t.get(`${e}:${n}`) ?? M(n);
2613
+ }
2614
+ function Or(e, t) {
2615
+ try {
2616
+ let n = new Intl.NumberFormat(e, {
2617
+ ...t && {
2618
+ style: "currency",
2619
+ currency: t
2620
+ },
2621
+ currencyDisplay: "narrowSymbol",
2622
+ minimumFractionDigits: 0,
2623
+ maximumFractionDigits: 2
2624
+ });
2625
+ return (e) => n.format(e);
2626
+ } catch {
2627
+ return (e) => String(e);
2628
+ }
2629
+ }
2630
+ function kr(e) {
2631
+ return Or(yn(e.lang, e.market), Ir(e));
2632
+ }
2633
+ function Ar(e, t = String, n) {
2634
+ let { priceMin: r, priceMax: i } = e;
2635
+ return r !== void 0 && i !== void 0 ? `${t(r)}–${t(i)}` : r === void 0 ? i === void 0 ? "" : n ? n(t(i)) : `${t(0)}–${t(i)}` : `${t(r)}+`;
2636
+ }
2637
+ function jr(e, t, n, r, i) {
2638
+ if (e === "price") return b(t) ? {
2639
+ values: [],
2640
+ labels: [Ar(t, r, i)]
2641
+ } : {
2642
+ values: [],
2643
+ labels: []
2644
+ };
2645
+ let a = t[e] ?? [];
2646
+ return {
2647
+ values: a,
2648
+ labels: a.map((t) => n(e, t))
2649
+ };
2650
+ }
2651
+ var Mr = [
2652
+ 1,
2653
+ 2,
2654
+ 5
2655
+ ];
2656
+ function Nr(e) {
2657
+ let t = e / 50;
2658
+ for (let e = 1;; e *= 10) for (let n of Mr) {
2659
+ let r = n * e;
2660
+ if (r >= t) return r;
2661
+ }
2662
+ }
2663
+ function Pr(e) {
2664
+ let t = e.flatMap((e) => e.price === void 0 ? [] : [e.price]), n = Math.max(...t);
2665
+ if (!(n > 0)) return null;
2666
+ let r = Nr(n);
2667
+ return {
2668
+ min: Math.min(...t),
2669
+ max: Math.ceil(n / r) * r,
2670
+ step: r
2671
+ };
2672
+ }
2673
+ function Fr(e) {
2674
+ return [...e.products, ...(e.sections ?? []).flatMap((e) => e.products)];
2675
+ }
2676
+ function Ir(e) {
2677
+ return Fr(e).find((e) => e.currency)?.currency;
2678
+ }
2679
+ function Lr(e, t) {
2680
+ let { priceMax: n } = t, { step: r } = e;
2681
+ return {
2682
+ min: e.min,
2683
+ max: n !== void 0 && n >= e.max ? Math.floor(n / r) * r + r : e.max,
2684
+ step: r
2685
+ };
2686
+ }
2687
+ // src/search/components/swatches.ts
2688
+ var Rr = [
2689
+ [["black"], "#111111"],
2690
+ [["silver"], "#c9ced6"],
2691
+ [["gold"], "#d4a72c"],
2692
+ [[
2693
+ "grey",
2694
+ "gray",
2695
+ "melange"
2696
+ ], "#8a8a8a"],
2697
+ [["navy"], "#1e3a8a"],
2698
+ [["blue"], "#2563eb"],
2699
+ [["brown", "mahogany"], "#7b4a2a"],
2700
+ [[
2701
+ "olive",
2702
+ "green",
2703
+ "moss",
2704
+ "khaki",
2705
+ "mint"
2706
+ ], "#2f9e55"],
2707
+ [["yellow", "lemon"], "#f6c21a"],
2708
+ [[
2709
+ "purple",
2710
+ "lilac",
2711
+ "lavender",
2712
+ "violet",
2713
+ "plum"
2714
+ ], "#8b3fd1"],
2715
+ [[
2716
+ "orange",
2717
+ "coral",
2718
+ "apricot",
2719
+ "rust"
2720
+ ], "#f07a1a"],
2721
+ [["teal", "turquoise"], "#13a3a3"],
2722
+ [["camel"], "#c3965f"],
2723
+ [[
2724
+ "dulce",
2725
+ "pink",
2726
+ "rose",
2727
+ "blush"
2728
+ ], "#ec5f9a"],
2729
+ [[
2730
+ "red",
2731
+ "berry",
2732
+ "cherry",
2733
+ "burgundy",
2734
+ "wine",
2735
+ "bordeaux"
2736
+ ], "#d7263d"],
2737
+ [["white"], "#ffffff"],
2738
+ [["beige", "sand"], "#dcc39b"],
2739
+ [["cream", "ivory"], "#f4ead2"]
2740
+ ];
2741
+ function zr(...e) {
2742
+ let t = e.map((e) => e.toLowerCase());
2743
+ for (let [e, n] of Rr) if (t.some((t) => e.some((e) => t.includes(e)))) return n;
2744
+ }
2745
+ // src/search/components/FilterOptions/OptionRow.tsx
2746
+ function Br({ type: e, variant: t, name: n, label: r, checked: i, swatch: a, onChange: o }) {
2747
+ let s = a ? zr(...a, r) : void 0;
2748
+ return /* @__PURE__ */ G("label", {
2749
+ className: "ecomid-search-option-row",
2750
+ "data-variant": t,
2751
+ "data-checked": i || void 0,
2752
+ children: [
2753
+ /* @__PURE__ */ W("input", {
2754
+ type: e,
2755
+ name: n,
2756
+ className: "ecomid-search-sr-only ecomid-search-option-row__input",
2757
+ checked: i,
2758
+ onChange: o
2759
+ }),
2760
+ t === "drawer" && /* @__PURE__ */ W("span", {
2761
+ className: "ecomid-search-option-row__box",
2762
+ "aria-hidden": "true",
2763
+ children: i && /* @__PURE__ */ W(St, { size: 14 })
2764
+ }),
2765
+ s && /* @__PURE__ */ W("span", {
2766
+ className: "ecomid-search-swatch",
2767
+ "aria-hidden": "true",
2768
+ style: { backgroundColor: s }
2769
+ }),
2770
+ /* @__PURE__ */ W("span", {
2771
+ className: "ecomid-search-option-row__label",
2772
+ children: r
2773
+ }),
2774
+ t === "menu" && i && /* @__PURE__ */ W("span", {
2775
+ className: "ecomid-search-option-row__check",
2776
+ "aria-hidden": "true",
2777
+ children: /* @__PURE__ */ W(St, {})
2778
+ })
2779
+ ]
2780
+ });
2781
+ }
2782
+ // src/search/components/FilterOptions/priceCeilings.ts
2783
+ var Vr = [
2784
+ 1,
2785
+ 1.5,
2786
+ 2,
2787
+ 2.5,
2788
+ 3,
2789
+ 4,
2790
+ 5,
2791
+ 6,
2792
+ 8
2793
+ ], Hr = 5, Ur = 9, Wr = {
2794
+ SEK: 100,
2795
+ NOK: 100,
2796
+ DKK: 100,
2797
+ CZK: 250,
2798
+ PLN: 25
2799
+ }, Gr = 10;
2800
+ function Kr(e) {
2801
+ let t = [];
2802
+ for (let n = 0; n <= Ur; n++) for (let r of Vr) {
2803
+ let i = r * 10 ** n;
2804
+ Number.isInteger(i) && i >= e && t.push(i);
2805
+ }
2806
+ return t;
2807
+ }
2808
+ function qr(e, t) {
2809
+ if (e.length <= t) return e;
2810
+ let n = e.length - 1;
2811
+ return Array.from({ length: t }, (r, i) => e[Math.round(i * n / (t - 1))]);
2812
+ }
2813
+ function Jr(e, t, n) {
2814
+ if (!(t > 0) || !(e >= 0) || e > t) return [];
2815
+ let r = Kr(n && Wr[n.toUpperCase()] || Gr), i = r.findIndex((t) => t >= e), a = r.findIndex((e) => e >= t);
2816
+ return i === -1 || a === -1 ? [] : qr(r.slice(i, a + 1), Hr);
2817
+ }
2818
+ // src/search/components/FilterOptions/index.tsx
2819
+ function Yr({ group: e, facet: t, label: n, selected: r, variant: i, onToggle: a }) {
2820
+ return /* @__PURE__ */ G("fieldset", {
2821
+ className: "ecomid-search-options",
2822
+ "data-variant": i,
2823
+ children: [/* @__PURE__ */ W("legend", {
2824
+ className: "ecomid-search-sr-only",
2825
+ children: n
2826
+ }), xr(t, r).map((t) => {
2827
+ let n = r.includes(t.value);
2828
+ return /* @__PURE__ */ W(Br, {
2829
+ type: "checkbox",
2830
+ variant: i,
2831
+ label: t.label,
2832
+ checked: n,
2833
+ swatch: e === "color" ? [t.value] : void 0,
2834
+ onChange: () => a(e, t.value)
2835
+ }, t.value);
2836
+ })]
2837
+ });
2838
+ }
2839
+ function Xr({ lang: e, label: t, variant: n, min: r, max: i, bounds: a, currency: o, market: s, onCommit: c }) {
2840
+ let { t: l } = Q(e), u = Or(yn(e, s), o), d = a ? Jr(a.min, a.max, o) : [], f = i !== void 0 && !d.includes(i) ? [...d, i].sort((e, t) => e - t) : d, p = r === void 0 && i === void 0;
2841
+ return /* @__PURE__ */ G("fieldset", {
2842
+ className: "ecomid-search-options",
2843
+ "data-variant": n,
2844
+ children: [
2845
+ /* @__PURE__ */ W("legend", {
2846
+ className: "ecomid-search-sr-only",
2847
+ children: t
2848
+ }),
2849
+ /* @__PURE__ */ W(Br, {
2850
+ type: "checkbox",
2851
+ variant: n,
2852
+ label: l("filters.any_price"),
2853
+ checked: p,
2854
+ onChange: () => c(void 0, void 0)
2855
+ }),
2856
+ f.map((e) => {
2857
+ let t = r === void 0 && i === e;
2858
+ return /* @__PURE__ */ W(Br, {
2859
+ type: "checkbox",
2860
+ variant: n,
2861
+ label: l("filters.price_under", { price: u(e) }),
2862
+ checked: t,
2863
+ onChange: () => t ? c(void 0, void 0) : c(void 0, e)
2864
+ }, e);
2865
+ })
2866
+ ]
2867
+ });
2868
+ }
2869
+ // src/search/components/FilterOptions/PriceSlider.tsx
2870
+ function Zr({ bounds: e, low: t, high: n, minLabel: r, maxLabel: i, format: a, onChange: o, onCommit: s }) {
2871
+ let c = V(null), l = V({
2872
+ min: null,
2873
+ max: null
2874
+ }), [u, d] = H(null), f = V(null), { min: p, max: m, step: h } = e, g = m - p, _ = (e, r, i = {
2875
+ low: t,
2876
+ high: n
2877
+ }) => {
2878
+ let a = Math.round((r - p) / h) * h + p;
2879
+ return e === "min" ? {
2880
+ low: Math.min(Math.max(a, p), i.high - h),
2881
+ high: i.high
2882
+ } : {
2883
+ low: i.low,
2884
+ high: Math.max(Math.min(a, m), i.low + h)
2885
+ };
2886
+ }, v = (e) => {
2887
+ let t = c.current?.getBoundingClientRect();
2888
+ if (!t || t.width === 0) return p;
2889
+ let n = Math.min(Math.max((e - t.left) / t.width, 0), 1);
2890
+ return p + n * g;
2891
+ }, y = (e) => {
2892
+ if (e.button !== 0) return;
2893
+ let r = v(e.clientX), i = Math.abs(r - t) < Math.abs(r - n) || t === n && r < t || Math.abs(r - t) === Math.abs(r - n) && r < t ? "min" : "max", a = _(i, r);
2894
+ f.current = {
2895
+ thumb: i,
2896
+ ...a
2897
+ }, e.currentTarget.setPointerCapture(e.pointerId), l.current[i]?.focus({ preventScroll: !0 }), d(i), o(a.low, a.high);
2898
+ }, b = (e) => {
2899
+ let t = f.current;
2900
+ if (!t) return;
2901
+ let n = _(t.thumb, v(e.clientX), t);
2902
+ (n.low !== t.low || n.high !== t.high) && (f.current = {
2903
+ thumb: t.thumb,
2904
+ ...n
2905
+ }, o(n.low, n.high));
2906
+ }, x = () => {
2907
+ let e = f.current;
2908
+ e && (f.current = null, d(null), s(e.low, e.high));
2909
+ }, S = (e) => (r) => {
2910
+ let i = e === "min" ? t : n, a;
2911
+ switch (r.key) {
2912
+ case "ArrowRight":
2913
+ case "ArrowUp":
2914
+ a = i + h;
2915
+ break;
2916
+ case "ArrowLeft":
2917
+ case "ArrowDown":
2918
+ a = i - h;
2919
+ break;
2920
+ case "PageUp":
2921
+ a = i + h * 10;
2922
+ break;
2923
+ case "PageDown":
2924
+ a = i - h * 10;
2925
+ break;
2926
+ case "Home":
2927
+ a = p;
2928
+ break;
2929
+ case "End":
2930
+ a = m;
2931
+ break;
2932
+ default: return;
2933
+ }
2934
+ r.preventDefault();
2935
+ let o = _(e, a);
2936
+ (o.low !== t || o.high !== n) && s(o.low, o.high);
2937
+ }, C = (e) => `${(e - p) / g * 100}%`, w = (e, t, n) => /* @__PURE__ */ W("div", {
2938
+ ref: (t) => {
2939
+ l.current[e] = t;
2940
+ },
2941
+ role: "slider",
2942
+ tabIndex: 0,
2943
+ className: "ecomid-search-price__thumb",
2944
+ "data-active": u === e || void 0,
2945
+ "aria-label": n,
2946
+ "aria-orientation": "horizontal",
2947
+ "aria-valuemin": p,
2948
+ "aria-valuemax": m,
2949
+ "aria-valuenow": t,
2950
+ "aria-valuetext": e === "max" && t >= m ? `${a(t)}+` : a(t),
2951
+ style: { left: C(t) },
2952
+ onKeyDown: S(e)
2953
+ }, e);
2954
+ return /* @__PURE__ */ G("div", {
2955
+ ref: c,
2956
+ className: "ecomid-search-price__slider",
2957
+ onPointerDown: y,
2958
+ onPointerMove: b,
2959
+ onPointerUp: x,
2960
+ onPointerCancel: x,
2961
+ children: [
2962
+ /* @__PURE__ */ W("div", { className: "ecomid-search-price__rail" }),
2963
+ /* @__PURE__ */ W("div", {
2964
+ className: "ecomid-search-price__range",
2965
+ style: {
2966
+ left: C(t),
2967
+ right: `calc(100% - ${C(n)})`
2968
+ }
2969
+ }),
2970
+ w("min", t, r),
2971
+ w("max", n, i)
2972
+ ]
2973
+ });
2974
+ }
2975
+ // src/search/components/FilterOptions/PriceRange.tsx
2976
+ function Qr(e) {
2977
+ if (e.trim() === "") return;
2978
+ let t = Number(e.replace(",", "."));
2979
+ return Number.isFinite(t) && t >= 0 ? t : void 0;
2980
+ }
2981
+ function $(e) {
2982
+ return e === void 0 ? "" : String(e);
2983
+ }
2984
+ function $r({ lang: e, min: t, max: n, bounds: r, currency: i, market: a, onCommit: o }) {
2985
+ let { t: s } = Q(e), [c, l] = H($(t)), [u, d] = H($(n)), [f, p] = H(null), m = Or(yn(e, a), i), h = V({
2986
+ minText: c,
2987
+ maxText: u
2988
+ });
2989
+ h.current = {
2990
+ minText: c,
2991
+ maxText: u
2992
+ };
2993
+ let g = V({
2994
+ min: t,
2995
+ max: n
2996
+ });
2997
+ z(() => {
2998
+ g.current.min !== t && (g.current.min = t, l($(t)));
2999
+ }, [t]), z(() => {
3000
+ g.current.max !== n && (g.current.max = n, d($(n)));
3001
+ }, [n]);
3002
+ let _ = () => {
3003
+ let e = Qr(h.current.minText);
3004
+ e === 0 && (e = void 0);
3005
+ let r = Qr(h.current.maxText);
3006
+ e !== void 0 && r !== void 0 && e > r && ([e, r] = [r, e], l($(e)), d($(r))), (e !== t || r !== n) && o(e, r);
3007
+ }, v = (e, i) => {
3008
+ if (!r) return;
3009
+ let a = e <= r.min ? void 0 : e, s = i >= r.max ? void 0 : i;
3010
+ l($(a)), d($(s)), h.current = {
3011
+ minText: $(a),
3012
+ maxText: $(s)
3013
+ }, (a !== t || s !== n) && o(a, s);
3014
+ }, y = (e, t) => {
3015
+ if (!r) return;
3016
+ let n = e <= r.min ? void 0 : e, i = t >= r.max ? void 0 : t;
3017
+ l($(n)), d($(i)), h.current = {
3018
+ minText: $(n),
3019
+ maxText: $(i)
3020
+ };
3021
+ }, b = m(Qr(c) ?? 0), x = Qr(u), S = x === void 0 ? r ? `${m(r.max)}+` : "" : m(x), C = (() => {
3022
+ if (!r) return null;
3023
+ let e = (e) => Math.min(Math.max(e, r.min), r.max), t = e(Qr(c) ?? r.min), n = e(Qr(u) ?? r.max);
3024
+ return t <= n ? {
3025
+ low: t,
3026
+ high: n
3027
+ } : {
3028
+ low: n,
3029
+ high: t
3030
+ };
3031
+ })(), w = (e) => {
3032
+ e.key === "Enter" && (e.preventDefault(), _());
3033
+ };
3034
+ return /* @__PURE__ */ G("div", {
3035
+ className: "ecomid-search-price",
3036
+ children: [r && C && /* @__PURE__ */ W(Zr, {
3037
+ bounds: r,
3038
+ low: C.low,
3039
+ high: C.high,
3040
+ minLabel: s("filters.min"),
3041
+ maxLabel: s("filters.max"),
3042
+ format: m,
3043
+ onChange: y,
3044
+ onCommit: v
3045
+ }), /* @__PURE__ */ G("div", {
3046
+ className: "ecomid-search-price__fields",
3047
+ children: [
3048
+ /* @__PURE__ */ G("label", {
3049
+ className: "ecomid-search-price__field",
3050
+ children: [/* @__PURE__ */ W("span", {
3051
+ className: "ecomid-search-price__label",
3052
+ children: s("filters.min")
3053
+ }), /* @__PURE__ */ W("input", {
3054
+ type: "text",
3055
+ inputMode: "decimal",
3056
+ className: "ecomid-search-price__input",
3057
+ value: f === "min" ? c : b,
3058
+ onInput: (e) => {
3059
+ h.current.minText = e.currentTarget.value, l(e.currentTarget.value);
3060
+ },
3061
+ onFocus: () => p("min"),
3062
+ onBlur: () => {
3063
+ p(null), _();
3064
+ },
3065
+ onKeyDown: w
3066
+ })]
3067
+ }),
3068
+ /* @__PURE__ */ W("span", {
3069
+ className: "ecomid-search-price__dash",
3070
+ "aria-hidden": "true"
3071
+ }),
3072
+ /* @__PURE__ */ G("label", {
3073
+ className: "ecomid-search-price__field",
3074
+ children: [/* @__PURE__ */ W("span", {
3075
+ className: "ecomid-search-price__label",
3076
+ children: s("filters.max")
3077
+ }), /* @__PURE__ */ W("input", {
3078
+ type: "text",
3079
+ inputMode: "decimal",
3080
+ className: "ecomid-search-price__input",
3081
+ value: f === "max" ? u : S,
3082
+ onInput: (e) => {
3083
+ h.current.maxText = e.currentTarget.value, d(e.currentTarget.value);
3084
+ },
3085
+ onFocus: () => p("max"),
3086
+ onBlur: () => {
3087
+ p(null), _();
3088
+ },
3089
+ onKeyDown: w
3090
+ })]
3091
+ })
3092
+ ]
3093
+ })]
3094
+ });
3095
+ }
3096
+ // src/search/components/hooks/useSwipeDismiss.ts
3097
+ var ei = "(max-width: 767px)", ti = 80;
3098
+ function ni(e) {
3099
+ let t = V(e);
3100
+ t.current = e;
3101
+ let n = V(null);
3102
+ return z(() => () => n.current?.(), []), L((e) => {
3103
+ if (e.button > 0 || !window.matchMedia(ei).matches) return;
3104
+ let r = e.currentTarget.closest(".ecomid-search-overlay");
3105
+ if (!r) return;
3106
+ let i = e.clientY, a = 0, o = (e) => {
3107
+ a = Math.max(0, e.clientY - i), r.style.transition = "none", r.style.transform = `translateY(${a}px)`;
3108
+ }, s = () => {
3109
+ document.removeEventListener("pointermove", o), document.removeEventListener("pointerup", c), document.removeEventListener("pointercancel", c), n.current = null;
3110
+ }, c = () => {
3111
+ s(), r.style.transition = "transform 200ms ease", r.style.transform = "", a >= ti && t.current();
3112
+ };
3113
+ n.current?.(), n.current = s, document.addEventListener("pointermove", o), document.addEventListener("pointerup", c), document.addEventListener("pointercancel", c);
3114
+ }, []);
3115
+ }
3116
+ // src/search/components/FilterDrawer/index.tsx
3117
+ function ri({ lang: e, results: t, filters: n, bounds: r, terms: i, excludedTerms: a, onRemoveTerm: o, onRemoveExcludedTerm: s, onApply: c, onClose: l, count: u }) {
3118
+ let { t: d } = Q(e), f = t.total ?? t.products.length, p = ne(), [m, h] = H(() => D(n)), g = V(m);
3119
+ g.current = m;
3120
+ let [_, v] = H(null), [S, C] = H(f), w = V(null), T = ni(l), E = () => {
3121
+ setTimeout(() => {
3122
+ let e = w.current, t = e?.closest("[role=\"dialog\"]");
3123
+ e && !t?.contains(document.activeElement) && e.focus({ preventScroll: !0 });
3124
+ }, 0);
3125
+ };
3126
+ z(() => {
3127
+ if (x(m, n)) {
3128
+ C(f);
3129
+ return;
3130
+ }
3131
+ let e = new AbortController(), t = setTimeout(() => {
3132
+ u(m, e.signal).then(C).catch(() => void 0);
3133
+ }, 250);
3134
+ return () => {
3135
+ clearTimeout(t), e.abort();
3136
+ };
3137
+ }, [
3138
+ m,
3139
+ n,
3140
+ f,
3141
+ u
3142
+ ]);
3143
+ let O = Dr(t), k = kr(t), A = Sr(t.facets ?? [], n), j = (e) => d(`filters.groups.${e}`), N = (e, t) => h((n) => te(n, e, t)), P = [...i.map((e) => ({
3144
+ id: `term:${e}`,
3145
+ label: M(e),
3146
+ remove: () => o(e)
3147
+ })), ...a.map((e) => ({
3148
+ id: `excluded:${e}`,
3149
+ label: M(e),
3150
+ removeLabel: d("filters.remove_exclusion", { filter: M(e) }),
3151
+ struck: !0,
3152
+ remove: () => s(e)
3153
+ }))];
3154
+ for (let e of A) if (e === "price") b(m) && P.push({
3155
+ id: "price",
3156
+ label: Ar(m, k),
3157
+ remove: () => h((e) => y(e, "price"))
3158
+ });
3159
+ else for (let t of m[e] ?? []) P.push({
3160
+ id: `${e}:${t}`,
3161
+ label: O(e, t),
3162
+ remove: () => N(e, t)
3163
+ });
3164
+ return m.onSale && P.push({
3165
+ id: "on_sale",
3166
+ label: d("filters.on_sale"),
3167
+ remove: () => h((e) => D({
3168
+ ...e,
3169
+ onSale: !1
3170
+ }))
3171
+ }), /* @__PURE__ */ G(Lt, {
3172
+ kind: "drawer",
3173
+ label: d("filters.title"),
3174
+ onClose: l,
3175
+ children: [
3176
+ /* @__PURE__ */ G("div", {
3177
+ className: "ecomid-search-drawer__header",
3178
+ onPointerDown: T,
3179
+ children: [
3180
+ /* @__PURE__ */ W("div", {
3181
+ className: "ecomid-search-drawer__handle",
3182
+ "aria-hidden": "true"
3183
+ }),
3184
+ /* @__PURE__ */ W("h2", {
3185
+ className: "ecomid-search-drawer__title",
3186
+ children: d("filters.title")
3187
+ }),
3188
+ /* @__PURE__ */ W("button", {
3189
+ type: "button",
3190
+ className: "ecomid-search-drawer__close",
3191
+ title: d("actions.close"),
3192
+ "aria-label": d("actions.close"),
3193
+ onClick: l,
3194
+ children: /* @__PURE__ */ W(pt, {})
3195
+ })
3196
+ ]
3197
+ }),
3198
+ /* @__PURE__ */ G("div", {
3199
+ ref: w,
3200
+ tabIndex: -1,
3201
+ className: "ecomid-search-drawer__body",
3202
+ children: [P.length > 0 && /* @__PURE__ */ W("div", {
3203
+ className: "ecomid-search-chips",
3204
+ children: P.map((e) => /* @__PURE__ */ G("button", {
3205
+ type: "button",
3206
+ className: "ecomid-search-chip",
3207
+ "aria-label": e.removeLabel ?? d("filters.remove", { filter: e.label }),
3208
+ onClick: () => {
3209
+ e.remove(), E();
3210
+ },
3211
+ children: [/* @__PURE__ */ W("span", {
3212
+ className: e.struck ? "ecomid-search-struck" : void 0,
3213
+ children: e.label
3214
+ }), /* @__PURE__ */ W(xt, {})]
3215
+ }, e.id))
3216
+ }), /* @__PURE__ */ G("div", {
3217
+ className: "ecomid-search-accordion",
3218
+ children: [A.map((n) => {
3219
+ let i = _ === n, a = jr(n, m, O, k).labels.join(", "), o = (t.facets ?? []).find((e) => e.key === n);
3220
+ return /* @__PURE__ */ G("div", {
3221
+ className: "ecomid-search-accordion__item",
3222
+ children: [/* @__PURE__ */ G("button", {
3223
+ type: "button",
3224
+ className: "ecomid-search-accordion__header",
3225
+ "aria-expanded": i,
3226
+ "aria-controls": `${p}-${n}`,
3227
+ onClick: () => v(i ? null : n),
3228
+ children: [
3229
+ /* @__PURE__ */ W("span", {
3230
+ className: "ecomid-search-accordion__name",
3231
+ children: j(n)
3232
+ }),
3233
+ a && /* @__PURE__ */ W("span", {
3234
+ className: "ecomid-search-accordion__value",
3235
+ children: a
3236
+ }),
3237
+ /* @__PURE__ */ W("span", {
3238
+ className: "ecomid-search-accordion__chevron",
3239
+ "data-open": i || void 0,
3240
+ children: /* @__PURE__ */ W(bt, { size: 16 })
3241
+ })
3242
+ ]
3243
+ }), i && /* @__PURE__ */ W("div", {
3244
+ id: `${p}-${n}`,
3245
+ className: "ecomid-search-accordion__panel",
3246
+ children: n === "price" ? /* @__PURE__ */ W($r, {
3247
+ lang: e,
3248
+ min: m.priceMin,
3249
+ max: m.priceMax,
3250
+ bounds: r && {
3251
+ ...r,
3252
+ min: 0
3253
+ },
3254
+ currency: Ir(t),
3255
+ market: t.market,
3256
+ onCommit: (e, t) => h((n) => D({
3257
+ ...n,
3258
+ priceMin: e,
3259
+ priceMax: t
3260
+ }))
3261
+ }) : o && /* @__PURE__ */ W(Yr, {
3262
+ group: n,
3263
+ facet: o,
3264
+ label: j(n),
3265
+ selected: m[n] ?? [],
3266
+ variant: "drawer",
3267
+ onToggle: N
3268
+ })
3269
+ })]
3270
+ }, n);
3271
+ }), /* @__PURE__ */ W("div", {
3272
+ className: "ecomid-search-accordion__item",
3273
+ children: /* @__PURE__ */ W(Br, {
3274
+ type: "checkbox",
3275
+ variant: "drawer",
3276
+ label: d("filters.on_sale"),
3277
+ checked: !!m.onSale,
3278
+ onChange: () => h((e) => D({
3279
+ ...e,
3280
+ onSale: !e.onSale
3281
+ }))
3282
+ })
3283
+ })]
3284
+ })]
3285
+ }),
3286
+ /* @__PURE__ */ G("div", {
3287
+ className: "ecomid-search-drawer__footer",
3288
+ children: [/* @__PURE__ */ W("button", {
3289
+ type: "button",
3290
+ className: "ecomid-search-button",
3291
+ "data-variant": "outline",
3292
+ disabled: ee(m) === 0,
3293
+ onClick: () => {
3294
+ h({}), E();
3295
+ },
3296
+ children: d("filters.clear_all")
3297
+ }), /* @__PURE__ */ W("button", {
3298
+ type: "button",
3299
+ className: "ecomid-search-button",
3300
+ "data-variant": "solid",
3301
+ onClick: () => {
3302
+ c(g.current), l();
3303
+ },
3304
+ children: d(S === 1 ? "filters.show_products.singular" : "filters.show_products.plural", { count: String(S) })
3305
+ })]
3306
+ })
3307
+ ]
3308
+ });
3309
+ }
3310
+ // src/search/components/hooks/usePriceBounds.ts
3311
+ function ii(e, t) {
3312
+ let n = V(null), { query: r } = e, i = b(t), { priceMin: a, priceMax: o } = t, s = B(() => Pr(Fr(e)), [e]);
3313
+ return i || (n.current = {
3314
+ query: r,
3315
+ bounds: s
3316
+ }), B(() => {
3317
+ if (!i) return s;
3318
+ let e = n.current, t = e && e.query === r ? e.bounds : s;
3319
+ return t ? Lr(t, {
3320
+ priceMin: a,
3321
+ priceMax: o
3322
+ }) : null;
3323
+ }, [
3324
+ i,
3325
+ s,
3326
+ r,
3327
+ a,
3328
+ o
3329
+ ]);
3330
+ }
3331
+ // src/search/components/ResultsToolbar/index.tsx
3332
+ var ai = (e) => e.currentTarget.closest(".ecomid-search-anchor");
3333
+ function oi({ lang: e, results: t, filters: n, sort: r, terms: i, excludedTerms: a, meta: o = !0, onRemoveTerm: s, onRemoveExcludedTerm: c, onFiltersChange: l, onSortChange: u, count: d }) {
3334
+ let { t: f, isLoading: p } = Q(e), m = Nt("(min-width: 900px)"), h = Nt("(min-width: 768px)"), [g, _] = H(null), v = L(() => _(null), []), b = V(null);
3335
+ Un(b, !p && !m), Xn(b, "horizontal", !p && !m);
3336
+ let x = ii(t, n), S = Dr(t), C = kr(t), w = Er(Sr(t.facets ?? [], n), t.facets ?? [], n), T = er(b, !p && m);
3337
+ if (p) return null;
3338
+ let O = (e) => f(`filters.groups.${e}`), k = (e) => f("filters.price_under", { price: e }), j = h ? "popover" : "sheet", ee = (e, t) => l(te(n, e, t)), N = (r) => {
3339
+ if (r === "price") return /* @__PURE__ */ W(Xr, {
3340
+ lang: e,
3341
+ label: O(r),
3342
+ variant: "menu",
3343
+ min: n.priceMin,
3344
+ max: n.priceMax,
3345
+ bounds: x,
3346
+ currency: Ir(t),
3347
+ market: t.market,
3348
+ onCommit: (e, t) => {
3349
+ l(D({
3350
+ ...y(n, "price"),
3351
+ priceMin: e,
3352
+ priceMax: t
3353
+ })), v();
3354
+ }
3355
+ });
3356
+ let i = (t.facets ?? []).find((e) => e.key === r);
3357
+ return i ? /* @__PURE__ */ W(Yr, {
3358
+ group: r,
3359
+ facet: i,
3360
+ label: O(r),
3361
+ selected: n[r] ?? [],
3362
+ variant: "menu",
3363
+ onToggle: ee
3364
+ }) : null;
3365
+ }, P = (e, t, n, r) => /* @__PURE__ */ W(Lt, {
3366
+ kind: j,
3367
+ label: e,
3368
+ onClose: v,
3369
+ anchor: n,
3370
+ align: r,
3371
+ children: h ? /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("div", {
3372
+ className: "ecomid-search-overlay__title",
3373
+ children: e
3374
+ }), t] }) : /* @__PURE__ */ W(Rt, {
3375
+ title: e,
3376
+ allLabel: f("filters.all"),
3377
+ closeLabel: f("actions.close"),
3378
+ onAll: () => _({ type: "drawer" }),
3379
+ onClose: v,
3380
+ children: t
3381
+ })
3382
+ }), F = E.includes(r) && !A(r) ? f(`sort.options.${r}`) : void 0, I = t.total ?? t.products.length, R = (e) => {
3383
+ let t = jr(e, n, S, C, k), r = g?.type === "group" && g.group === e, [i] = t.values, a = e === "color" && i !== void 0 ? zr(i, S(e, i)) : void 0, [o] = t.labels, s = t.labels.length - 1;
3384
+ return /* @__PURE__ */ G("div", {
3385
+ className: "ecomid-search-anchor",
3386
+ children: [/* @__PURE__ */ G("button", {
3387
+ type: "button",
3388
+ className: "ecomid-search-pill",
3389
+ "data-active": t.labels.length > 0 || void 0,
3390
+ "aria-haspopup": "dialog",
3391
+ "aria-expanded": r,
3392
+ "aria-label": s > 0 ? t.labels.join(", ") : void 0,
3393
+ onClick: (t) => _(r ? null : {
3394
+ type: "group",
3395
+ group: e,
3396
+ anchor: ai(t)
3397
+ }),
3398
+ children: [
3399
+ a && /* @__PURE__ */ W("span", {
3400
+ className: "ecomid-search-swatch",
3401
+ "aria-hidden": "true",
3402
+ style: { backgroundColor: a }
3403
+ }),
3404
+ /* @__PURE__ */ W("span", {
3405
+ className: "ecomid-search-pill__label",
3406
+ children: o === void 0 ? O(e) : s > 0 ? `${o} +${s}` : o
3407
+ }),
3408
+ /* @__PURE__ */ W(bt, {})
3409
+ ]
3410
+ }), r && P(O(e), N(e), g.anchor)]
3411
+ }, e);
3412
+ }, z = jr("category", n, S, C).labels.length > 0 && w.includes("category");
3413
+ return /* @__PURE__ */ G(U, { children: [
3414
+ /* @__PURE__ */ G("div", {
3415
+ ref: b,
3416
+ className: "ecomid-search-toolbar__pills",
3417
+ children: [
3418
+ /* @__PURE__ */ W("button", {
3419
+ type: "button",
3420
+ className: "ecomid-search-pill",
3421
+ "data-icon": "true",
3422
+ title: f("filters.title"),
3423
+ "aria-label": f("filters.title"),
3424
+ "aria-haspopup": "dialog",
3425
+ "aria-expanded": g?.type === "drawer",
3426
+ onClick: () => _(g?.type === "drawer" ? null : { type: "drawer" }),
3427
+ children: /* @__PURE__ */ W(vt, {})
3428
+ }),
3429
+ z && R("category"),
3430
+ i.map((e) => /* @__PURE__ */ G("button", {
3431
+ type: "button",
3432
+ className: "ecomid-search-pill",
3433
+ "data-active": "true",
3434
+ "aria-label": f("filters.remove", { filter: M(e) }),
3435
+ onClick: () => s(e),
3436
+ children: [/* @__PURE__ */ W("span", {
3437
+ className: "ecomid-search-pill__label",
3438
+ children: M(e)
3439
+ }), /* @__PURE__ */ W(xt, {})]
3440
+ }, `term:${e}`)),
3441
+ a.map((e) => /* @__PURE__ */ G("button", {
3442
+ type: "button",
3443
+ className: "ecomid-search-pill",
3444
+ "data-active": "true",
3445
+ "aria-label": f("filters.remove_exclusion", { filter: M(e) }),
3446
+ onClick: () => c(e),
3447
+ children: [/* @__PURE__ */ W("span", {
3448
+ className: "ecomid-search-pill__label ecomid-search-struck",
3449
+ children: M(e)
3450
+ }), /* @__PURE__ */ W(xt, {})]
3451
+ }, `excluded:${e}`)),
3452
+ w.map((e) => e === "category" && z ? null : R(e)),
3453
+ /* @__PURE__ */ W("button", {
3454
+ type: "button",
3455
+ className: "ecomid-search-pill",
3456
+ "data-more": "true",
3457
+ hidden: T === 0,
3458
+ title: f("filters.more_count", { count: String(T) }),
3459
+ "aria-label": f("filters.more_count", { count: String(T) }),
3460
+ "aria-haspopup": "dialog",
3461
+ "aria-expanded": g?.type === "drawer",
3462
+ onClick: () => _(g?.type === "drawer" ? null : { type: "drawer" }),
3463
+ children: `+${T}`
3464
+ })
3465
+ ]
3466
+ }),
3467
+ o && /* @__PURE__ */ G("div", {
3468
+ className: "ecomid-search-toolbar__meta",
3469
+ children: [/* @__PURE__ */ W("span", {
3470
+ className: "ecomid-search-toolbar__count",
3471
+ children: f(I === 1 ? "results_count.singular" : "results_count.plural", { count: String(I) })
3472
+ }), /* @__PURE__ */ G("div", {
3473
+ className: "ecomid-search-anchor",
3474
+ children: [/* @__PURE__ */ G("button", {
3475
+ type: "button",
3476
+ className: "ecomid-search-sort",
3477
+ "aria-haspopup": "dialog",
3478
+ "aria-expanded": g?.type === "sort",
3479
+ "aria-label": F ? f("sort.selected", { option: F }) : void 0,
3480
+ onClick: (e) => _(g?.type === "sort" ? null : {
3481
+ type: "sort",
3482
+ anchor: ai(e)
3483
+ }),
3484
+ children: [/* @__PURE__ */ W("span", { children: F ?? f("sort.label") }), /* @__PURE__ */ W(bt, {})]
3485
+ }), g?.type === "sort" && P(f("sort.label"), /* @__PURE__ */ W("div", {
3486
+ role: "radiogroup",
3487
+ "aria-label": f("sort.label"),
3488
+ className: "ecomid-search-options",
3489
+ "data-variant": "menu",
3490
+ children: E.map((e) => /* @__PURE__ */ W(Br, {
3491
+ type: "radio",
3492
+ variant: "menu",
3493
+ name: "ecomid-search-sort",
3494
+ label: f(`sort.options.${e}`),
3495
+ checked: (A(r) ? "relevance" : r) === e,
3496
+ onChange: () => {
3497
+ u(e), v();
3498
+ }
3499
+ }, e))
3500
+ }), g.anchor, "end")]
3501
+ })]
3502
+ }),
3503
+ g?.type === "drawer" && /* @__PURE__ */ W(ri, {
3504
+ lang: e,
3505
+ results: t,
3506
+ filters: n,
3507
+ bounds: x,
3508
+ count: d,
3509
+ terms: i,
3510
+ excludedTerms: a,
3511
+ onRemoveTerm: s,
3512
+ onRemoveExcludedTerm: c,
3513
+ onApply: l,
3514
+ onClose: v
3515
+ })
3516
+ ] });
3517
+ }
3518
+ // src/search/components/BackToTop/index.tsx
3519
+ var si = 600;
3520
+ function ci({ lang: e }) {
3521
+ let { t } = Q(e), [n, r] = H(null), [i, a] = H(!1);
3522
+ return z(() => {
3523
+ r(document.body);
3524
+ let e = () => a(window.scrollY > si);
3525
+ return e(), window.addEventListener("scroll", e, { passive: !0 }), () => window.removeEventListener("scroll", e);
3526
+ }, []), !n || !i ? null : K(/* @__PURE__ */ W("button", {
3527
+ type: "button",
3528
+ className: "ecomid-search-top",
3529
+ title: t("shell.back_to_top"),
3530
+ "aria-label": t("shell.back_to_top"),
3531
+ onClick: () => {
3532
+ let e = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
3533
+ window.scrollTo({
3534
+ top: 0,
3535
+ behavior: e ? "auto" : "smooth"
3536
+ });
3537
+ },
3538
+ children: /* @__PURE__ */ W(ht, {})
3539
+ }), n);
3540
+ }
3541
+ // src/search/components/EarlierSteps/index.tsx
3542
+ function li({ lang: e, steps: t, activeId: n, onSelect: r }) {
3543
+ let { t: i } = Q(e), [a, o] = H(!1), [s, c] = H(null), l = L(() => o(!1), []);
3544
+ if (t.length < 1) return null;
3545
+ let u = t[t.length - 1]?.id, d = i("history.title"), f = /* @__PURE__ */ G("div", {
3546
+ className: "ecomid-search-history__menu",
3547
+ children: [/* @__PURE__ */ W("p", {
3548
+ className: "ecomid-search-history__title",
3549
+ children: d
3550
+ }), t.map((e) => /* @__PURE__ */ G("button", {
3551
+ type: "button",
3552
+ className: "ecomid-search-history__item",
3553
+ "data-autofocus": e.id === n ? "" : void 0,
3554
+ "aria-current": e.id === n ? "step" : void 0,
3555
+ onClick: () => {
3556
+ l(), r(e.id);
3557
+ },
3558
+ children: [/* @__PURE__ */ W("span", {
3559
+ className: "ecomid-search-history__label",
3560
+ children: e.label
3561
+ }), e.id === u && /* @__PURE__ */ W("span", {
3562
+ className: "ecomid-search-history__now",
3563
+ children: i("history.now")
3564
+ })]
3565
+ }, e.id))]
3566
+ });
3567
+ return /* @__PURE__ */ G("div", {
3568
+ className: "ecomid-search-history",
3569
+ children: [/* @__PURE__ */ W("button", {
3570
+ ref: c,
3571
+ type: "button",
3572
+ className: "ecomid-search-history__button",
3573
+ title: d,
3574
+ "aria-label": d,
3575
+ "aria-haspopup": "dialog",
3576
+ "aria-expanded": a,
3577
+ onClick: () => o((e) => !e),
3578
+ children: /* @__PURE__ */ W(jt, {
3579
+ className: "ecomid-search-icon",
3580
+ "aria-hidden": "true",
3581
+ focusable: "false"
3582
+ })
3583
+ }), a && /* @__PURE__ */ W(Lt, {
3584
+ kind: "popover",
3585
+ label: d,
3586
+ onClose: l,
3587
+ anchor: s,
3588
+ children: f
3589
+ })]
3590
+ });
3591
+ }
3592
+ // src/helpers/scrollState.ts
3593
+ function ui(e, t) {
3594
+ let n = !1, r, i = () => {
3595
+ n || (n = !0, e(!0)), clearTimeout(r), r = setTimeout(() => {
3596
+ n = !1, e(!1);
3597
+ }, t);
3598
+ };
3599
+ return window.addEventListener("scroll", i, { passive: !0 }), () => {
3600
+ clearTimeout(r), window.removeEventListener("scroll", i);
3601
+ };
3602
+ }
3603
+ // src/search/components/hooks/useScrolling.ts
3604
+ function di(e) {
3605
+ let [t, n] = H(!1);
3606
+ return z(() => ui(n, e), [e]), t;
3607
+ }
3608
+ // src/search/components/FloatingBar/index.tsx
3609
+ var fi = 200;
3610
+ function pi({ placeholder: e, sendLabel: t, followUps: n = [], onSend: r }) {
3611
+ let [i, a] = H(null), [o, s] = H(""), c = V(null), l = V(null), u = di(450);
3612
+ er(l, n.length > 0 && i !== null), z(() => {
3613
+ a(document.body);
3614
+ }, []);
3615
+ let d = () => {
3616
+ let e = c.current;
3617
+ e && (e.style.height = "0px", e.style.height = `${e.scrollHeight}px`);
3618
+ }, f = (e) => {
3619
+ let t = o.trim();
3620
+ t && (s(""), c.current && (c.current.style.height = ""), r(t), e?.reset());
3621
+ };
3622
+ return i ? K(/* @__PURE__ */ G("div", {
3623
+ className: "ecomid-search-bar-dock",
3624
+ children: [n.length > 0 && /* @__PURE__ */ W("div", {
3625
+ ref: l,
3626
+ className: "ecomid-search-bar__follow-ups",
3627
+ "data-scrolling": u || void 0,
3628
+ children: n.map((e) => /* @__PURE__ */ W("button", {
3629
+ type: "button",
3630
+ className: "ecomid-search-starters__pill",
3631
+ onClick: () => r(e),
3632
+ children: e
3633
+ }, e))
3634
+ }), /* @__PURE__ */ G("form", {
3635
+ className: "ecomid-search-bar",
3636
+ onSubmit: (e) => {
3637
+ e.preventDefault(), f(e.currentTarget);
3638
+ },
3639
+ children: [/* @__PURE__ */ W("textarea", {
3640
+ ref: c,
3641
+ className: "ecomid-search-bar__input",
3642
+ rows: 1,
3643
+ value: o,
3644
+ maxLength: fi,
3645
+ placeholder: e,
3646
+ "aria-label": e,
3647
+ enterkeyhint: "send",
3648
+ autoComplete: "off",
3649
+ onInput: (e) => {
3650
+ s(e.currentTarget.value), d();
3651
+ },
3652
+ onFocus: d,
3653
+ onBlur: (e) => {
3654
+ e.currentTarget.style.height = "";
3655
+ },
3656
+ onKeyDown: (e) => {
3657
+ e.key !== "Enter" || e.shiftKey || e.isComposing || (e.preventDefault(), e.repeat || f(e.currentTarget.form));
3658
+ }
3659
+ }), /* @__PURE__ */ W("button", {
3660
+ type: "submit",
3661
+ className: "ecomid-search-bar__send",
3662
+ title: t,
3663
+ "aria-label": t,
3664
+ disabled: !o.trim(),
3665
+ children: /* @__PURE__ */ W(ht, {})
3666
+ })]
3667
+ })]
3668
+ }), i) : null;
3669
+ }
3670
+ // src/search/components/RevealText/index.tsx
3671
+ function mi({ text: e, className: t, animate: n = !0 }) {
3672
+ let r = V([]), i = V(0);
3673
+ if (!n) return /* @__PURE__ */ W("p", {
3674
+ className: t,
3675
+ children: e
3676
+ });
3677
+ let a = i.current, o = 0, s = e.split(/(\s+)/).map((e) => {
3678
+ if (e === "" || /^\s+$/.test(e)) return e;
3679
+ let t = o;
3680
+ return o += 1, r.current[t] ??= ln(Math.max(t - a, 0), a === 0), /* @__PURE__ */ W("span", {
3681
+ className: "ecomid-search-reveal-word",
3682
+ style: { animationDelay: `${r.current[t]}ms` },
3683
+ children: e
3684
+ }, t);
3685
+ });
3686
+ return i.current = o, /* @__PURE__ */ W("p", {
3687
+ className: t,
3688
+ children: s
3689
+ });
3690
+ }
3691
+ // src/search/components/ComposedPage/index.tsx
3692
+ function hi({ variant: e, count: t, delay: n }) {
3693
+ let [r, i] = H(!1);
3694
+ return r ? null : /* @__PURE__ */ W("div", {
3695
+ className: "ecomid-search-compose__handoff",
3696
+ style: { animationDelay: `${n}ms` },
3697
+ "aria-hidden": "true",
3698
+ onAnimationEnd: (e) => {
3699
+ e.target === e.currentTarget && i(!0);
3700
+ },
3701
+ children: /* @__PURE__ */ W(Pn, {
3702
+ variant: e,
3703
+ count: t
3704
+ })
3705
+ });
3706
+ }
3707
+ var gi = ["min(560px, 92%)", "min(400px, 70%)"];
3708
+ function _i(e) {
3709
+ return !!e && (e.terms.length > 0 || e.excludedTerms.length > 0 || e.filters.length > 0);
3710
+ }
3711
+ function vi({ page: e, turnState: t, query: n, lang: r, market: i, store: a, onApply: o }) {
3712
+ let s = B(() => {
3713
+ let a = e.order.flatMap((t) => e.sections[t]?.products ?? []), o = e.facets ?? [], s = Object.entries(h(t.filters)).filter((e) => Array.isArray(e[1]) && !o.some((t) => t.key === e[0])).map(([e, n]) => {
3714
+ let r = t.filters.find((t) => t.key === e);
3715
+ return {
3716
+ key: e,
3717
+ values: n.map((e) => ({
3718
+ value: e,
3719
+ label: r?.labels?.[r.values.indexOf(e)] ?? M(e),
3720
+ available: !0
3721
+ }))
3722
+ };
3723
+ });
3724
+ return C({
3725
+ products: a,
3726
+ total: a.length
3727
+ }, {
3728
+ query: n,
3729
+ lang: r,
3730
+ market: i
3731
+ }, {
3732
+ state: t,
3733
+ facets: [...o, ...s]
3734
+ });
3735
+ }, [
3736
+ e,
3737
+ t,
3738
+ n,
3739
+ r,
3740
+ i
3741
+ ]);
3742
+ return /* @__PURE__ */ W("div", {
3743
+ className: "ecomid-search-compose__filters",
3744
+ children: /* @__PURE__ */ W(oi, {
3745
+ lang: r,
3746
+ results: s,
3747
+ filters: h(t.filters),
3748
+ sort: S(t.sort),
3749
+ terms: t.terms,
3750
+ excludedTerms: t.excludedTerms,
3751
+ meta: !1,
3752
+ onRemoveTerm: (e) => o({
3753
+ ...t,
3754
+ terms: t.terms.filter((t) => t !== e)
3755
+ }),
3756
+ onRemoveExcludedTerm: (e) => o({
3757
+ ...t,
3758
+ excludedTerms: t.excludedTerms.filter((t) => t !== e)
3759
+ }),
3760
+ onFiltersChange: (e) => o(N(t, e)),
3761
+ onSortChange: (e) => o({
3762
+ ...t,
3763
+ sort: e
3764
+ }),
3765
+ count: (e, n) => a.count(e, n, t)
3766
+ })
3767
+ });
3768
+ }
3769
+ function yi({ turn: e, page: t, animate: n, loading: r, bubble: i, filters: a, headingLevel: o, lang: s, market: c, onSend: l, onProductClick: u, renderProduct: d, onRenderError: f }) {
3770
+ let p = ne(), { t: m } = Q(s), h = `h${o}`, g = `h${o + 1}`, _ = t.order.map((e) => t.sections[e]).filter((e) => !!e), v = _.find((e) => e.kind === "intro"), y = n, b = k(t), x = v?.text ?? "", S = Nt("(min-width: 768px)"), C = t.mode === "discovery" && S && !b, w = r && !b, T = w && (C || !x), E = V(null);
3771
+ E.current === null && !C && (x || b) && (E.current = performance.now());
3772
+ let D = V(/* @__PURE__ */ new Map()), O = V(/* @__PURE__ */ new Set()), A = (e, n) => {
3773
+ let r = D.current.get(e);
3774
+ if (r !== void 0) return r;
3775
+ let i = un(on(x, !!t.question)[n], E.current === null ? 0 : performance.now() - E.current);
3776
+ return D.current.set(e, i), i;
3777
+ }, j = (e, t) => ({ animationDelay: `${A(e, t)}ms` }), ee = t.failed ? t.error || m("results_error") : "", te = M(i), N = 0, P = /* @__PURE__ */ new Map();
3778
+ for (let e of _) P.set(e.id, N), N += e.products.length;
3779
+ let F = t.followUps.length > 0 && /* @__PURE__ */ G("div", {
3780
+ className: "ecomid-search-compose__follow-ups",
3781
+ children: [t.question && /* @__PURE__ */ W(g, {
3782
+ className: y ? "ecomid-search-compose__question ecomid-search-seq" : "ecomid-search-compose__question",
3783
+ style: y ? j("question", "question") : void 0,
3784
+ children: t.question
3785
+ }), /* @__PURE__ */ W("div", {
3786
+ className: y ? "ecomid-search-compose__chips ecomid-search-seq" : "ecomid-search-compose__chips",
3787
+ style: y ? j("chips", "chips") : void 0,
3788
+ children: t.followUps.map((e) => /* @__PURE__ */ W("button", {
3789
+ type: "button",
3790
+ className: "ecomid-search-starters__pill",
3791
+ onClick: () => l(e),
3792
+ children: e
3793
+ }, e))
3794
+ })]
3795
+ }, "follow-ups"), I = (e, n = 0) => {
3796
+ if (e.kind === "intro") return C ? null : /* @__PURE__ */ W("div", {
3797
+ className: t.mode === "discovery" ? "ecomid-search-compose__intro ecomid-search-compose__intro--discovery" : "ecomid-search-compose__intro",
3798
+ children: e.text && /* @__PURE__ */ W(mi, {
3799
+ className: "ecomid-search-compose__text",
3800
+ text: e.text,
3801
+ animate: y
3802
+ })
3803
+ }, e.id);
3804
+ let r = `${p}-section-${e.id}`, i = P.get(e.id) ?? 0, a = e.products.length, o = (e, t) => u(e, i + t), l = d && ((e, t) => d(e, {
3805
+ ...t,
3806
+ position: i + t.position
3807
+ })), h = e.kind === "picks" ? "picks" : "wide", _ = e.kind === "picks" ? "picks" : "browse", v = `section:${e.id}`;
3808
+ e.pending && O.current.add(e.id);
3809
+ let b = !e.pending && O.current.has(e.id), x = b ? A(`content:${e.id}`, _) : void 0, S = y ? {
3810
+ section: n,
3811
+ base: x
3812
+ } : void 0;
3813
+ return /* @__PURE__ */ G("section", {
3814
+ className: [
3815
+ "ecomid-search-section",
3816
+ "ecomid-search-compose__section",
3817
+ `ecomid-search-compose__section--${e.kind}`,
3818
+ y && "ecomid-search-seq"
3819
+ ].filter(Boolean).join(" "),
3820
+ style: y ? j(v, _) : void 0,
3821
+ "aria-labelledby": e.title ? r : void 0,
3822
+ "aria-busy": e.pending,
3823
+ children: [
3824
+ (e.title || !e.pending && a > 0) && /* @__PURE__ */ G("div", {
3825
+ className: "ecomid-search-compose__section-header",
3826
+ children: [e.title && /* @__PURE__ */ W(g, {
3827
+ id: r,
3828
+ className: "ecomid-search-compose__section-title",
3829
+ children: e.title
3830
+ }), !e.pending && a > 0 && /* @__PURE__ */ W("span", {
3831
+ className: "ecomid-search-compose__count",
3832
+ children: m(a === 1 ? "results_count.singular" : "results_count.plural", { count: String(a) })
3833
+ })]
3834
+ }),
3835
+ e.pending && /* @__PURE__ */ W(Pn, {
3836
+ variant: h,
3837
+ count: e.kind === "grid" ? 5 : 4
3838
+ }),
3839
+ !e.pending && a > 0 && /* @__PURE__ */ G("div", {
3840
+ className: "ecomid-search-compose__content",
3841
+ children: [b && y && /* @__PURE__ */ W(hi, {
3842
+ variant: h,
3843
+ count: e.kind === "grid" ? 5 : 4,
3844
+ delay: (x ?? 0) + sn(n, 0)
3845
+ }), e.kind === "carousel" ? /* @__PURE__ */ W(jn, {
3846
+ products: e.products,
3847
+ lang: s,
3848
+ market: c,
3849
+ previousLabel: m("actions.previous"),
3850
+ nextLabel: m("actions.next"),
3851
+ onProductClick: o,
3852
+ renderProduct: l,
3853
+ reveal: S,
3854
+ onRenderError: f
3855
+ }) : /* @__PURE__ */ W(Dn, {
3856
+ products: e.products,
3857
+ lang: s,
3858
+ market: c,
3859
+ variant: h,
3860
+ reveal: S,
3861
+ onProductClick: o,
3862
+ renderProduct: l,
3863
+ onRenderError: f
3864
+ })]
3865
+ })
3866
+ ]
3867
+ }, e.id);
3868
+ }, L = v ? I(v) : null, R = b ? _.filter((e) => e !== v).map((e, t) => I(e, t)) : [];
3869
+ return /* @__PURE__ */ G("div", {
3870
+ className: [
3871
+ "ecomid-search-compose__turn",
3872
+ a && "ecomid-search-compose__turn--filtered",
3873
+ y && "ecomid-search-up"
3874
+ ].filter(Boolean).join(" "),
3875
+ "data-turn": e.id,
3876
+ children: [
3877
+ t.mode === "discovery" && /* @__PURE__ */ G("div", {
3878
+ className: "ecomid-search-compose__lead ecomid-search-compose__lead--discovery",
3879
+ children: [/* @__PURE__ */ G("div", {
3880
+ className: "ecomid-search-compose__answer ecomid-search-compose__answer--discovery",
3881
+ children: [/* @__PURE__ */ W(h, {
3882
+ className: "ecomid-search-compose__title",
3883
+ children: te
3884
+ }), T ? /* @__PURE__ */ W(Ln, {
3885
+ className: "ecomid-search-compose__intro ecomid-search-compose__intro--discovery ecomid-search-compose__text",
3886
+ widths: gi
3887
+ }) : L]
3888
+ }), a]
3889
+ }),
3890
+ t.mode === "conversation" && /* @__PURE__ */ G("div", {
3891
+ className: "ecomid-search-compose__lead ecomid-search-compose__lead--conversation",
3892
+ children: [
3893
+ /* @__PURE__ */ G("div", {
3894
+ className: "ecomid-search-compose__answer",
3895
+ children: [/* @__PURE__ */ W("div", {
3896
+ className: "ecomid-search-compose__thread",
3897
+ children: /* @__PURE__ */ W("div", {
3898
+ className: "ecomid-search-compose__bubble-row",
3899
+ children: /* @__PURE__ */ W(h, {
3900
+ className: "ecomid-search-compose__bubble",
3901
+ children: i
3902
+ })
3903
+ })
3904
+ }), T ? /* @__PURE__ */ W(Ln, {
3905
+ className: "ecomid-search-compose__intro ecomid-search-compose__text",
3906
+ widths: gi
3907
+ }) : L]
3908
+ }),
3909
+ F,
3910
+ a
3911
+ ]
3912
+ }),
3913
+ R.length > 0 && /* @__PURE__ */ W("div", {
3914
+ className: "ecomid-search-compose__sections",
3915
+ children: R
3916
+ }),
3917
+ w && t.mode === "discovery" && /* @__PURE__ */ W("div", {
3918
+ className: "ecomid-search-compose__sections",
3919
+ children: /* @__PURE__ */ W(Bn, {})
3920
+ }),
3921
+ b && ee && /* @__PURE__ */ W("p", {
3922
+ className: "ecomid-search-compose__error",
3923
+ children: ee
3924
+ })
3925
+ ]
3926
+ });
3927
+ }
3928
+ function bi({ store: e, lang: t, market: n, headingLevel: r, onNewSearch: i, onPersonalize: a, onProductClick: o, renderProduct: s, onRenderError: c }) {
3929
+ let { t: l } = Q(t), [u, d] = H(null), f = V(null), p = ve(e.subscribe, e.getState, e.getState), m = p.turns[p.turns.length - 1], h = u ?? m?.id ?? 0, _ = p.turns.find((e) => e.id === h) ?? m, v = p.status === "loading" && u === null, y = _ && p.archive[_.id] || (_?.id === m?.id ? p.page : void 0) || p.page, b = V(u);
3930
+ re(() => {
3931
+ if (b.current === u) return;
3932
+ b.current = u;
3933
+ let e = f.current;
3934
+ e && e.getBoundingClientRect().top < 0 && e.scrollIntoView({
3935
+ block: "start",
3936
+ behavior: "instant"
3937
+ });
3938
+ }, [u]);
3939
+ let x = (t) => {
3940
+ d(null), e.send(t);
3941
+ }, S = (t) => {
3942
+ d(null), e.applyState(t);
3943
+ }, C = y.failed ? y.error || l("results_error") : "", w = y.sections[y.order.find((e) => y.sections[e]?.kind === "intro") ?? ""], T = C || (y.completed ? w?.text ?? "" : ""), E = p.turns.filter((e) => {
3944
+ let t = p.archive[e.id];
3945
+ return !!t && g(t);
3946
+ }).map((e) => ({
3947
+ id: e.id,
3948
+ label: e.text
3949
+ })), D = p.turns.length > 1 && E.length > 0;
3950
+ return /* @__PURE__ */ W(zt.Provider, {
3951
+ value: x,
3952
+ children: /* @__PURE__ */ G("div", {
3953
+ ref: f,
3954
+ className: "ecomid-search-compose",
3955
+ "aria-busy": v,
3956
+ children: [
3957
+ /* @__PURE__ */ W(br, {
3958
+ lang: t,
3959
+ onNewSearch: i,
3960
+ onPersonalize: a,
3961
+ history: D ? /* @__PURE__ */ W(li, {
3962
+ lang: t,
3963
+ steps: E,
3964
+ activeId: h,
3965
+ onSelect: (e) => d(e === E[E.length - 1]?.id ? null : e)
3966
+ }) : void 0
3967
+ }),
3968
+ _ && /* @__PURE__ */ W(yi, {
3969
+ turn: _,
3970
+ page: y,
3971
+ animate: u === null,
3972
+ loading: u === null && !y.completed,
3973
+ bubble: _.text,
3974
+ filters: y.state && _i(y.state) ? /* @__PURE__ */ W(vi, {
3975
+ page: y,
3976
+ turnState: y.state,
3977
+ query: _.text,
3978
+ lang: t,
3979
+ market: n,
3980
+ store: e,
3981
+ onApply: S
3982
+ }) : void 0,
3983
+ headingLevel: r,
3984
+ lang: t,
3985
+ market: n,
3986
+ onSend: x,
3987
+ onProductClick: o,
3988
+ renderProduct: s,
3989
+ onRenderError: c
3990
+ }, _.id),
3991
+ y.completed && /* @__PURE__ */ W("div", {
3992
+ className: "ecomid-search-footer",
3993
+ children: /* @__PURE__ */ W(et, {})
3994
+ }),
3995
+ /* @__PURE__ */ W("p", {
3996
+ role: "status",
3997
+ className: "ecomid-search-sr-only",
3998
+ children: T
3999
+ }),
4000
+ /* @__PURE__ */ W(pi, {
4001
+ placeholder: l("compose.placeholder"),
4002
+ sendLabel: l("compose.send"),
4003
+ followUps: y.mode === "discovery" ? y.followUps : [],
4004
+ onSend: x
4005
+ })
4006
+ ]
4007
+ })
4008
+ });
4009
+ }
4010
+ // src/search/components/EmptyResults/index.tsx
4011
+ var xi = 12, Si = 4;
4012
+ function Ci({ clientId: e, lang: n, market: r, baseUrl: i, query: a, filtered: o, headingLevel: s, titleId: c, onSearch: l, onProductClick: u, renderProduct: d, onRenderError: f }) {
4013
+ let { t: p } = Q(n), [m, h] = H(null), g = `h${s}`, _ = `h${Math.min(s + 1, 6)}`;
4014
+ z(() => {
4015
+ if (o) return;
4016
+ let a = !1;
4017
+ return t(e, {
4018
+ lang: n,
4019
+ market: r,
4020
+ baseUrl: i
4021
+ }).then((e) => {
4022
+ a || h(e);
4023
+ }, () => {}), () => {
4024
+ a = !0;
4025
+ };
4026
+ }, [
4027
+ o,
4028
+ e,
4029
+ n,
4030
+ r,
4031
+ i
4032
+ ]);
4033
+ let v = (m?.recommendedProducts ?? []).slice(0, xi);
4034
+ return o ? /* @__PURE__ */ G("div", {
4035
+ className: "ecomid-search-empty",
4036
+ children: [/* @__PURE__ */ W(g, {
4037
+ id: c,
4038
+ className: "ecomid-search-empty__title",
4039
+ children: p("empty.filtered_title")
4040
+ }), /* @__PURE__ */ W("p", {
4041
+ className: "ecomid-search-empty__hint",
4042
+ children: p("empty.filtered_hint")
4043
+ })]
4044
+ }) : /* @__PURE__ */ G("div", {
4045
+ className: "ecomid-search-empty",
4046
+ children: [
4047
+ /* @__PURE__ */ W(g, {
4048
+ id: c,
4049
+ className: "ecomid-search-empty__title",
4050
+ children: p("empty.title", { query: a })
4051
+ }),
4052
+ /* @__PURE__ */ W("p", {
4053
+ className: "ecomid-search-empty__hint",
4054
+ children: p("empty.hint")
4055
+ }),
4056
+ m && m.starters.length > 0 && /* @__PURE__ */ W("div", {
4057
+ className: "ecomid-search-empty__pills",
4058
+ children: /* @__PURE__ */ W(tr, {
4059
+ starters: m.starters.slice(0, Si),
4060
+ onSelect: l
4061
+ })
4062
+ }),
4063
+ v.length > 0 && /* @__PURE__ */ G("section", {
4064
+ className: "ecomid-search-section ecomid-search-empty__section",
4065
+ children: [/* @__PURE__ */ G("div", {
4066
+ className: "ecomid-search-compose__section-header",
4067
+ children: [/* @__PURE__ */ W(_, {
4068
+ className: "ecomid-search-compose__section-title",
4069
+ children: p("empty.popular")
4070
+ }), /* @__PURE__ */ W("span", {
4071
+ className: "ecomid-search-compose__count",
4072
+ children: p(v.length === 1 ? "results_count.singular" : "results_count.plural", { count: String(v.length) })
4073
+ })]
4074
+ }), /* @__PURE__ */ W(jn, {
4075
+ products: v,
4076
+ lang: n,
4077
+ market: r,
4078
+ previousLabel: p("actions.previous"),
4079
+ nextLabel: p("actions.next"),
4080
+ onProductClick: u,
4081
+ renderProduct: d,
4082
+ onRenderError: f
4083
+ })]
4084
+ })
4085
+ ]
4086
+ });
4087
+ }
4088
+ // src/search/components/LoadingDots/index.tsx
4089
+ function wi({ className: e }) {
4090
+ return /* @__PURE__ */ G("span", {
4091
+ className: e ? `ecomid-search-loading-more ${e}` : "ecomid-search-loading-more",
4092
+ "aria-hidden": "true",
4093
+ children: [
4094
+ /* @__PURE__ */ W("span", { className: "ecomid-search-loading-more__dot" }),
4095
+ /* @__PURE__ */ W("span", {
4096
+ className: "ecomid-search-loading-more__dot",
4097
+ style: { animationDelay: "0.15s" }
4098
+ }),
4099
+ /* @__PURE__ */ W("span", {
4100
+ className: "ecomid-search-loading-more__dot",
4101
+ style: { animationDelay: "0.3s" }
4102
+ })
4103
+ ]
4104
+ });
4105
+ }
4106
+ // src/search/components/StartView/index.tsx
4107
+ function Ti({ clientId: e, lang: t, market: n, baseUrl: r, headingLevel: i, track: a, onClose: o, onSubmit: s, onProductClick: c, renderProduct: l, onRenderError: u }) {
4108
+ let { t: d } = Q(t), p = V(null), m = B(() => f({
4109
+ clientId: e,
4110
+ market: n,
4111
+ lang: t,
4112
+ baseUrl: r
4113
+ }), [
4114
+ e,
4115
+ n,
4116
+ t,
4117
+ r
4118
+ ]), h = `h${i}`;
4119
+ z(() => () => m.destroy(), [m]), z(() => {
4120
+ window.scrollTo?.({ top: 0 }), p.current?.querySelector(".ecomid-search-panel__input")?.focus({ preventScroll: !0 });
4121
+ }, []);
4122
+ let g = yr({
4123
+ clientId: e,
4124
+ lang: t,
4125
+ market: n
4126
+ });
4127
+ return /* @__PURE__ */ G("div", {
4128
+ ref: p,
4129
+ className: "ecomid-search-start",
4130
+ children: [
4131
+ /* @__PURE__ */ W(Et, {
4132
+ lang: t,
4133
+ onClose: o,
4134
+ onPersonalize: g
4135
+ }),
4136
+ /* @__PURE__ */ W(h, {
4137
+ className: "ecomid-search-start__title",
4138
+ children: d("placeholder")
4139
+ }),
4140
+ /* @__PURE__ */ W("div", {
4141
+ className: "ecomid-search-start__panel",
4142
+ children: /* @__PURE__ */ W(lr, {
4143
+ store: m,
4144
+ track: a,
4145
+ onSubmit: s,
4146
+ onProductClick: c,
4147
+ renderProduct: l,
4148
+ onRenderError: u,
4149
+ lang: t,
4150
+ market: n,
4151
+ showCount: !0,
4152
+ floatingSuggestions: !0
4153
+ })
4154
+ }),
4155
+ /* @__PURE__ */ W("div", {
4156
+ className: "ecomid-search-footer",
4157
+ children: /* @__PURE__ */ W(et, {})
4158
+ })
4159
+ ]
4160
+ });
4161
+ }
4162
+ // src/search/components/SearchResults/index.tsx
4163
+ function Ei({ query: e, lang: t, market: n, limit: r, page: i }) {
4164
+ return `query ${JSON.stringify(e)} lang ${JSON.stringify(t)} market ${JSON.stringify(n)} limit ${JSON.stringify(r)} page ${JSON.stringify(i)}`;
4165
+ }
4166
+ function Di({ clientId: e, lang: t, market: i, baseUrl: a, query: o = "", page: s, onPageChange: c, initialResults: u, limit: d, headingLevel: f = 1, onProductClick: m, renderProduct: h }) {
4167
+ let g = ne(), _ = me(), v = _e(), { t: y } = Q(t), { track: b, onRenderError: x } = Pe({
4168
+ clientId: e,
4169
+ lang: t,
4170
+ market: i
4171
+ }), S = yr({
4172
+ clientId: e,
4173
+ lang: t,
4174
+ market: i
4175
+ }), C = V(o);
4176
+ C.current = o;
4177
+ let w = V(u);
4178
+ w.current = u;
4179
+ let T = V(s);
4180
+ T.current = s;
4181
+ let E = B(() => {
4182
+ let e = s == null ? null : p(s);
4183
+ return e ? r(e) : null;
4184
+ }, [s]), D = B(() => {
4185
+ let n = w.current, o = T.current == null ? null : p(T.current);
4186
+ return {
4187
+ seed: n,
4188
+ expected: {
4189
+ query: o ? l(o) : C.current.trim(),
4190
+ lang: t,
4191
+ market: i,
4192
+ limit: d,
4193
+ page: o ? r(o) : void 0
4194
+ },
4195
+ store: j({
4196
+ clientId: e,
4197
+ market: i,
4198
+ lang: t,
4199
+ baseUrl: a,
4200
+ limit: d,
4201
+ page: T.current,
4202
+ query: C.current,
4203
+ initialResults: n
4204
+ })
4205
+ };
4206
+ }, [
4207
+ e,
4208
+ i,
4209
+ t,
4210
+ a,
4211
+ d
4212
+ ]), { store: k } = D;
4213
+ z(() => () => k.destroy(), [k]);
4214
+ let te = V(E ? {
4215
+ store: k,
4216
+ query: o
4217
+ } : null);
4218
+ z(() => {
4219
+ let e = te.current;
4220
+ te.current = {
4221
+ store: k,
4222
+ query: o
4223
+ }, (e?.store !== k || e.query !== o) && k.setQuery(o, w.current), k.load();
4224
+ }, [k, o]);
4225
+ let N = V(E !== null), P = V(E);
4226
+ z(() => {
4227
+ (E !== null || N.current) && (N.current = E !== null, P.current = E, k.setPage(T.current ?? null, w.current));
4228
+ }, [k, E]);
4229
+ let F = V(D), I = V(!1);
4230
+ z(() => {
4231
+ if (D !== F.current || I.current) return;
4232
+ let { seed: e, expected: t } = D;
4233
+ e && !O(e, t) && (I.current = !0, _(/* @__PURE__ */ Error(`Search initialResults ignored: expected ${Ei(t)}, received ${Ei(e)}`)));
4234
+ }, [D, _]);
4235
+ let R = ve(k.subscribe, k.getState, k.getState), ie = V(c);
4236
+ ie.current = c, z(() => {
4237
+ let e = k.getPage();
4238
+ if (!e) {
4239
+ R.status === "idle" && (P.current = null);
4240
+ return;
4241
+ }
4242
+ let t = r(e);
4243
+ t !== P.current && (P.current = t, v(() => ie.current?.(n(e))));
4244
+ }, [
4245
+ k,
4246
+ R,
4247
+ v
4248
+ ]), z(() => {
4249
+ R.status === "error" && R.error && _(R.error);
4250
+ }, [
4251
+ R.status,
4252
+ R.error,
4253
+ _
4254
+ ]), z(() => {
4255
+ R.moreError && _(R.moreError);
4256
+ }, [R.moreError, _]);
4257
+ let U = V(m);
4258
+ U.current = m;
4259
+ let K = V({
4260
+ contextId: R.contextId,
4261
+ turn: R.turnNumber
4262
+ });
4263
+ K.current = {
4264
+ contextId: R.contextId,
4265
+ turn: R.turnNumber
4266
+ };
4267
+ let q = L((e, t) => (n) => {
4268
+ let { contextId: r, turn: i } = K.current;
4269
+ b(X.PRODUCT_CLICK, { attrs: {
4270
+ variant_id: e.id,
4271
+ name: e.name,
4272
+ url: e.url,
4273
+ position: String(t),
4274
+ ...r && { context_id: r },
4275
+ ...i !== void 0 && { turn: String(i) }
4276
+ } }), v(() => U.current?.(e, n));
4277
+ }, [b, v]), ae = L((e) => {
4278
+ b(X.PRE_PROMPT_CLICK, { attrs: { text: e } }), k.setQuery(e);
4279
+ }, [b, k]), oe = R.pending, [se, J] = H(!1), [ce, le] = H(!1), ue = L(() => {
4280
+ le(!1), J(!0);
4281
+ }, []), de = L((e) => {
4282
+ le(!0), k.setQuery(e);
4283
+ }, [k]), fe = R.status === "loading", pe = fe && R.mode !== void 0, he = se && !(ce && (!fe || pe));
4284
+ z(() => {
4285
+ se && !he && (J(!1), le(!1));
4286
+ }, [se, he]);
4287
+ let Y = R.results, ge = R.surface === "compose", ye = R.turns[R.turns.length - 1]?.id ?? 0, be = (Y?.sections?.length ? Y.sections : [{ products: Y?.products ?? [] }]).filter((e) => e.products.length > 0).map((e, t, n) => ({
4288
+ ...e,
4289
+ key: `${e.title ?? ""}:${e.products[0]?.id}`,
4290
+ offset: n.slice(0, t).reduce((e, t) => e + t.products.length, 0)
4291
+ })), Z = be.reduce((e, t) => e + t.products.length, 0), xe = Math.max(Y?.total ?? 0, Z), Se = !!Y?.nextPageToken, Ce = !!Y && !!R.query && (Z > 0 || ee(R.filters) > 0 || !A(R.sort)), we = R.status === "success", Te = R.status === "loading", Ee = R.status === "error", De = we && Z === 0, Oe = Ee ? y("results_error") : De ? y("no_results") : we ? y(xe === 1 ? "results_status.title_singular" : "results_status.title_plural", {
4292
+ count: String(xe),
4293
+ query: R.query
4294
+ }) : "", ke = V(null), Ae = V(oe);
4295
+ re(() => {
4296
+ let e = Ae.current;
4297
+ if (Ae.current = oe, e !== "results" || oe === "results") return;
4298
+ let t = ke.current;
4299
+ t && t.getBoundingClientRect().top < 0 && t.scrollIntoView({
4300
+ block: "start",
4301
+ behavior: "instant"
4302
+ });
4303
+ }, [oe]);
4304
+ let je = V(null), Me = R.loadingMore;
4305
+ z(() => {
4306
+ let e = je.current;
4307
+ if (!Se || Z === 0 || !e || typeof IntersectionObserver > "u") return;
4308
+ let t = new IntersectionObserver((e) => {
4309
+ e.some((e) => e.isIntersecting) && k.loadMore();
4310
+ }, { rootMargin: "0px 0px 600px 0px" });
4311
+ return t.observe(e), () => t.disconnect();
4312
+ }, [
4313
+ k,
4314
+ Se,
4315
+ Z
4316
+ ]);
4317
+ let Ne = V({
4318
+ run: ye,
4319
+ count: 0
4320
+ });
4321
+ Ne.current.run !== ye && (Ne.current = {
4322
+ run: ye,
4323
+ count: 0
4324
+ });
4325
+ let Fe = Ne.current.count;
4326
+ z(() => {
4327
+ Ne.current.count = Z;
4328
+ });
4329
+ let Ie = !!Y && !!R.query, Le = De && ee(R.filters) > 0, Re = oe === "grid", ze = Y && (!De || Le) ? M(Y.title ?? R.title) : Re ? M(R.title) : "", Be = R.turns.filter((e) => !!R.gridArchive[e.id]).map((e) => ({
4330
+ id: e.id,
4331
+ label: e.text
4332
+ })), Ve = R.turns.length > 1 && Be.length > 0, He = /* @__PURE__ */ W(br, {
4333
+ lang: t,
4334
+ onNewSearch: ue,
4335
+ onPersonalize: S,
4336
+ history: Ve ? /* @__PURE__ */ W(li, {
4337
+ lang: t,
4338
+ steps: Be,
4339
+ activeId: R.activeTurn,
4340
+ onSelect: k.jumpTo
4341
+ }) : void 0
4342
+ }), Ue = `h${f}`, We = `h${ze ? f + 1 : f}`, Ge = `${g}-title`;
4343
+ return he ? /* @__PURE__ */ W("section", {
4344
+ ref: ke,
4345
+ className: "ecomid-search-results ecomid-search-results--start",
4346
+ children: /* @__PURE__ */ W(Ti, {
4347
+ clientId: e,
4348
+ lang: t,
4349
+ market: i,
4350
+ baseUrl: a,
4351
+ headingLevel: f,
4352
+ track: b,
4353
+ onClose: () => J(!1),
4354
+ onSubmit: de,
4355
+ onProductClick: m,
4356
+ renderProduct: h,
4357
+ onRenderError: x
4358
+ })
4359
+ }) : ge ? /* @__PURE__ */ G("section", {
4360
+ ref: ke,
4361
+ className: "ecomid-search-results ecomid-search-results--compose ecomid-search-results--bar",
4362
+ children: [/* @__PURE__ */ W(bi, {
4363
+ store: k,
4364
+ lang: t,
4365
+ market: i,
4366
+ headingLevel: f,
4367
+ onNewSearch: ue,
4368
+ onPersonalize: S,
4369
+ onProductClick: q,
4370
+ renderProduct: h,
4371
+ onRenderError: x
4372
+ }), /* @__PURE__ */ W(ci, { lang: t })]
4373
+ }) : /* @__PURE__ */ W(zt.Provider, {
4374
+ value: k.send,
4375
+ children: /* @__PURE__ */ G("section", {
4376
+ ref: ke,
4377
+ className: Ie ? "ecomid-search-results ecomid-search-results--bar" : "ecomid-search-results",
4378
+ "aria-busy": Te || Me,
4379
+ "aria-labelledby": ze || De ? Ge : void 0,
4380
+ children: [
4381
+ He,
4382
+ (ze || Ce || Re) && /* @__PURE__ */ G("div", {
4383
+ className: "ecomid-search-results__header ecomid-search-page-enter",
4384
+ children: [
4385
+ ze && /* @__PURE__ */ W(Ue, {
4386
+ id: Ge,
4387
+ className: "ecomid-search-results__title",
4388
+ children: ze
4389
+ }),
4390
+ Y && Ce && /* @__PURE__ */ W(oi, {
4391
+ lang: t,
4392
+ results: Y,
4393
+ filters: R.filters,
4394
+ sort: R.sort,
4395
+ terms: Y.state?.terms ?? [],
4396
+ excludedTerms: Y.state?.excludedTerms ?? [],
4397
+ onRemoveTerm: k.removeTerm,
4398
+ onRemoveExcludedTerm: k.removeExcludedTerm,
4399
+ onFiltersChange: k.setFilters,
4400
+ onSortChange: k.setSort,
4401
+ count: k.count
4402
+ }),
4403
+ Re && /* @__PURE__ */ W(zn, {})
4404
+ ]
4405
+ }, `${ye}:header`),
4406
+ Re && /* @__PURE__ */ W("div", {
4407
+ className: "ecomid-search-section",
4408
+ children: /* @__PURE__ */ W(Pn, {
4409
+ variant: "results",
4410
+ count: 20
4411
+ })
4412
+ }),
4413
+ Y?.description && /* @__PURE__ */ W("p", {
4414
+ className: "ecomid-search-results__description",
4415
+ children: Y.description
4416
+ }),
4417
+ Ee && /* @__PURE__ */ W("p", {
4418
+ className: "ecomid-search-no-results",
4419
+ children: y("results_error")
4420
+ }),
4421
+ De && /* @__PURE__ */ W(Ci, {
4422
+ clientId: e,
4423
+ lang: t,
4424
+ market: i,
4425
+ baseUrl: a,
4426
+ query: R.query,
4427
+ filtered: Le,
4428
+ headingLevel: Le ? f + 1 : f,
4429
+ titleId: Le ? `${g}-empty-title` : Ge,
4430
+ onSearch: ae,
4431
+ onProductClick: q,
4432
+ renderProduct: h,
4433
+ onRenderError: x
4434
+ }),
4435
+ be.map((e, n) => {
4436
+ let r = `${g}-section-${n}`;
4437
+ return /* @__PURE__ */ G("section", {
4438
+ className: "ecomid-search-section ecomid-search-page-enter",
4439
+ "aria-labelledby": e.title ? r : void 0,
4440
+ children: [e.title && /* @__PURE__ */ W(We, {
4441
+ id: r,
4442
+ className: "ecomid-search-section__heading",
4443
+ children: e.title
4444
+ }), /* @__PURE__ */ W(Dn, {
4445
+ products: e.products,
4446
+ lang: t,
4447
+ market: i,
4448
+ variant: "results",
4449
+ reveal: {
4450
+ section: n,
4451
+ from: Math.max(Fe - e.offset, 0)
4452
+ },
4453
+ onProductClick: (t, n) => q(t, e.offset + n),
4454
+ renderProduct: h && ((t, n) => h(t, {
4455
+ ...n,
4456
+ position: e.offset + n.position
4457
+ })),
4458
+ onRenderError: x
4459
+ })]
4460
+ }, `${ye}:${e.key}`);
4461
+ }),
4462
+ Me && /* @__PURE__ */ W(wi, {}),
4463
+ Se && /* @__PURE__ */ W("div", {
4464
+ ref: je,
4465
+ className: "ecomid-search-results__sentinel",
4466
+ "aria-hidden": "true"
4467
+ }),
4468
+ /* @__PURE__ */ W("div", {
4469
+ className: "ecomid-search-footer",
4470
+ children: /* @__PURE__ */ W(et, {})
4471
+ }),
4472
+ /* @__PURE__ */ W("p", {
4473
+ role: "status",
4474
+ className: "ecomid-search-sr-only",
4475
+ children: Oe
4476
+ }),
4477
+ /* @__PURE__ */ W(ci, { lang: t }),
4478
+ Ie && /* @__PURE__ */ W(pi, {
4479
+ placeholder: y("bar.describe_placeholder"),
4480
+ sendLabel: y("compose.send"),
4481
+ followUps: R.followUps,
4482
+ onSend: k.send
4483
+ })
4484
+ ]
4485
+ })
4486
+ });
4487
+ }
4488
+ function Oi(e) {
4489
+ return /* @__PURE__ */ W(he, { children: /* @__PURE__ */ W(Di, { ...e }) });
4490
+ }
4491
+ // src/search/react/SearchResults.tsx
4492
+ function ki({ clientId: e, locale: t, environment: n, ...r }) {
4493
+ let i = fe({
4494
+ clientId: e,
4495
+ locale: t,
4496
+ environment: n,
4497
+ active: !0
4498
+ });
4499
+ return /* @__PURE__ */ W(pe.Provider, {
4500
+ value: i.report,
4501
+ children: /* @__PURE__ */ W(ge, {
4502
+ clientId: i.clientId,
4503
+ locale: i.locale,
4504
+ children: (e) => /* @__PURE__ */ W(Oi, {
4505
+ ...r,
4506
+ clientId: e.clientId,
4507
+ lang: e.lang,
4508
+ market: e.market,
4509
+ baseUrl: i.urls.cgw
4510
+ })
4511
+ })
4512
+ });
4513
+ }
4514
+ // src/search/react/index.ts
4515
+ le();
4516
+ // src/react/EcomidProvider.tsx
4517
+ function Ai({ clientId: e, locale: t, environment: n = "production", children: r }) {
4518
+ let i = B(() => ({
4519
+ clientId: e,
4520
+ locale: t,
4521
+ environment: n
4522
+ }), [
4523
+ e,
4524
+ t,
4525
+ n
4526
+ ]);
4527
+ return /* @__PURE__ */ W(ue.Provider, {
4528
+ value: i,
4529
+ children: r
4530
+ });
4531
+ }
4532
+ export { Ai as EcomidProvider, vr as SearchModal, ki as SearchResults };