import { j as json } from './exports-D1quPX8S.js';
import { as as listNpmVersions } from './src-CidJbygh.js';
import { r as requireAdmin, d as getRequestId } from './helpers-kzwksNq1.js';
import { i as invalidateVersionCache, w as withCache } from './version-cache-CSnmLqxQ.js';
import './utils-BSRjJDrZ.js';
import './chunk-CLZ62Ad-.js';
import 'node:module';
import './provider-constants-DPrj3yBX.js';
import './dist-DOFcG0Zp.js';
import 'node:fs';
import 'node:path';
import 'buffer';
import 'fs';
import 'path';
import 'node:child_process';
import 'node:url';
import 'node:crypto';
import 'events';
import 'node:events';
import 'node:stream';
import 'node:string_decoder';
import 'assert';
import 'zlib';
import 'node:assert';
import 'node:fs/promises';
import 'node:os';
import './endpoints-UdQGgKsR.js';
import './state-fxN45gBp.js';

//#region src/routes/admin/versions/ui/+server.ts
var UI_PACKAGE = "@openpalm/ui";
var CACHE_KEY = `npm:${UI_PACKAGE}`;
/**
* List published `@openpalm/ui` npm versions for the admin "UI build" picker.
*
* The UI is independently versioned and distributed via npm (not GitHub release
* assets), so this is the authoritative source of installable UI builds — the
* selected version is POSTed to /admin/ui-version, which seeds it from npm.
* Returns newest-first; 404 (package not yet published) yields an empty list.
* Cached server-side so tab switches / polls do not hit the npm registry.
*/
var GET = async (event) => {
	const authError = requireAdmin(event, getRequestId(event));
	if (authError) return authError;
	if (event.url.searchParams.get("refresh") === "1") invalidateVersionCache();
	const cached = await withCache(CACHE_KEY, async () => {
		const versions = await listNpmVersions(UI_PACKAGE, { max: 20 });
		const distTags = {};
		for (const v of versions) if (v.distTag) distTags[v.distTag] = v.version;
		return {
			versions,
			distTags
		};
	});
	if (cached !== void 0) return json(cached);
	return json({
		versions: [],
		distTags: {},
		error: "npm registry unavailable"
	});
};

export { GET };
//# sourceMappingURL=_server.ts-BDRFGcRb.js.map
