@gobolt/genesis 0.3.4 → 0.3.6

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.js CHANGED
@@ -74898,11 +74898,96 @@ const ThinkingIndicator = () => /* @__PURE__ */ jsxs(ThinkingDots, { children: [
74898
74898
  /* @__PURE__ */ jsx("div", { className: "dot dot-2" }),
74899
74899
  /* @__PURE__ */ jsx("div", { className: "dot dot-3" })
74900
74900
  ] });
74901
- const Message$1 = ({ message: message2, handle, isThinking = false }) => {
74901
+ const DataTable = styled.table`
74902
+ width: 100%;
74903
+ border-collapse: collapse;
74904
+ margin-top: 10px;
74905
+ font-size: 14px;
74906
+ `;
74907
+ styled.th`
74908
+ background-color: #f8f9fa;
74909
+ padding: 8px;
74910
+ text-align: left;
74911
+ border-bottom: 1px solid #ddd;
74912
+ font-weight: 600;
74913
+ `;
74914
+ styled.td`
74915
+ padding: 8px;
74916
+ border-bottom: 1px solid #ddd;
74917
+ `;
74918
+ styled.tr`
74919
+ &:hover {
74920
+ background-color: #f5f5f5;
74921
+ }
74922
+ `;
74923
+ const DataContainer = styled.div`
74924
+ margin-top: 10px;
74925
+ `;
74926
+ const Message$1 = ({
74927
+ message: message2,
74928
+ handle,
74929
+ isThinking = false,
74930
+ data
74931
+ }) => {
74902
74932
  const isBot = handle === "bot";
74933
+ const renderData = () => {
74934
+ if (!data || data.length === 0) return null;
74935
+ const isProposalData = (item) => "title" in item && "proposal_json" in item;
74936
+ const isOwnerCountData = (item) => "owner_email" in item && "proposal_count" in item;
74937
+ const isMonthlyCountData = (item) => "creation_month" in item && "proposal_count" in item;
74938
+ if (isProposalData(data[0])) {
74939
+ return /* @__PURE__ */ jsx(DataContainer, { children: /* @__PURE__ */ jsxs(DataTable, { children: [
74940
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
74941
+ /* @__PURE__ */ jsx("th", { children: "Title" }),
74942
+ /* @__PURE__ */ jsx("th", { children: "Created At" }),
74943
+ /* @__PURE__ */ jsx("th", { children: "Updated At" })
74944
+ ] }) }),
74945
+ /* @__PURE__ */ jsx("tbody", { children: data.map((proposal, index2) => /* @__PURE__ */ jsxs("tr", { children: [
74946
+ /* @__PURE__ */ jsx("td", { children: proposal.title }),
74947
+ /* @__PURE__ */ jsx("td", { children: new Date(proposal.created_at).toLocaleDateString() }),
74948
+ /* @__PURE__ */ jsx("td", { children: new Date(proposal.updated_at).toLocaleDateString() })
74949
+ ] }, proposal.id || index2)) })
74950
+ ] }) });
74951
+ }
74952
+ if (isOwnerCountData(data[0])) {
74953
+ return /* @__PURE__ */ jsx(DataContainer, { children: /* @__PURE__ */ jsxs(DataTable, { children: [
74954
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
74955
+ /* @__PURE__ */ jsx("th", { children: "Owner Email" }),
74956
+ /* @__PURE__ */ jsx("th", { children: "Number of Proposals" })
74957
+ ] }) }),
74958
+ /* @__PURE__ */ jsx("tbody", { children: data.map((row2, index2) => /* @__PURE__ */ jsxs("tr", { children: [
74959
+ /* @__PURE__ */ jsx("td", { children: row2.owner_email }),
74960
+ /* @__PURE__ */ jsx("td", { children: row2.proposal_count })
74961
+ ] }, index2)) })
74962
+ ] }) });
74963
+ }
74964
+ if (isMonthlyCountData(data[0])) {
74965
+ return /* @__PURE__ */ jsx(DataContainer, { children: /* @__PURE__ */ jsxs(DataTable, { children: [
74966
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
74967
+ /* @__PURE__ */ jsx("th", { children: "Month" }),
74968
+ /* @__PURE__ */ jsx("th", { children: "Number of Proposals" })
74969
+ ] }) }),
74970
+ /* @__PURE__ */ jsx("tbody", { children: data.map((row2, index2) => /* @__PURE__ */ jsxs("tr", { children: [
74971
+ /* @__PURE__ */ jsx("td", { children: new Date(2024, row2.creation_month - 1).toLocaleString(
74972
+ "default",
74973
+ { month: "long" }
74974
+ ) }),
74975
+ /* @__PURE__ */ jsx("td", { children: row2.proposal_count })
74976
+ ] }, index2)) })
74977
+ ] }) });
74978
+ }
74979
+ return /* @__PURE__ */ jsx(DataContainer, { children: /* @__PURE__ */ jsxs(DataTable, { children: [
74980
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: Object.keys(data[0]).map((key) => /* @__PURE__ */ jsx("th", { children: key }, key)) }) }),
74981
+ /* @__PURE__ */ jsx("tbody", { children: data.map((row2, index2) => /* @__PURE__ */ jsx("tr", { children: Object.values(row2).map((value2, i) => /* @__PURE__ */ jsx("td", { children: JSON.stringify(value2) }, i)) }, index2)) })
74982
+ ] }) });
74983
+ };
74903
74984
  return /* @__PURE__ */ jsxs(MessageContainer, { $isBot: isBot, children: [
74904
74985
  /* @__PURE__ */ jsx(IconContainer, { children: isBot ? /* @__PURE__ */ jsx(BotIcon, {}) : /* @__PURE__ */ jsx(UserIcon, {}) }),
74905
- /* @__PURE__ */ jsx(TextContainer, { $isBot: isBot, children: isThinking ? /* @__PURE__ */ jsx(ThinkingIndicator, {}) : handle === "bot" ? /* @__PURE__ */ jsx(Markdown, { children: message2 }) : /* @__PURE__ */ jsx(MessageText, { children: message2 }) })
74986
+ /* @__PURE__ */ jsx(TextContainer, { $isBot: isBot, children: isThinking || message2 === PROCESSING_MESSAGE ? /* @__PURE__ */ jsx(ThinkingIndicator, {}) : handle === "bot" ? /* @__PURE__ */ jsxs(Fragment, { children: [
74987
+ /* @__PURE__ */ jsx(Markdown, { children: message2 }),
74988
+ data && renderData(),
74989
+ message2 === PROCESSING_MESSAGE && /* @__PURE__ */ jsx(ThinkingIndicator, {})
74990
+ ] }) : /* @__PURE__ */ jsx(MessageText, { children: message2 }) })
74906
74991
  ] });
74907
74992
  };
74908
74993
  const getStateColors = (colors2, type4, state) => {
@@ -75314,73 +75399,480 @@ const Typography = ({
75314
75399
  }
75315
75400
  );
75316
75401
  };
75317
- const ChatContainer = styled.div`
75402
+ const getBackgroundColor = (colors2, disabled2, $variant) => {
75403
+ if ($variant === "simple") return "#F4F4F4";
75404
+ if (disabled2) return "#F4F4F4";
75405
+ return "#fff";
75406
+ };
75407
+ const TriggerWrapper = styled.div`
75318
75408
  display: flex;
75319
- flex-direction: column;
75409
+ align-items: center;
75410
+ justify-content: space-between;
75411
+ cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
75412
+ opacity: ${({ $disabled }) => $disabled ? 0.4 : 1};
75320
75413
  position: relative;
75321
- width: 600px;
75322
- overflow: hidden;
75414
+ box-shadow: ${({ $variant }) => $variant === "simple" ? "none" : "0px 1px 2px 0px rgba(0, 0, 0, 0.12)"};
75415
+ transition: all 0.2s ease-in-out;
75416
+ min-height: ${({ $variant }) => $variant === "simple" ? "32px" : "40px"};
75417
+
75418
+ &:focus-visible {
75419
+ outline: none;
75420
+ }
75421
+
75422
+ &:focus {
75423
+ box-shadow:
75424
+ 0px 1px 2px 0px rgba(0, 0, 0, 0.12),
75425
+ 0 0 0 3px
75426
+ ${({ theme, $themeType = "primary" }) => theme.colors[$themeType].focussed.ringColor};
75427
+ }
75428
+
75429
+ ${({ $variant, theme, $disabled }) => {
75430
+ var _a;
75431
+ return $variant === "simple" ? `
75432
+ padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
75433
+ background: ${$disabled ? theme.colors.inputs.surface.disabled : "rgba(0, 0, 0, 0.04)"};
75434
+ border: none;
75435
+ border-radius: ${theme.borderRadius.BorderRadiusSm}px;
75436
+ min-height: ${({ $variant: $variant2 }) => $variant2 === "simple" ? "32px" : "40px"};
75437
+
75438
+ &:hover {
75439
+ border: none;
75440
+ }
75441
+ ` : `
75442
+ padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
75443
+ background: ${$disabled ? theme.colors.inputs.surface.disabled : (_a = theme.colors.surface.default) == null ? void 0 : _a.backgroundColor};
75444
+ border: 1px solid #9a9a9a;
75445
+ border-radius: ${theme.borderRadius.BorderRadiusSm}px;
75446
+ min-height: ${({ $variant: $variant2 }) => $variant2 === "simple" ? "32px" : "40px"};
75447
+
75448
+ &:hover {
75449
+ border-color: rgba(0, 0, 0, 0.2);
75450
+ }
75451
+ `;
75452
+ }}
75323
75453
  `;
75324
- const HeroContainer = styled.div`
75454
+ const ValueContainer = styled.div`
75325
75455
  display: flex;
75326
75456
  align-items: center;
75327
- justify-content: center;
75328
- opacity: ${({ $isVisible }) => $isVisible ? 1 : 0};
75329
- transition: opacity 0.3s ease;
75330
- `;
75331
- styled.h1`
75332
- font-family: "Helvetica", "Arial", sans-serif;
75333
- color: teal;
75334
- font-size: 24px;
75335
- text-align: center;
75336
- `;
75337
- const Subtitle = styled.p`
75338
- font-family: "Helvetica", "Arial", sans-serif;
75339
- color: #666;
75340
- font-size: 16px;
75341
- text-align: center;
75342
- `;
75343
- const ErrorMessage = styled(Subtitle)`
75344
- color: red;
75457
+ gap: ${({ theme }) => theme.sizing.Size2}px;
75458
+ flex: 1;
75459
+ padding: 4px 8px;
75345
75460
  `;
75346
- const InputContainer = styled.div`
75461
+ const ChevronContainer = styled.div`
75347
75462
  display: flex;
75348
- justify-content: center;
75349
75463
  align-items: center;
75350
- padding: 8px;
75351
- gap: 8px;
75464
+ justify-content: center;
75465
+ margin-right: ${({ $variant }) => $variant === "simple" ? "4px" : "4px"};
75466
+ margin-left: ${({ $variant }) => $variant === "simple" ? "4px" : "0"};
75352
75467
  `;
75353
- const ChatButton = styled(Button$1)`
75354
- display: flex;
75355
- justify-content: flex-end;
75356
- margin: 16px;
75468
+ const SelectTrigger2 = ({
75469
+ type: type4 = "primary",
75470
+ theme,
75471
+ state,
75472
+ value: value2,
75473
+ placeholder = "Select...",
75474
+ open,
75475
+ onClick,
75476
+ renderValue,
75477
+ options = [],
75478
+ disabled: disabled2 = false,
75479
+ variant = "none"
75480
+ }) => {
75481
+ const handleClick = React__default.useCallback(() => {
75482
+ if (disabled2) return;
75483
+ onClick == null ? void 0 : onClick();
75484
+ }, [disabled2, onClick]);
75485
+ const displayValue = React__default.useMemo(() => {
75486
+ if (!value2) return null;
75487
+ if (renderValue) return renderValue(value2);
75488
+ if (Array.isArray(value2)) {
75489
+ if (value2.length === 0) return null;
75490
+ const selectedLabels = value2.map(String).map((v) => {
75491
+ var _a;
75492
+ return (_a = options.find((opt) => opt.value === v)) == null ? void 0 : _a.label;
75493
+ }).filter(Boolean);
75494
+ return selectedLabels.length > 0 ? selectedLabels.join(", ") : `${value2.length} selected`;
75495
+ }
75496
+ const selectedOption = options.find((opt) => opt.value === String(value2));
75497
+ return (selectedOption == null ? void 0 : selectedOption.label) || value2.toString();
75498
+ }, [value2, renderValue, options]);
75499
+ return /* @__PURE__ */ jsxs(
75500
+ TriggerWrapper,
75501
+ {
75502
+ $themeType: type4,
75503
+ $state: state,
75504
+ onClick: handleClick,
75505
+ tabIndex: disabled2 ? -1 : 0,
75506
+ role: "button",
75507
+ $disabled: disabled2,
75508
+ $variant: variant,
75509
+ style: {
75510
+ backgroundColor: getBackgroundColor(theme, disabled2, variant)
75511
+ },
75512
+ children: [
75513
+ /* @__PURE__ */ jsx(ValueContainer, { $variant: variant, children: displayValue ? /* @__PURE__ */ jsx(Typography, { variant: "body2", color: disabled2 ? "copy-light" : "copy", children: displayValue }) : /* @__PURE__ */ jsx(
75514
+ Typography,
75515
+ {
75516
+ variant: "body2",
75517
+ color: disabled2 ? "copy-light" : "copy-light",
75518
+ children: placeholder
75519
+ }
75520
+ ) }),
75521
+ /* @__PURE__ */ jsx(ChevronContainer, { $variant: variant, children: /* @__PURE__ */ jsx(DropdownChevron, {}) })
75522
+ ]
75523
+ }
75524
+ );
75525
+ };
75526
+ const SelectWrapper = styled.div`
75527
+ position: relative;
75528
+ background-color: transparent;
75529
+ border-radius: 8px;
75530
+ width: auto;
75531
+
75532
+ ${({ $isFocused, theme, type: type4 = "primary" }) => $isFocused && `
75533
+ background-color: transparent;
75534
+ `}
75535
+
75536
+ ${({ disabled: disabled2, theme }) => disabled2 && `
75537
+ cursor: not-allowed;
75538
+
75539
+ &:hover {
75540
+ border-color: ${theme.colors.inputs.surface.border};
75541
+ }
75542
+ `}
75357
75543
  `;
75358
- const MessageList = styled.div`
75544
+ const SelectDropdown = styled.div`
75545
+ padding: 0px;
75546
+ border-radius: 0px;
75547
+ animation-duration: ${({ theme }) => `${theme.motion.veryfast}s`};
75548
+ transition: all ${({ theme }) => `${theme.motion.veryfast}s`}
75549
+ cubic-bezier(0.645, 0.045, 0.355, 1);
75550
+
75551
+ &.entering {
75552
+ opacity: 0;
75553
+ transform: scaleY(0.8);
75554
+ }
75555
+
75556
+ &.entered {
75557
+ opacity: 1;
75558
+ transform: scaleY(1);
75559
+ }
75560
+
75561
+ &.exiting {
75562
+ opacity: 0;
75563
+ transform: scaleY(0.8);
75564
+ }
75565
+ `;
75566
+ const MenuItem = styled.div`
75567
+ padding: 8px 12px;
75568
+ cursor: ${({ disabled: disabled2 }) => disabled2 ? "not-allowed" : "pointer"};
75569
+ background-color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.backgroundColor : "transparent"};
75570
+ color: ${({ $isSelected, disabled: disabled2, theme, type: type4 = "primary" }) => disabled2 ? theme.colors.inputs.onsurface.disabled : $isSelected ? theme.colors[type4].hover.color : theme.colors.onsurface.copy};
75359
75571
  display: flex;
75360
- flex-direction: column;
75361
- padding: 16px;
75362
- gap: 8px;
75363
- max-height: 400px;
75364
- overflow-y: auto;
75572
+ justify-content: space-between;
75573
+ align-items: center;
75574
+ transition: all ${({ theme }) => `${theme.motion.veryfast}s`} ease-in-out;
75575
+ opacity: ${({ disabled: disabled2 }) => disabled2 ? 0.5 : 1};
75576
+
75577
+ ${({ disabled: disabled2 }) => !disabled2 && `
75578
+ &:hover {
75579
+ background-color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.backgroundColor : "rgba(0, 0, 0, 0.04)"};
75580
+ color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.color : theme.colors.onsurface["copy-dark"]};
75581
+ }
75582
+
75583
+ &:active {
75584
+ background-color: ${({ theme, type: type4 = "primary" }) => theme.colors[type4].hover.backgroundColor};
75585
+ color: ${({ theme, type: type4 = "primary" }) => theme.colors[type4].hover.color};
75586
+ }
75587
+ `}
75365
75588
  `;
75366
- const Chat = ({
75367
- socketUrl = "http://localhost:3000",
75368
- isOpen = false,
75369
- messageHistory = [],
75370
- title = null,
75371
- isSimulated = false,
75372
- authToken
75589
+ const Select = ({
75590
+ type: type4 = TYPE.primary,
75591
+ state,
75592
+ variant = "none",
75593
+ defaultValue,
75594
+ onChange,
75595
+ size = "normal",
75596
+ width = "100%",
75597
+ value: value2,
75598
+ options = [],
75599
+ placeholder,
75600
+ selectDisplayMode = "count",
75601
+ isSingleSelect = false,
75602
+ disabled: disabled2 = false,
75603
+ ...rest
75373
75604
  }) => {
75374
- const [isChatOpen, setIsChatOpen] = useState(isOpen);
75375
- const [message2, setMessage] = useState("");
75376
- const [messages2, setMessages] = useState(messageHistory);
75377
- const [serverStatus, setServerStatus] = useState("unknown");
75378
- const [serverError, setServerError] = useState("");
75379
- const socketRef = useRef(null);
75380
- const messageListRef = useRef(null);
75605
+ const [isOpen, setIsOpen] = React__default.useState(false);
75606
+ const [isFocused, setIsFocused] = React__default.useState(false);
75607
+ const [dropdownAnimation, setDropdownAnimation] = React__default.useState("entered");
75608
+ const selectReference = React__default.useRef(null);
75609
+ const { theme } = useGenesis();
75610
+ React__default.useEffect(() => {
75611
+ const handleClickOutside = (event) => {
75612
+ if (selectReference.current && !selectReference.current.contains(event.target)) {
75613
+ handleClose();
75614
+ setIsFocused(false);
75615
+ }
75616
+ };
75617
+ if (isOpen) {
75618
+ document.addEventListener("mousedown", handleClickOutside);
75619
+ }
75620
+ return () => {
75621
+ document.removeEventListener("mousedown", handleClickOutside);
75622
+ };
75623
+ }, [isOpen]);
75624
+ const handleClose = () => {
75625
+ setDropdownAnimation("exiting");
75626
+ setTimeout(() => {
75627
+ setIsOpen(false);
75628
+ setDropdownAnimation("entered");
75629
+ }, 200);
75630
+ };
75631
+ const handleTriggerClick = () => {
75632
+ if (disabled2) return;
75633
+ setIsFocused(true);
75634
+ if (isOpen) {
75635
+ handleClose();
75636
+ } else {
75637
+ setIsOpen(true);
75638
+ setDropdownAnimation("entering");
75639
+ setTimeout(() => {
75640
+ setDropdownAnimation("entered");
75641
+ }, 0);
75642
+ }
75643
+ };
75644
+ const handleOptionSelect = (optionValue) => {
75645
+ if (disabled2) return;
75646
+ let newValue;
75647
+ if (Array.isArray(value2)) {
75648
+ const stringValue = value2.map(String);
75649
+ newValue = stringValue.includes(optionValue) ? stringValue.filter((v) => v !== optionValue) : [...stringValue, optionValue];
75650
+ } else {
75651
+ newValue = optionValue;
75652
+ }
75653
+ onChange == null ? void 0 : onChange(newValue);
75654
+ if (isSingleSelect) {
75655
+ handleClose();
75656
+ }
75657
+ };
75658
+ const getSelectModeValue = (value22) => {
75659
+ if (Array.isArray(value22)) {
75660
+ if (selectDisplayMode === "count") {
75661
+ return `${value22.length} selected`;
75662
+ }
75663
+ return value22;
75664
+ }
75665
+ return value22;
75666
+ };
75667
+ const modeValue = getSelectModeValue(value2);
75668
+ return /* @__PURE__ */ jsx("div", { style: { position: "relative", width }, children: /* @__PURE__ */ jsxs(
75669
+ SelectWrapper,
75670
+ {
75671
+ ref: selectReference,
75672
+ $isFocused: isFocused,
75673
+ type: type4,
75674
+ disabled: disabled2,
75675
+ onFocus: () => !disabled2 && setIsFocused(true),
75676
+ onBlur: () => !isOpen && setIsFocused(false),
75677
+ tabIndex: disabled2 ? -1 : 0,
75678
+ children: [
75679
+ /* @__PURE__ */ jsx(
75680
+ SelectTrigger2,
75681
+ {
75682
+ theme,
75683
+ type: type4,
75684
+ state,
75685
+ value: modeValue,
75686
+ placeholder,
75687
+ open: isOpen,
75688
+ onClick: handleTriggerClick,
75689
+ options,
75690
+ disabled: disabled2,
75691
+ variant
75692
+ }
75693
+ ),
75694
+ isOpen && !disabled2 && /* @__PURE__ */ jsx(
75695
+ SelectDropdown,
75696
+ {
75697
+ type: type4,
75698
+ state,
75699
+ className: dropdownAnimation,
75700
+ style: {
75701
+ position: "absolute",
75702
+ top: "calc(100% + 4px)",
75703
+ left: 0,
75704
+ right: 0,
75705
+ zIndex: 1e3,
75706
+ backgroundColor: "white",
75707
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
75708
+ border: "1px solid #d9d9d9",
75709
+ transformOrigin: "top"
75710
+ },
75711
+ children: options.map((option) => {
75712
+ const isSelected = Array.isArray(value2) ? value2.map(String).includes(option.value) : String(value2) === option.value;
75713
+ return /* @__PURE__ */ jsxs(
75714
+ MenuItem,
75715
+ {
75716
+ onClick: () => handleOptionSelect(option.value),
75717
+ $isSelected: isSelected,
75718
+ type: type4,
75719
+ disabled: disabled2,
75720
+ children: [
75721
+ option.label,
75722
+ isSelected && /* @__PURE__ */ jsx("span", { style: { marginLeft: "8px" }, children: "✓" })
75723
+ ]
75724
+ },
75725
+ option.value
75726
+ );
75727
+ })
75728
+ }
75729
+ )
75730
+ ]
75731
+ }
75732
+ ) });
75733
+ };
75734
+ const PROCESSING_MESSAGE = "Processing your query...";
75735
+ const PREDEFINED_QUERIES = [
75736
+ "What are the most recent proposals?",
75737
+ "How many proposals does each owner have?",
75738
+ "Show me all proposals created in the last month",
75739
+ "What are the top 5 most active proposal owners?",
75740
+ "How many proposals were created in each month of this year?"
75741
+ ];
75742
+ const ChatContainer = styled.div`
75743
+ display: flex;
75744
+ flex-direction: column;
75745
+ position: relative;
75746
+ width: "100%";
75747
+ max-width: "800px";
75748
+ //overflow: hidden;
75749
+ `;
75750
+ const HeroContainer = styled.div`
75751
+ display: flex;
75752
+ align-items: center;
75753
+ justify-content: center;
75754
+ opacity: ${({ $isVisible }) => $isVisible ? 1 : 0};
75755
+ transition: opacity 0.3s ease;
75756
+ `;
75757
+ styled.h1`
75758
+ font-family: "Helvetica", "Arial", sans-serif;
75759
+ color: teal;
75760
+ font-size: 24px;
75761
+ text-align: center;
75762
+ `;
75763
+ const Subtitle = styled.p`
75764
+ font-family: "Helvetica", "Arial", sans-serif;
75765
+ color: #666;
75766
+ font-size: 16px;
75767
+ text-align: center;
75768
+ `;
75769
+ const ErrorMessage = styled(Subtitle)`
75770
+ color: red;
75771
+ `;
75772
+ const InputContainer = styled.div`
75773
+ display: flex;
75774
+ justify-content: center;
75775
+ align-items: center;
75776
+ padding: 8px;
75777
+ gap: 8px;
75778
+ `;
75779
+ const ChatButton = styled(Button$1)`
75780
+ display: flex;
75781
+ justify-content: flex-end;
75782
+ margin: 16px;
75783
+ `;
75784
+ const MessageList = styled.div`
75785
+ display: flex;
75786
+ flex-direction: column;
75787
+ padding: 16px;
75788
+ gap: 8px;
75789
+ max-height: 400px;
75790
+ overflow-y: auto;
75791
+ `;
75792
+ const ToggleContainer = styled.div`
75793
+ display: flex;
75794
+ align-items: center;
75795
+ gap: 10px;
75796
+ margin-bottom: 15px;
75797
+ padding: 0 16px;
75798
+ `;
75799
+ const ToggleSwitch = styled.label`
75800
+ position: relative;
75801
+ display: inline-block;
75802
+ width: 60px;
75803
+ height: 34px;
75804
+ `;
75805
+ const ToggleInput = styled.input`
75806
+ opacity: 0;
75807
+ width: 0;
75808
+ height: 0;
75809
+
75810
+ &:checked + span {
75811
+ background-color: teal;
75812
+ }
75813
+
75814
+ &:checked + span:before {
75815
+ transform: translateX(26px);
75816
+ }
75817
+ `;
75818
+ const ToggleSlider = styled.span`
75819
+ position: absolute;
75820
+ cursor: pointer;
75821
+ top: 0;
75822
+ left: 0;
75823
+ right: 0;
75824
+ bottom: 0;
75825
+ background-color: #ccc;
75826
+ transition: 0.4s;
75827
+ border-radius: 34px;
75828
+
75829
+ &:before {
75830
+ position: absolute;
75831
+ content: "";
75832
+ height: 26px;
75833
+ width: 26px;
75834
+ left: 4px;
75835
+ bottom: 4px;
75836
+ background-color: white;
75837
+ transition: 0.4s;
75838
+ border-radius: 50%;
75839
+ }
75840
+ `;
75841
+ const ToggleLabel = styled.span`
75842
+ font-family: "Helvetica", "Arial", sans-serif;
75843
+ color: #666;
75844
+ font-size: 14px;
75845
+ `;
75846
+ styled(Select)`
75847
+ width: 600px;
75848
+ margin-bottom: 8px;
75849
+ margin: 26px;
75850
+ `;
75851
+ const Chat = ({
75852
+ socketUrl = "http://localhost:3000",
75853
+ isOpen = false,
75854
+ messageHistory = [],
75855
+ title = null,
75856
+ isSimulated = false,
75857
+ authToken,
75858
+ overrideStyle,
75859
+ onChange
75860
+ }) => {
75861
+ const [isChatOpen, setIsChatOpen] = useState(isOpen);
75862
+ const [message2, setMessage] = useState("");
75863
+ const [messages2, setMessages] = useState(messageHistory);
75864
+ const [serverStatus, setServerStatus] = useState("unknown");
75865
+ const [serverError, setServerError] = useState("");
75866
+ const socketRef = useRef(null);
75867
+ const messageListRef = useRef(null);
75381
75868
  const serverReadyRef = useRef(false);
75382
75869
  const handle = "user";
75383
75870
  const [isLocked, setIsLocked] = useState(false);
75871
+ const [messageStartTime, setMessageStartTime] = useState(null);
75872
+ const [currentQuestion, setCurrentQuestion] = useState("");
75873
+ const [isDataQueryMode, setIsDataQueryMode] = useState(false);
75874
+ const [hasReceivedResponse, setHasReceivedResponse] = useState(false);
75875
+ const timeoutRef = useRef(null);
75384
75876
  useEffect(() => {
75385
75877
  if (isSimulated) return;
75386
75878
  const socketUrlToUse = window.location.hostname === "localhost" && window.location.port === "6006" ? "http://localhost:3000" : socketUrl;
@@ -75445,27 +75937,46 @@ const Chat = ({
75445
75937
  serverReadyRef.current = true;
75446
75938
  });
75447
75939
  socket.on("message", (newMessage) => {
75940
+ console.log("\n=== Received Message Event ===");
75941
+ console.log("New Message:", newMessage);
75448
75942
  setMessages((prev2) => {
75449
75943
  if (newMessage.sender === "bot") {
75450
- if (newMessage.content === "Processing your message...") {
75944
+ if (newMessage.isThinking) {
75451
75945
  const hasThinkingMessage = prev2.some((msg) => msg.isThinking);
75452
75946
  if (hasThinkingMessage) {
75947
+ console.log("Already have thinking message, skipping");
75453
75948
  return prev2;
75454
75949
  }
75950
+ console.log("Adding thinking message");
75455
75951
  return [...prev2, { ...newMessage, isThinking: true }];
75456
75952
  }
75457
75953
  const thinkingMessage = prev2.find((msg) => msg.isThinking);
75458
75954
  if (thinkingMessage) {
75955
+ console.log("Replacing thinking message with final response");
75956
+ const updatedMessage = {
75957
+ ...newMessage,
75958
+ isThinking: false,
75959
+ content: newMessage.content || newMessage.response || "No response content"
75960
+ };
75459
75961
  return prev2.map(
75460
- (msg) => msg.isThinking ? { ...newMessage, isThinking: false } : msg
75962
+ (msg) => msg.isThinking ? updatedMessage : msg
75461
75963
  );
75462
75964
  }
75463
- return [...prev2, { ...newMessage, isThinking: false }];
75965
+ console.log("Adding new bot message");
75966
+ const messageToAdd = {
75967
+ ...newMessage,
75968
+ isThinking: false,
75969
+ content: newMessage.content || newMessage.response || "No response content"
75970
+ };
75971
+ console.log("messageToAdd", messageToAdd);
75972
+ return [...prev2, messageToAdd];
75464
75973
  }
75465
75974
  const lastUserMsg = [...prev2].reverse().find((msg) => msg.sender === "user");
75466
75975
  if (lastUserMsg && lastUserMsg.content === newMessage.content) {
75976
+ console.log("Duplicate user message, skipping");
75467
75977
  return prev2;
75468
75978
  }
75979
+ console.log("Adding new user message");
75469
75980
  return [...prev2, newMessage];
75470
75981
  });
75471
75982
  setIsLocked(false);
@@ -75496,6 +76007,44 @@ const Chat = ({
75496
76007
  setIsLocked(false);
75497
76008
  }
75498
76009
  }, 2e3);
76010
+ socket.on(
76011
+ "query_data_response",
76012
+ (response2) => {
76013
+ console.log("\n=== Received Query Data Response ===");
76014
+ console.log("Response:", response2);
76015
+ setMessages((prev2) => {
76016
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76017
+ if (!thinkingMessage) {
76018
+ console.log("No thinking message found, adding new message");
76019
+ return [
76020
+ ...prev2,
76021
+ {
76022
+ id: `bot_${Date.now()}`,
76023
+ content: response2.error || response2.response,
76024
+ sender: "bot",
76025
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76026
+ isThinking: false,
76027
+ data: response2.data,
76028
+ respondedBy: "ai"
76029
+ }
76030
+ ];
76031
+ }
76032
+ console.log("Replacing thinking message with response");
76033
+ return prev2.map(
76034
+ (msg) => msg.isThinking ? {
76035
+ id: msg.id,
76036
+ content: response2.error || response2.response,
76037
+ sender: "bot",
76038
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76039
+ isThinking: false,
76040
+ data: response2.data,
76041
+ respondedBy: "ai"
76042
+ } : msg
76043
+ );
76044
+ });
76045
+ setIsLocked(false);
76046
+ }
76047
+ );
75499
76048
  return () => {
75500
76049
  console.log("Disconnecting socket");
75501
76050
  socket.disconnect();
@@ -75538,11 +76087,14 @@ const Chat = ({
75538
76087
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
75539
76088
  };
75540
76089
  setIsLocked(true);
76090
+ setHasReceivedResponse(false);
76091
+ setMessageStartTime(Date.now());
76092
+ setCurrentQuestion(message2);
75541
76093
  setMessages((prev2) => [...prev2, userMessage]);
75542
76094
  if ((_a = socketRef.current) == null ? void 0 : _a.connected) {
75543
76095
  const botMessageId = `bot_${timestamp}`;
75544
76096
  const thinkingMessage = {
75545
- content: "",
76097
+ content: PROCESSING_MESSAGE,
75546
76098
  sender: "bot",
75547
76099
  id: botMessageId,
75548
76100
  isThinking: true,
@@ -75555,23 +76107,98 @@ const Chat = ({
75555
76107
  setIsLocked(false);
75556
76108
  return;
75557
76109
  }
75558
- socketRef.current.emit("message", userMessage);
75559
- if (socketRef.current.connected) {
75560
- setTimeout(() => {
75561
- setMessages(
75562
- (prev2) => prev2.map(
75563
- (msg) => msg.isThinking ? { ...msg, content: "Processing your message..." } : msg
75564
- )
75565
- );
75566
- }, 300);
75567
- setTimeout(() => {
75568
- setMessages((prev2) => prev2.filter((msg) => !msg.isThinking));
75569
- setServerError("No response from server");
75570
- setIsLocked(false);
75571
- }, 1e4);
76110
+ if (isDataQueryMode) {
76111
+ socketRef.current.emit(
76112
+ "query_data",
76113
+ { query: message2 },
76114
+ (response) => {
76115
+ console.log("\n=== Query Data Callback Response ===");
76116
+ console.log("Response:", response);
76117
+ if (timeoutRef.current) {
76118
+ clearTimeout(timeoutRef.current);
76119
+ timeoutRef.current = null;
76120
+ }
76121
+ setHasReceivedResponse(true);
76122
+ setMessages((prev2) => {
76123
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76124
+ if (!thinkingMessage) {
76125
+ console.log("No thinking message found, adding new message");
76126
+ return [
76127
+ ...prev2,
76128
+ {
76129
+ id: `bot_${Date.now()}`,
76130
+ content: response.error || response.response,
76131
+ sender: "bot",
76132
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76133
+ isThinking: false,
76134
+ data: response.data,
76135
+ respondedBy: "ai"
76136
+ }
76137
+ ];
76138
+ }
76139
+ console.log("Replacing thinking message with response");
76140
+ return prev2.map(
76141
+ (msg) => msg.isThinking ? {
76142
+ id: msg.id,
76143
+ content: response.error || response.response,
76144
+ sender: "bot",
76145
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76146
+ isThinking: false,
76147
+ data: response.data,
76148
+ respondedBy: "ai"
76149
+ } : msg
76150
+ );
76151
+ });
76152
+ setIsLocked(false);
76153
+ }
76154
+ );
76155
+ timeoutRef.current = setTimeout(() => {
76156
+ if (!hasReceivedResponse) {
76157
+ setMessages((prev2) => {
76158
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76159
+ if (thinkingMessage) {
76160
+ return prev2.map(
76161
+ (msg) => msg.isThinking ? {
76162
+ ...msg,
76163
+ content: "The query is taking longer than expected. Please try again or rephrase your question.",
76164
+ isThinking: false,
76165
+ respondedBy: "ai"
76166
+ } : msg
76167
+ );
76168
+ }
76169
+ return prev2;
76170
+ });
76171
+ setIsLocked(false);
76172
+ }
76173
+ }, 9e4);
76174
+ } else {
76175
+ socketRef.current.emit("message", userMessage);
75572
76176
  }
75573
76177
  setMessage("");
75574
76178
  };
76179
+ useEffect(() => {
76180
+ const lastMessage = messages2.at(-1);
76181
+ if (!lastMessage || !messageStartTime || !currentQuestion) return;
76182
+ if (lastMessage.sender === "bot" && !lastMessage.isThinking) {
76183
+ const timeToRespond = Date.now() - messageStartTime;
76184
+ const chatHistoryRecord = {
76185
+ visitorId: "user",
76186
+ // You might want to get this from props or context
76187
+ visitorEmail: "",
76188
+ // You might want to get this from props or context
76189
+ name: handle,
76190
+ question: currentQuestion,
76191
+ response: lastMessage.content,
76192
+ timeToRespond,
76193
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
76194
+ responseBy: lastMessage.respondedBy || "ai"
76195
+ // Use the respondedBy from the message, default to "ai"
76196
+ };
76197
+ onChange == null ? void 0 : onChange(chatHistoryRecord);
76198
+ setMessageStartTime(null);
76199
+ setCurrentQuestion("");
76200
+ }
76201
+ }, [messages2, messageStartTime, currentQuestion, onChange, handle]);
75575
76202
  const toggleChat = () => {
75576
76203
  setIsChatOpen(!isChatOpen);
75577
76204
  };
@@ -75581,40 +76208,93 @@ const Chat = ({
75581
76208
  if (serverStatus === "error") {
75582
76209
  return /* @__PURE__ */ jsx(ErrorMessage, { children: "Network error" });
75583
76210
  }
75584
- const uniqueMessages = messages2.filter(
75585
- (msg, index2, self2) => index2 === self2.findIndex((t2) => t2.id === msg.id)
75586
- );
76211
+ const uniqueMessages = messages2.filter((msg, index2, self2) => {
76212
+ const duplicates = self2.filter((m) => m.id === msg.id);
76213
+ if (duplicates.length > 1) {
76214
+ if (msg.respondedBy === "ai" || msg.respondedBy === "search") return true;
76215
+ if (msg.isThinking || msg.content === PROCESSING_MESSAGE) {
76216
+ return !duplicates.some(
76217
+ (m) => m.respondedBy === "ai" || m.respondedBy === "search"
76218
+ );
76219
+ }
76220
+ return false;
76221
+ }
76222
+ return true;
76223
+ });
75587
76224
  console.log("uniqueMessages", uniqueMessages);
75588
- return /* @__PURE__ */ jsxs(ChatContainer, { children: [
75589
- /* @__PURE__ */ jsx(HeroContainer, { $isVisible: !isChatOpen, children: /* @__PURE__ */ jsxs("div", { children: [
75590
- title ? /* @__PURE__ */ jsx(Typography, { variant: "heading3", children: title }) : null,
76225
+ console.log("messages", messages2);
76226
+ useEffect(() => {
76227
+ return () => {
76228
+ if (timeoutRef.current) {
76229
+ clearTimeout(timeoutRef.current);
76230
+ }
76231
+ };
76232
+ }, []);
76233
+ return /* @__PURE__ */ jsxs(ChatContainer, { style: overrideStyle || {}, children: [
76234
+ /* @__PURE__ */ jsx(HeroContainer, { $isVisible: !isChatOpen, children: /* @__PURE__ */ jsxs("div", { children: [
76235
+ title && /* @__PURE__ */ jsx(Typography, { variant: "heading3", children: title }),
75591
76236
  /* @__PURE__ */ jsx(Subtitle, { children: "Click the Chat Icon below to begin" }),
75592
76237
  serverError ? /* @__PURE__ */ jsx(ErrorMessage, { children: serverError }) : null
75593
76238
  ] }) }),
75594
76239
  isChatOpen ? /* @__PURE__ */ jsxs(Fragment, { children: [
75595
76240
  /* @__PURE__ */ jsx(HeroContainer, { $isVisible: true, children: /* @__PURE__ */ jsx("div", { children: title ? /* @__PURE__ */ jsx(Typography, { variant: "heading2", children: title }) : null }) }),
76241
+ /* @__PURE__ */ jsxs(ToggleContainer, { children: [
76242
+ /* @__PURE__ */ jsxs(ToggleSwitch, { children: [
76243
+ /* @__PURE__ */ jsx(
76244
+ ToggleInput,
76245
+ {
76246
+ type: "checkbox",
76247
+ checked: isDataQueryMode,
76248
+ onChange: (e2) => setIsDataQueryMode(e2.target.checked)
76249
+ }
76250
+ ),
76251
+ /* @__PURE__ */ jsx(ToggleSlider, {})
76252
+ ] }),
76253
+ /* @__PURE__ */ jsx(ToggleLabel, { children: isDataQueryMode ? "Data Query Mode" : "Regular Chat" })
76254
+ ] }),
75596
76255
  /* @__PURE__ */ jsx(MessageList, { ref: messageListRef, children: uniqueMessages.map((msg) => /* @__PURE__ */ jsx(
75597
76256
  Message$1,
75598
76257
  {
75599
76258
  message: msg.content,
75600
76259
  handle: msg.sender,
75601
- isThinking: msg.isThinking
76260
+ isThinking: msg.isThinking,
76261
+ data: msg.data
75602
76262
  },
75603
76263
  msg.id
75604
76264
  )) }),
75605
- /* @__PURE__ */ jsxs(InputContainer, { children: [
75606
- /* @__PURE__ */ jsx(
75607
- Input2,
76265
+ /* @__PURE__ */ jsxs(Fragment, { children: [
76266
+ /* @__PURE__ */ jsxs(InputContainer, { children: [
76267
+ /* @__PURE__ */ jsx("div", { style: { width: 600 }, children: /* @__PURE__ */ jsx(
76268
+ Input2,
76269
+ {
76270
+ type: "text",
76271
+ value: message2,
76272
+ onChange: handleInputChange,
76273
+ onKeyDown: handleKeyDown,
76274
+ placeholder: isDataQueryMode ? "Ask about proposals, views, or chat questions..." : "Type a message...",
76275
+ disabled: isLocked,
76276
+ style: { width: 600 }
76277
+ }
76278
+ ) }),
76279
+ /* @__PURE__ */ jsx(Button$1, { onClick: sendMessage, disabled: isLocked, children: "Send" })
76280
+ ] }),
76281
+ isDataQueryMode && /* @__PURE__ */ jsx("div", { style: { marginTop: 8, marginLeft: 8 }, children: /* @__PURE__ */ jsx(
76282
+ Select,
75608
76283
  {
75609
- type: "text",
75610
- value: message2,
75611
- onChange: handleInputChange,
75612
- onKeyDown: handleKeyDown,
75613
- placeholder: "Type a message & press Enter or Send",
75614
- disabled: isLocked
76284
+ width: 400,
76285
+ options: PREDEFINED_QUERIES.map((query) => ({
76286
+ label: query,
76287
+ value: query
76288
+ })),
76289
+ placeholder: "Select a predefined query...",
76290
+ onChange: (selected) => {
76291
+ if (selected) {
76292
+ setMessage(selected);
76293
+ }
76294
+ },
76295
+ isSingleSelect: true
75615
76296
  }
75616
- ),
75617
- /* @__PURE__ */ jsx(Button$1, { onClick: sendMessage, disabled: isLocked, children: "Send" })
76297
+ ) })
75618
76298
  ] })
75619
76299
  ] }) : /* @__PURE__ */ jsx(ChatButton, { onClick: toggleChat, children: "Chat" })
75620
76300
  ] });
@@ -78681,338 +79361,6 @@ const SegmentedControls = ({
78681
79361
  }
78682
79362
  );
78683
79363
  };
78684
- const getBackgroundColor = (colors2, disabled2, $variant) => {
78685
- if ($variant === "simple") return "#F4F4F4";
78686
- if (disabled2) return "#F4F4F4";
78687
- return "#fff";
78688
- };
78689
- const TriggerWrapper = styled.div`
78690
- display: flex;
78691
- align-items: center;
78692
- justify-content: space-between;
78693
- cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
78694
- opacity: ${({ $disabled }) => $disabled ? 0.4 : 1};
78695
- position: relative;
78696
- box-shadow: ${({ $variant }) => $variant === "simple" ? "none" : "0px 1px 2px 0px rgba(0, 0, 0, 0.12)"};
78697
- transition: all 0.2s ease-in-out;
78698
- min-height: ${({ $variant }) => $variant === "simple" ? "32px" : "40px"};
78699
-
78700
- &:focus-visible {
78701
- outline: none;
78702
- }
78703
-
78704
- &:focus {
78705
- box-shadow:
78706
- 0px 1px 2px 0px rgba(0, 0, 0, 0.12),
78707
- 0 0 0 3px
78708
- ${({ theme, $themeType = "primary" }) => theme.colors[$themeType].focussed.ringColor};
78709
- }
78710
-
78711
- ${({ $variant, theme, $disabled }) => {
78712
- var _a;
78713
- return $variant === "simple" ? `
78714
- padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
78715
- background: ${$disabled ? theme.colors.inputs.surface.disabled : "rgba(0, 0, 0, 0.04)"};
78716
- border: none;
78717
- border-radius: ${theme.borderRadius.BorderRadiusSm}px;
78718
- min-height: ${({ $variant: $variant2 }) => $variant2 === "simple" ? "32px" : "40px"};
78719
-
78720
- &:hover {
78721
- border: none;
78722
- }
78723
- ` : `
78724
- padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
78725
- background: ${$disabled ? theme.colors.inputs.surface.disabled : (_a = theme.colors.surface.default) == null ? void 0 : _a.backgroundColor};
78726
- border: 1px solid #9a9a9a;
78727
- border-radius: ${theme.borderRadius.BorderRadiusSm}px;
78728
- min-height: ${({ $variant: $variant2 }) => $variant2 === "simple" ? "32px" : "40px"};
78729
-
78730
- &:hover {
78731
- border-color: rgba(0, 0, 0, 0.2);
78732
- }
78733
- `;
78734
- }}
78735
- `;
78736
- const ValueContainer = styled.div`
78737
- display: flex;
78738
- align-items: center;
78739
- gap: ${({ theme }) => theme.sizing.Size2}px;
78740
- flex: 1;
78741
- padding: 4px 8px;
78742
- `;
78743
- const ChevronContainer = styled.div`
78744
- display: flex;
78745
- align-items: center;
78746
- justify-content: center;
78747
- margin-right: ${({ $variant }) => $variant === "simple" ? "4px" : "4px"};
78748
- margin-left: ${({ $variant }) => $variant === "simple" ? "4px" : "0"};
78749
- `;
78750
- const SelectTrigger2 = ({
78751
- type: type4 = "primary",
78752
- theme,
78753
- state,
78754
- value: value2,
78755
- placeholder = "Select...",
78756
- open,
78757
- onClick,
78758
- renderValue,
78759
- options = [],
78760
- disabled: disabled2 = false,
78761
- variant = "none"
78762
- }) => {
78763
- const handleClick = React__default.useCallback(() => {
78764
- if (disabled2) return;
78765
- onClick == null ? void 0 : onClick();
78766
- }, [disabled2, onClick]);
78767
- const displayValue = React__default.useMemo(() => {
78768
- if (!value2) return null;
78769
- if (renderValue) return renderValue(value2);
78770
- if (Array.isArray(value2)) {
78771
- if (value2.length === 0) return null;
78772
- const selectedLabels = value2.map(String).map((v) => {
78773
- var _a;
78774
- return (_a = options.find((opt) => opt.value === v)) == null ? void 0 : _a.label;
78775
- }).filter(Boolean);
78776
- return selectedLabels.length > 0 ? selectedLabels.join(", ") : `${value2.length} selected`;
78777
- }
78778
- const selectedOption = options.find((opt) => opt.value === String(value2));
78779
- return (selectedOption == null ? void 0 : selectedOption.label) || value2.toString();
78780
- }, [value2, renderValue, options]);
78781
- return /* @__PURE__ */ jsxs(
78782
- TriggerWrapper,
78783
- {
78784
- $themeType: type4,
78785
- $state: state,
78786
- onClick: handleClick,
78787
- tabIndex: disabled2 ? -1 : 0,
78788
- role: "button",
78789
- $disabled: disabled2,
78790
- $variant: variant,
78791
- style: {
78792
- backgroundColor: getBackgroundColor(theme, disabled2, variant)
78793
- },
78794
- children: [
78795
- /* @__PURE__ */ jsx(ValueContainer, { $variant: variant, children: displayValue ? /* @__PURE__ */ jsx(Typography, { variant: "body2", color: disabled2 ? "copy-light" : "copy", children: displayValue }) : /* @__PURE__ */ jsx(
78796
- Typography,
78797
- {
78798
- variant: "body2",
78799
- color: disabled2 ? "copy-light" : "copy-light",
78800
- children: placeholder
78801
- }
78802
- ) }),
78803
- /* @__PURE__ */ jsx(ChevronContainer, { $variant: variant, children: /* @__PURE__ */ jsx(DropdownChevron, {}) })
78804
- ]
78805
- }
78806
- );
78807
- };
78808
- const SelectWrapper = styled.div`
78809
- position: relative;
78810
- background-color: transparent;
78811
- border-radius: 8px;
78812
- width: auto;
78813
-
78814
- ${({ $isFocused, theme, type: type4 = "primary" }) => $isFocused && `
78815
- background-color: transparent;
78816
- `}
78817
-
78818
- ${({ disabled: disabled2, theme }) => disabled2 && `
78819
- cursor: not-allowed;
78820
-
78821
- &:hover {
78822
- border-color: ${theme.colors.inputs.surface.border};
78823
- }
78824
- `}
78825
- `;
78826
- const SelectDropdown = styled.div`
78827
- padding: 0px;
78828
- border-radius: 0px;
78829
- animation-duration: ${({ theme }) => `${theme.motion.veryfast}s`};
78830
- transition: all ${({ theme }) => `${theme.motion.veryfast}s`}
78831
- cubic-bezier(0.645, 0.045, 0.355, 1);
78832
-
78833
- &.entering {
78834
- opacity: 0;
78835
- transform: scaleY(0.8);
78836
- }
78837
-
78838
- &.entered {
78839
- opacity: 1;
78840
- transform: scaleY(1);
78841
- }
78842
-
78843
- &.exiting {
78844
- opacity: 0;
78845
- transform: scaleY(0.8);
78846
- }
78847
- `;
78848
- const MenuItem = styled.div`
78849
- padding: 8px 12px;
78850
- cursor: ${({ disabled: disabled2 }) => disabled2 ? "not-allowed" : "pointer"};
78851
- background-color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.backgroundColor : "transparent"};
78852
- color: ${({ $isSelected, disabled: disabled2, theme, type: type4 = "primary" }) => disabled2 ? theme.colors.inputs.onsurface.disabled : $isSelected ? theme.colors[type4].hover.color : theme.colors.onsurface.copy};
78853
- display: flex;
78854
- justify-content: space-between;
78855
- align-items: center;
78856
- transition: all ${({ theme }) => `${theme.motion.veryfast}s`} ease-in-out;
78857
- opacity: ${({ disabled: disabled2 }) => disabled2 ? 0.5 : 1};
78858
-
78859
- ${({ disabled: disabled2 }) => !disabled2 && `
78860
- &:hover {
78861
- background-color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.backgroundColor : "rgba(0, 0, 0, 0.04)"};
78862
- color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.color : theme.colors.onsurface["copy-dark"]};
78863
- }
78864
-
78865
- &:active {
78866
- background-color: ${({ theme, type: type4 = "primary" }) => theme.colors[type4].hover.backgroundColor};
78867
- color: ${({ theme, type: type4 = "primary" }) => theme.colors[type4].hover.color};
78868
- }
78869
- `}
78870
- `;
78871
- const Select = ({
78872
- type: type4 = TYPE.primary,
78873
- state,
78874
- variant = "none",
78875
- defaultValue,
78876
- onChange,
78877
- size = "normal",
78878
- width = "100%",
78879
- value: value2,
78880
- options = [],
78881
- placeholder,
78882
- selectDisplayMode = "count",
78883
- isSingleSelect = false,
78884
- disabled: disabled2 = false,
78885
- ...rest
78886
- }) => {
78887
- const [isOpen, setIsOpen] = React__default.useState(false);
78888
- const [isFocused, setIsFocused] = React__default.useState(false);
78889
- const [dropdownAnimation, setDropdownAnimation] = React__default.useState("entered");
78890
- const selectReference = React__default.useRef(null);
78891
- const { theme } = useGenesis();
78892
- React__default.useEffect(() => {
78893
- const handleClickOutside = (event) => {
78894
- if (selectReference.current && !selectReference.current.contains(event.target)) {
78895
- handleClose();
78896
- setIsFocused(false);
78897
- }
78898
- };
78899
- if (isOpen) {
78900
- document.addEventListener("mousedown", handleClickOutside);
78901
- }
78902
- return () => {
78903
- document.removeEventListener("mousedown", handleClickOutside);
78904
- };
78905
- }, [isOpen]);
78906
- const handleClose = () => {
78907
- setDropdownAnimation("exiting");
78908
- setTimeout(() => {
78909
- setIsOpen(false);
78910
- setDropdownAnimation("entered");
78911
- }, 200);
78912
- };
78913
- const handleTriggerClick = () => {
78914
- if (disabled2) return;
78915
- setIsFocused(true);
78916
- if (isOpen) {
78917
- handleClose();
78918
- } else {
78919
- setIsOpen(true);
78920
- setDropdownAnimation("entering");
78921
- setTimeout(() => {
78922
- setDropdownAnimation("entered");
78923
- }, 0);
78924
- }
78925
- };
78926
- const handleOptionSelect = (optionValue) => {
78927
- if (disabled2) return;
78928
- let newValue;
78929
- if (Array.isArray(value2)) {
78930
- const stringValue = value2.map(String);
78931
- newValue = stringValue.includes(optionValue) ? stringValue.filter((v) => v !== optionValue) : [...stringValue, optionValue];
78932
- } else {
78933
- newValue = optionValue;
78934
- }
78935
- onChange == null ? void 0 : onChange(newValue);
78936
- if (isSingleSelect) {
78937
- handleClose();
78938
- }
78939
- };
78940
- const getSelectModeValue = (value22) => {
78941
- if (Array.isArray(value22)) {
78942
- if (selectDisplayMode === "count") {
78943
- return `${value22.length} selected`;
78944
- }
78945
- return value22;
78946
- }
78947
- return value22;
78948
- };
78949
- const modeValue = getSelectModeValue(value2);
78950
- return /* @__PURE__ */ jsx("div", { style: { position: "relative", width }, children: /* @__PURE__ */ jsxs(
78951
- SelectWrapper,
78952
- {
78953
- ref: selectReference,
78954
- $isFocused: isFocused,
78955
- type: type4,
78956
- disabled: disabled2,
78957
- onFocus: () => !disabled2 && setIsFocused(true),
78958
- onBlur: () => !isOpen && setIsFocused(false),
78959
- tabIndex: disabled2 ? -1 : 0,
78960
- children: [
78961
- /* @__PURE__ */ jsx(
78962
- SelectTrigger2,
78963
- {
78964
- theme,
78965
- type: type4,
78966
- state,
78967
- value: modeValue,
78968
- placeholder,
78969
- open: isOpen,
78970
- onClick: handleTriggerClick,
78971
- options,
78972
- disabled: disabled2,
78973
- variant
78974
- }
78975
- ),
78976
- isOpen && !disabled2 && /* @__PURE__ */ jsx(
78977
- SelectDropdown,
78978
- {
78979
- type: type4,
78980
- state,
78981
- className: dropdownAnimation,
78982
- style: {
78983
- position: "absolute",
78984
- top: "calc(100% + 4px)",
78985
- left: 0,
78986
- right: 0,
78987
- zIndex: 1e3,
78988
- backgroundColor: "white",
78989
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
78990
- border: "1px solid #d9d9d9",
78991
- transformOrigin: "top"
78992
- },
78993
- children: options.map((option) => {
78994
- const isSelected = Array.isArray(value2) ? value2.map(String).includes(option.value) : String(value2) === option.value;
78995
- return /* @__PURE__ */ jsxs(
78996
- MenuItem,
78997
- {
78998
- onClick: () => handleOptionSelect(option.value),
78999
- $isSelected: isSelected,
79000
- type: type4,
79001
- disabled: disabled2,
79002
- children: [
79003
- option.label,
79004
- isSelected && /* @__PURE__ */ jsx("span", { style: { marginLeft: "8px" }, children: "✓" })
79005
- ]
79006
- },
79007
- option.value
79008
- );
79009
- })
79010
- }
79011
- )
79012
- ]
79013
- }
79014
- ) });
79015
- };
79016
79364
  const Circle2 = ({ fill = "#CF3237", dataTestId }) => /* @__PURE__ */ jsx(
79017
79365
  "svg",
79018
79366
  {