
var abFeatureHelper = function() {
  const config = {
    currentCartPath: 'modules/cart/current/',
    legacyCartPath: 'modules/cart/legacy/',
    v3ServicesPath: 'services/v3/object/',
    contractsTemplatePath: `${appRoot}partials/components/contract/`,
    cartTemplatePath: `${appRoot}partials/components/cart/`
  }

  return {
    isCartV3Enabled: isCartV3Enabled,
    getCartPath : getCartPath,
    getCartDepencies: getCartDepencies,
    getCheckoutCtrl: getCheckoutCtrl,
    getCheckoutBillingCtrl: getCheckoutBillingCtrl,
    getContractsTemplatePath: getContractsTemplatePath,
    getMiniCartPath: getMiniCartPath,
  }

  function isCartV3Enabled() {
    return !!appSettings.useV3Cart
  }
  
  function getCartPath() {
    return isCartV3Enabled() ? config.currentCartPath : config.legacyCartPath
  }

  /**
   * Use these to return list of all Cart V3 related gql dependencies
   * @returns []
   */
  function getCartDepencies() {
    let dependencies = [
      'app',
      `${getCartPath()}api`, 
      `${getCartPath()}dialog`, 
      `${getCartPath()}items`, 
      'modules/cart/manager',
      'modules/cart/plan',
    ]

    // V3 Specific dependencies
    if (isCartV3Enabled()) {
      dependencies.push(`${config.v3ServicesPath}cart/gqlCartService`)
      dependencies.push(`${config.v3ServicesPath}track/gqlTrackService`)
      dependencies.push(`${config.v3ServicesPath}album/gqlAlbumService`)
    }

    return dependencies
  }

  function getCheckoutCtrl() {
    return isCartV3Enabled() ? 'checkoutPay' : 'checkout'
  }

  function getCheckoutBillingCtrl() {
    return isCartV3Enabled() ? 'checkoutBillingV3' : 'checkoutBilling'
  }

  function getContractsTemplatePath() {
    return isCartV3Enabled() 
      ? `${config.contractsTemplatePath}contracts.html` 
      : `${config.contractsTemplatePath}licenses.html` 
  }

  function getMiniCartPath() {
    return isCartV3Enabled() 
      ? `${config.cartTemplatePath}current/mini-cart.html` 
      : `${config.cartTemplatePath}legacy/mini-cart.html` 
  }
}
