/**
 * Customer Mode Config — runtime store for customerMode config.
 * Framework-agnostic (zero npm dependencies).
 */

let _config = {
  enabled: false,
  hideChrome: false,
  hideHomepage: false,
  protoHomepage: '',
  canvasHomepage: '',
}

/**
 * Initialize customer mode config.
 * If both `protoHomepage` and `canvasHomepage` are set, `canvasHomepage` wins
 * (it's the more specific landing-page case) and a console warning is logged.
 * @param {object} config - The customerMode object from storyboard.config.json
 */
export function initCustomerModeConfig(config) {
  _config = {
    enabled: false,
    hideChrome: false,
    hideHomepage: false,
    protoHomepage: '',
    canvasHomepage: '',
    ...config,
  }
  if (_config.protoHomepage && _config.canvasHomepage) {
    console.warn(
      '[storyboard] customerMode has both `protoHomepage` and `canvasHomepage` set. ' +
      '`canvasHomepage` takes precedence; ignoring `protoHomepage`.'
    )
  }
}

/**
 * Get the current customer mode config.
 * @returns {{ enabled: boolean, hideChrome: boolean, hideHomepage: boolean, protoHomepage: string, canvasHomepage: string }}
 */
export function getCustomerModeConfig() {
  return _config
}

/**
 * Check if customer mode is enabled.
 * @returns {boolean}
 */
export function isCustomerMode() {
  return _config.enabled
}
