import { au as datasourceSystemProperties } from "./use-page-data.BgY0vKG4.js";
import "lodash-es";
function defineDatasource(datasource) {
  return {
    ...datasource,
    provider: "internal",
    schema: mapDatasourceSchemaWithInternalProperties(datasource.schema)
  };
}
function mapDatasourceSchemaWithInternalProperties(schema) {
  const { items, ...rest } = schema;
  return {
    ...rest,
    items: {
      ...items,
      type: "object",
      properties: {
        ...items.properties,
        ...datasourceSystemProperties.properties
      },
      required: Array.from(/* @__PURE__ */ new Set([
        "$id",
        "$slug",
        "$lastModificationDate",
        ...items.required
      ]))
    }
  };
}
function getDatasourceIndexedFieldsWithTitles(datasource) {
  if ("indexes" in datasource === false) {
    console.error("no datasource or indexes found", datasource);
    return [];
  }
  const properties = datasource.schema?.items?.properties || {};
  return Array.from(new Set(datasource.indexes?.map((idx) => idx.fields[0]) ?? [])).map((field) => ({
    value: field,
    title: properties[field]?.title || field
  }));
}
export {
  defineDatasource as d,
  getDatasourceIndexedFieldsWithTitles as g
};
//# sourceMappingURL=utils.Bfvth39C.js.map
