/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
function defineDatasource(datasource) {
  return {
    ...datasource,
    provider: "internal",
    // make sure to use Upstart provider
    schema: mapDatasourceSchemaWithInternalProperties(
      // datasource.provider === "internal" ? datasource.schema : getSchemaByProvider(datasource.provider),
      datasource.schema
    )
  };
}
function mapDatasourceSchemaWithInternalProperties(schema) {
  const { items, ...rest } = schema;
  return {
    ...rest,
    items: {
      ...items,
      type: "object",
      properties: {
        ...items.properties,
        $id: { type: "string", title: "Id" },
        $slug: { type: "string", format: "slug", title: "Slug" },
        $publicationDate: { type: "string", format: "date-time", title: "Publication Date" },
        $lastModificationDate: { type: "string", format: "date-time", title: "Last Modification Date" }
      },
      required: Array.from(
        /* @__PURE__ */ new Set(["$id", "$slug", "$publicationDate", "$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 || {};
  const uniqueFields = Array.from(new Set(datasource.indexes?.map((idx) => idx.fields[0]) ?? []));
  return uniqueFields.map((field) => ({
    value: field,
    title: properties[field]?.title || field
  }));
}
export {
  defineDatasource as d,
  getDatasourceIndexedFieldsWithTitles as g
};
//# sourceMappingURL=datasources.B4KHvcBE.js.map
