import 'html-escaper'; import { Traverse } from 'neotraverse/modern'; import * as z from 'zod/v4'; import { i as generateCspDigest, s as spreadAttributes, u as unescapeHTML, r as renderTemplate, A as AstroError, j as UnknownContentCollectionError } from './server_CW1mBpZH.mjs'; import { c as createComponent } from './astro-component_Y0jc7Trv.mjs'; import 'clsx'; import { removeBase, isRemotePath } from '@astrojs/internal-helpers/path'; import { b as VALID_INPUT_FORMATS } from './consts_BLFvATRa.mjs'; import 'piccolore'; import * as devalue from 'devalue'; function createSvgComponent({ meta, attributes, children, styles }) { const hasStyles = styles.length > 0; const Component = createComponent({ async factory(result, props) { const normalizedProps = normalizeProps(attributes, props); if (hasStyles && result.cspDestination) { for (const style of styles) { const hash = await generateCspDigest(style, result.cspAlgorithm); result._metadata.extraStyleHashes.push(hash); } } return renderTemplate`${unescapeHTML(children)}`; }, propagation: hasStyles ? "self" : "none" }); Object.defineProperty(Component, "toJSON", { value: () => meta, enumerable: false }); return Object.assign(Component, meta); } const ATTRS_TO_DROP = ["xmlns", "xmlns:xlink", "version"]; const DEFAULT_ATTRS = {}; function dropAttributes(attributes) { for (const attr of ATTRS_TO_DROP) { delete attributes[attr]; } return attributes; } function normalizeProps(attributes, props) { return dropAttributes({ ...DEFAULT_ATTRS, ...attributes, ...props }); } const CONTENT_IMAGE_FLAG = "astroContentImageFlag"; const IMAGE_IMPORT_PREFIX = "__ASTRO_IMAGE_"; function imageSrcToImportId(imageSrc, filePath) { imageSrc = removeBase(imageSrc, IMAGE_IMPORT_PREFIX); if (isRemotePath(imageSrc)) { return; } const ext = imageSrc.split(".").at(-1)?.toLowerCase(); if (!ext || !VALID_INPUT_FORMATS.includes(ext)) { return; } const params = new URLSearchParams(CONTENT_IMAGE_FLAG); if (filePath) { params.set("importer", filePath); } return `${imageSrc}?${params.toString()}`; } class ImmutableDataStore { _collections = /* @__PURE__ */ new Map(); constructor() { this._collections = /* @__PURE__ */ new Map(); } get(collectionName, key) { return this._collections.get(collectionName)?.get(String(key)); } entries(collectionName) { const collection = this._collections.get(collectionName) ?? /* @__PURE__ */ new Map(); return [...collection.entries()]; } values(collectionName) { const collection = this._collections.get(collectionName) ?? /* @__PURE__ */ new Map(); return [...collection.values()]; } keys(collectionName) { const collection = this._collections.get(collectionName) ?? /* @__PURE__ */ new Map(); return [...collection.keys()]; } has(collectionName, key) { const collection = this._collections.get(collectionName); if (collection) { return collection.has(String(key)); } return false; } hasCollection(collectionName) { return this._collections.has(collectionName); } collections() { return this._collections; } /** * Attempts to load a DataStore from the virtual module. * This only works in Vite. */ static async fromModule() { try { const data = await import('./_astro_data-layer-content_Cj7QvjDI.mjs'); if (data.default instanceof Map) { return ImmutableDataStore.fromMap(data.default); } const map = devalue.unflatten(data.default); return ImmutableDataStore.fromMap(map); } catch { } return new ImmutableDataStore(); } static async fromMap(data) { const store = new ImmutableDataStore(); store._collections = data; return store; } } function dataStoreSingleton() { let instance = void 0; return { get: async () => { if (!instance) { instance = ImmutableDataStore.fromModule(); } return instance; }, set: (store) => { instance = store; } }; } const globalDataStore = dataStoreSingleton(); z.object({ tags: z.array(z.string()).optional(), lastModified: z.date().optional() }); function createGetCollection({ liveCollections }) { return async function getCollection(collection, filter) { if (collection in liveCollections) { throw new AstroError({ ...UnknownContentCollectionError, message: `Collection "${collection}" is a live collection. Use getLiveCollection() instead of getCollection().` }); } const hasFilter = typeof filter === "function"; const store = await globalDataStore.get(); if (store.hasCollection(collection)) { const { default: imageAssetMap } = await import('./content-assets_DleWbedO.mjs'); const result = []; for (const rawEntry of store.values(collection)) { const data = updateImageReferencesInData(rawEntry.data, rawEntry.filePath, imageAssetMap); let entry = { ...rawEntry, data, collection }; if (hasFilter && !filter(entry)) { continue; } result.push(entry); } return result; } else { console.warn( `The collection ${JSON.stringify( collection )} does not exist or is empty. Please check your content config file for errors.` ); return []; } }; } function updateImageReferencesInData(data, fileName, imageAssetMap) { return new Traverse(data).map(function(ctx, val) { if (typeof val === "string" && val.startsWith(IMAGE_IMPORT_PREFIX)) { const src = val.replace(IMAGE_IMPORT_PREFIX, ""); const id = imageSrcToImportId(src, fileName); if (!id) { ctx.update(src); return; } const imported = imageAssetMap?.get(id); if (imported) { if (imported.__svgData) { const { __svgData: svgData, ...meta } = imported; ctx.update(createSvgComponent({ meta, ...svgData })); } else { ctx.update(imported); } } else { ctx.update(src); } } }); } // astro-head-inject const liveCollections = {}; const getCollection = createGetCollection({ liveCollections, }); export { getCollection as g };