'use strict';

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

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

/**
 * Returns 'billingAddress' specified in the order.
 */
function useBillingAddress() {
  const api$1 = api.useApi();
  const extensionTarget = api$1.extension.target;
  if (!('billingAddress' in api$1)) {
    throw new errors.ExtensionHasNoFieldError('billingAddress', extensionTarget);
  }
  const billingAddress = api$1.billingAddress;
  if (!billingAddress) {
    throw new errors.ScopeNotGrantedError('Using billing address requires having billing address permissions granted to your app.');
  }
  return subscription.useSubscription(billingAddress);
}

exports.useBillingAddress = useBillingAddress;
