/**
 * commerce-storefront blueprint · wiring seam for `@platform-modules/seo` subpaths.
 *
 * No seo barrel — import jsonld + canonical directly and compose with host config.
 */
import { buildLocaleUrl } from '@platform-modules/seo/canonical'
import * as jsonld from '@platform-modules/seo/jsonld'
import * as sitemap from '@platform-modules/seo/sitemap'

export type SeoHelpersConfig = {
  baseUrl: string
  siteName: string
}

export type StorefrontSeo = {
  siteName: string
  jsonld: typeof jsonld
  sitemap: typeof sitemap
  getOrigin: (path: string) => string
}

export function createSeoHelpers(config: SeoHelpersConfig): StorefrontSeo {
  const origin = config.baseUrl.replace(/\/$/, '')
  return {
    siteName: config.siteName,
    jsonld,
    sitemap,
    getOrigin: (path: string) => buildLocaleUrl(origin, '', path),
  }
}
