'use strict';

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

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

/**
 * Returns the full API object that was passed in to your extension when it was created.
 * Depending on the extension target, this object can contain different properties.
 */
function useApi() {
  const api = globalThis === null || globalThis === void 0 ? void 0 : globalThis.shopify;
  if (api == null) {
    throw new errors.CustomerAccountUIExtensionError('You can only call this hook when running as a customer account UI extension.');
  }
  return api;
}

/**
 * Returns the full API object that was passed in to your extension when it was created.
 * Depending on the extension target, this object can contain different properties.
 *
 * > Caution: This is deprecated, use `useApi` instead.
 *
 * @deprecated This is deprecated, use `useApi` instead.
 */
function useExtensionApi() {
  return useApi();
}

exports.useApi = useApi;
exports.useExtensionApi = useExtensionApi;
