import { useApi } from './api.mjs';
import { useSubscription } from './subscription.mjs';

/**
 * Returns the delivery group the extension is attached to. This hook can only be used by extensions in the following
 * extension targets:
 * - purchase.checkout.shipping-option-list.render-before
 * - purchase.checkout.shipping-option-list.render-after
 *
 * > Caution: Deprecated as of version `2024-07`, use `useDeliveryGroupListTarget()` instead.
 *
 * @deprecated Deprecated as of version `2024-07`, use `useDeliveryGroupListTarget()` instead.
 */
function useDeliveryGroupTarget() {
  const api = useApi();
  const target = useSubscription(api.target);
  return target === null || target === void 0 ? void 0 : target.deliveryGroups[0];
}

export { useDeliveryGroupTarget };
