'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var api = require('./api.js');
var subscription = require('./subscription.js');
var errors = require('./errors.js');

/**
 * Returns the current discount codes applied to the cart, and automatically re-renders
 * your component if discount codes are added or removed.
 */
function useDiscountCodes() {
  const api$1 = api.useApi();
  const extensionTarget = api$1.extension.target;
  if (!('discountCodes' in api$1)) {
    throw new errors.ExtensionHasNoFieldError('discountCodes', extensionTarget);
  }
  return subscription.useSubscription(api$1.discountCodes);
}

/**
 * Returns the current discount allocations applied to the cart, and automatically re-renders
 * your component if discount allocations changed.
 */
function useDiscountAllocations() {
  const api$1 = api.useApi();
  const extensionTarget = api$1.extension.target;
  if (!('discountAllocations' in api$1)) {
    throw new errors.ExtensionHasNoFieldError('discountAllocations', extensionTarget);
  }
  return subscription.useSubscription(api$1.discountAllocations);
}

exports.useDiscountAllocations = useDiscountAllocations;
exports.useDiscountCodes = useDiscountCodes;
