import Boom from '@hapi/boom';
/**
 * Throws when the form has been taken offline. The plugin's
 * unavailable-response extension catches the marker and renders the
 * "Sorry, this form is unavailable" view at HTTP 200.
 */
export function assertFormAvailable(metadata) {
  if (metadata.offline === true) {
    const data = {
      offline: true,
      metadata
    };
    throw Boom.boomify(new Error(`Form ${metadata.slug} is offline`), {
      statusCode: 503,
      data
    });
  }
}

/** Type guard for the offline Boom marker. */
export function isOfflineBoom(err) {
  if (!Boom.isBoom(err)) return false;
  const data = err.data;
  return data?.offline === true && !!data.metadata;
}
//# sourceMappingURL=form-availability.js.map