import { isPostmanCollection } from "./is-postman-collection.js";
//#region src/v2/features/command-palette/helpers/get-postman-document-details.ts
var extractSchemaLabel = (schema) => {
	if (typeof schema !== "string") return;
	return schema.match(/\/collection\/(v[\d.]+)\//i)?.[1];
};
/**
* Extracts document details from a Postman collection JSON string.
*
* We parse and validate in a single pass to avoid the performance cost
* of parsing the JSON twice.
*
* @param content - The JSON string representing the Postman collection
* @returns The collection details if valid, null otherwise
*/
var getPostmanDocumentDetails = (content) => {
	if (!isPostmanCollection(content)) return null;
	try {
		const parsed = JSON.parse(content);
		const schemaLabel = extractSchemaLabel(parsed.info?.schema);
		const collectionItems = Array.isArray(parsed.item) ? parsed.item : [];
		return {
			type: "json",
			title: parsed.info?.name || "Postman Collection",
			version: parsed.info?.version || "1.0",
			schemaLabel: schemaLabel ?? void 0,
			collection: collectionItems
		};
	} catch {
		return null;
	}
};
//#endregion
export { getPostmanDocumentDetails };

//# sourceMappingURL=get-postman-document-details.js.map