import type { AdminEditorConfig } from '@actuate-media/cms-core'

/** Resolve whether a section editor should open with Site preview active. */
export function resolveDefaultSitePreview(
  editor: AdminEditorConfig | undefined,
  kind: 'pages' | 'posts',
): boolean {
  const setting = editor?.defaultSitePreview
  if (setting === true) return true
  if (setting == null || setting === false) return false
  return kind === 'pages' ? setting.pages === true : setting.posts === true
}
