import { a as o } from "./chunk-CCI4C3TM.js";
import { e as s, c as n } from "./chunk-A3GF4PYW.js";
import { a as l } from "./chunk-QWGUMKZC.js";
import { a as d, e as c } from "./chunk-5YRC3IT3.js";
import { a as p } from "./chunk-GACHLACT.js";
import { a as m, c as u } from "./chunk-4BTB3MU2.js";
import { a as f, c as h } from "./chunk-DHI3IBOD.js";
import { c as y, a as g } from "./chunk-ZTZJHY4E.js";
import { b } from "./chunk-CZRCW5EN.js";
import { a as S, c as L } from "./chunk-NM5MMPCF.js";
import { a as q } from "./chunk-W33JMRRN.js";
import { a as v, c as x, e as A } from "./chunk-SWLUQVK7.js";
import { b as O } from "./chunk-OHNYCXPX.js";
import { a as r } from "./chunk-KFM6KXSE.js";
import { a as I } from "./chunk-JMN3HTZU.js";
import U from "../../../../_virtual/ajv.js";
import w from "../../../../_virtual/index2.js";
import { Type as e } from "@sinclair/typebox";
import "lodash-es";
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
e.Union([e.Literal("internal")]);
var D = e.Object({ id: e.String({ title: "ID", description: "Unique identifier of the datasource. Used to reference the datasource in the system. Use a url-safe string like a slug." }), label: e.String({ title: "Label", description: "Label of the datasource displayed in the UI" }), provider: e.Literal("internal", { title: "Internal", description: "Internal datasource saved locally in Upstart." }), schema: e.Any({ title: "Schema", description: "JSON Schema of datasource. MUST Always an array of objects." }), indexes: e.Optional(e.Array(e.Object({ name: e.String({ title: "Index name" }), fields: e.Array(e.String(), { title: "Fields to index" }), unique: e.Optional(e.Boolean({ title: "Unique index", default: !1 })) }), { title: "Indexes", description: "IMPORTANT: Indexes to create on the datasource. use it to enforce uniqueness or improve query performance." })) }, { examples: [{ id: "customers", label: "Customers", provider: "internal", schema: { type: "array", items: { type: "object", properties: { name: { type: "string", title: "Name" }, email: { type: "string", title: "Email", format: "email" } }, required: ["name", "email"], title: "Customer", examples: [{ name: "John Doe", email: "john.doe@example.com" }, { name: "Jane Smith", email: "jane.smith@example.com" }, { name: "Alice Johnson", email: "alice.johnson@example.com" }, { name: "Bob Brown", email: "bob.brown@example.com" }, { name: "Charlie Davis", email: "charlie.davis@example.com" }] } }, indexes: [{ name: "idx_customers_email", fields: ["email"], unique: !0 }] }, { id: "blog_posts", label: "Blog Posts", provider: "internal", schema: { type: "array", items: { type: "object", properties: { title: { type: "string", title: "Title" }, content: { type: "string", title: "Content" }, author: { type: "string", title: "Author" } }, required: ["title", "content", "author"], title: "Blog Post", examples: [{ title: "My First Blog Post", content: "This is the content of my first blog post.", author: "John Doe" }, { title: "Exploring the Cosmos", content: "A journey through the stars and galaxies.", author: "Jane Smith" }, { title: "The Art of Cooking", content: "Delicious recipes and cooking tips.", author: "Alice Johnson" }, { title: "Traveling the World", content: "My adventures in different countries.", author: "Bob Brown" }, { title: "Technology Trends", content: "The latest trends in technology.", author: "Charlie Davis" }] } }, indexes: [{ name: "idx_blog_posts_title", fields: ["title"], unique: !0 }] }] }), j = D;
e.Array(j);
var F = e.Object({ field: e.String(), op: e.Union([e.Literal("eq"), e.Literal("ne"), e.Literal("contains"), e.Literal("notContains"), e.Literal("startsWith"), e.Literal("notStartsWith"), e.Literal("endsWith"), e.Literal("notEndsWith")]), value: e.String() }), $ = e.Object({ field: e.String(), op: e.Union([e.Literal("eq"), e.Literal("ne"), e.Literal("lt"), e.Literal("lte"), e.Literal("gt"), e.Literal("gte")]), value: e.Number() }), C = e.Object({ field: e.String(), op: e.Union([e.Literal("before"), e.Literal("after")]), value: e.String() }), k = e.Object({ field: e.String(), op: e.Union([e.Literal("beforeNow"), e.Literal("afterNow")]), value: e.Null() }), P = e.Object({ field: e.String(), op: e.Union([e.Literal("contains"), e.Literal("notContains"), e.Literal("containsAll"), e.Literal("containsAny"), e.Literal("notContainsAny")]), value: e.Array(e.String()) }), T = e.Object({ field: e.String(), op: e.Literal("eq"), value: e.Boolean() }), i = e.Union([F, $, C, k, P, T]), N = e.Recursive((t) => e.Union([e.Object({ op: e.Literal("and"), fields: e.Array(e.Union([i, t]), { title: "Indexed Fields" }) }), e.Object({ op: e.Literal("or"), fields: e.Array(e.Union([i, t])) })], { default: { op: "and", fields: [] }, examples: [{ op: "and", fields: [{ field: "$id", op: "eq", value: "123" }, { field: "$publicationDate", op: "beforeNow" }] }] }), { title: "Filter Expression", description: "Expression used to filter query results. Can be a combination of and/or conditions." }), le = e.Object({ id: e.String({ title: "Query ID", description: "Unique identifier for the query. Used to reference the query in the system. URL-safe string like a slug." }), label: e.String({ title: "Label", maxLength: 100, description: "Label of the query displayed in the UI" }), datasourceId: e.String({ title: "Database", description: "ID of the datasource to query" }), limit: e.Number({ title: "Limit", description: "Limit the number of records to fetch from the datasource.", minimum: 1, default: 10 }), sortDirection: e.Optional(I(["asc", "desc"], { title: "Sort", enumNames: ["Ascending", "Descending"], description: "Direction to sort the records by", default: "desc" })), sortField: e.Optional(e.String({ title: "Sort Field", description: "Field to sort by (must be an indexed field)", default: "$publicationDate" })), filters: e.Optional(N), parameters: e.Optional(e.Array(e.Object({ field: e.String({ title: "Field", description: "Field name to use as parameter" }), op: e.Union([e.Literal("eq"), e.Literal("ne"), e.Literal("contains"), e.Literal("notContains"), e.Literal("startsWith"), e.Literal("notStartsWith"), e.Literal("endsWith"), e.Literal("notEndsWith"), e.Literal("lt"), e.Literal("lte"), e.Literal("gt"), e.Literal("gte"), e.Literal("before"), e.Literal("after"), e.Literal("beforeNow"), e.Literal("afterNow"), e.Literal("containsAll"), e.Literal("containsAny"), e.Literal("notContainsAny")], { title: "Operator", description: "Operator to use for the parameter" }) }), { title: "Parameters", description: "Field name and operator that will be used as parameters when using the query in pages. Only indexed fields can be used as parameters.", default: [], examples: [[{ field: "$slug", op: "eq" }], [{ field: "category", op: "eq" }], [{ field: "tags", op: "containsAny" }], [{ field: "author", op: "eq" }], [{ field: "title", op: "contains" }]] })) }, { examples: [{ id: "latest-posts", label: "Latest posts", datasourceId: "blog_posts", limit: 5, sortDirection: "desc", sortField: "$publicationDate" }, { id: "posts-by-category", label: "Posts by category", datasourceId: "blog_posts", limit: 10, sortDirection: "desc", sortField: "$publicationDate", parameters: [{ field: "category", op: "eq" }] }, { id: "posts-by-tag", label: "Posts by tag", datasourceId: "blog_posts", limit: 10, sortDirection: "desc", sortField: "$publicationDate", parameters: [{ field: "tags", op: "containsAny" }] }, { id: "author-posts", label: "Author posts", datasourceId: "blog_posts", limit: 10, sortDirection: "desc", sortField: "$publicationDate", parameters: [{ field: "author", op: "eq" }] }, { id: "search-posts", label: "Search posts", datasourceId: "blog_posts", limit: 10, sortDirection: "desc", sortField: "$publicationDate", parameters: [{ field: "title", op: "contains" }] }] });
function _() {
  return e.Object({ queryId: e.String({ description: "The Site Query ID to use." }), alias: e.String({ title: "Alias", minLength: 1, maxLength: 100, pattern: "^[a-zA-Z0-9_]+$", description: "Alias for the query results, used in dynamic content. Use a simple keyword without spaces or special characters. Aliases are unique across the page.", "ai:instructions": "Use a simple keyword without spaces or special characters. Aliases are unique across the page. You can use the same query several times with different aliases in order to, for example, apply different parameters to the same query." }), params: e.Optional(e.Array(i, { description: "Additional query parameters/filters to apply to the query. One can use placeholders in values like ':slug' to reference URL parameters.", title: "Query Parameters", default: [] })) }, { title: "Query", description: "When set, this brick will loop through the results of the query and render the content for each item.", "ui:field": "query", metadata: { category: "content" }, examples: [{ queryId: "get-latest-posts", alias: "latestPosts" }, { queryId: "get-user-profile", alias: "userProfile", params: [{ field: "userId", op: "eq", value: ":slug" }] }, { queryId: "get-posts-by-category", alias: "postsByCategory", params: [{ field: "category", op: "eq", value: ":slug" }] }] });
}
var de = B();
function B(t = {}) {
  return r("content:queryUse", t);
}
function W(t = {}) {
  return e.Object({ over: e.String({ title: "Over", description: "The query alias to loop over. If not set, the brick will be rendered only once.", "ai:instructions": "Specify the Query Alias to loop over the results." }), overrideLimit: e.Optional(e.Number({ minimum: 1, description: "Override the limit of items to loop through. If not set, it will use the default limit of the query. If set to 1, it will not loop and will render only the first item." })) }, { title: "Repeat over", description: "Repeat this brick for each item in the specified query results.", "ui:field": "loop", "ui:hidden-if": "no-page-queries", metadata: { category: "content" }, examples: [{ over: "latestBlogPosts", overrideLimit: 5 }, { over: "featuredProducts", overrideLimit: 3 }, { over: "popularProducts" }], ...t });
}
function ce(t = {}) {
  return r("content:loop", t);
}
var E = ["date-time", "date", "email", "url"];
function J() {
  let t = new U({ useDefaults: !0, strictSchema: !1, validateSchema: !1, coerceTypes: !0, allErrors: !0, inlineRefs: !0 });
  return t.addSchema(f(), "styles:background"), t.addSchema(h(), "styles:backgroundColor"), t.addSchema(v(), "styles:justifyContent"), t.addSchema(x(), "styles:alignItems"), t.addSchema(A(), "styles:alignSelf"), t.addSchema(y(), "styles:rounding"), t.addSchema(d(), "styles:fontSize"), t.addSchema(q(), "styles:hidden"), t.addSchema(p(), "styles:direction"), t.addSchema(g(), "styles:border"), t.addSchema(S(), "styles:color"), t.addSchema(L(), "styles:borderColor"), t.addSchema(m(), "styles:shadow"), t.addSchema(u(), "styles:textShadow"), t.addSchema(O(), "styles:cssLength"), t.addSchema(o(), "assets:image"), t.addSchema(s(), "assets:icon"), t.addSchema(c(), "content:text"), t.addSchema(n(), "content:urlOrPageId"), t.addSchema(W(), "content:loop"), t.addSchema(_(), "content:queryUse"), t.addSchema(b(), "presets:color"), t.addSchema(l(), "content:tags"), w(t, [...E]), t.addFormat("slug", { validate: (a) => typeof a == "string", async: !1, type: "string" }), t.addFormat("image", { validate: (a) => typeof a == "string", async: !1, type: "string" }), t.addFormat("file", { validate: (a) => typeof a == "string", async: !1, type: "string" }), t.addFormat("nanoid", { validate: (a) => typeof a == "string", async: !1, type: "string" }), t.addFormat("richtext", { validate: (a) => typeof a == "string", async: !1, type: "string" }), t.addFormat("markdown", { validate: (a) => typeof a == "string", async: !1, type: "string" }), t.addFormat("multiline", { validate: (a) => typeof a == "string", async: !1, type: "string" }), t.addFormat("password", { validate: (a) => typeof a == "string", async: !1, type: "string" }), t;
}
var pe = J();
export {
  j as d,
  i as g,
  le as h,
  _ as i,
  de as j,
  B as k,
  W as l,
  ce as m,
  E as n,
  J as o,
  pe as p
};
//# sourceMappingURL=chunk-AFVJZPLS.js.map
