export {} // import React, { useState, useRef, useCallback } from 'react' // import { AnchorHTMLAttributes } from 'react' // import { createPortal } from 'react-dom' // import { useRouter } from 'next/navigation.js' // import Link from 'next/link.js' // import { useDocSearchKeyboardEvents } from '@docsearch/react' // import type { // DocSearchModal as DocSearchModalType, // DocSearchProps, // DocSearchModalProps, // InternalDocSearchHit, // StoredDocSearchHit, // } from '@docsearch/react' // import type { LinkProps } from 'next/link' // export type AlgoliaSearchProps = { // algoliaConfig: DocSearchProps // } // export interface AlgoliaConfig { // provider: 'algolia' // algoliaConfig: DocSearchProps // } // export interface AlgoliaSearchQuery { // setSearch: (search: string) => void // toggle: () => void // } // export interface AlgoliaSearchContext { // query: AlgoliaSearchQuery // } // let DocSearchModal: typeof DocSearchModalType | null = null // const CustomLink = ({ href, ...rest }: LinkProps & AnchorHTMLAttributes) => { // const isInternalLink = href && href.startsWith('/') // const isAnchorLink = href && href.startsWith('#') // if (isInternalLink) { // return // } // if (isAnchorLink) { // return // } // return // } // function Hit({ // hit, // children, // }: { // hit: InternalDocSearchHit | StoredDocSearchHit // children: React.ReactNode // }) { // return {children} // } // export const AlgoliaSearchContext = React.createContext( // {} as AlgoliaSearchContext // ) // /** // * Command palette like search component for algolia - `ctrl-k` to open the palette. // * To toggle the modal or search from child components, use the search context: // * ``` // * import { AlgoliaSearchContext } from 'pliny/search/algolia' // * const { query } = useContext(AlgoliaSearchContext) // * ``` // * // */ // export const AlgoliaSearchProvider: React.FC> = ( // props // ) => { // const { algoliaConfig } = props // const router = useRouter() // const [isOpen, setIsOpen] = useState(false) // const [initialQuery, setInitialQuery] = useState(undefined) // const importDocSearchModalIfNeeded = useCallback(() => { // if (DocSearchModal) { // return Promise.resolve() // } // return Promise.all([import('@docsearch/react')]).then(([{ DocSearchModal: Modal }]) => { // DocSearchModal = Modal // }) // }, []) // const onOpen = useCallback(() => { // importDocSearchModalIfNeeded().then(() => { // setIsOpen(true) // }) // }, [importDocSearchModalIfNeeded, setIsOpen]) // const onClose = useCallback(() => { // setIsOpen(false) // }, [setIsOpen]) // const onInput = useCallback( // (event: KeyboardEvent) => { // importDocSearchModalIfNeeded().then(() => { // setIsOpen(true) // setInitialQuery(event.key) // }) // }, // [importDocSearchModalIfNeeded, setIsOpen, setInitialQuery] // ) // const navigator = useRef({ // navigate({ itemUrl }: { itemUrl?: string }) { // // Algolia results could contain URL's from other domains which cannot // // be served through history and should navigate with window.location // const isInternalLink = itemUrl.startsWith('/') // const isAnchorLink = itemUrl.startsWith('#') // if (!isInternalLink && !isAnchorLink) { // window.open(itemUrl, '_blank') // } else { // router.push(itemUrl) // } // }, // }).current // const transformItems = useRef((items) => // items.map((item) => { // // If Algolia contains a external domain, we should navigate without // // relative URL // const isInternalLink = item.url.startsWith('/') // const isAnchorLink = item.url.startsWith('#') // if (!isInternalLink && !isAnchorLink) { // return item // } // // We transform the absolute URL into a relative URL. // const url = new URL(item.url) // return { // ...item, // // url: withBaseUrl(`${url.pathname}${url.hash}`), // url: `${url.pathname}${url.hash}`, // } // }) // ).current // useDocSearchKeyboardEvents({ // isOpen, // onOpen, // onClose, // onInput, // }) // return ( // // {props.children} // {isOpen && // DocSearchModal && // createPortal( // , // document.body // )} // // ) // }