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G,CAAW,CACd,GAAG6C,CAAsB,CAC1BtE,KAAK,mBACLV,OAAO,IACPuB,QAASgD,EACT8D,mBAAkBnF,EAClB3C,UAAU,oBACX,iBAGH,CACF,UAACkG,IAAAA,UACKjE,EAAAA,KAAAA,EAAAA,EAAgBJ,gBAAhBI,GAAmC,CACvCjC,UAAU,wCACV0E,GAAI/B,WAEHd,wBAUjB,EAEI,SAFW,EAEVkG,EAAAA,EAAW,EACVC,aAAc,IACRC,GAAQjG,GACVA,GAEJ,UAH8B,EAK9B,UAAC+F,EAAAA,EAAc,EACb/H,UAAU,kCACVK,aAAW,kBAEX,UAACgB,EAAAA,CAAIA,CAAAA,CAACC,KAAK,aAEb,UAACyG,EAAAA,EAAa,WACZ,UAACA,EAAAA,EAAc,EAAC/H,UAAU,mCACxB,WAAC+H,EAAAA,EAAc,EAAC/H,UAAU,4CACvB6E,EAED,UAACkD,EAAAA,EAAY,EAAC/H,UAAU,yCAAgC,oBAS3D6E,CAEX,2EG1eA,IAAMqD,EAAS,CAAC,aAAc,UAAW,OAAQ,OAAO,CAElDC,EAAU,CAAC,CAAC,SAAU,IAAK,SAAU,IAAK,QAAS,IAAI,CAAC,CAEvD,SAASV,EAAUW,CAAY,EACpC,IAAIC,EAASD,EAOb,IAAK,IAAME,KAJXD,EAASA,EACNT,UAAU,CAAC,SAAU,UACrBA,UAAU,CAAC,UAAW,WAERM,GACfG,EAASA,EADc,UACG,CAACC,EAAI,IAEjC,IAAK,GAAM,CAACtD,EAAK5E,EAAM,GAAI+H,EACzBE,EAASA,EAAOT,EADkB,QACR,CAAC5C,EAAK5E,GAQlC,OAJSiI,EACNT,UAAU,CAAC,SAAU,UACrBA,UAAU,CAAC,UAAW,UAG3B","sources":["webpack://_N_E/../design-system/src/components/search/search-box/search-box.tsx","webpack://_N_E/../design-system/src/components/search/search-dropdown/search-dropdown.tsx","webpack://_N_E/../design-system/src/components/search/search-box/search-box.scss?8b43","webpack://_N_E/../design-system/src/components/search/search-dropdown/search-dropdown.scss?2769","webpack://_N_E/./src/contentful/components/utils/strip-html.ts"],"sourcesContent":["import \"./search-box.scss\";\n\nimport cn from \"clsx\";\nimport {\n useState,\n useEffect,\n forwardRef,\n ChangeEvent,\n InputHTMLAttributes,\n Dispatch,\n SetStateAction,\n MouseEventHandler,\n KeyboardEventHandler,\n} from \"react\";\nimport { Icon } from \"design-system/components/icons/icon\";\n\ntype InputProps = Omit<\n InputHTMLAttributes,\n \"className\" | \"type\" | \"value\" | \"onChange\" | \"aria-label\"\n>;\n\nexport interface SearchBoxProps extends InputProps {\n searchTerm?: string;\n placeholder?: string;\n hasDropdown?: boolean;\n triggerOverlay?: boolean;\n isSmall?: boolean;\n handleSearch?: (term: string) => void;\n handleKeydownSearch?: KeyboardEventHandler;\n handleMousedownSearch?: MouseEventHandler;\n onReset?: () => void;\n setShowDropdown?: Dispatch>;\n}\n\n/**\n * ## See it in use on...\n * - The [archive page](/story/example-pages-archive-pages-story-archive--story)\n *\n * - **`id: P-021-000-00`**\n */\nexport const SearchBox = forwardRef(\n (\n {\n searchTerm = \"\",\n handleSearch,\n handleKeydownSearch,\n handleMousedownSearch,\n onReset,\n hasDropdown = false,\n placeholder,\n setShowDropdown,\n isSmall = false,\n ...inputProps\n },\n ref,\n ) => {\n const [searchValue, setSearchValue] = useState(searchTerm);\n\n useEffect(() => {\n setSearchValue(searchTerm);\n }, [searchTerm]);\n\n function handleChange(e: ChangeEvent) {\n if (e.currentTarget) {\n setSearchValue(e.currentTarget.value);\n if (hasDropdown) {\n handleSearch?.(e.currentTarget.value);\n }\n }\n }\n\n const handleReset = () => {\n setSearchValue(\"\");\n\n if (onReset) {\n onReset();\n }\n\n if (setShowDropdown) {\n setShowDropdown(false);\n }\n };\n\n return (\n
\n \n {\n setShowDropdown?.((prev) => !prev);\n }}\n onMouseDown={handleMousedownSearch}\n tabIndex={-1}\n >\n Search\n \n \n
\n );\n },\n);\n","import \"./search-dropdown.scss\";\n\nimport cn from \"clsx\";\nimport {\n useState,\n useRef,\n KeyboardEventHandler,\n MouseEventHandler,\n useId,\n} from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport { Link } from \"design-system/components/primitives/link/link\";\nimport {\n CtaLink,\n CtaLinkProps,\n} from \"design-system/components/primitives/cta-link/cta-link\";\nimport { SearchBox } from \"../search-box/search-box\";\nimport { Icon } from \"design-system/components/icons/icon\";\nimport { EditAttributes } from \"design-system/types/types\";\nimport { Suggestions, ModernSearchHit } from \"frontend/types\";\nimport { Display } from \"frontend/lib/es/es-types\";\nimport { DataLayerEvent, useDataLayer } from \"frontend/hooks/use-data-layer\";\nimport { SiteEntry } from \"frontend/contentful/schema/universal\";\nimport { stripHtml } from \"frontend/contentful/components/utils/strip-html\";\n\nexport interface SearchBoxDropdownProps {\n searchTerm?: string;\n handleSearch?: (term: string) => void;\n onReset?: () => void;\n placeholder?: string;\n hasDropdown?: boolean;\n dropdownItems?: Array;\n dropdownSuggestions?: Suggestions[\"updatedSuggestions\"];\n dropdownCta?: CtaLinkProps;\n dropdownFooterLabel?: string;\n isOverlay?: boolean;\n searchLink?: string;\n onOpenCallback?: () => void;\n site?: SiteEntry;\n editAttributes?: {\n dropdownFooterLabel?: EditAttributes;\n };\n}\n\n/**\n * ## See it in use on...\n * - The [archive page](/story/example-pages-archive-pages-story-archive--story)\n *\n * - **`id: P-021-000-00`**\n */\nexport function SearchBoxDropdown({\n searchTerm = \"\",\n handleSearch,\n hasDropdown = false,\n onReset,\n placeholder,\n dropdownItems,\n dropdownSuggestions,\n dropdownCta,\n dropdownFooterLabel,\n isOverlay = false,\n searchLink,\n onOpenCallback,\n editAttributes,\n site,\n}: SearchBoxDropdownProps) {\n const [showDropdown, setShowDropdown] = useState(false);\n const [selectedItemIndex, setSelectedItemIndex] = useState(\n null,\n );\n const selectedItem =\n selectedItemIndex !== null ? dropdownItems?.[selectedItemIndex] : null;\n\n if (!showDropdown && selectedItemIndex !== null) {\n setSelectedItemIndex(null);\n }\n const inputRef = useRef(null);\n\n const dropdownId = useId();\n const dropdownListLabelId = useId();\n const dropdownFooterLabelId = useId();\n const { pushDataLayer } = useDataLayer();\n const dataLayerEvent: DataLayerEvent = {\n event: \"search_results\",\n /* eslint-disable camelcase */\n event_data: {\n search_numresults: dropdownItems?.length,\n search_type: \"search-primary\",\n search_type_ahead: false,\n top_search: true,\n search_result_page_url:\n typeof window !== \"undefined\" ? window.location.href : \"\",\n explore_search: site?.fields.title?.includes(\"Knowledge\") ? true : false,\n },\n /* eslint-enable camelcase */\n };\n\n const numberOfItems = (dropdownItems?.length || 0) + 1;\n\n const hasResults = dropdownItems && dropdownItems.length > 0;\n\n const hasSuggestions =\n dropdownSuggestions?.total && dropdownSuggestions.total > 0;\n\n function blurHandler() {\n if (!hasSuggestions && !hasResults) {\n setTimeout(function () {\n setShowDropdown(false);\n }, 300);\n }\n }\n\n function handleChange(term: string) {\n if (term) {\n handleSearch?.(term);\n setShowDropdown(true);\n } else if (term === \"\" && !isOverlay) {\n setShowDropdown(false);\n }\n }\n\n function focusHandler(term?: string) {\n if (\n inputRef?.current?.value &&\n inputRef?.current?.value !== \"\" &&\n hasResults\n ) {\n setShowDropdown(true);\n } else if (term === \"\") {\n setShowDropdown(false);\n }\n }\n\n const redirectToSearch = () => {\n if (inputRef.current) {\n const inputValue = inputRef.current?.value\n ? encodeURIComponent(inputRef.current?.value)\n : undefined;\n const href = searchLink || \"https://www.hbs.edu/search\";\n window.location.href = `${href}?q=${inputValue}`;\n }\n };\n\n const redirectQuerySearch = (searchQuery: string | undefined) => {\n if (inputRef.current || searchQuery) {\n const inputValue = inputRef.current?.value\n ? encodeURIComponent(inputRef.current?.value)\n : undefined;\n const q = inputValue || searchQuery;\n const href = searchLink || \"https://www.hbs.edu/search\";\n window.location.href = `${href}?q=${q}`;\n }\n };\n\n const redirectMouseQueryToSearch:\n | MouseEventHandler\n | undefined = (e) => {\n const input = e.currentTarget?.previousElementSibling as HTMLInputElement;\n if (\n !e.currentTarget?.previousElementSibling?.classList.contains(\n \"hbs-search-box__input\",\n )\n ) {\n return;\n }\n e.preventDefault();\n redirectQuerySearch(input.value);\n };\n\n const redirectQueryToSearch: KeyboardEventHandler = (e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n const inputValue = inputRef?.current?.value;\n if (inputValue) redirectQuerySearch(inputValue);\n }\n };\n\n const handleInputKeyDown: KeyboardEventHandler = (e) => {\n switch (e.key) {\n case \"ArrowDown\":\n if (!hasResults && !hasSuggestions) {\n return;\n }\n\n setShowDropdown(true);\n\n setSelectedItemIndex((prev) => {\n if (prev === null) return 0;\n return prev === numberOfItems - 1 ? 0 : prev + 1;\n });\n\n e.stopPropagation();\n e.preventDefault();\n break;\n case \"ArrowUp\":\n if (!hasResults && !hasSuggestions) {\n return;\n }\n\n setShowDropdown(true);\n\n setSelectedItemIndex((prev) => {\n if (prev === null) return numberOfItems - 1;\n return prev === 0 ? numberOfItems - 1 : prev - 1;\n });\n\n e.stopPropagation();\n e.preventDefault();\n break;\n case \"Escape\":\n if (showDropdown && !isOverlay) {\n e.stopPropagation();\n e.preventDefault();\n\n setShowDropdown(false);\n }\n\n break;\n case \"Enter\":\n if (selectedItem?.url) {\n window.location.href = selectedItem.url;\n } else {\n setShowDropdown(false);\n }\n break;\n default:\n if (e.key !== \"Home\" && e.key !== \"End\") {\n setSelectedItemIndex(null);\n }\n break;\n }\n };\n\n const footerCtaComboboxProps = {\n id: `${dropdownId}-${dropdownItems?.length || 0}`,\n \"aria-selected\":\n selectedItemIndex !== null && selectedItemIndex === dropdownItems?.length,\n tabIndex: -1,\n };\n\n const isDropdownVisible = showDropdown || isOverlay;\n\n let display: Display = {};\n let handleOnClick: (() => void) | undefined;\n\n const searchBoxDropdown = (\n \n focusHandler()}\n onBlur={() => blurHandler()}\n ref={inputRef}\n autoFocus={isOverlay}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={isDropdownVisible}\n aria-controls={dropdownId}\n aria-activedescendant={\n selectedItemIndex !== null\n ? `${dropdownId}-${selectedItemIndex}`\n : undefined\n }\n />\n
\n {isDropdownVisible && (\n 0 &&\n \"suggestions\",\n )}\n >\n
\n
\n {hasResults && (\n \n Top {searchTerm === \"\" ? \"Searches\" : \"Results\"}\n

\n )}\n {dropdownItems && dropdownItems.length > 0 && (\n \n {dropdownItems.map(\n (item, i) => (\n (display = item.display || {}),\n /* eslint-disable camelcase */\n inputRef.current?.value &&\n (handleOnClick = () => {\n dataLayerEvent.event_data.search_term =\n inputRef.current?.value;\n dataLayerEvent.event_data.search_result_title =\n item.title;\n dataLayerEvent.event_data.search_result_url =\n item.url;\n dataLayerEvent.event_data.search_result_position =\n i + 1;\n dataLayerEvent.event_data.search_numresults =\n undefined;\n pushDataLayer(dataLayerEvent);\n }),\n (\n /* eslint-enable camelcase */\n \n \n \n {display.category?.label && (\n

\n {display.category?.label}\n

\n )}\n \n \n )\n ),\n )}\n \n )}\n\n {dropdownSuggestions?.suggestions?.map(\n (type, i) =>\n type.group &&\n type.group?.length > 0 && (\n \n {type?.group?.map((suggestion, i) => {\n handleOnClick = () => {\n /* eslint-disable camelcase */\n dataLayerEvent.event_data.search_term =\n inputRef.current?.value;\n dataLayerEvent.event_data.search_result_title =\n suggestion.suggestion\n ? stripHtml(suggestion.suggestion)\n : suggestion.suggestion;\n dataLayerEvent.event_data.search_result_url =\n suggestion.conceptUri;\n dataLayerEvent.event_data.search_result_position =\n i + 1;\n dataLayerEvent.event_data.explore_search_category =\n type.groupName;\n dataLayerEvent.event_data.search_type =\n \"search-secondary\";\n dataLayerEvent.event_data.search_numresults =\n undefined;\n pushDataLayer(dataLayerEvent);\n /* eslint-enable camelcase */\n };\n\n return (\n suggestion.suggestion && (\n \n \n \", \"\")\n .replaceAll(\"\", \"\"),\n }}\n />\n \n \n )\n );\n })}\n \n ),\n )}\n
\n
\n {dropdownCta &&\n (hasResults || hasSuggestions ? (\n \n ) : (\n \n View Results\n \n ))}\n \n {dropdownFooterLabel}\n

\n
\n
\n
\n )}\n \n \n );\n\n if (isOverlay) {\n return (\n {\n if (open && onOpenCallback) {\n onOpenCallback();\n }\n }}\n >\n \n \n \n \n \n \n {searchBoxDropdown}\n\n \n Close\n \n \n \n \n \n );\n } else {\n return searchBoxDropdown;\n }\n}\n","// extracted by mini-css-extract-plugin","// extracted by mini-css-extract-plugin","const remove = [/<[^>]*>?/gm, /\\u00AD/g, \"<\", \">\"] as const;\n\nconst replace = [[\""\", '\"', \"'\", \"'\", \"&\", \"&\"]] as const;\n\nexport function stripHtml(html: string): string {\n let result = html;\n\n // Protect the mark tags returned from highlighted search results\n result = result\n .replaceAll(\"\", \"[mark]\")\n .replaceAll(\"\", \"[/mark]\");\n\n for (const rm of remove) {\n result = result.replaceAll(rm, \"\");\n }\n for (const [key, value] of replace) {\n result = result.replaceAll(key, value);\n }\n\n // Return the mark tags to original state\n result = result\n .replaceAll(\"[mark]\", \"\")\n .replaceAll(\"[/mark]\", \"\");\n\n return result;\n}\n"],"names":["SearchBox","forwardRef","ref","searchTerm","handleSearch","handleKeydownSearch","handleMousedownSearch","onReset","hasDropdown","placeholder","setShowDropdown","isSmall","inputProps","searchValue","setSearchValue","useState","useEffect","div","className","cn","input","type","value","aria-label","onChange","handleChange","e","currentTarget","onKeyDown","handleReset","button","title","aria-expanded","aria-controls","onClick","prev","onMouseDown","tabIndex","span","Icon","name","SearchBoxDropdown","site","dropdownSuggestions","handleOnClick","dropdownItems","dropdownCta","dropdownFooterLabel","isOverlay","searchLink","onOpenCallback","editAttributes","showDropdown","selectedItemIndex","setSelectedItemIndex","selectedItem","inputRef","useRef","dropdownId","useId","dropdownListLabelId","dropdownFooterLabelId","pushDataLayer","useDataLayer","dataLayerEvent","event","event_data","search_numresults","length","search_type","search_type_ahead","top_search","search_result_page_url","location","href","explore_search","fields","includes","numberOfItems","hasResults","hasSuggestions","total","redirectToSearch","current","inputValue","encodeURIComponent","undefined","window","redirectQuerySearch","searchQuery","q","footerCtaComboboxProps","id","isDropdownVisible","display","searchBoxDropdown","term","handleInputKeyDown","key","stopPropagation","preventDefault","url","redirectQueryToSearch","redirectMouseQueryToSearch","previousElementSibling","classList","contains","onFocus","focusHandler","onBlur","blurHandler","setTimeout","autoFocus","role","aria-autocomplete","aria-activedescendant","p","ul","aria-labelledby","map","item","i","search_term","search_result_title","search_result_url","search_result_position","li","Link","aria-selected","dangerouslySetInnerHTML","__html","highlight","autocomplete","category","label","suggestions","group","groupName","suggestion","stripHtml","conceptUri","explore_search_category","replaceAll","CtaLink","aria-describedby","Dialog","onOpenChange","open","remove","replace","html","result","rm"],"sourceRoot":"","ignoreList":[]}