@nuskin/react-search-components 1.0.0-comx-3067.7 → 1.0.0-widget-integration.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/index.d.mts +90 -163
- package/dist/index.d.ts +90 -163
- package/dist/index.js +419 -1375
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +419 -1367
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -11
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import React, { useState, useEffect, useId, useRef
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useEffect, useId, useRef } from 'react';
|
|
2
|
+
import styled4 from '@emotion/styled';
|
|
3
3
|
import { nuskinTheme } from '@nuskin/foundation-theme';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { createPortal } from 'react-dom';
|
|
8
|
-
import { ProductCarousel, PRODUCT_CAROUSEL_ERROR_CODES } from '@nuskin/react-product-components';
|
|
9
|
-
import { getStack } from '@ns/ns-contentstack-lib';
|
|
10
|
-
import { keyframes } from '@emotion/react';
|
|
5
|
+
import { NsIcon } from '@nuskin/foundation-ui-components';
|
|
6
|
+
import { Modal } from '@mui/material';
|
|
11
7
|
|
|
12
8
|
var __create = Object.create;
|
|
13
9
|
var __defProp = Object.defineProperty;
|
|
@@ -407,7 +403,7 @@ var require_checkPropTypes = __commonJS({
|
|
|
407
403
|
var ReactPropTypesSecret;
|
|
408
404
|
var loggedTypeFailures;
|
|
409
405
|
var has;
|
|
410
|
-
function checkPropTypes(typeSpecs, values, location, componentName,
|
|
406
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
411
407
|
{
|
|
412
408
|
for (var typeSpecName in typeSpecs) {
|
|
413
409
|
if (has(typeSpecs, typeSpecName)) {
|
|
@@ -431,7 +427,7 @@ var require_checkPropTypes = __commonJS({
|
|
|
431
427
|
}
|
|
432
428
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
433
429
|
loggedTypeFailures[error.message] = true;
|
|
434
|
-
var stack =
|
|
430
|
+
var stack = getStack ? getStack() : "";
|
|
435
431
|
printWarning(
|
|
436
432
|
"Failed " + location + " type: " + error.message + (stack != null ? stack : "")
|
|
437
433
|
);
|
|
@@ -2568,7 +2564,7 @@ function initializeContent(effects) {
|
|
|
2568
2564
|
}
|
|
2569
2565
|
|
|
2570
2566
|
// node_modules/micromark/lib/initialize/document.js
|
|
2571
|
-
var
|
|
2567
|
+
var document = {
|
|
2572
2568
|
tokenize: initializeDocument
|
|
2573
2569
|
};
|
|
2574
2570
|
var containerConstruct = {
|
|
@@ -8262,14 +8258,14 @@ __export(constructs_exports, {
|
|
|
8262
8258
|
attentionMarkers: () => attentionMarkers,
|
|
8263
8259
|
contentInitial: () => contentInitial,
|
|
8264
8260
|
disable: () => disable,
|
|
8265
|
-
document: () =>
|
|
8261
|
+
document: () => document2,
|
|
8266
8262
|
flow: () => flow2,
|
|
8267
8263
|
flowInitial: () => flowInitial,
|
|
8268
8264
|
insideSpan: () => insideSpan,
|
|
8269
8265
|
string: () => string2,
|
|
8270
8266
|
text: () => text2
|
|
8271
8267
|
});
|
|
8272
|
-
var
|
|
8268
|
+
var document2 = {
|
|
8273
8269
|
[42]: list,
|
|
8274
8270
|
[43]: list,
|
|
8275
8271
|
[45]: list,
|
|
@@ -8343,7 +8339,7 @@ function parse(options) {
|
|
|
8343
8339
|
lazy: {},
|
|
8344
8340
|
constructs: constructs2,
|
|
8345
8341
|
content: create2(content),
|
|
8346
|
-
document: create2(
|
|
8342
|
+
document: create2(document),
|
|
8347
8343
|
flow: create2(flow),
|
|
8348
8344
|
string: create2(string),
|
|
8349
8345
|
text: create2(text)
|
|
@@ -11973,13 +11969,13 @@ var SEARCH_MESSAGE_SENDERS = {
|
|
|
11973
11969
|
|
|
11974
11970
|
// src/components/SearchMessage/SearchMessage.styled.tsx
|
|
11975
11971
|
var { colors } = nuskinTheme;
|
|
11976
|
-
var SearchMessageRoot =
|
|
11972
|
+
var SearchMessageRoot = styled4.div`
|
|
11977
11973
|
display: flex;
|
|
11978
11974
|
inline-size: 100%;
|
|
11979
11975
|
justify-content: ${({ $sender }) => $sender === SEARCH_MESSAGE_SENDERS.USER ? "flex-end" : "flex-start"};
|
|
11980
11976
|
min-inline-size: 0;
|
|
11981
11977
|
`;
|
|
11982
|
-
var SearchMessageContent =
|
|
11978
|
+
var SearchMessageContent = styled4.div`
|
|
11983
11979
|
background-color: ${({ $sender }) => $sender === SEARCH_MESSAGE_SENDERS.USER ? colors.neutral[30] : "transparent"};
|
|
11984
11980
|
border-radius: ${({ $sender }) => $sender === SEARCH_MESSAGE_SENDERS.USER ? "999px" : "0"};
|
|
11985
11981
|
max-inline-size: ${({ $sender }) => $sender === SEARCH_MESSAGE_SENDERS.USER ? "min(100%, 40rem)" : "100%"};
|
|
@@ -12045,13 +12041,17 @@ var ICON_COLOR_BY_TYPE = {
|
|
|
12045
12041
|
[ICON_TYPES.CHECK_VERIFIED]: "#5f86ad",
|
|
12046
12042
|
[ICON_TYPES.STAR_GREY]: "#c9c9c9"
|
|
12047
12043
|
};
|
|
12048
|
-
var
|
|
12049
|
-
[ICON_TYPES.ARROW_DOWN]: "
|
|
12050
|
-
[ICON_TYPES.ARROW_LEFT]: "
|
|
12051
|
-
[ICON_TYPES.ARROW_RIGHT]: "
|
|
12052
|
-
[ICON_TYPES.ARROW_UP]: "
|
|
12053
|
-
[ICON_TYPES.CHECK_VERIFIED]: "
|
|
12054
|
-
[ICON_TYPES.CLOSE]: "
|
|
12044
|
+
var FOUNDATION_ICON_NAME_BY_ICON_TYPE = {
|
|
12045
|
+
[ICON_TYPES.ARROW_DOWN]: "arrowDown",
|
|
12046
|
+
[ICON_TYPES.ARROW_LEFT]: "arrowLeft",
|
|
12047
|
+
[ICON_TYPES.ARROW_RIGHT]: "arrowRight",
|
|
12048
|
+
[ICON_TYPES.ARROW_UP]: "arrowUp",
|
|
12049
|
+
[ICON_TYPES.CHECK_VERIFIED]: "checkVerified",
|
|
12050
|
+
[ICON_TYPES.CLOSE]: "close"
|
|
12051
|
+
};
|
|
12052
|
+
var FOUNDATION_SIZE_BY_ICON_SIZE = {
|
|
12053
|
+
[ICON_SIZES.LARGE]: "large",
|
|
12054
|
+
[ICON_SIZES.SMALL]: "small"
|
|
12055
12055
|
};
|
|
12056
12056
|
function iconStyle(color2, cursor) {
|
|
12057
12057
|
return {
|
|
@@ -12060,34 +12060,24 @@ function iconStyle(color2, cursor) {
|
|
|
12060
12060
|
display: "block"
|
|
12061
12061
|
};
|
|
12062
12062
|
}
|
|
12063
|
-
function
|
|
12063
|
+
function FoundationIcon({
|
|
12064
12064
|
className,
|
|
12065
12065
|
color: color2,
|
|
12066
12066
|
cursor,
|
|
12067
|
-
|
|
12067
|
+
name,
|
|
12068
12068
|
size,
|
|
12069
12069
|
testId
|
|
12070
12070
|
}) {
|
|
12071
|
-
const dimensions = SQUARE_SIZE_BY_ICON_SIZE[size];
|
|
12072
12071
|
return /* @__PURE__ */ jsx(
|
|
12073
|
-
|
|
12072
|
+
NsIcon,
|
|
12074
12073
|
{
|
|
12075
|
-
"aria-hidden":
|
|
12076
|
-
className,
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
fontSize: dimensions,
|
|
12083
|
-
fontWeight: 300,
|
|
12084
|
-
height: dimensions,
|
|
12085
|
-
justifyContent: "center",
|
|
12086
|
-
lineHeight: 1,
|
|
12087
|
-
textAlign: "center",
|
|
12088
|
-
width: dimensions
|
|
12089
|
-
},
|
|
12090
|
-
children: glyph
|
|
12074
|
+
"aria-hidden": true,
|
|
12075
|
+
...className === void 0 ? {} : { className },
|
|
12076
|
+
colorOverride: color2,
|
|
12077
|
+
cursor,
|
|
12078
|
+
name,
|
|
12079
|
+
size: FOUNDATION_SIZE_BY_ICON_SIZE[size],
|
|
12080
|
+
testId
|
|
12091
12081
|
}
|
|
12092
12082
|
);
|
|
12093
12083
|
}
|
|
@@ -12455,16 +12445,16 @@ function Icon({
|
|
|
12455
12445
|
size,
|
|
12456
12446
|
testId: resolvedTestId
|
|
12457
12447
|
};
|
|
12458
|
-
const
|
|
12459
|
-
if (
|
|
12460
|
-
return /* @__PURE__ */ jsx(
|
|
12448
|
+
const foundationName = FOUNDATION_ICON_NAME_BY_ICON_TYPE[type];
|
|
12449
|
+
if (foundationName !== void 0) {
|
|
12450
|
+
return /* @__PURE__ */ jsx(FoundationIcon, { ...customProps, name: foundationName });
|
|
12461
12451
|
}
|
|
12462
12452
|
const IconView = ICON_VIEW_BY_TYPE[type];
|
|
12463
12453
|
return IconView === void 0 ? null : /* @__PURE__ */ jsx(IconView, { ...customProps });
|
|
12464
12454
|
}
|
|
12465
12455
|
var { colors: colors2 } = nuskinTheme;
|
|
12466
12456
|
var voiceListeningColor = "#6964f1";
|
|
12467
|
-
var SearchMessageInputRoot =
|
|
12457
|
+
var SearchMessageInputRoot = styled4.form`
|
|
12468
12458
|
&& {
|
|
12469
12459
|
align-items: end;
|
|
12470
12460
|
background-color: ${colors2.primary.white};
|
|
@@ -12487,7 +12477,7 @@ var SearchMessageInputRoot = styled6.form`
|
|
|
12487
12477
|
}
|
|
12488
12478
|
}
|
|
12489
12479
|
`;
|
|
12490
|
-
var SearchMessageInputField =
|
|
12480
|
+
var SearchMessageInputField = styled4.textarea`
|
|
12491
12481
|
appearance: none;
|
|
12492
12482
|
background: transparent;
|
|
12493
12483
|
border: 0;
|
|
@@ -12506,12 +12496,12 @@ var SearchMessageInputField = styled6.textarea`
|
|
|
12506
12496
|
opacity: 1;
|
|
12507
12497
|
}
|
|
12508
12498
|
`;
|
|
12509
|
-
var SearchMessageInputActions =
|
|
12499
|
+
var SearchMessageInputActions = styled4.div`
|
|
12510
12500
|
align-items: center;
|
|
12511
12501
|
display: flex;
|
|
12512
12502
|
gap: 0.375rem;
|
|
12513
12503
|
`;
|
|
12514
|
-
var SearchMessageInputActionButton =
|
|
12504
|
+
var SearchMessageInputActionButton = styled4.button`
|
|
12515
12505
|
&&&& {
|
|
12516
12506
|
align-items: center;
|
|
12517
12507
|
appearance: none;
|
|
@@ -12655,7 +12645,7 @@ function SearchMessageInput({
|
|
|
12655
12645
|
] });
|
|
12656
12646
|
}
|
|
12657
12647
|
var { colors: colors3 } = nuskinTheme;
|
|
12658
|
-
|
|
12648
|
+
styled4.div`
|
|
12659
12649
|
position: fixed;
|
|
12660
12650
|
inset: 0;
|
|
12661
12651
|
z-index: 10000;
|
|
@@ -12663,7 +12653,7 @@ var SearchModalOverlay = styled6.div`
|
|
|
12663
12653
|
display: flex;
|
|
12664
12654
|
flex-direction: column;
|
|
12665
12655
|
`;
|
|
12666
|
-
var SearchPanelRoot =
|
|
12656
|
+
var SearchPanelRoot = styled4.section`
|
|
12667
12657
|
background-color: ${colors3.primary.white};
|
|
12668
12658
|
border-block-end: 1px solid ${colors3.neutral[30]};
|
|
12669
12659
|
color: ${colors3.primary.black};
|
|
@@ -12671,11 +12661,15 @@ var SearchPanelRoot = styled6.section`
|
|
|
12671
12661
|
${({ $chatMode }) => $chatMode && `
|
|
12672
12662
|
display: flex;
|
|
12673
12663
|
flex-direction: column;
|
|
12674
|
-
max-
|
|
12664
|
+
max-block-size: 92dvh;
|
|
12675
12665
|
overflow: hidden;
|
|
12676
12666
|
`}
|
|
12667
|
+
${({ $agentMode }) => $agentMode && `
|
|
12668
|
+
/* a definite height, so an embedded agent that fills its host has room to lay out */
|
|
12669
|
+
block-size: 92dvh;
|
|
12670
|
+
`}
|
|
12677
12671
|
`;
|
|
12678
|
-
var SearchPanelInner =
|
|
12672
|
+
var SearchPanelInner = styled4.div`
|
|
12679
12673
|
display: grid;
|
|
12680
12674
|
gap: 1.5rem;
|
|
12681
12675
|
inline-size: min(100%, 75rem);
|
|
@@ -12689,7 +12683,7 @@ var SearchPanelInner = styled6.div`
|
|
|
12689
12683
|
overflow: hidden;
|
|
12690
12684
|
`}
|
|
12691
12685
|
`;
|
|
12692
|
-
var SearchPanelScrollContent =
|
|
12686
|
+
var SearchPanelScrollContent = styled4.div`
|
|
12693
12687
|
flex: 1;
|
|
12694
12688
|
min-block-size: 0;
|
|
12695
12689
|
overflow-y: auto;
|
|
@@ -12699,7 +12693,14 @@ var SearchPanelScrollContent = styled6.div`
|
|
|
12699
12693
|
display: none;
|
|
12700
12694
|
}
|
|
12701
12695
|
`;
|
|
12702
|
-
var
|
|
12696
|
+
var SearchPanelAgentContent = styled4.div`
|
|
12697
|
+
flex: 1;
|
|
12698
|
+
min-block-size: 0;
|
|
12699
|
+
min-inline-size: 0;
|
|
12700
|
+
overflow: hidden;
|
|
12701
|
+
position: relative;
|
|
12702
|
+
`;
|
|
12703
|
+
var SearchPanelHeader = styled4.header`
|
|
12703
12704
|
display: flex;
|
|
12704
12705
|
justify-content: space-between;
|
|
12705
12706
|
align-items: center;
|
|
@@ -12708,12 +12709,12 @@ var SearchPanelHeader = styled6.header`
|
|
|
12708
12709
|
justify-content: flex-end;
|
|
12709
12710
|
`}
|
|
12710
12711
|
`;
|
|
12711
|
-
var SearchPanelLogoSlot =
|
|
12712
|
+
var SearchPanelLogoSlot = styled4.div`
|
|
12712
12713
|
flex: 0 0 auto;
|
|
12713
12714
|
/* when header is flex-end (chat mode), push the logo to the far left */
|
|
12714
12715
|
margin-inline-end: auto;
|
|
12715
12716
|
`;
|
|
12716
|
-
var SearchPanelCloseButton =
|
|
12717
|
+
var SearchPanelCloseButton = styled4.button`
|
|
12717
12718
|
align-items: center;
|
|
12718
12719
|
appearance: none;
|
|
12719
12720
|
background: transparent;
|
|
@@ -12730,16 +12731,17 @@ var SearchPanelCloseButton = styled6.button`
|
|
|
12730
12731
|
outline-offset: 2px;
|
|
12731
12732
|
}
|
|
12732
12733
|
`;
|
|
12733
|
-
var SearchPanelContent =
|
|
12734
|
+
var SearchPanelContent = styled4.div`
|
|
12734
12735
|
min-inline-size: 0;
|
|
12735
12736
|
`;
|
|
12736
|
-
var SearchPanelMessageInput =
|
|
12737
|
+
var SearchPanelMessageInput = styled4.div`
|
|
12737
12738
|
inline-size: min(100%, 44rem);
|
|
12738
12739
|
justify-self: center;
|
|
12739
12740
|
width: 100%;
|
|
12740
12741
|
`;
|
|
12741
12742
|
function SearchPanel({
|
|
12742
12743
|
"aria-label": ariaLabel,
|
|
12744
|
+
agentMode = false,
|
|
12743
12745
|
children,
|
|
12744
12746
|
chatMode = false,
|
|
12745
12747
|
closeLabel,
|
|
@@ -12750,83 +12752,243 @@ function SearchPanel({
|
|
|
12750
12752
|
onClose,
|
|
12751
12753
|
...props
|
|
12752
12754
|
}) {
|
|
12753
|
-
const
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12755
|
+
const flexLayout = chatMode || agentMode;
|
|
12756
|
+
let content3;
|
|
12757
|
+
if (agentMode) {
|
|
12758
|
+
content3 = /* @__PURE__ */ jsx(SearchPanelAgentContent, { "data-agent-container": "", children });
|
|
12759
|
+
} else if (chatMode) {
|
|
12760
|
+
content3 = /* @__PURE__ */ jsx(SearchPanelScrollContent, { "data-scroll-container": "", children });
|
|
12761
|
+
} else {
|
|
12762
|
+
content3 = /* @__PURE__ */ jsx(SearchPanelContent, { children });
|
|
12763
|
+
}
|
|
12764
|
+
return /* @__PURE__ */ jsx(
|
|
12765
|
+
SearchPanelRoot,
|
|
12766
|
+
{
|
|
12767
|
+
...props,
|
|
12768
|
+
"aria-label": ariaLabel,
|
|
12769
|
+
$chatMode: flexLayout,
|
|
12770
|
+
$agentMode: agentMode,
|
|
12771
|
+
children: /* @__PURE__ */ jsxs(SearchPanelInner, { $chatMode: flexLayout, children: [
|
|
12772
|
+
/* @__PURE__ */ jsxs(SearchPanelHeader, { $chatMode: flexLayout, children: [
|
|
12773
|
+
logoSlot && /* @__PURE__ */ jsx(SearchPanelLogoSlot, { children: logoSlot }),
|
|
12774
|
+
/* @__PURE__ */ jsxs(
|
|
12775
|
+
SearchPanelCloseButton,
|
|
12776
|
+
{
|
|
12777
|
+
type: "button",
|
|
12778
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
12779
|
+
onClick: onClose,
|
|
12780
|
+
children: [
|
|
12781
|
+
/* @__PURE__ */ jsx(Icon, { cursor: ICON_CURSORS.POINTER, size: ICON_SIZES.SMALL, type: ICON_TYPES.CLOSE }),
|
|
12782
|
+
closeLabel
|
|
12783
|
+
]
|
|
12784
|
+
}
|
|
12785
|
+
)
|
|
12786
|
+
] }),
|
|
12787
|
+
!flexLayout && inputSlot && /* @__PURE__ */ jsx(SearchPanelMessageInput, { children: inputSlot }),
|
|
12788
|
+
!agentMode && initialPrompt && /* @__PURE__ */ jsx(SearchMessage, { sender: SEARCH_MESSAGE_SENDERS.USER, text: initialPrompt }),
|
|
12789
|
+
content3,
|
|
12790
|
+
!agentMode && (chatMode || !inputSlot && messageInputProps) && messageInputProps && /* @__PURE__ */ jsx(SearchPanelMessageInput, { children: /* @__PURE__ */ jsx(SearchMessageInput, { ...messageInputProps }) })
|
|
12791
|
+
] })
|
|
12792
|
+
}
|
|
12793
|
+
);
|
|
12794
|
+
}
|
|
12795
|
+
var MOBILE_MAX_PX = 1024;
|
|
12796
|
+
var colors4 = {
|
|
12797
|
+
text: "#111827",
|
|
12798
|
+
muted: "#6b7280",
|
|
12799
|
+
hover: "#f3f4f6",
|
|
12800
|
+
surface: "#ffffff",
|
|
12801
|
+
borderLight: "#e5e7eb"
|
|
12802
|
+
};
|
|
12803
|
+
var SearchModalBackdropRoot = styled4.div`
|
|
12804
|
+
-webkit-tap-highlight-color: transparent;
|
|
12805
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
12806
|
+
inset: 0;
|
|
12807
|
+
position: fixed;
|
|
12808
|
+
`;
|
|
12809
|
+
var SearchModalSurface = styled4.div`
|
|
12810
|
+
inline-size: 100%;
|
|
12811
|
+
outline: none;
|
|
12812
|
+
`;
|
|
12813
|
+
var SearchSuggestionsPanel = styled4.div`
|
|
12814
|
+
position: relative;
|
|
12815
|
+
width: 100%;
|
|
12816
|
+
margin-top: 8px;
|
|
12817
|
+
`;
|
|
12818
|
+
var SearchSuggestionsList = styled4.ul`
|
|
12819
|
+
display: flex;
|
|
12820
|
+
flex-direction: column;
|
|
12821
|
+
list-style: none;
|
|
12822
|
+
margin: 0;
|
|
12823
|
+
padding: 0;
|
|
12824
|
+
`;
|
|
12825
|
+
var SearchSuggestionOption = styled4.li`
|
|
12826
|
+
display: flex;
|
|
12827
|
+
align-items: center;
|
|
12828
|
+
width: 100%;
|
|
12829
|
+
min-height: 58px;
|
|
12830
|
+
padding: 4px 24px;
|
|
12831
|
+
box-sizing: border-box;
|
|
12832
|
+
color: ${colors4.text};
|
|
12833
|
+
`;
|
|
12834
|
+
var PassiveSuggestionOption = styled4(SearchSuggestionOption)`
|
|
12835
|
+
cursor: default;
|
|
12836
|
+
color: ${colors4.muted};
|
|
12837
|
+
`;
|
|
12838
|
+
var SuggestionSectionHeading = styled4.div`
|
|
12839
|
+
padding: 12px 24px 8px;
|
|
12840
|
+
margin-bottom: 4px;
|
|
12841
|
+
font-size: 16px;
|
|
12842
|
+
font-weight: 700;
|
|
12843
|
+
color: ${colors4.text};
|
|
12844
|
+
background: ${colors4.surface};
|
|
12845
|
+
border-bottom: 1px solid ${colors4.borderLight};
|
|
12846
|
+
`;
|
|
12847
|
+
var RecentSearchesSection = styled4.section`
|
|
12848
|
+
padding: 24px 35px 18px;
|
|
12849
|
+
background: ${colors4.surface};
|
|
12850
|
+
|
|
12851
|
+
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
12852
|
+
padding: 18px 20px 16px;
|
|
12853
|
+
}
|
|
12854
|
+
`;
|
|
12855
|
+
var RecentSearchesHeader = styled4.div`
|
|
12856
|
+
display: flex;
|
|
12857
|
+
align-items: center;
|
|
12858
|
+
justify-content: space-between;
|
|
12859
|
+
gap: 16px;
|
|
12860
|
+
margin-bottom: 13px;
|
|
12861
|
+
`;
|
|
12862
|
+
var RecentSearchesTitle = styled4.h3`
|
|
12863
|
+
margin: 0;
|
|
12864
|
+
font-size: 16px;
|
|
12865
|
+
font-weight: 700;
|
|
12866
|
+
color: ${colors4.text};
|
|
12867
|
+
|
|
12868
|
+
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
12869
|
+
font-size: 15px;
|
|
12870
|
+
line-height: 1.35;
|
|
12871
|
+
}
|
|
12872
|
+
`;
|
|
12873
|
+
var RecentSearchesClearButton = styled4.button`
|
|
12874
|
+
margin: 0;
|
|
12875
|
+
padding: 0;
|
|
12876
|
+
border: none;
|
|
12877
|
+
background: transparent;
|
|
12878
|
+
color: ${colors4.text};
|
|
12879
|
+
font-size: 16px;
|
|
12880
|
+
cursor: pointer;
|
|
12881
|
+
|
|
12882
|
+
&:focus-visible {
|
|
12883
|
+
outline: 2px solid ${colors4.text};
|
|
12884
|
+
outline-offset: 2px;
|
|
12885
|
+
border-radius: 4px;
|
|
12886
|
+
}
|
|
12887
|
+
|
|
12888
|
+
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
12889
|
+
font-size: 14px;
|
|
12890
|
+
}
|
|
12891
|
+
`;
|
|
12892
|
+
var RecentSearchesList = styled4.div`
|
|
12893
|
+
display: flex;
|
|
12894
|
+
flex-wrap: wrap;
|
|
12895
|
+
gap: 10px;
|
|
12896
|
+
`;
|
|
12897
|
+
var RecentSearchChip = styled4.button`
|
|
12898
|
+
display: inline-flex;
|
|
12899
|
+
align-items: center;
|
|
12900
|
+
justify-content: center;
|
|
12901
|
+
min-height: 40px;
|
|
12902
|
+
padding: 8px 16px;
|
|
12903
|
+
border: 1px solid ${colors4.borderLight};
|
|
12904
|
+
border-radius: 999px;
|
|
12905
|
+
background: ${colors4.surface};
|
|
12906
|
+
color: ${colors4.text};
|
|
12907
|
+
font-size: 16px;
|
|
12908
|
+
cursor: pointer;
|
|
12909
|
+
|
|
12910
|
+
&:hover {
|
|
12911
|
+
background: ${colors4.hover};
|
|
12912
|
+
}
|
|
12913
|
+
|
|
12914
|
+
&:focus-visible {
|
|
12915
|
+
outline: 2px solid ${colors4.text};
|
|
12916
|
+
outline-offset: 2px;
|
|
12917
|
+
}
|
|
12918
|
+
|
|
12919
|
+
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
12920
|
+
min-height: 36px;
|
|
12921
|
+
padding: 6px 14px;
|
|
12922
|
+
font-size: 14px;
|
|
12923
|
+
border-radius: 10px;
|
|
12924
|
+
}
|
|
12925
|
+
`;
|
|
12926
|
+
var MAX_RECENT = 6;
|
|
12927
|
+
function RecentSearches({
|
|
12928
|
+
items,
|
|
12929
|
+
title,
|
|
12930
|
+
clearLabel,
|
|
12931
|
+
onSelect,
|
|
12932
|
+
onClear
|
|
12933
|
+
}) {
|
|
12934
|
+
const [showAll, setShowAll] = useState(false);
|
|
12935
|
+
const visible = showAll ? items : items.slice(0, MAX_RECENT);
|
|
12936
|
+
return /* @__PURE__ */ jsxs(RecentSearchesSection, { "aria-label": title, children: [
|
|
12937
|
+
/* @__PURE__ */ jsxs(RecentSearchesHeader, { children: [
|
|
12938
|
+
/* @__PURE__ */ jsx(RecentSearchesTitle, { children: title }),
|
|
12939
|
+
/* @__PURE__ */ jsx(
|
|
12940
|
+
RecentSearchesClearButton,
|
|
12941
|
+
{
|
|
12942
|
+
type: "button",
|
|
12943
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
12944
|
+
onClick: onClear,
|
|
12945
|
+
children: clearLabel
|
|
12946
|
+
}
|
|
12947
|
+
)
|
|
12948
|
+
] }),
|
|
12949
|
+
/* @__PURE__ */ jsxs(RecentSearchesList, { children: [
|
|
12950
|
+
visible.map((query) => /* @__PURE__ */ jsx(
|
|
12951
|
+
RecentSearchChip,
|
|
12952
|
+
{
|
|
12953
|
+
type: "button",
|
|
12954
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
12955
|
+
onClick: () => onSelect(query),
|
|
12956
|
+
children: query
|
|
12957
|
+
},
|
|
12958
|
+
query
|
|
12959
|
+
)),
|
|
12960
|
+
!showAll && items.length > MAX_RECENT && /* @__PURE__ */ jsxs(
|
|
12961
|
+
RecentSearchChip,
|
|
12759
12962
|
{
|
|
12760
12963
|
type: "button",
|
|
12761
12964
|
onMouseDown: (e) => e.preventDefault(),
|
|
12762
|
-
onClick:
|
|
12965
|
+
onClick: () => setShowAll(true),
|
|
12763
12966
|
children: [
|
|
12764
|
-
|
|
12765
|
-
|
|
12967
|
+
"+",
|
|
12968
|
+
items.length - MAX_RECENT,
|
|
12969
|
+
" More"
|
|
12766
12970
|
]
|
|
12767
12971
|
}
|
|
12768
12972
|
)
|
|
12769
|
-
] })
|
|
12770
|
-
|
|
12771
|
-
initialPrompt && /* @__PURE__ */ jsx(SearchMessage, { sender: SEARCH_MESSAGE_SENDERS.USER, text: initialPrompt }),
|
|
12772
|
-
content3,
|
|
12773
|
-
(chatMode || !inputSlot && messageInputProps) && messageInputProps && /* @__PURE__ */ jsx(SearchPanelMessageInput, { children: /* @__PURE__ */ jsx(SearchMessageInput, { ...messageInputProps }) })
|
|
12774
|
-
] }) });
|
|
12775
|
-
}
|
|
12776
|
-
var AI_CHAT_CONVERSATION_ID_KEY = "ai_chat_conversation_id";
|
|
12777
|
-
function getStoredConversationId() {
|
|
12778
|
-
try {
|
|
12779
|
-
const raw = typeof window !== "undefined" ? window.sessionStorage.getItem(AI_CHAT_CONVERSATION_ID_KEY) : null;
|
|
12780
|
-
if (!raw) return null;
|
|
12781
|
-
const id = parseInt(raw, 10);
|
|
12782
|
-
return Number.isNaN(id) ? null : id;
|
|
12783
|
-
} catch {
|
|
12784
|
-
return null;
|
|
12785
|
-
}
|
|
12786
|
-
}
|
|
12787
|
-
function storeConversationId(id) {
|
|
12788
|
-
try {
|
|
12789
|
-
if (typeof window !== "undefined")
|
|
12790
|
-
window.sessionStorage.setItem(AI_CHAT_CONVERSATION_ID_KEY, String(id));
|
|
12791
|
-
} catch {
|
|
12792
|
-
}
|
|
12793
|
-
}
|
|
12794
|
-
async function callAICommerceChat(config) {
|
|
12795
|
-
var _a, _b;
|
|
12796
|
-
const { searchTerm, market, language, salesAiAppKey, salesAiParentOrigin } = config;
|
|
12797
|
-
const chatService = createChatService({
|
|
12798
|
-
salesAiAppKey,
|
|
12799
|
-
salesAiParentOrigin,
|
|
12800
|
-
market,
|
|
12801
|
-
language
|
|
12802
|
-
});
|
|
12803
|
-
let conversationId = getStoredConversationId();
|
|
12804
|
-
if (conversationId === null) {
|
|
12805
|
-
conversationId = await chatService.createConversation("Search Session");
|
|
12806
|
-
storeConversationId(conversationId);
|
|
12807
|
-
}
|
|
12808
|
-
const result = await chatService.sendMessage(conversationId, searchTerm.trim());
|
|
12809
|
-
return {
|
|
12810
|
-
products: (_a = result == null ? void 0 : result.products) != null ? _a : [],
|
|
12811
|
-
summary: (_b = result == null ? void 0 : result.summary) != null ? _b : ""
|
|
12812
|
-
};
|
|
12973
|
+
] })
|
|
12974
|
+
] });
|
|
12813
12975
|
}
|
|
12814
12976
|
var SUGGESTION_MOBILE_MAX_PX = 1024;
|
|
12815
|
-
var
|
|
12977
|
+
var colors5 = {
|
|
12816
12978
|
text: "#111827",
|
|
12817
12979
|
muted: "#6b7280",
|
|
12818
12980
|
accent: "rgb(15, 118, 110)"
|
|
12819
12981
|
};
|
|
12820
|
-
var SuggestionOption =
|
|
12982
|
+
var SuggestionOption = styled4.li`
|
|
12821
12983
|
display: flex;
|
|
12822
12984
|
align-items: center;
|
|
12823
12985
|
width: 100%;
|
|
12824
12986
|
min-height: 58px;
|
|
12825
12987
|
padding: 4px 24px;
|
|
12826
12988
|
box-sizing: border-box;
|
|
12827
|
-
color: ${
|
|
12989
|
+
color: ${colors5.text};
|
|
12828
12990
|
`;
|
|
12829
|
-
var SuggestionRow =
|
|
12991
|
+
var SuggestionRow = styled4(SuggestionOption)`
|
|
12830
12992
|
display: grid;
|
|
12831
12993
|
grid-template-columns: minmax(0, 1fr) 18px;
|
|
12832
12994
|
align-items: center;
|
|
@@ -12836,7 +12998,7 @@ var SuggestionRow = styled6(SuggestionOption)`
|
|
|
12836
12998
|
|
|
12837
12999
|
&[data-selected='true'] {
|
|
12838
13000
|
background: rgba(15, 118, 110, 0.08);
|
|
12839
|
-
box-shadow: inset 3px 0 0 ${
|
|
13001
|
+
box-shadow: inset 3px 0 0 ${colors5.accent};
|
|
12840
13002
|
}
|
|
12841
13003
|
|
|
12842
13004
|
&[data-highlighted='true'],
|
|
@@ -12847,7 +13009,7 @@ var SuggestionRow = styled6(SuggestionOption)`
|
|
|
12847
13009
|
&[data-highlighted='true'][data-selected='true'] {
|
|
12848
13010
|
background: rgba(15, 118, 110, 0.12);
|
|
12849
13011
|
box-shadow:
|
|
12850
|
-
inset 3px 0 0 ${
|
|
13012
|
+
inset 3px 0 0 ${colors5.accent},
|
|
12851
13013
|
inset 0 0 0 2px rgba(17, 24, 39, 0.12);
|
|
12852
13014
|
}
|
|
12853
13015
|
|
|
@@ -12864,7 +13026,7 @@ var SuggestionRow = styled6(SuggestionOption)`
|
|
|
12864
13026
|
column-gap: 8px;
|
|
12865
13027
|
}
|
|
12866
13028
|
`;
|
|
12867
|
-
var SuggestionContentWrapper =
|
|
13029
|
+
var SuggestionContentWrapper = styled4.div`
|
|
12868
13030
|
display: grid;
|
|
12869
13031
|
grid-template-columns: 50px minmax(0, 1fr);
|
|
12870
13032
|
align-items: center;
|
|
@@ -12886,7 +13048,7 @@ var SuggestionContentWrapper = styled6.div`
|
|
|
12886
13048
|
}
|
|
12887
13049
|
|
|
12888
13050
|
&:focus-visible {
|
|
12889
|
-
outline: 2px solid ${
|
|
13051
|
+
outline: 2px solid ${colors5.text};
|
|
12890
13052
|
outline-offset: 3px;
|
|
12891
13053
|
}
|
|
12892
13054
|
|
|
@@ -12894,14 +13056,14 @@ var SuggestionContentWrapper = styled6.div`
|
|
|
12894
13056
|
grid-template-columns: minmax(0, 1fr);
|
|
12895
13057
|
}
|
|
12896
13058
|
`;
|
|
12897
|
-
var SuggestionThumbnail =
|
|
13059
|
+
var SuggestionThumbnail = styled4.img`
|
|
12898
13060
|
width: 50px;
|
|
12899
13061
|
height: 50px;
|
|
12900
13062
|
object-fit: contain;
|
|
12901
13063
|
flex-shrink: 0;
|
|
12902
13064
|
align-self: center;
|
|
12903
13065
|
`;
|
|
12904
|
-
var SuggestionLabel =
|
|
13066
|
+
var SuggestionLabel = styled4.span`
|
|
12905
13067
|
display: block;
|
|
12906
13068
|
min-width: 0;
|
|
12907
13069
|
line-height: 24px;
|
|
@@ -12909,25 +13071,25 @@ var SuggestionLabel = styled6.span`
|
|
|
12909
13071
|
overflow-wrap: anywhere;
|
|
12910
13072
|
word-break: break-word;
|
|
12911
13073
|
font-size: 16px;
|
|
12912
|
-
color: ${
|
|
13074
|
+
color: ${colors5.text};
|
|
12913
13075
|
|
|
12914
13076
|
@media (max-width: ${SUGGESTION_MOBILE_MAX_PX}px) {
|
|
12915
13077
|
font-size: 14px;
|
|
12916
13078
|
line-height: 20px;
|
|
12917
13079
|
}
|
|
12918
13080
|
`;
|
|
12919
|
-
var SuggestionActionIcon =
|
|
13081
|
+
var SuggestionActionIcon = styled4.span`
|
|
12920
13082
|
display: inline-flex;
|
|
12921
13083
|
align-items: center;
|
|
12922
13084
|
justify-content: center;
|
|
12923
13085
|
width: 24px;
|
|
12924
13086
|
height: 24px;
|
|
12925
|
-
color: var(--suggestion-icon-color, ${
|
|
13087
|
+
color: var(--suggestion-icon-color, ${colors5.text});
|
|
12926
13088
|
flex-shrink: 0;
|
|
12927
13089
|
align-self: center;
|
|
12928
13090
|
|
|
12929
13091
|
&[data-cart-disabled='true'] {
|
|
12930
|
-
color: var(--suggestion-muted, ${
|
|
13092
|
+
color: var(--suggestion-muted, ${colors5.muted});
|
|
12931
13093
|
}
|
|
12932
13094
|
|
|
12933
13095
|
svg {
|
|
@@ -12936,7 +13098,7 @@ var SuggestionActionIcon = styled6.span`
|
|
|
12936
13098
|
display: block;
|
|
12937
13099
|
}
|
|
12938
13100
|
`;
|
|
12939
|
-
var SuggestionActionButton =
|
|
13101
|
+
var SuggestionActionButton = styled4.button`
|
|
12940
13102
|
display: inline-flex;
|
|
12941
13103
|
align-items: center;
|
|
12942
13104
|
justify-content: center;
|
|
@@ -12946,13 +13108,13 @@ var SuggestionActionButton = styled6.button`
|
|
|
12946
13108
|
padding: 0;
|
|
12947
13109
|
border: none;
|
|
12948
13110
|
background: transparent;
|
|
12949
|
-
color: var(--suggestion-icon-color, ${
|
|
13111
|
+
color: var(--suggestion-icon-color, ${colors5.text});
|
|
12950
13112
|
flex-shrink: 0;
|
|
12951
13113
|
align-self: center;
|
|
12952
13114
|
cursor: pointer;
|
|
12953
13115
|
|
|
12954
13116
|
&:focus-visible {
|
|
12955
|
-
outline: 2px solid ${
|
|
13117
|
+
outline: 2px solid ${colors5.text};
|
|
12956
13118
|
outline-offset: 3px;
|
|
12957
13119
|
border-radius: 4px;
|
|
12958
13120
|
}
|
|
@@ -12963,6 +13125,38 @@ var SuggestionActionButton = styled6.button`
|
|
|
12963
13125
|
display: block;
|
|
12964
13126
|
}
|
|
12965
13127
|
`;
|
|
13128
|
+
|
|
13129
|
+
// src/components/SuggestionRow/helpers.ts
|
|
13130
|
+
var CART_DISABLED_PRODUCT_STATUSES = /* @__PURE__ */ new Set([
|
|
13131
|
+
"discontinued",
|
|
13132
|
+
"preview",
|
|
13133
|
+
"previewproduct",
|
|
13134
|
+
"test",
|
|
13135
|
+
"stopped",
|
|
13136
|
+
"replacement",
|
|
13137
|
+
"bundleonly",
|
|
13138
|
+
"inactive",
|
|
13139
|
+
"notavailable"
|
|
13140
|
+
]);
|
|
13141
|
+
function normalizeProductStatusValue(value) {
|
|
13142
|
+
const text4 = typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
13143
|
+
return text4.trim().toLowerCase().replace(/\s+/g, "");
|
|
13144
|
+
}
|
|
13145
|
+
function isNonSellableStatusValue(statusValue) {
|
|
13146
|
+
if (CART_DISABLED_PRODUCT_STATUSES.has(statusValue)) return true;
|
|
13147
|
+
return statusValue !== "sellable" && statusValue !== "active";
|
|
13148
|
+
}
|
|
13149
|
+
function isCartActionDisabled(option) {
|
|
13150
|
+
var _a;
|
|
13151
|
+
if ((_a = option["out_of_stock"]) != null ? _a : option["outOfStock"]) return true;
|
|
13152
|
+
const statusValues = [
|
|
13153
|
+
option["productStatus"],
|
|
13154
|
+
option["product_status"],
|
|
13155
|
+
option["status"],
|
|
13156
|
+
option["sku_status"]
|
|
13157
|
+
].map(normalizeProductStatusValue).filter(Boolean);
|
|
13158
|
+
return statusValues.some(isNonSellableStatusValue);
|
|
13159
|
+
}
|
|
12966
13160
|
function resolveImageSrc(option, isDidYouMean) {
|
|
12967
13161
|
var _a, _b, _c;
|
|
12968
13162
|
if (isDidYouMean) return "";
|
|
@@ -13155,12 +13349,12 @@ function SuggestionRow2({
|
|
|
13155
13349
|
}
|
|
13156
13350
|
);
|
|
13157
13351
|
}
|
|
13158
|
-
var
|
|
13352
|
+
var colors6 = {
|
|
13159
13353
|
text: "#111827",
|
|
13160
13354
|
surface: "#ffffff",
|
|
13161
13355
|
borderLight: "#e5e7eb"
|
|
13162
13356
|
};
|
|
13163
|
-
var SeeMoreLinkContainer =
|
|
13357
|
+
var SeeMoreLinkContainer = styled4.div`
|
|
13164
13358
|
position: relative;
|
|
13165
13359
|
display: flex;
|
|
13166
13360
|
align-items: center;
|
|
@@ -13169,7 +13363,7 @@ var SeeMoreLinkContainer = styled6.div`
|
|
|
13169
13363
|
min-height: 48px;
|
|
13170
13364
|
padding: 0 16px;
|
|
13171
13365
|
box-sizing: border-box;
|
|
13172
|
-
background: ${
|
|
13366
|
+
background: ${colors6.surface};
|
|
13173
13367
|
|
|
13174
13368
|
&::before {
|
|
13175
13369
|
content: '';
|
|
@@ -13177,12 +13371,12 @@ var SeeMoreLinkContainer = styled6.div`
|
|
|
13177
13371
|
top: 0;
|
|
13178
13372
|
left: 50%;
|
|
13179
13373
|
width: 100vw;
|
|
13180
|
-
border-top: 1px solid ${
|
|
13374
|
+
border-top: 1px solid ${colors6.borderLight};
|
|
13181
13375
|
transform: translateX(-50%);
|
|
13182
13376
|
pointer-events: none;
|
|
13183
13377
|
}
|
|
13184
13378
|
`;
|
|
13185
|
-
var SeeMoreLinkText =
|
|
13379
|
+
var SeeMoreLinkText = styled4.button`
|
|
13186
13380
|
width: auto;
|
|
13187
13381
|
height: auto;
|
|
13188
13382
|
padding: 8px 0;
|
|
@@ -13194,7 +13388,7 @@ var SeeMoreLinkText = styled6.button`
|
|
|
13194
13388
|
text-decoration: underline;
|
|
13195
13389
|
text-underline-offset: 2px;
|
|
13196
13390
|
cursor: pointer;
|
|
13197
|
-
color: ${
|
|
13391
|
+
color: ${colors6.text};
|
|
13198
13392
|
|
|
13199
13393
|
&:hover {
|
|
13200
13394
|
opacity: 0.8;
|
|
@@ -13205,7 +13399,7 @@ var SeeMoreLinkText = styled6.button`
|
|
|
13205
13399
|
}
|
|
13206
13400
|
|
|
13207
13401
|
&:focus-visible {
|
|
13208
|
-
outline: 2px solid ${
|
|
13402
|
+
outline: 2px solid ${colors6.text};
|
|
13209
13403
|
outline-offset: 2px;
|
|
13210
13404
|
border-radius: 4px;
|
|
13211
13405
|
}
|
|
@@ -13252,600 +13446,27 @@ function SeeMoreLink({
|
|
|
13252
13446
|
}
|
|
13253
13447
|
) });
|
|
13254
13448
|
}
|
|
13255
|
-
|
|
13256
|
-
var colors6 = {
|
|
13257
|
-
text: "#111827",
|
|
13258
|
-
muted: "#6b7280",
|
|
13259
|
-
hover: "#f3f4f6",
|
|
13260
|
-
surface: "#ffffff",
|
|
13261
|
-
borderLight: "#e5e7eb"
|
|
13262
|
-
};
|
|
13263
|
-
var SearchSuggestionsPanel = styled6.div`
|
|
13264
|
-
position: relative;
|
|
13265
|
-
width: 100%;
|
|
13266
|
-
margin-top: 8px;
|
|
13267
|
-
`;
|
|
13268
|
-
var SearchSuggestionsList = styled6.ul`
|
|
13269
|
-
display: flex;
|
|
13270
|
-
flex-direction: column;
|
|
13271
|
-
list-style: none;
|
|
13272
|
-
margin: 0;
|
|
13273
|
-
padding: 0;
|
|
13274
|
-
`;
|
|
13275
|
-
var SearchSuggestionOption = styled6.li`
|
|
13276
|
-
display: flex;
|
|
13277
|
-
align-items: center;
|
|
13278
|
-
width: 100%;
|
|
13279
|
-
min-height: 58px;
|
|
13280
|
-
padding: 4px 24px;
|
|
13281
|
-
box-sizing: border-box;
|
|
13282
|
-
color: ${colors6.text};
|
|
13283
|
-
`;
|
|
13284
|
-
var PassiveSuggestionOption = styled6(SearchSuggestionOption)`
|
|
13285
|
-
cursor: default;
|
|
13286
|
-
color: ${colors6.muted};
|
|
13287
|
-
`;
|
|
13288
|
-
var AIStatusMessage = styled6.div`
|
|
13289
|
-
padding: 12px 24px;
|
|
13290
|
-
font-size: 14px;
|
|
13291
|
-
font-style: italic;
|
|
13292
|
-
color: ${colors6.muted};
|
|
13293
|
-
min-height: 44px;
|
|
13294
|
-
display: flex;
|
|
13295
|
-
align-items: center;
|
|
13296
|
-
gap: 4px;
|
|
13297
|
-
`;
|
|
13298
|
-
var AIStatusCursor = styled6.span`
|
|
13299
|
-
display: inline-block;
|
|
13300
|
-
width: 2px;
|
|
13301
|
-
height: 1em;
|
|
13302
|
-
background: currentColor;
|
|
13303
|
-
margin-left: 1px;
|
|
13304
|
-
vertical-align: text-bottom;
|
|
13305
|
-
animation: blink 0.8s step-end infinite;
|
|
13306
|
-
@keyframes blink {
|
|
13307
|
-
0%,
|
|
13308
|
-
100% {
|
|
13309
|
-
opacity: 1;
|
|
13310
|
-
}
|
|
13311
|
-
50% {
|
|
13312
|
-
opacity: 0;
|
|
13313
|
-
}
|
|
13314
|
-
}
|
|
13315
|
-
`;
|
|
13316
|
-
var ChatScrollIndicator = styled6.button`
|
|
13317
|
-
align-self: center;
|
|
13318
|
-
appearance: none;
|
|
13319
|
-
background: ${colors6.hover};
|
|
13320
|
-
border: 0;
|
|
13321
|
-
border-radius: 50%;
|
|
13322
|
-
color: ${colors6.text};
|
|
13323
|
-
cursor: pointer;
|
|
13324
|
-
display: grid;
|
|
13325
|
-
place-items: center;
|
|
13326
|
-
block-size: 2rem;
|
|
13327
|
-
inline-size: 2rem;
|
|
13328
|
-
margin-block: 0.25rem 0.75rem;
|
|
13329
|
-
padding: 0;
|
|
13330
|
-
position: sticky;
|
|
13331
|
-
inset-block-end: 0.75rem;
|
|
13332
|
-
z-index: 1;
|
|
13333
|
-
|
|
13334
|
-
&:hover {
|
|
13335
|
-
background: ${colors6.borderLight};
|
|
13336
|
-
}
|
|
13337
|
-
|
|
13338
|
-
&:focus-visible {
|
|
13339
|
-
outline: 2px solid ${colors6.text};
|
|
13340
|
-
outline-offset: 2px;
|
|
13341
|
-
}
|
|
13342
|
-
`;
|
|
13343
|
-
var SuggestionSectionHeading = styled6.div`
|
|
13344
|
-
padding: 12px 24px 8px;
|
|
13345
|
-
margin-bottom: 4px;
|
|
13346
|
-
font-size: 16px;
|
|
13347
|
-
font-weight: 700;
|
|
13348
|
-
color: ${colors6.text};
|
|
13349
|
-
background: ${colors6.surface};
|
|
13350
|
-
border-bottom: 1px solid ${colors6.borderLight};
|
|
13351
|
-
`;
|
|
13352
|
-
var RecentSearchesSection = styled6.section`
|
|
13353
|
-
padding: 24px 35px 18px;
|
|
13354
|
-
background: ${colors6.surface};
|
|
13355
|
-
|
|
13356
|
-
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
13357
|
-
padding: 18px 20px 16px;
|
|
13358
|
-
}
|
|
13359
|
-
`;
|
|
13360
|
-
var RecentSearchesHeader = styled6.div`
|
|
13361
|
-
display: flex;
|
|
13362
|
-
align-items: center;
|
|
13363
|
-
justify-content: space-between;
|
|
13364
|
-
gap: 16px;
|
|
13365
|
-
margin-bottom: 13px;
|
|
13366
|
-
`;
|
|
13367
|
-
var RecentSearchesTitle = styled6.h3`
|
|
13368
|
-
margin: 0;
|
|
13369
|
-
font-size: 16px;
|
|
13370
|
-
font-weight: 700;
|
|
13371
|
-
color: ${colors6.text};
|
|
13372
|
-
|
|
13373
|
-
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
13374
|
-
font-size: 15px;
|
|
13375
|
-
line-height: 1.35;
|
|
13376
|
-
}
|
|
13377
|
-
`;
|
|
13378
|
-
var RecentSearchesClearButton = styled6.button`
|
|
13379
|
-
margin: 0;
|
|
13380
|
-
padding: 0;
|
|
13381
|
-
border: none;
|
|
13382
|
-
background: transparent;
|
|
13383
|
-
color: ${colors6.text};
|
|
13384
|
-
font-size: 16px;
|
|
13385
|
-
cursor: pointer;
|
|
13386
|
-
|
|
13387
|
-
&:focus-visible {
|
|
13388
|
-
outline: 2px solid ${colors6.text};
|
|
13389
|
-
outline-offset: 2px;
|
|
13390
|
-
border-radius: 4px;
|
|
13391
|
-
}
|
|
13392
|
-
|
|
13393
|
-
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
13394
|
-
font-size: 14px;
|
|
13395
|
-
}
|
|
13396
|
-
`;
|
|
13397
|
-
var RecentSearchesList = styled6.div`
|
|
13398
|
-
display: flex;
|
|
13399
|
-
flex-wrap: wrap;
|
|
13400
|
-
gap: 10px;
|
|
13401
|
-
`;
|
|
13402
|
-
var RecentSearchChip = styled6.button`
|
|
13403
|
-
display: inline-flex;
|
|
13404
|
-
align-items: center;
|
|
13405
|
-
justify-content: center;
|
|
13406
|
-
min-height: 40px;
|
|
13407
|
-
padding: 8px 16px;
|
|
13408
|
-
border: 1px solid ${colors6.borderLight};
|
|
13409
|
-
border-radius: 999px;
|
|
13410
|
-
background: ${colors6.surface};
|
|
13411
|
-
color: ${colors6.text};
|
|
13412
|
-
font-size: 16px;
|
|
13413
|
-
cursor: pointer;
|
|
13414
|
-
|
|
13415
|
-
&:hover {
|
|
13416
|
-
background: ${colors6.hover};
|
|
13417
|
-
}
|
|
13418
|
-
|
|
13419
|
-
&:focus-visible {
|
|
13420
|
-
outline: 2px solid ${colors6.text};
|
|
13421
|
-
outline-offset: 2px;
|
|
13422
|
-
}
|
|
13423
|
-
|
|
13424
|
-
@media (max-width: ${MOBILE_MAX_PX}px) {
|
|
13425
|
-
min-height: 36px;
|
|
13426
|
-
padding: 6px 14px;
|
|
13427
|
-
font-size: 14px;
|
|
13428
|
-
border-radius: 10px;
|
|
13429
|
-
}
|
|
13430
|
-
`;
|
|
13431
|
-
var { colors: colors7 } = nuskinTheme;
|
|
13432
|
-
var ChatResultRoot = styled6.div`
|
|
13433
|
-
display: flex;
|
|
13434
|
-
flex-direction: column;
|
|
13435
|
-
gap: 1.5rem;
|
|
13436
|
-
min-block-size: 0;
|
|
13437
|
-
overflow-y: auto;
|
|
13438
|
-
padding-block-end: 2rem;
|
|
13439
|
-
position: relative;
|
|
13440
|
-
`;
|
|
13441
|
-
var ProductCarouselWrapper = styled6.div`
|
|
13442
|
-
display: flex;
|
|
13443
|
-
flex-direction: column;
|
|
13444
|
-
gap: 0.75rem;
|
|
13445
|
-
`;
|
|
13446
|
-
styled6.div`
|
|
13447
|
-
display: flex;
|
|
13448
|
-
gap: 1rem;
|
|
13449
|
-
overflow-x: auto;
|
|
13450
|
-
padding-block-end: 0.5rem;
|
|
13451
|
-
scroll-snap-type: x mandatory;
|
|
13452
|
-
-webkit-overflow-scrolling: touch;
|
|
13453
|
-
scrollbar-width: none;
|
|
13454
|
-
&::-webkit-scrollbar {
|
|
13455
|
-
display: none;
|
|
13456
|
-
}
|
|
13457
|
-
`;
|
|
13458
|
-
styled6.a`
|
|
13459
|
-
display: flex;
|
|
13460
|
-
flex: 0 0 auto;
|
|
13461
|
-
flex-direction: column;
|
|
13462
|
-
gap: 0.5rem;
|
|
13463
|
-
scroll-snap-align: start;
|
|
13464
|
-
text-decoration: none;
|
|
13465
|
-
width: 9rem;
|
|
13466
|
-
`;
|
|
13467
|
-
styled6.img`
|
|
13468
|
-
background: ${colors7.primary.gray};
|
|
13469
|
-
border-radius: 0.5rem;
|
|
13470
|
-
block-size: 9rem;
|
|
13471
|
-
inline-size: 9rem;
|
|
13472
|
-
object-fit: contain;
|
|
13473
|
-
padding: 0.5rem;
|
|
13474
|
-
`;
|
|
13475
|
-
styled6.span`
|
|
13476
|
-
color: ${colors7.primary.black};
|
|
13477
|
-
display: -webkit-box;
|
|
13478
|
-
font-size: 0.8125rem;
|
|
13479
|
-
line-height: 1.4;
|
|
13480
|
-
overflow: hidden;
|
|
13481
|
-
-webkit-box-orient: vertical;
|
|
13482
|
-
-webkit-line-clamp: 2;
|
|
13483
|
-
`;
|
|
13484
|
-
styled6.span`
|
|
13485
|
-
color: ${colors7.neutral[70]};
|
|
13486
|
-
font-size: 0.8125rem;
|
|
13487
|
-
font-weight: 600;
|
|
13488
|
-
`;
|
|
13489
|
-
styled6.button`
|
|
13490
|
-
align-items: center;
|
|
13491
|
-
align-self: center;
|
|
13492
|
-
appearance: none;
|
|
13493
|
-
background: ${colors7.neutral[30]};
|
|
13494
|
-
border: 0;
|
|
13495
|
-
border-radius: 50%;
|
|
13496
|
-
bottom: 0.75rem;
|
|
13497
|
-
color: ${colors7.primary.black};
|
|
13498
|
-
cursor: pointer;
|
|
13499
|
-
display: inline-flex;
|
|
13500
|
-
justify-content: center;
|
|
13501
|
-
block-size: 2rem;
|
|
13502
|
-
inline-size: 2rem;
|
|
13503
|
-
padding: 0;
|
|
13504
|
-
position: sticky;
|
|
13505
|
-
|
|
13506
|
-
&:hover {
|
|
13507
|
-
background: ${colors7.neutral[40]};
|
|
13508
|
-
}
|
|
13509
|
-
`;
|
|
13510
|
-
function isDigit(char) {
|
|
13511
|
-
return char !== void 0 && char >= "0" && char <= "9";
|
|
13512
|
-
}
|
|
13513
|
-
function isLetter(char) {
|
|
13514
|
-
if (char === void 0) return false;
|
|
13515
|
-
const lower = char.toLowerCase();
|
|
13516
|
-
return lower >= "a" && lower <= "z";
|
|
13517
|
-
}
|
|
13518
|
-
function isPricingSpace(char) {
|
|
13519
|
-
return char === " " || char === "\n" || char === "\r" || char === " " || char === "\f";
|
|
13520
|
-
}
|
|
13521
|
-
function findNumberEnd(text4, start, allowCommas) {
|
|
13522
|
-
let cursor = start;
|
|
13523
|
-
let hasDigit = false;
|
|
13524
|
-
while (cursor < text4.length && (isDigit(text4[cursor]) || allowCommas && text4[cursor] === ",")) {
|
|
13525
|
-
hasDigit = hasDigit || isDigit(text4[cursor]);
|
|
13526
|
-
cursor += 1;
|
|
13527
|
-
}
|
|
13528
|
-
if (text4[cursor] === "." && isDigit(text4[cursor + 1])) {
|
|
13529
|
-
cursor += 1;
|
|
13530
|
-
while (cursor < text4.length && isDigit(text4[cursor])) {
|
|
13531
|
-
cursor += 1;
|
|
13532
|
-
}
|
|
13533
|
-
}
|
|
13534
|
-
return hasDigit ? cursor : start;
|
|
13535
|
-
}
|
|
13536
|
-
function removeCurrencyAmounts(text4) {
|
|
13537
|
-
let result = "";
|
|
13538
|
-
let cursor = 0;
|
|
13539
|
-
while (cursor < text4.length) {
|
|
13540
|
-
if (text4[cursor] === "$") {
|
|
13541
|
-
const amountEnd = findNumberEnd(text4, cursor + 1, true);
|
|
13542
|
-
if (amountEnd > cursor + 1) {
|
|
13543
|
-
cursor = amountEnd;
|
|
13544
|
-
continue;
|
|
13545
|
-
}
|
|
13546
|
-
}
|
|
13547
|
-
result += text4[cursor];
|
|
13548
|
-
cursor += 1;
|
|
13549
|
-
}
|
|
13550
|
-
return result;
|
|
13551
|
-
}
|
|
13552
|
-
function removeUnitAmounts(text4, unit) {
|
|
13553
|
-
let result = "";
|
|
13554
|
-
let cursor = 0;
|
|
13555
|
-
while (cursor < text4.length) {
|
|
13556
|
-
if (isDigit(text4[cursor])) {
|
|
13557
|
-
const numberEnd = findNumberEnd(text4, cursor, false);
|
|
13558
|
-
let unitStart = numberEnd;
|
|
13559
|
-
while (isPricingSpace(text4[unitStart])) {
|
|
13560
|
-
unitStart += 1;
|
|
13561
|
-
}
|
|
13562
|
-
const unitEnd = unitStart + unit.length;
|
|
13563
|
-
if (text4.slice(unitStart, unitEnd).toUpperCase() === unit && !isLetter(text4[unitEnd])) {
|
|
13564
|
-
cursor = unitEnd;
|
|
13565
|
-
continue;
|
|
13566
|
-
}
|
|
13567
|
-
}
|
|
13568
|
-
result += text4[cursor];
|
|
13569
|
-
cursor += 1;
|
|
13570
|
-
}
|
|
13571
|
-
return result;
|
|
13572
|
-
}
|
|
13573
|
-
function removeEmptyPricingParentheses(text4) {
|
|
13574
|
-
let result = "";
|
|
13575
|
-
let cursor = 0;
|
|
13576
|
-
while (cursor < text4.length) {
|
|
13577
|
-
if (text4[cursor] === "(") {
|
|
13578
|
-
const candidateStart = cursor;
|
|
13579
|
-
cursor += 1;
|
|
13580
|
-
while (isPricingSpace(text4[cursor]) || text4[cursor] === "," || text4[cursor] === ";") {
|
|
13581
|
-
cursor += 1;
|
|
13582
|
-
}
|
|
13583
|
-
if (text4[cursor] === ")") {
|
|
13584
|
-
cursor += 1;
|
|
13585
|
-
continue;
|
|
13586
|
-
}
|
|
13587
|
-
result += text4.slice(candidateStart, cursor);
|
|
13588
|
-
continue;
|
|
13589
|
-
}
|
|
13590
|
-
result += text4[cursor];
|
|
13591
|
-
cursor += 1;
|
|
13592
|
-
}
|
|
13593
|
-
return result;
|
|
13594
|
-
}
|
|
13595
|
-
function normalizePricingSpace(text4) {
|
|
13596
|
-
let result = "";
|
|
13597
|
-
let previousWasWhitespace = false;
|
|
13598
|
-
for (const char of text4) {
|
|
13599
|
-
if (isPricingSpace(char)) {
|
|
13600
|
-
if (!previousWasWhitespace) {
|
|
13601
|
-
result += " ";
|
|
13602
|
-
previousWasWhitespace = true;
|
|
13603
|
-
}
|
|
13604
|
-
continue;
|
|
13605
|
-
}
|
|
13606
|
-
result += char;
|
|
13607
|
-
previousWasWhitespace = false;
|
|
13608
|
-
}
|
|
13609
|
-
return result.trim();
|
|
13610
|
-
}
|
|
13611
|
-
function stripPricingText(text4) {
|
|
13612
|
-
return normalizePricingSpace(
|
|
13613
|
-
removeEmptyPricingParentheses(
|
|
13614
|
-
removeUnitAmounts(removeUnitAmounts(removeCurrencyAmounts(text4), "PV"), "CV")
|
|
13615
|
-
)
|
|
13616
|
-
);
|
|
13617
|
-
}
|
|
13618
|
-
function toCarouselItem(product, index2, showPricing, history) {
|
|
13619
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
13620
|
-
const slotKey = `ai-${(_b = (_a = product.id) != null ? _a : product.sku) != null ? _b : index2}-${index2}`;
|
|
13621
|
-
const productName = (_f = (_d = (_c = product.name) == null ? void 0 : _c.trim()) != null ? _d : product.sku) != null ? _f : `Product ${(_e = product.id) != null ? _e : index2}`;
|
|
13622
|
-
if (!productName) {
|
|
13623
|
-
return {
|
|
13624
|
-
status: "error",
|
|
13625
|
-
slotKey,
|
|
13626
|
-
productId: String((_h = (_g = product.id) != null ? _g : product.sku) != null ? _h : index2),
|
|
13627
|
-
error: {
|
|
13628
|
-
code: PRODUCT_CAROUSEL_ERROR_CODES.PRODUCT_NOT_FOUND,
|
|
13629
|
-
technicalMessage: "Missing product name"
|
|
13630
|
-
}
|
|
13631
|
-
};
|
|
13632
|
-
}
|
|
13633
|
-
const href = (_i = product.url) != null ? _i : "#";
|
|
13634
|
-
const routeHref = (_j = product.routeUrl) != null ? _j : product.sku ? `/product/${product.sku}` : href;
|
|
13635
|
-
const imageUrl = (_k = product.imageUrl) != null ? _k : product.image_url;
|
|
13636
|
-
const priceText = (_l = product.price) != null ? _l : product.pv != null ? `${product.pv} PV` : void 0;
|
|
13637
|
-
return {
|
|
13638
|
-
status: "ready",
|
|
13639
|
-
slotKey,
|
|
13640
|
-
productId: String((_n = (_m = product.id) != null ? _m : product.sku) != null ? _n : index2),
|
|
13641
|
-
cardProps: {
|
|
13642
|
-
mode: "cta",
|
|
13643
|
-
title: productName,
|
|
13644
|
-
images: imageUrl ? [{ url: imageUrl, alt: productName }] : [],
|
|
13645
|
-
productHref: href,
|
|
13646
|
-
productAriaLabel: productName,
|
|
13647
|
-
price: showPricing ? priceText : void 0,
|
|
13648
|
-
addToCartLabel: "View Product",
|
|
13649
|
-
addToCartAriaLabel: `View ${productName}`,
|
|
13650
|
-
onProductClick: ({ event } = {}) => {
|
|
13651
|
-
if (href === "#") return;
|
|
13652
|
-
event == null ? void 0 : event.preventDefault();
|
|
13653
|
-
if (history && typeof history.push === "function") {
|
|
13654
|
-
history.push(routeHref);
|
|
13655
|
-
}
|
|
13656
|
-
}
|
|
13657
|
-
}
|
|
13658
|
-
};
|
|
13659
|
-
}
|
|
13660
|
-
function SearchChatResult({
|
|
13661
|
-
result,
|
|
13662
|
-
showPricing = true,
|
|
13663
|
-
history,
|
|
13664
|
-
productsAriaLabel = "AI recommended products"
|
|
13665
|
-
}) {
|
|
13666
|
-
var _a;
|
|
13667
|
-
const products = (_a = result.products) != null ? _a : [];
|
|
13668
|
-
const carouselItems = products.map((p, i) => toCarouselItem(p, i, showPricing, history));
|
|
13669
|
-
const summaryText = showPricing ? result.aiResponseText : stripPricingText(result.aiResponseText);
|
|
13670
|
-
return /* @__PURE__ */ jsxs(ChatResultRoot, { "data-testid": "search-chat-result", children: [
|
|
13671
|
-
/* @__PURE__ */ jsx(
|
|
13672
|
-
SearchMessage,
|
|
13673
|
-
{
|
|
13674
|
-
sender: SEARCH_MESSAGE_SENDERS.USER,
|
|
13675
|
-
text: result.userQuery,
|
|
13676
|
-
"data-testid": "chat-user-query"
|
|
13677
|
-
}
|
|
13678
|
-
),
|
|
13679
|
-
/* @__PURE__ */ jsx(
|
|
13680
|
-
SearchMessage,
|
|
13681
|
-
{
|
|
13682
|
-
sender: SEARCH_MESSAGE_SENDERS.AGENT,
|
|
13683
|
-
text: summaryText,
|
|
13684
|
-
"data-testid": "chat-ai-response"
|
|
13685
|
-
}
|
|
13686
|
-
),
|
|
13687
|
-
carouselItems.length > 0 && /* @__PURE__ */ jsx(ProductCarouselWrapper, { "data-testid": "chat-product-carousel", children: /* @__PURE__ */ jsx(ProductCarousel, { items: carouselItems, ariaLabel: productsAriaLabel }) })
|
|
13688
|
-
] });
|
|
13689
|
-
}
|
|
13690
|
-
|
|
13691
|
-
// src/components/SearchModal/SearchModalConstants.ts
|
|
13692
|
-
var DEFAULT_AI_STATUS_LABELS = {
|
|
13693
|
-
analyzing: "Analyzing your question...",
|
|
13694
|
-
pulling: "Pulling up your analytics...",
|
|
13695
|
-
routing: "Routing to specialist agents...",
|
|
13696
|
-
thinking: "Thinking..."
|
|
13697
|
-
};
|
|
13698
|
-
var AI_CONV_KEY = "ai_chat_conversation_id";
|
|
13699
|
-
function getSessionConversationId() {
|
|
13700
|
-
try {
|
|
13701
|
-
const raw = typeof window !== "undefined" ? window.sessionStorage.getItem(AI_CONV_KEY) : null;
|
|
13702
|
-
if (!raw) return null;
|
|
13703
|
-
const id = Number.parseInt(raw, 10);
|
|
13704
|
-
return Number.isNaN(id) ? null : id;
|
|
13705
|
-
} catch {
|
|
13706
|
-
return null;
|
|
13707
|
-
}
|
|
13708
|
-
}
|
|
13709
|
-
function storeSessionConversationId(id) {
|
|
13710
|
-
try {
|
|
13711
|
-
if (typeof window !== "undefined") window.sessionStorage.setItem(AI_CONV_KEY, String(id));
|
|
13712
|
-
} catch (e) {
|
|
13713
|
-
console.error("Error while setting key", e);
|
|
13714
|
-
}
|
|
13715
|
-
}
|
|
13716
|
-
var MAX_RECENT = 6;
|
|
13717
|
-
function getAIStatusLabels(copy) {
|
|
13718
|
-
var _a, _b, _c, _d;
|
|
13719
|
-
return {
|
|
13720
|
-
analyzing: (_a = copy == null ? void 0 : copy.analyzing_label) != null ? _a : DEFAULT_AI_STATUS_LABELS.analyzing,
|
|
13721
|
-
pulling: (_b = copy == null ? void 0 : copy.pulling_label) != null ? _b : DEFAULT_AI_STATUS_LABELS.pulling,
|
|
13722
|
-
routing: (_c = copy == null ? void 0 : copy.routing_label) != null ? _c : DEFAULT_AI_STATUS_LABELS.routing,
|
|
13723
|
-
thinking: (_d = copy == null ? void 0 : copy.thinking_label) != null ? _d : DEFAULT_AI_STATUS_LABELS.thinking
|
|
13724
|
-
};
|
|
13725
|
-
}
|
|
13726
|
-
function getAIStatusLabel(text4, aiStatusLabels) {
|
|
13727
|
-
const normalizedText = text4.trim().toLowerCase();
|
|
13728
|
-
const defaultStatus = Object.entries(DEFAULT_AI_STATUS_LABELS).find(([, label]) => label.toLowerCase() === normalizedText);
|
|
13729
|
-
return defaultStatus ? aiStatusLabels[defaultStatus[0]] : text4;
|
|
13730
|
-
}
|
|
13731
|
-
function getUniqueRecentSearches(entries) {
|
|
13732
|
-
return entries.filter(
|
|
13733
|
-
(entry, idx, arr) => arr.findIndex(
|
|
13734
|
-
(e) => e.query.toLowerCase() === entry.query.toLowerCase()
|
|
13735
|
-
) === idx
|
|
13736
|
-
);
|
|
13737
|
-
}
|
|
13738
|
-
function getProductId(rawId) {
|
|
13739
|
-
return typeof rawId === "string" || typeof rawId === "number" ? String(rawId) : JSON.stringify(rawId);
|
|
13740
|
-
}
|
|
13741
|
-
function getProductName(product, productId) {
|
|
13742
|
-
var _a;
|
|
13743
|
-
return ((_a = product.name) == null ? void 0 : _a.trim()) || (typeof product.sku === "string" ? product.sku.trim() : "") || `Product ${productId}`;
|
|
13744
|
-
}
|
|
13745
|
-
function isVoiceSearchState(value) {
|
|
13746
|
-
if (!value || typeof value !== "object") return false;
|
|
13747
|
-
const candidate = value;
|
|
13748
|
-
return typeof candidate.listening === "boolean" && typeof candidate.supported === "boolean" && typeof candidate.start === "function" && typeof candidate.stop === "function";
|
|
13749
|
-
}
|
|
13750
|
-
function SearchModalChatContent({
|
|
13751
|
-
aiChatHistory,
|
|
13752
|
-
resolvedShowPricing,
|
|
13753
|
-
history,
|
|
13754
|
-
chatResultRefs,
|
|
13755
|
-
pendingQuery,
|
|
13756
|
-
pendingQueryRef,
|
|
13757
|
-
aiLoading,
|
|
13758
|
-
typedStatus,
|
|
13759
|
-
analyzingLabel,
|
|
13760
|
-
chatEndRef
|
|
13761
|
-
}) {
|
|
13762
|
-
const hasChatResults = aiChatHistory.length > 0;
|
|
13763
|
-
function scrollToBottom() {
|
|
13764
|
-
var _a;
|
|
13765
|
-
(_a = chatEndRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
13766
|
-
}
|
|
13767
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13768
|
-
aiChatHistory.map((result, idx) => /* @__PURE__ */ jsx(
|
|
13769
|
-
"div",
|
|
13770
|
-
{
|
|
13771
|
-
ref: (el) => {
|
|
13772
|
-
if (el) chatResultRefs.current.set(result.userQuery, el);
|
|
13773
|
-
else chatResultRefs.current.delete(result.userQuery);
|
|
13774
|
-
},
|
|
13775
|
-
style: { marginBottom: "1.5rem" },
|
|
13776
|
-
children: /* @__PURE__ */ jsx(
|
|
13777
|
-
SearchChatResult,
|
|
13778
|
-
{
|
|
13779
|
-
result,
|
|
13780
|
-
showPricing: resolvedShowPricing,
|
|
13781
|
-
history: history != null ? history : null
|
|
13782
|
-
}
|
|
13783
|
-
)
|
|
13784
|
-
},
|
|
13785
|
-
`${result.userQuery}-${idx}`
|
|
13786
|
-
)),
|
|
13787
|
-
pendingQuery && /* @__PURE__ */ jsx("div", { ref: pendingQueryRef, children: /* @__PURE__ */ jsx(SearchMessage, { sender: SEARCH_MESSAGE_SENDERS.USER, text: pendingQuery }) }),
|
|
13788
|
-
aiLoading && /* @__PURE__ */ jsxs(AIStatusMessage, { "aria-live": "polite", children: [
|
|
13789
|
-
typedStatus || analyzingLabel,
|
|
13790
|
-
/* @__PURE__ */ jsx(AIStatusCursor, { "aria-hidden": "true" })
|
|
13791
|
-
] }),
|
|
13792
|
-
hasChatResults && /* @__PURE__ */ jsx(
|
|
13793
|
-
ChatScrollIndicator,
|
|
13794
|
-
{
|
|
13795
|
-
type: "button",
|
|
13796
|
-
"aria-label": "Scroll to bottom",
|
|
13797
|
-
onClick: scrollToBottom,
|
|
13798
|
-
"data-testid": "chat-scroll-indicator",
|
|
13799
|
-
children: /* @__PURE__ */ jsx(
|
|
13800
|
-
Icon,
|
|
13801
|
-
{
|
|
13802
|
-
cursor: ICON_CURSORS.POINTER,
|
|
13803
|
-
size: ICON_SIZES.SMALL,
|
|
13804
|
-
type: ICON_TYPES.ARROW_DOWN
|
|
13805
|
-
}
|
|
13806
|
-
)
|
|
13807
|
-
}
|
|
13808
|
-
),
|
|
13809
|
-
/* @__PURE__ */ jsx("div", { ref: chatEndRef })
|
|
13810
|
-
] });
|
|
13811
|
-
}
|
|
13812
|
-
function pushSearchPath(history, path2) {
|
|
13813
|
-
if (path2 && path2 !== "action-handled" && path2 !== "action-pending" && history && typeof history.push === "function") {
|
|
13814
|
-
history.push(path2);
|
|
13815
|
-
}
|
|
13816
|
-
}
|
|
13817
|
-
function SearchModalSuggestionsContent({
|
|
13449
|
+
function SearchSuggestions({
|
|
13818
13450
|
listboxId,
|
|
13819
13451
|
ariaLabel,
|
|
13452
|
+
items,
|
|
13820
13453
|
loading,
|
|
13454
|
+
showNoResults,
|
|
13821
13455
|
showDidYouMean,
|
|
13456
|
+
hasMore,
|
|
13457
|
+
query,
|
|
13822
13458
|
didYouMeanText,
|
|
13823
|
-
visibleSuggestions,
|
|
13824
|
-
highlightedIndex,
|
|
13825
|
-
setHighlightedIndex,
|
|
13826
|
-
runSuggestionAction,
|
|
13827
|
-
selectOption,
|
|
13828
|
-
suggestionRowRefs,
|
|
13829
|
-
fallbackImageUrl,
|
|
13830
|
-
showNoResults,
|
|
13831
13459
|
noSuggestionsText,
|
|
13832
|
-
showInlineAILoading,
|
|
13833
|
-
typedStatus,
|
|
13834
|
-
analyzingLabel,
|
|
13835
|
-
hasMoreResults,
|
|
13836
|
-
footerRef,
|
|
13837
|
-
handleSeeMore,
|
|
13838
13460
|
seeMoreText,
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13843
|
-
showAllRecent,
|
|
13844
|
-
recentSearches,
|
|
13845
|
-
handleRecentSearchSelect,
|
|
13846
|
-
setShowAllRecent
|
|
13461
|
+
fallbackImageUrl,
|
|
13462
|
+
onSelect,
|
|
13463
|
+
onRunAction,
|
|
13464
|
+
onSeeMore
|
|
13847
13465
|
}) {
|
|
13848
|
-
|
|
13466
|
+
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
13467
|
+
const footerRef = useRef(null);
|
|
13468
|
+
const suggestionRowRefs = useRef({});
|
|
13469
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13849
13470
|
/* @__PURE__ */ jsxs(
|
|
13850
13471
|
SearchSuggestionsList,
|
|
13851
13472
|
{
|
|
@@ -13855,15 +13476,15 @@ function SearchModalSuggestionsContent({
|
|
|
13855
13476
|
"data-testid": "autocomplete-results-list",
|
|
13856
13477
|
children: [
|
|
13857
13478
|
showDidYouMean && /* @__PURE__ */ jsx(SuggestionSectionHeading, { "data-testid": "autocomplete-did-you-mean-heading", children: didYouMeanText }),
|
|
13858
|
-
!loading &&
|
|
13479
|
+
!loading && items.map((option, index2) => /* @__PURE__ */ jsx(
|
|
13859
13480
|
SuggestionRow2,
|
|
13860
13481
|
{
|
|
13861
13482
|
inputRef: { current: null },
|
|
13862
13483
|
isHighlighted: index2 === highlightedIndex,
|
|
13863
13484
|
isSelected: false,
|
|
13864
13485
|
onHighlightSuggestion: setHighlightedIndex,
|
|
13865
|
-
onRunSuggestionAction:
|
|
13866
|
-
onSelectSuggestion:
|
|
13486
|
+
onRunSuggestionAction: onRunAction,
|
|
13487
|
+
onSelectSuggestion: onSelect,
|
|
13867
13488
|
registerSuggestionNode: (node2) => {
|
|
13868
13489
|
if (node2) suggestionRowRefs.current[option.id] = node2;
|
|
13869
13490
|
else delete suggestionRowRefs.current[option.id];
|
|
@@ -13875,15 +13496,11 @@ function SearchModalSuggestionsContent({
|
|
|
13875
13496
|
},
|
|
13876
13497
|
option.id
|
|
13877
13498
|
)),
|
|
13878
|
-
showNoResults && /* @__PURE__ */ jsx(PassiveSuggestionOption, { "data-highlighted": "false", children: noSuggestionsText })
|
|
13879
|
-
showInlineAILoading && /* @__PURE__ */ jsxs(AIStatusMessage, { "aria-live": "polite", children: [
|
|
13880
|
-
typedStatus || analyzingLabel,
|
|
13881
|
-
/* @__PURE__ */ jsx(AIStatusCursor, { "aria-hidden": "true" })
|
|
13882
|
-
] })
|
|
13499
|
+
showNoResults && /* @__PURE__ */ jsx(PassiveSuggestionOption, { "data-highlighted": "false", children: noSuggestionsText })
|
|
13883
13500
|
]
|
|
13884
13501
|
}
|
|
13885
13502
|
),
|
|
13886
|
-
!loading &&
|
|
13503
|
+
!loading && hasMore && !showDidYouMean && /* @__PURE__ */ jsx(
|
|
13887
13504
|
SeeMoreLink,
|
|
13888
13505
|
{
|
|
13889
13506
|
seeMoreLinkRef: footerRef,
|
|
@@ -13893,7 +13510,7 @@ function SearchModalSuggestionsContent({
|
|
|
13893
13510
|
},
|
|
13894
13511
|
onFocusSeeMoreLink: () => {
|
|
13895
13512
|
},
|
|
13896
|
-
onSeeMoreResults:
|
|
13513
|
+
onSeeMoreResults: onSeeMore,
|
|
13897
13514
|
resetSeeMoreLinkFocus: () => {
|
|
13898
13515
|
},
|
|
13899
13516
|
restoreLastSuggestion: () => {
|
|
@@ -13901,667 +13518,102 @@ function SearchModalSuggestionsContent({
|
|
|
13901
13518
|
seeMoreResultsText: seeMoreText,
|
|
13902
13519
|
searchQuery: query
|
|
13903
13520
|
}
|
|
13904
|
-
)
|
|
13905
|
-
showRecentSearches && /* @__PURE__ */ jsxs(RecentSearchesSection, { "aria-label": "Recent searches", children: [
|
|
13906
|
-
/* @__PURE__ */ jsxs(RecentSearchesHeader, { children: [
|
|
13907
|
-
/* @__PURE__ */ jsx(RecentSearchesTitle, { children: "Recent searches" }),
|
|
13908
|
-
/* @__PURE__ */ jsx(
|
|
13909
|
-
RecentSearchesClearButton,
|
|
13910
|
-
{
|
|
13911
|
-
type: "button",
|
|
13912
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
13913
|
-
onClick: handleClearRecentSearches,
|
|
13914
|
-
children: clearAllLabel
|
|
13915
|
-
}
|
|
13916
|
-
)
|
|
13917
|
-
] }),
|
|
13918
|
-
/* @__PURE__ */ jsxs(RecentSearchesList, { children: [
|
|
13919
|
-
(showAllRecent ? recentSearches : recentSearches.slice(0, MAX_RECENT)).map((entry) => /* @__PURE__ */ jsx(
|
|
13920
|
-
RecentSearchChip,
|
|
13921
|
-
{
|
|
13922
|
-
type: "button",
|
|
13923
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
13924
|
-
onClick: () => handleRecentSearchSelect(entry),
|
|
13925
|
-
children: entry.query
|
|
13926
|
-
},
|
|
13927
|
-
`${entry.query}-${entry.timestamp}`
|
|
13928
|
-
)),
|
|
13929
|
-
!showAllRecent && recentSearches.length > MAX_RECENT && /* @__PURE__ */ jsxs(
|
|
13930
|
-
RecentSearchChip,
|
|
13931
|
-
{
|
|
13932
|
-
type: "button",
|
|
13933
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
13934
|
-
onClick: () => setShowAllRecent(true),
|
|
13935
|
-
children: [
|
|
13936
|
-
"+",
|
|
13937
|
-
recentSearches.length - MAX_RECENT,
|
|
13938
|
-
" More"
|
|
13939
|
-
]
|
|
13940
|
-
}
|
|
13941
|
-
)
|
|
13942
|
-
] })
|
|
13943
|
-
] })
|
|
13521
|
+
)
|
|
13944
13522
|
] });
|
|
13945
13523
|
}
|
|
13524
|
+
var SEARCH_MODAL_Z_INDEX = 1e4;
|
|
13525
|
+
var BACKDROP_PROPS = { "data-testid": "search-modal-backdrop" };
|
|
13526
|
+
var SearchModalBackdrop = React.forwardRef(function SearchModalBackdrop2({ open: _open, transitionDuration: _duration, ...rest }, ref) {
|
|
13527
|
+
return /* @__PURE__ */ jsx(SearchModalBackdropRoot, { ref, ...rest });
|
|
13528
|
+
});
|
|
13946
13529
|
function SearchModal({
|
|
13947
13530
|
isOpen,
|
|
13948
13531
|
onClose,
|
|
13949
|
-
service,
|
|
13950
|
-
history,
|
|
13951
|
-
copy = {},
|
|
13952
13532
|
logo,
|
|
13953
13533
|
cancelLabel = "Cancel",
|
|
13954
13534
|
fallbackImageUrl = "",
|
|
13955
|
-
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
13535
|
+
copy = {},
|
|
13536
|
+
input,
|
|
13537
|
+
suggestions,
|
|
13538
|
+
recentSearches,
|
|
13539
|
+
agentPanel
|
|
13960
13540
|
}) {
|
|
13961
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
13541
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13962
13542
|
const listboxId = useId();
|
|
13963
|
-
const
|
|
13964
|
-
const
|
|
13965
|
-
const historyEntries = useSearchHistory().entries;
|
|
13966
|
-
const selectHistory = useSearchHistoryStore;
|
|
13967
|
-
const historyAddEntry = selectHistory((s) => s.addEntry);
|
|
13968
|
-
const historyClearAll = selectHistory((s) => s.clearAll);
|
|
13969
|
-
const [legacyRecentSearches, setLegacyRecentSearches] = useState([]);
|
|
13970
|
-
const legacyEntries = legacyRecentSearches.map((q) => ({
|
|
13971
|
-
query: q,
|
|
13972
|
-
isAI: false,
|
|
13973
|
-
timestamp: 0
|
|
13974
|
-
}));
|
|
13975
|
-
const recentSearches = getUniqueRecentSearches(enableAIChat ? historyEntries : legacyEntries);
|
|
13976
|
-
const clearRecentSearches = useCallback(() => {
|
|
13977
|
-
var _a2;
|
|
13978
|
-
if (enableAIChat) {
|
|
13979
|
-
historyClearAll();
|
|
13980
|
-
setAiChatHistory([]);
|
|
13981
|
-
} else {
|
|
13982
|
-
(_a2 = service.clearRecentSearches) == null ? void 0 : _a2.call(service);
|
|
13983
|
-
setLegacyRecentSearches([]);
|
|
13984
|
-
}
|
|
13985
|
-
}, [enableAIChat, historyClearAll, service]);
|
|
13986
|
-
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
13987
|
-
const [aiChatHistory, setAiChatHistory] = useState([]);
|
|
13988
|
-
const [pendingQuery, setPendingQuery] = useState("");
|
|
13989
|
-
const [aiLoading, setAiLoading] = useState(false);
|
|
13990
|
-
const isInChatMode = aiChatHistory.length > 0 || pendingQuery !== "" || aiLoading;
|
|
13991
|
-
const [aiStatus, setAiStatus] = useState("");
|
|
13992
|
-
const [typedStatus, setTypedStatus] = useState("");
|
|
13993
|
-
const [showAllRecent, setShowAllRecent] = useState(false);
|
|
13994
|
-
const [highlightedQuery, setHighlightedQuery] = useState(null);
|
|
13995
|
-
const chatResultRefs = useRef(/* @__PURE__ */ new Map());
|
|
13996
|
-
const pendingQueryRef = useRef(null);
|
|
13997
|
-
const aiChatConfigRef = useRef(aiChatConfig);
|
|
13998
|
-
aiChatConfigRef.current = aiChatConfig;
|
|
13999
|
-
const aiChatHeaderContentRef = useRef(aiChatHeaderContent);
|
|
14000
|
-
aiChatHeaderContentRef.current = aiChatHeaderContent;
|
|
14001
|
-
const gtmContextRef = useRef(gtmContext);
|
|
14002
|
-
gtmContextRef.current = gtmContext;
|
|
14003
|
-
const historyEntriesRef = useRef(historyEntries);
|
|
14004
|
-
historyEntriesRef.current = historyEntries;
|
|
14005
|
-
const chatEndRef = useRef(null);
|
|
14006
|
-
const aiRequestCounterRef = useRef(0);
|
|
14007
|
-
const [suggestionsRequestFailed, setSuggestionsRequestFailed] = useState(false);
|
|
14008
|
-
const suggestionAwareService = useMemo(
|
|
14009
|
-
() => ({
|
|
14010
|
-
...service,
|
|
14011
|
-
async fetchSuggestions(searchTerm) {
|
|
14012
|
-
setSuggestionsRequestFailed(false);
|
|
14013
|
-
try {
|
|
14014
|
-
const response = await service.fetchSuggestions(searchTerm);
|
|
14015
|
-
setSuggestionsRequestFailed(false);
|
|
14016
|
-
return response;
|
|
14017
|
-
} catch (error) {
|
|
14018
|
-
setSuggestionsRequestFailed(true);
|
|
14019
|
-
throw error;
|
|
14020
|
-
}
|
|
14021
|
-
}
|
|
14022
|
-
}),
|
|
14023
|
-
[service]
|
|
14024
|
-
);
|
|
14025
|
-
const searchSuggestions = useSearchSuggestions({
|
|
14026
|
-
service: suggestionAwareService,
|
|
14027
|
-
enabled: isOpen && !isInChatMode
|
|
14028
|
-
});
|
|
14029
|
-
const {
|
|
14030
|
-
didYouMean,
|
|
14031
|
-
emptyFetched,
|
|
14032
|
-
hasMoreResults,
|
|
14033
|
-
hasQuery,
|
|
14034
|
-
loading,
|
|
14035
|
-
query,
|
|
14036
|
-
suggestions,
|
|
14037
|
-
updateQuery
|
|
14038
|
-
} = searchSuggestions;
|
|
14039
|
-
const suggestionFetchFailed = ((_a = searchSuggestions.suggestionFetchFailed) != null ? _a : false) || suggestionsRequestFailed;
|
|
14040
|
-
const [searchInputValue, setSearchInputValue] = useState(query);
|
|
14041
|
-
const searchInputValueRef = useRef(query);
|
|
14042
|
-
const voiceInputBaseValueRef = useRef(query);
|
|
14043
|
-
const setSearchInput = useCallback(
|
|
14044
|
-
(value, updateVoiceBase = true, resetSuggestionFailure = true) => {
|
|
14045
|
-
if (resetSuggestionFailure) {
|
|
14046
|
-
setSuggestionsRequestFailed(false);
|
|
14047
|
-
}
|
|
14048
|
-
searchInputValueRef.current = value;
|
|
14049
|
-
if (updateVoiceBase) {
|
|
14050
|
-
voiceInputBaseValueRef.current = value;
|
|
14051
|
-
}
|
|
14052
|
-
setSearchInputValue(value);
|
|
14053
|
-
updateQuery(value);
|
|
14054
|
-
},
|
|
14055
|
-
[updateQuery]
|
|
14056
|
-
);
|
|
14057
|
-
const getVoiceInputValue = useCallback((value) => {
|
|
14058
|
-
const transcript = value.trim();
|
|
14059
|
-
if (!transcript) return voiceInputBaseValueRef.current;
|
|
14060
|
-
const currentValue = voiceInputBaseValueRef.current.trimEnd();
|
|
14061
|
-
return currentValue ? `${currentValue} ${transcript}` : transcript;
|
|
14062
|
-
}, []);
|
|
14063
|
-
const previewVoiceResult = useCallback(
|
|
14064
|
-
(value) => {
|
|
14065
|
-
const nextValue = getVoiceInputValue(value);
|
|
14066
|
-
if (!nextValue) return;
|
|
14067
|
-
searchInputValueRef.current = nextValue;
|
|
14068
|
-
setSearchInputValue(nextValue);
|
|
14069
|
-
},
|
|
14070
|
-
[getVoiceInputValue]
|
|
14071
|
-
);
|
|
14072
|
-
const appendVoiceResult = useCallback(
|
|
14073
|
-
(value) => {
|
|
14074
|
-
const nextValue = getVoiceInputValue(value);
|
|
14075
|
-
if (!nextValue) return;
|
|
14076
|
-
voiceInputBaseValueRef.current = nextValue;
|
|
14077
|
-
setSearchInput(nextValue);
|
|
14078
|
-
},
|
|
14079
|
-
[getVoiceInputValue, setSearchInput]
|
|
14080
|
-
);
|
|
13543
|
+
const surfaceRef = useRef(null);
|
|
13544
|
+
const hasAgent = agentPanel != null;
|
|
14081
13545
|
useEffect(() => {
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
setSearchInputValue(query);
|
|
14085
|
-
}, [query]);
|
|
14086
|
-
const hasDidYouMean = didYouMean.length > 0;
|
|
14087
|
-
const showDidYouMean = hasDidYouMean && !enableAIChat;
|
|
14088
|
-
const visibleSuggestions = enableAIChat ? suggestions : getVisibleSuggestions({ didYouMean, suggestions });
|
|
14089
|
-
const safeUseVoiceSearch = useVoiceSearch;
|
|
14090
|
-
const voiceSearchRaw = safeUseVoiceSearch({
|
|
14091
|
-
onInterimResult: previewVoiceResult,
|
|
14092
|
-
onResult: appendVoiceResult
|
|
14093
|
-
});
|
|
14094
|
-
const voiceSearch = isVoiceSearchState(voiceSearchRaw) ? voiceSearchRaw : null;
|
|
14095
|
-
const voiceListening = (_b = voiceSearch == null ? void 0 : voiceSearch.listening) != null ? _b : false;
|
|
14096
|
-
const voiceSupported = (_c = voiceSearch == null ? void 0 : voiceSearch.supported) != null ? _c : false;
|
|
14097
|
-
const startVoice = voiceSearch == null ? void 0 : voiceSearch.start;
|
|
14098
|
-
const stopVoice = voiceSearch == null ? void 0 : voiceSearch.stop;
|
|
14099
|
-
const toggleVoice = useCallback(() => {
|
|
14100
|
-
if (voiceListening) {
|
|
14101
|
-
stopVoice == null ? void 0 : stopVoice();
|
|
14102
|
-
return;
|
|
14103
|
-
}
|
|
14104
|
-
voiceInputBaseValueRef.current = searchInputValueRef.current.trimEnd();
|
|
14105
|
-
startVoice == null ? void 0 : startVoice();
|
|
14106
|
-
}, [startVoice, stopVoice, voiceListening]);
|
|
14107
|
-
const showPricingFromHeader = ((_e = (_d = aiChatHeaderContentRef.current) == null ? void 0 : _d.configurations) == null ? void 0 : _e.enablepricingpvsv) !== "false";
|
|
14108
|
-
const resolvedShowPricing = aiChatHeaderContent ? showPricingFromHeader : showPricing;
|
|
14109
|
-
const aiStatusLabels = getAIStatusLabels(copy);
|
|
14110
|
-
function voiceSearchProps() {
|
|
14111
|
-
var _a2;
|
|
14112
|
-
if (!voiceSupported || !startVoice) return {};
|
|
14113
|
-
return {
|
|
14114
|
-
showVoiceInput: true,
|
|
14115
|
-
voiceInputLabel: voiceListening ? "Listening\u2026" : "Search by voice",
|
|
14116
|
-
voiceListening,
|
|
14117
|
-
voiceListeningLabel: (_a2 = copy == null ? void 0 : copy.listening_label) != null ? _a2 : "Listening...",
|
|
14118
|
-
onVoiceInput: toggleVoice
|
|
14119
|
-
};
|
|
14120
|
-
}
|
|
14121
|
-
const buildGtmContext = useCallback(() => {
|
|
14122
|
-
var _a2;
|
|
14123
|
-
return (_a2 = gtmContextRef.current) != null ? _a2 : {};
|
|
14124
|
-
}, []);
|
|
14125
|
-
const chatEntryFiredRef = useRef(false);
|
|
14126
|
-
useEffect(() => {
|
|
14127
|
-
if (!isOpen) {
|
|
14128
|
-
chatEntryFiredRef.current = false;
|
|
14129
|
-
return;
|
|
14130
|
-
}
|
|
14131
|
-
if (!enableAIChat || chatEntryFiredRef.current) return;
|
|
14132
|
-
chatEntryFiredRef.current = true;
|
|
14133
|
-
trackChatEntryPoint(buildGtmContext());
|
|
14134
|
-
}, [isOpen, enableAIChat, buildGtmContext]);
|
|
14135
|
-
useEffect(() => {
|
|
14136
|
-
if (isOpen) return;
|
|
14137
|
-
updateQuery("");
|
|
14138
|
-
setAiChatHistory([]);
|
|
14139
|
-
setPendingQuery("");
|
|
14140
|
-
setAiLoading(false);
|
|
14141
|
-
setAiStatus("");
|
|
14142
|
-
setTypedStatus("");
|
|
14143
|
-
setShowAllRecent(false);
|
|
14144
|
-
aiRequestCounterRef.current += 1;
|
|
14145
|
-
}, [isOpen, updateQuery]);
|
|
14146
|
-
useEffect(() => {
|
|
14147
|
-
if (!aiStatus) {
|
|
14148
|
-
setTypedStatus("");
|
|
14149
|
-
return;
|
|
14150
|
-
}
|
|
14151
|
-
let i = 0;
|
|
14152
|
-
setTypedStatus("");
|
|
14153
|
-
const id = setInterval(() => {
|
|
14154
|
-
i += 1;
|
|
14155
|
-
setTypedStatus(aiStatus.slice(0, i));
|
|
14156
|
-
if (i >= aiStatus.length) clearInterval(id);
|
|
14157
|
-
}, 25);
|
|
14158
|
-
return () => clearInterval(id);
|
|
14159
|
-
}, [aiStatus]);
|
|
14160
|
-
useEffect(() => {
|
|
14161
|
-
var _a2;
|
|
14162
|
-
if (!isInChatMode) return;
|
|
14163
|
-
(_a2 = chatEndRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "smooth" });
|
|
14164
|
-
}, [aiChatHistory.length, isInChatMode]);
|
|
14165
|
-
useEffect(() => {
|
|
14166
|
-
var _a2;
|
|
14167
|
-
if (!pendingQuery) return;
|
|
14168
|
-
(_a2 = pendingQueryRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
14169
|
-
}, [pendingQuery]);
|
|
14170
|
-
useEffect(() => {
|
|
14171
|
-
if (!highlightedQuery || aiChatHistory.length === 0) return;
|
|
14172
|
-
const el = chatResultRefs.current.get(highlightedQuery);
|
|
14173
|
-
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
14174
|
-
setHighlightedQuery(null);
|
|
14175
|
-
}, [highlightedQuery, aiChatHistory]);
|
|
14176
|
-
useEffect(() => {
|
|
14177
|
-
var _a2, _b2;
|
|
14178
|
-
if (enableAIChat || !isOpen) return;
|
|
14179
|
-
setLegacyRecentSearches((_b2 = (_a2 = service.getRecentSearches) == null ? void 0 : _a2.call(service)) != null ? _b2 : []);
|
|
14180
|
-
}, [enableAIChat, isOpen, service]);
|
|
14181
|
-
useEffect(() => {
|
|
14182
|
-
if (!isOpen) return void 0;
|
|
14183
|
-
const onKeyDown = (e) => {
|
|
14184
|
-
if (e.key === "Escape") onClose();
|
|
14185
|
-
};
|
|
14186
|
-
document.addEventListener("keydown", onKeyDown);
|
|
14187
|
-
document.body.style.overflow = "hidden";
|
|
14188
|
-
return () => {
|
|
14189
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
14190
|
-
document.body.style.overflow = "";
|
|
14191
|
-
};
|
|
14192
|
-
}, [isOpen, onClose]);
|
|
14193
|
-
const sendAIMessage = useCallback(
|
|
14194
|
-
(queryText) => {
|
|
14195
|
-
const config = aiChatConfigRef.current;
|
|
14196
|
-
if (!config || !queryText.trim()) return;
|
|
14197
|
-
setSearchInput("", true, false);
|
|
14198
|
-
setPendingQuery(queryText.trim());
|
|
14199
|
-
setAiStatus(aiStatusLabels.analyzing);
|
|
14200
|
-
const trimmedQuery = queryText.trim();
|
|
14201
|
-
trackSearchType({
|
|
14202
|
-
...buildGtmContext(),
|
|
14203
|
-
searchType: SEARCH_GTM_SEARCH_TYPES.AI_AGENT,
|
|
14204
|
-
searchResponse: trimmedQuery
|
|
14205
|
-
});
|
|
14206
|
-
const requestId = aiRequestCounterRef.current;
|
|
14207
|
-
const productBasePath = `/${config.market.toLowerCase()}/${config.language.toLowerCase()}/product`;
|
|
14208
|
-
const chatService = createChatService({
|
|
14209
|
-
conversationsUrl: config.conversationsUrl,
|
|
14210
|
-
messagesUrl: config.messagesUrl,
|
|
14211
|
-
salesAiAppKey: config.salesAiAppKey,
|
|
14212
|
-
salesAiParentOrigin: config.salesAiParentOrigin,
|
|
14213
|
-
market: config.market,
|
|
14214
|
-
language: config.language
|
|
14215
|
-
});
|
|
14216
|
-
setAiLoading(true);
|
|
14217
|
-
const onChunk = (type, text4) => {
|
|
14218
|
-
if (type === "status") setAiStatus(getAIStatusLabel(text4, aiStatusLabels));
|
|
14219
|
-
};
|
|
14220
|
-
const existingConvId = getSessionConversationId();
|
|
14221
|
-
const conversationPromise = existingConvId !== null ? Promise.resolve(existingConvId) : chatService.createConversation("Search Session").then((id) => {
|
|
14222
|
-
storeSessionConversationId(id);
|
|
14223
|
-
return id;
|
|
14224
|
-
});
|
|
14225
|
-
conversationPromise.then(
|
|
14226
|
-
(conversationId) => {
|
|
14227
|
-
if (requestId !== aiRequestCounterRef.current) return Promise.resolve(null);
|
|
14228
|
-
return chatService.sendMessage(conversationId, queryText.trim(), onChunk);
|
|
14229
|
-
}
|
|
14230
|
-
).then((result) => {
|
|
14231
|
-
if (!result || requestId !== aiRequestCounterRef.current) return;
|
|
14232
|
-
const products = result.products.map((p, i) => {
|
|
14233
|
-
var _a2, _b2;
|
|
14234
|
-
const productId = getProductId((_b2 = (_a2 = p.id) != null ? _a2 : p.sku) != null ? _b2 : i);
|
|
14235
|
-
const productName = getProductName(p, productId);
|
|
14236
|
-
return {
|
|
14237
|
-
id: productId,
|
|
14238
|
-
sku: p.sku,
|
|
14239
|
-
name: String(productName),
|
|
14240
|
-
...p.image_url ? { imageUrl: p.image_url, image_url: p.image_url } : {},
|
|
14241
|
-
...p.pv != null ? { pv: p.pv } : {},
|
|
14242
|
-
...p.retail_price != null ? { retail_price: p.retail_price } : {},
|
|
14243
|
-
...p.description ? { description: p.description } : {},
|
|
14244
|
-
...p.badge ? { badge: p.badge } : {},
|
|
14245
|
-
...p.sku != null ? {
|
|
14246
|
-
url: `${productBasePath}/${p.sku}`,
|
|
14247
|
-
routeUrl: `/product/${p.sku}`
|
|
14248
|
-
} : {}
|
|
14249
|
-
};
|
|
14250
|
-
});
|
|
14251
|
-
setAiStatus("");
|
|
14252
|
-
setPendingQuery("");
|
|
14253
|
-
const newResult = {
|
|
14254
|
-
userQuery: queryText.trim(),
|
|
14255
|
-
aiResponseText: result.summary,
|
|
14256
|
-
products
|
|
14257
|
-
};
|
|
14258
|
-
const priorHistory = historyEntriesRef.current.filter((e) => e.isAI && e.aiResult != null).slice().reverse().map((e) => e.aiResult);
|
|
14259
|
-
setAiChatHistory([...priorHistory, newResult]);
|
|
14260
|
-
historyAddEntry({ query: queryText.trim(), isAI: true, aiResult: newResult });
|
|
14261
|
-
trackProductSearch({
|
|
14262
|
-
...buildGtmContext(),
|
|
14263
|
-
searchType: SEARCH_GTM_SEARCH_TYPES.AI_AGENT,
|
|
14264
|
-
productResults: products.length,
|
|
14265
|
-
productResultsData: products
|
|
14266
|
-
});
|
|
14267
|
-
}).catch(() => {
|
|
14268
|
-
setPendingQuery("");
|
|
14269
|
-
setAiStatus("");
|
|
14270
|
-
trackErrorPopup({
|
|
14271
|
-
...buildGtmContext(),
|
|
14272
|
-
searchType: SEARCH_GTM_SEARCH_TYPES.AI_AGENT
|
|
14273
|
-
});
|
|
14274
|
-
}).finally(() => {
|
|
14275
|
-
if (requestId === aiRequestCounterRef.current) setAiLoading(false);
|
|
14276
|
-
});
|
|
14277
|
-
},
|
|
14278
|
-
[aiStatusLabels, historyAddEntry, setSearchInput, buildGtmContext]
|
|
14279
|
-
);
|
|
14280
|
-
const selectOption = useCallback(
|
|
14281
|
-
(option) => {
|
|
14282
|
-
var _a2, _b2, _c2, _d2;
|
|
14283
|
-
if (isSuggestionDisabled(option)) return;
|
|
14284
|
-
const term = String((_b2 = (_a2 = option["value"]) != null ? _a2 : option["label"]) != null ? _b2 : "");
|
|
14285
|
-
historyAddEntry({ query: term, isAI: false });
|
|
14286
|
-
if (term.trim()) {
|
|
14287
|
-
trackProductSearch({
|
|
14288
|
-
...buildGtmContext(),
|
|
14289
|
-
searchType: SEARCH_GTM_SEARCH_TYPES.SEMANTIC,
|
|
14290
|
-
productResultsData: [option]
|
|
14291
|
-
});
|
|
14292
|
-
}
|
|
14293
|
-
const optionHref = service.getSuggestionHref(option);
|
|
14294
|
-
if (optionHref) {
|
|
14295
|
-
pushSearchPath(history, optionHref);
|
|
14296
|
-
onClose();
|
|
14297
|
-
return;
|
|
14298
|
-
}
|
|
14299
|
-
pushSearchPath(
|
|
14300
|
-
history,
|
|
14301
|
-
service.submitProductSearch(term, option)
|
|
14302
|
-
);
|
|
14303
|
-
if (!enableAIChat) setLegacyRecentSearches((_d2 = (_c2 = service.getRecentSearches) == null ? void 0 : _c2.call(service)) != null ? _d2 : []);
|
|
14304
|
-
onClose();
|
|
14305
|
-
},
|
|
14306
|
-
[buildGtmContext, enableAIChat, service, onClose, historyAddEntry, history]
|
|
14307
|
-
);
|
|
14308
|
-
const runSuggestionAction = useCallback(
|
|
14309
|
-
(option) => {
|
|
14310
|
-
if (isSuggestionDisabled(option)) return;
|
|
14311
|
-
const result = service.activateSuggestionAction(option);
|
|
14312
|
-
void Promise.resolve(result).then((path2) => pushSearchPath(history, path2)).catch(() => {
|
|
14313
|
-
});
|
|
14314
|
-
},
|
|
14315
|
-
[history, service]
|
|
14316
|
-
);
|
|
14317
|
-
const handleRecentSearchSelect = useCallback(
|
|
14318
|
-
(entry) => {
|
|
13546
|
+
if (!isOpen || hasAgent) return void 0;
|
|
13547
|
+
const frame = requestAnimationFrame(() => {
|
|
14319
13548
|
var _a2, _b2;
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
...buildGtmContext(),
|
|
14329
|
-
searchType: SEARCH_GTM_SEARCH_TYPES.SEMANTIC,
|
|
14330
|
-
productResultsData: { query: entry.query.trim() }
|
|
14331
|
-
});
|
|
14332
|
-
}
|
|
14333
|
-
const url = service.submitProductSearch(entry.query);
|
|
14334
|
-
if (url && history && typeof history.push === "function") {
|
|
14335
|
-
history.push(url);
|
|
14336
|
-
}
|
|
14337
|
-
if (!enableAIChat) setLegacyRecentSearches((_b2 = (_a2 = service.getRecentSearches) == null ? void 0 : _a2.call(service)) != null ? _b2 : []);
|
|
14338
|
-
onClose();
|
|
14339
|
-
}
|
|
14340
|
-
},
|
|
14341
|
-
[buildGtmContext, enableAIChat, service, onClose, historyAddEntry, history]
|
|
14342
|
-
);
|
|
14343
|
-
const handleClearRecentSearches = useCallback(() => {
|
|
14344
|
-
clearRecentSearches();
|
|
14345
|
-
}, [clearRecentSearches]);
|
|
14346
|
-
const handleSeeMore = useCallback(() => {
|
|
14347
|
-
if (query.trim()) {
|
|
14348
|
-
pushSearchPath(history, service.viewMoreResults({ query: query.trim() }));
|
|
14349
|
-
}
|
|
14350
|
-
}, [history, service, query]);
|
|
14351
|
-
const handleSearchSubmit = useCallback(
|
|
14352
|
-
(value) => {
|
|
14353
|
-
var _a2, _b2;
|
|
14354
|
-
if (enableAIChat && suggestionFetchFailed) {
|
|
14355
|
-
sendAIMessage(value);
|
|
14356
|
-
return;
|
|
14357
|
-
}
|
|
14358
|
-
historyAddEntry({ query: value, isAI: false });
|
|
14359
|
-
const trimmed = value.trim();
|
|
14360
|
-
if (trimmed) {
|
|
14361
|
-
trackProductSearch({
|
|
14362
|
-
...buildGtmContext(),
|
|
14363
|
-
searchType: SEARCH_GTM_SEARCH_TYPES.SEMANTIC,
|
|
14364
|
-
productResultsData: visibleSuggestions.length > 0 ? visibleSuggestions : { query: trimmed }
|
|
14365
|
-
});
|
|
14366
|
-
}
|
|
14367
|
-
const url = service.submitProductSearch(value);
|
|
14368
|
-
pushSearchPath(history, url);
|
|
14369
|
-
if (!enableAIChat) setLegacyRecentSearches((_b2 = (_a2 = service.getRecentSearches) == null ? void 0 : _a2.call(service)) != null ? _b2 : []);
|
|
14370
|
-
onClose();
|
|
14371
|
-
},
|
|
14372
|
-
[
|
|
14373
|
-
buildGtmContext,
|
|
14374
|
-
enableAIChat,
|
|
14375
|
-
history,
|
|
14376
|
-
historyAddEntry,
|
|
14377
|
-
onClose,
|
|
14378
|
-
sendAIMessage,
|
|
14379
|
-
service,
|
|
14380
|
-
suggestionFetchFailed,
|
|
14381
|
-
visibleSuggestions
|
|
14382
|
-
]
|
|
14383
|
-
);
|
|
14384
|
-
if (!isOpen) return null;
|
|
14385
|
-
const placeholder = (_f = copy == null ? void 0 : copy.extended_search_textbox_desktop) != null ? _f : "Search";
|
|
14386
|
-
const ariaLabel = (_g = copy == null ? void 0 : copy.extended_search_box_aria_label) != null ? _g : placeholder;
|
|
14387
|
-
const didYouMeanText = (_h = copy == null ? void 0 : copy.did_you_mean_text) != null ? _h : "Did You Mean?";
|
|
14388
|
-
const noSuggestionsText = (_i = copy == null ? void 0 : copy.no_suggestions_text) != null ? _i : "No suggestions";
|
|
14389
|
-
const seeMoreText = (_j = copy == null ? void 0 : copy.see_more_results_text) != null ? _j : "See More Results";
|
|
14390
|
-
const showRecentSearches = !hasQuery && !aiLoading && !isInChatMode && recentSearches.length > 0;
|
|
14391
|
-
const showNoResults = !isInChatMode && !loading && emptyFetched && visibleSuggestions.length === 0 && !aiLoading;
|
|
13549
|
+
(_b2 = (_a2 = surfaceRef.current) == null ? void 0 : _a2.querySelector("textarea, input")) == null ? void 0 : _b2.focus();
|
|
13550
|
+
});
|
|
13551
|
+
return () => cancelAnimationFrame(frame);
|
|
13552
|
+
}, [isOpen, hasAgent]);
|
|
13553
|
+
const placeholder = (_a = copy.extended_search_textbox_desktop) != null ? _a : "Search";
|
|
13554
|
+
const ariaLabel = (_b = copy.extended_search_box_aria_label) != null ? _b : placeholder;
|
|
13555
|
+
const hasQuery = input.value.trim() !== "";
|
|
13556
|
+
const hasRecentSearches = ((_c = recentSearches == null ? void 0 : recentSearches.items.length) != null ? _c : 0) > 0;
|
|
14392
13557
|
const searchInput = /* @__PURE__ */ jsx(
|
|
14393
13558
|
SearchMessageInput,
|
|
14394
13559
|
{
|
|
14395
13560
|
inputLabel: ariaLabel,
|
|
14396
|
-
onChange:
|
|
14397
|
-
onSubmit:
|
|
13561
|
+
onChange: input.onChange,
|
|
13562
|
+
onSubmit: input.onSubmit,
|
|
14398
13563
|
placeholder,
|
|
14399
13564
|
submitLabel: placeholder,
|
|
14400
|
-
value:
|
|
13565
|
+
value: input.value,
|
|
14401
13566
|
clearOnSubmit: false,
|
|
14402
|
-
"data-testid": "search-modal-input"
|
|
14403
|
-
...voiceSearchProps()
|
|
13567
|
+
"data-testid": "search-modal-input"
|
|
14404
13568
|
}
|
|
14405
13569
|
);
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14428
|
-
|
|
14429
|
-
{
|
|
14430
|
-
"aria-label": ariaLabel,
|
|
14431
|
-
closeLabel: cancelLabel,
|
|
14432
|
-
onClose,
|
|
14433
|
-
logoSlot: logo,
|
|
14434
|
-
chatMode: isInChatMode,
|
|
14435
|
-
...panelInputProps,
|
|
14436
|
-
children: isInChatMode ? /* @__PURE__ */ jsx(
|
|
14437
|
-
SearchModalChatContent,
|
|
14438
|
-
{
|
|
14439
|
-
aiChatHistory,
|
|
14440
|
-
resolvedShowPricing,
|
|
14441
|
-
history,
|
|
14442
|
-
chatResultRefs,
|
|
14443
|
-
pendingQuery,
|
|
14444
|
-
pendingQueryRef,
|
|
14445
|
-
aiLoading,
|
|
14446
|
-
typedStatus,
|
|
14447
|
-
analyzingLabel: aiStatusLabels.analyzing,
|
|
14448
|
-
chatEndRef
|
|
14449
|
-
}
|
|
14450
|
-
) : /* @__PURE__ */ jsx(
|
|
14451
|
-
SearchModalSuggestionsContent,
|
|
13570
|
+
return /* @__PURE__ */ jsx(
|
|
13571
|
+
Modal,
|
|
13572
|
+
{
|
|
13573
|
+
open: isOpen,
|
|
13574
|
+
onClose,
|
|
13575
|
+
style: { zIndex: SEARCH_MODAL_Z_INDEX },
|
|
13576
|
+
slots: { backdrop: SearchModalBackdrop },
|
|
13577
|
+
slotProps: { backdrop: BACKDROP_PROPS },
|
|
13578
|
+
"data-testid": "search-modal-overlay",
|
|
13579
|
+
children: /* @__PURE__ */ jsx(SearchModalSurface, { ref: surfaceRef, children: /* @__PURE__ */ jsx(
|
|
13580
|
+
SearchPanel,
|
|
13581
|
+
{
|
|
13582
|
+
role: "dialog",
|
|
13583
|
+
"aria-modal": "true",
|
|
13584
|
+
"aria-label": ariaLabel,
|
|
13585
|
+
closeLabel: cancelLabel,
|
|
13586
|
+
onClose,
|
|
13587
|
+
logoSlot: logo,
|
|
13588
|
+
agentMode: hasAgent,
|
|
13589
|
+
inputSlot: hasAgent ? void 0 : searchInput,
|
|
13590
|
+
children: agentPanel != null ? agentPanel : /* @__PURE__ */ jsxs(SearchSuggestionsPanel, { "data-testid": "autocomplete-suggestions-panel", children: [
|
|
13591
|
+
/* @__PURE__ */ jsx(
|
|
13592
|
+
SearchSuggestions,
|
|
14452
13593
|
{
|
|
13594
|
+
...suggestions,
|
|
14453
13595
|
listboxId,
|
|
14454
13596
|
ariaLabel,
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
showInlineAILoading: !isInChatMode && aiLoading,
|
|
14468
|
-
typedStatus,
|
|
14469
|
-
analyzingLabel: aiStatusLabels.analyzing,
|
|
14470
|
-
hasMoreResults,
|
|
14471
|
-
footerRef,
|
|
14472
|
-
handleSeeMore,
|
|
14473
|
-
seeMoreText,
|
|
14474
|
-
query,
|
|
14475
|
-
showRecentSearches,
|
|
14476
|
-
handleClearRecentSearches,
|
|
14477
|
-
clearAllLabel: (_k = copy == null ? void 0 : copy.clear_all_label) != null ? _k : "Clear all",
|
|
14478
|
-
showAllRecent,
|
|
14479
|
-
recentSearches,
|
|
14480
|
-
handleRecentSearchSelect,
|
|
14481
|
-
setShowAllRecent
|
|
13597
|
+
didYouMeanText: (_d = copy.did_you_mean_text) != null ? _d : "Did You Mean?",
|
|
13598
|
+
noSuggestionsText: (_e = copy.no_suggestions_text) != null ? _e : "No suggestions",
|
|
13599
|
+
seeMoreText: (_f = copy.see_more_results_text) != null ? _f : "See More Results",
|
|
13600
|
+
fallbackImageUrl
|
|
13601
|
+
}
|
|
13602
|
+
),
|
|
13603
|
+
!hasQuery && recentSearches && hasRecentSearches && /* @__PURE__ */ jsx(
|
|
13604
|
+
RecentSearches,
|
|
13605
|
+
{
|
|
13606
|
+
...recentSearches,
|
|
13607
|
+
title: (_g = copy.recent_searches_label) != null ? _g : "Recent searches",
|
|
13608
|
+
clearLabel: (_h = copy.clear_all_label) != null ? _h : "Clear all"
|
|
14482
13609
|
}
|
|
14483
13610
|
)
|
|
14484
|
-
}
|
|
14485
|
-
|
|
14486
|
-
}
|
|
14487
|
-
|
|
14488
|
-
document.body
|
|
13611
|
+
] })
|
|
13612
|
+
}
|
|
13613
|
+
) })
|
|
13614
|
+
}
|
|
14489
13615
|
);
|
|
14490
13616
|
}
|
|
14491
|
-
async function fetchAIChatHeaderContent(config) {
|
|
14492
|
-
const { environment = "prod", country, language } = config;
|
|
14493
|
-
if (!country || !language) {
|
|
14494
|
-
throw new Error("country and language are required to fetch ai_chat_nuskin_header");
|
|
14495
|
-
}
|
|
14496
|
-
const stack = getStack(environment);
|
|
14497
|
-
const entries = await stack.getSingletonEntries({
|
|
14498
|
-
contentTypeUIDs: ["ai_chat_nuskin_header"],
|
|
14499
|
-
country: country.toUpperCase(),
|
|
14500
|
-
language: language.toLowerCase(),
|
|
14501
|
-
camelcase: true
|
|
14502
|
-
});
|
|
14503
|
-
const [aiChatHeader] = entries;
|
|
14504
|
-
return aiChatHeader != null ? aiChatHeader : null;
|
|
14505
|
-
}
|
|
14506
|
-
function useAIChatHeaderContent(config) {
|
|
14507
|
-
const [content3, setContent] = useState(null);
|
|
14508
|
-
const [loading, setLoading] = useState(false);
|
|
14509
|
-
const [error, setError] = useState(null);
|
|
14510
|
-
const country = config == null ? void 0 : config.country;
|
|
14511
|
-
const language = config == null ? void 0 : config.language;
|
|
14512
|
-
const environment = config == null ? void 0 : config.environment;
|
|
14513
|
-
useEffect(() => {
|
|
14514
|
-
if (!country || !language) return;
|
|
14515
|
-
let cancelled = false;
|
|
14516
|
-
setLoading(true);
|
|
14517
|
-
setError(null);
|
|
14518
|
-
fetchAIChatHeaderContent({
|
|
14519
|
-
country,
|
|
14520
|
-
language,
|
|
14521
|
-
...environment !== void 0 && { environment }
|
|
14522
|
-
}).then((result) => {
|
|
14523
|
-
if (!cancelled) setContent(result);
|
|
14524
|
-
}).catch((err) => {
|
|
14525
|
-
if (!cancelled) setError(err instanceof Error ? err : new Error(String(err)));
|
|
14526
|
-
}).finally(() => {
|
|
14527
|
-
if (!cancelled) setLoading(false);
|
|
14528
|
-
});
|
|
14529
|
-
return () => {
|
|
14530
|
-
cancelled = true;
|
|
14531
|
-
};
|
|
14532
|
-
}, [country, language, environment]);
|
|
14533
|
-
return { content: content3, loading, error };
|
|
14534
|
-
}
|
|
14535
|
-
var bounce = keyframes`
|
|
14536
|
-
0%, 60%, 100% {
|
|
14537
|
-
transform: translateY(0);
|
|
14538
|
-
opacity: 0.4;
|
|
14539
|
-
}
|
|
14540
|
-
30% {
|
|
14541
|
-
transform: translateY(-6px);
|
|
14542
|
-
opacity: 1;
|
|
14543
|
-
}
|
|
14544
|
-
`;
|
|
14545
|
-
var ChatLoadingRoot = styled6.div`
|
|
14546
|
-
display: flex;
|
|
14547
|
-
align-items: center;
|
|
14548
|
-
gap: 6px;
|
|
14549
|
-
padding: 10px 4px;
|
|
14550
|
-
`;
|
|
14551
|
-
var ChatLoadingDot = styled6.span`
|
|
14552
|
-
display: block;
|
|
14553
|
-
width: 10px;
|
|
14554
|
-
height: 10px;
|
|
14555
|
-
border-radius: 50%;
|
|
14556
|
-
background-color: currentColor;
|
|
14557
|
-
opacity: 0.4;
|
|
14558
|
-
animation: ${bounce} 1.2s ease-in-out infinite;
|
|
14559
|
-
animation-delay: ${({ $delay }) => $delay}ms;
|
|
14560
|
-
`;
|
|
14561
|
-
var DOTS = [0, 160, 320];
|
|
14562
|
-
function ChatLoading({ label = "Loading\u2026", ...props }) {
|
|
14563
|
-
return /* @__PURE__ */ jsx(ChatLoadingRoot, { ...props, "aria-label": label, children: DOTS.map((delay) => /* @__PURE__ */ jsx(ChatLoadingDot, { $delay: delay, "aria-hidden": "true" }, delay)) });
|
|
14564
|
-
}
|
|
14565
13617
|
/*! Bundled license information:
|
|
14566
13618
|
|
|
14567
13619
|
is-buffer/index.js:
|
|
@@ -14601,6 +13653,6 @@ react-is/cjs/react-is.development.js:
|
|
|
14601
13653
|
*)
|
|
14602
13654
|
*/
|
|
14603
13655
|
|
|
14604
|
-
export {
|
|
13656
|
+
export { SEARCH_MESSAGE_SENDERS, SearchMessage, SearchMessageInput, SearchModal, SearchPanel, SeeMoreLink, SuggestionRow2 as SuggestionRow, getSuggestionDisplayData };
|
|
14605
13657
|
//# sourceMappingURL=index.mjs.map
|
|
14606
13658
|
//# sourceMappingURL=index.mjs.map
|