'use strict';
import { npmRegistry } from '../constants/npm-commands.js';
import { createEarlyInfraError } from '../tools/create-early-infra-error.js';
import { cliLogError, cliLogInfo } from '../../../fd-toolbox/logging/cli-logger.js';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { apiBaseGet } from '../../../fd-toolbox/api/base-api.js';
import { isProblemDetails } from '../../../fd-toolbox/errors/problem-details.js';

var __defProp=Object['defineProperty'],__name=(_0x2f6078,_0x38e1d9)=>__defProp(_0x2f6078,'name',{'value':_0x38e1d9,'configurable':!![]});async function getLatestNpmPackageInfo(_0x7d105a){const _0x128964=await apiBaseGet(_0x7d105a);if(!_0x128964)throw createEarlyInfraError('Failed\x20to\x20fetch\x20from\x20npm\x20registry.\x20\x27response\x27\x20is\x20undefined');if(isProblemDetails(_0x128964))throw createEarlyInfraError('Failed\x20to\x20fetch\x20from\x20npm\x20registry.\x20Title:\x20'+_0x128964['title']+'.\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Status:\x20'+_0x128964['status']+'.\x20Detail:\x20'+_0x128964?.['detail']+'.\x20Instance:\x20'+_0x128964?.['instance']);const {latestVersion:_0x6998fc,data:_0x2a77b6}=await getLatestVersionInfo(_0x128964);return {'version':_0x6998fc,'data':_0x2a77b6};}__name(getLatestNpmPackageInfo,'getLatestNpmPackageInfo');async function getLatestVersionInfo(_0x357213){const _0x45ccae=_0x357213[npmRegistry['distTagsKey']]?.['latest'];if(typeof _0x45ccae!==jsBasicTypes['string']||!_0x45ccae){cliLogError('Could\x20not\x20find\x20\x27'+npmRegistry['distTagsKey']+'.latest\x27\x20in\x20the\x20npm\x20registry\x20response.\x20Received\x20object:'),cliLogInfo(JSON['stringify'](_0x357213));throw createEarlyInfraError('Post-publish\x20verification\x20failed:\x20version\x20not\x20found\x20in\x20registry.');}return {'latestVersion':_0x45ccae,'data':_0x357213};}__name(getLatestVersionInfo,'getLatestVersionInfo');

export { getLatestNpmPackageInfo };
