"use client" import React, { useCallback, useEffect, useMemo, useState } from 'react' import type { Faq } from '../../types/faq' import { FaqAccordion, type FaqItem } from '../faq-accordion' import { useSelfFetch } from '../../hooks/use-self-fetch' import { buildSuggestionUrl } from '../../utils/suggestion-url' import { serializeJsonLd } from '../../utils/common' import { useScrollToHash } from '../../hooks/use-scroll-to-hash' import { navigateSamePageHash, STICKY_HEADER_OFFSET_PX } from '../../utils/same-page-hash-nav' import { faqSectionSlug, parseFaqHash, type FaqHashTarget } from '../../utils/faq-anchor' import { cn } from '../../utils/cn' import { buildFaqJsonLdFromFaqs, type FaqSchemaOptions } from './json-ld' import { SECTION_HEADING_CLASS } from '../layout/page-heading' export interface FaqSectionProps { /** * SSR hydrate. When provided, the hook skips the first client fetch (per * useSelfFetch contract). The consuming server page resolves FAQs then drills * them into this prop — the lib never re-fetches what the host already gated on. */ initialFaqs?: Faq[] /** Both required together for entity-attached FAQs; partial → bare /api/faqs. */ entityType?: string entityId?: number | string /** * Heading node above the grouped list. `undefined` → default * `

`"Frequently Asked Questions". `null` → no heading (the host page * owns the `

`, as the standalone /faqs surface does). A React node lets a * platform drill its own without the lib referencing platform * state. Also drives category nesting so the document outline stays correct: * `null` → categories render `

` (directly under the page `

`); * otherwise categories render `

` beneath this heading. */ heading?: React.ReactNode | null /** Inject FAQPage schema.org JSON-LD as a " must not break the tag. dangerouslySetInnerHTML={{ __html: serializeJsonLd(schema) }} /> )} ) }