{"version":3,"file":"index.mjs","names":["#props","trim","#props","#props","#queryId","#promise","#reject","#resolve","#plugins","#transformResult","#node","#expr","#alias","#props","#join","#queryBuilder","#alias","#props","#aggregateFunctionBuilder","#alias","#props","#node","#createBuilderWithPathLeg","#jsonPath","#alias","#props","#toOperationNode","#getExecutor","#compile","#rawBuilder","#alias","constants","constants","copy","copy","constants","buildFullSlug","constants","copy","constants","copy","constants","constants","copy","constants","copy","constants","copy","copy","constants","copy","copy","constants","copy","copy","constants","constants","copy","copy","constants","constants"],"sources":["../src/constants.ts","../src/utils/get-parent-page-id.ts","../src/utils/normalize-path-value.ts","../src/utils/format-fullslug.ts","../src/utils/build-fullslug-from-fullslug.ts","../src/utils/resolve-collection-prefix.ts","../src/services/construct-parent-fullslug.ts","../../../node_modules/kysely/dist/util/object-utils.js","../../../node_modules/kysely/dist/operation-node/identifier-node.js","../../../node_modules/kysely/dist/operation-node/schemable-identifier-node.js","../../../node_modules/kysely/dist/operation-node/alias-node.js","../../../node_modules/kysely/dist/operation-node/table-node.js","../../../node_modules/kysely/dist/operation-node/operation-node-source.js","../../../node_modules/kysely/dist/expression/expression.js","../../../node_modules/kysely/dist/operation-node/select-modifier-node.js","../../../node_modules/kysely/dist/operation-node/and-node.js","../../../node_modules/kysely/dist/operation-node/or-node.js","../../../node_modules/kysely/dist/operation-node/on-node.js","../../../node_modules/kysely/dist/operation-node/join-node.js","../../../node_modules/kysely/dist/operation-node/binary-operation-node.js","../../../node_modules/kysely/dist/operation-node/operator-node.js","../../../node_modules/kysely/dist/operation-node/column-node.js","../../../node_modules/kysely/dist/operation-node/select-all-node.js","../../../node_modules/kysely/dist/operation-node/reference-node.js","../../../node_modules/kysely/dist/dynamic/dynamic-reference-builder.js","../../../node_modules/kysely/dist/operation-node/order-by-item-node.js","../../../node_modules/kysely/dist/operation-node/raw-node.js","../../../node_modules/kysely/dist/operation-node/collate-node.js","../../../node_modules/kysely/dist/query-builder/order-by-item-builder.js","../../../node_modules/kysely/dist/util/log-once.js","../../../node_modules/kysely/dist/parser/order-by-parser.js","../../../node_modules/kysely/dist/operation-node/json-reference-node.js","../../../node_modules/kysely/dist/operation-node/json-operator-chain-node.js","../../../node_modules/kysely/dist/operation-node/json-path-node.js","../../../node_modules/kysely/dist/parser/reference-parser.js","../../../node_modules/kysely/dist/operation-node/primitive-value-list-node.js","../../../node_modules/kysely/dist/operation-node/value-list-node.js","../../../node_modules/kysely/dist/operation-node/value-node.js","../../../node_modules/kysely/dist/parser/value-parser.js","../../../node_modules/kysely/dist/operation-node/parens-node.js","../../../node_modules/kysely/dist/parser/binary-operation-parser.js","../../../node_modules/kysely/dist/operation-node/order-by-node.js","../../../node_modules/kysely/dist/operation-node/partition-by-node.js","../../../node_modules/kysely/dist/operation-node/over-node.js","../../../node_modules/kysely/dist/operation-node/from-node.js","../../../node_modules/kysely/dist/operation-node/group-by-node.js","../../../node_modules/kysely/dist/operation-node/having-node.js","../../../node_modules/kysely/dist/operation-node/insert-query-node.js","../../../node_modules/kysely/dist/operation-node/list-node.js","../../../node_modules/kysely/dist/operation-node/update-query-node.js","../../../node_modules/kysely/dist/operation-node/using-node.js","../../../node_modules/kysely/dist/operation-node/delete-query-node.js","../../../node_modules/kysely/dist/operation-node/where-node.js","../../../node_modules/kysely/dist/operation-node/returning-node.js","../../../node_modules/kysely/dist/operation-node/explain-node.js","../../../node_modules/kysely/dist/operation-node/when-node.js","../../../node_modules/kysely/dist/operation-node/merge-query-node.js","../../../node_modules/kysely/dist/operation-node/output-node.js","../../../node_modules/kysely/dist/operation-node/query-node.js","../../../node_modules/kysely/dist/operation-node/select-query-node.js","../../../node_modules/kysely/dist/query-builder/join-builder.js","../../../node_modules/kysely/dist/operation-node/partition-by-item-node.js","../../../node_modules/kysely/dist/parser/partition-by-parser.js","../../../node_modules/kysely/dist/query-builder/over-builder.js","../../../node_modules/kysely/dist/operation-node/selection-node.js","../../../node_modules/kysely/dist/parser/select-parser.js","../../../node_modules/kysely/dist/query-builder/no-result-error.js","../../../node_modules/kysely/dist/operation-node/top-node.js","../../../node_modules/kysely/dist/parser/top-parser.js","../../../node_modules/kysely/dist/operation-node/limit-node.js","../../../node_modules/kysely/dist/util/random-string.js","../../../node_modules/kysely/dist/util/query-id.js","../../../node_modules/kysely/dist/util/deferred.js","../../../node_modules/kysely/dist/util/provide-controlled-connection.js","../../../node_modules/kysely/dist/util/abort.js","../../../node_modules/kysely/dist/query-executor/query-executor-base.js","../../../node_modules/kysely/dist/query-executor/noop-query-executor.js","../../../node_modules/kysely/dist/parser/parse-utils.js","../../../node_modules/kysely/dist/parser/join-parser.js","../../../node_modules/kysely/dist/operation-node/offset-node.js","../../../node_modules/kysely/dist/operation-node/group-by-item-node.js","../../../node_modules/kysely/dist/parser/group-by-parser.js","../../../node_modules/kysely/dist/operation-node/set-operation-node.js","../../../node_modules/kysely/dist/parser/set-operation-parser.js","../../../node_modules/kysely/dist/expression/expression-wrapper.js","../../../node_modules/kysely/dist/operation-node/fetch-node.js","../../../node_modules/kysely/dist/parser/fetch-parser.js","../../../node_modules/kysely/dist/query-builder/select-query-builder.js","../../../node_modules/kysely/dist/operation-node/aggregate-function-node.js","../../../node_modules/kysely/dist/operation-node/function-node.js","../../../node_modules/kysely/dist/query-builder/aggregate-function-builder.js","../../../node_modules/kysely/dist/query-builder/function-module.js","../../../node_modules/kysely/dist/operation-node/unary-operation-node.js","../../../node_modules/kysely/dist/parser/unary-operation-parser.js","../../../node_modules/kysely/dist/operation-node/case-node.js","../../../node_modules/kysely/dist/query-builder/case-builder.js","../../../node_modules/kysely/dist/operation-node/json-path-leg-node.js","../../../node_modules/kysely/dist/query-builder/json-path-builder.js","../../../node_modules/kysely/dist/operation-node/tuple-node.js","../../../node_modules/kysely/dist/operation-node/data-type-node.js","../../../node_modules/kysely/dist/parser/data-type-parser.js","../../../node_modules/kysely/dist/operation-node/cast-node.js","../../../node_modules/kysely/dist/expression/expression-builder.js","../../../node_modules/kysely/dist/parser/expression-parser.js","../../../node_modules/kysely/dist/dynamic/dynamic-table-builder.js","../../../node_modules/kysely/dist/parser/table-parser.js","../../../node_modules/kysely/dist/raw-builder/raw-builder.js","../../../node_modules/kysely/dist/raw-builder/sql.js","../src/utils/apply-tenant-scope.ts","../src/utils/get-parent-page-relation-table.ts","../src/services/get-parent-fields.ts","../src/services/get-target-collection.ts","../src/services/hooks/after-fetch-handler.ts","../src/utils/build-fullslug-from-slugs.ts","../src/services/construct-child-fullslugs.ts","../src/services/get-descendant-fields.ts","../src/services/get-document-version-fields.ts","../src/services/plugin-options.ts","../src/services/register-fields.ts","../src/services/set-full-slug.ts","../src/services/update-fullslug-fields.ts","../src/services/update-slug-fields.ts","../src/services/hooks/after-upsert-handler.ts","../src/services/checks/check-fields-exist.ts","../src/services/checks/circular-parents.ts","../src/utils/duplicate-route-message.ts","../src/utils/route-uniqueness.ts","../src/services/checks/fullslug-unique-fields.ts","../src/services/checks/fullslug-uniqueness.ts","../src/services/checks/page-is-parent-of-self.ts","../src/services/checks/root-slug-withparent.ts","../src/services/hooks/before-delete-handler.ts","../src/services/hooks/before-upsert-handler.ts","../src/utils/field-res-to-schema.ts","../src/services/hooks/version-promote.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["export const PLUGIN_KEY = \"plugin-pages\";\nexport const LUCID_VERSION = \"0.x.x\";\n\nexport default {\n\tfields: {\n\t\tparentPage: {\n\t\t\tkey: \"parentPage\",\n\t\t},\n\t\tslug: {\n\t\t\tkey: \"slug\",\n\t\t},\n\t\tfullSlug: {\n\t\t\tkey: \"fullSlug\",\n\t\t},\n\t},\n};\n","import type { FieldInputSchema } from \"@lucidcms/core/types\";\n\n/**\n * Returns the single parent page ID used by the pages plugin.\n */\nconst getParentPageId = (field: FieldInputSchema): number | null => {\n\tif (!Array.isArray(field.value)) return null;\n\n\tconst parentPageValue = field.value[0];\n\tif (typeof parentPageValue !== \"object\" || parentPageValue === null) {\n\t\treturn null;\n\t}\n\tif (!(\"id\" in parentPageValue)) return null;\n\n\treturn typeof parentPageValue.id === \"number\" ? parentPageValue.id : null;\n};\n\nexport default getParentPageId;\n","const normalizePathValue = (\n\tvalue: string | null | undefined,\n): string | null | undefined => {\n\tif (value === null || value === undefined) return value;\n\tif (value === \"/\") return \"/\";\n\n\treturn value.toLowerCase();\n};\n\nexport default normalizePathValue;\n","import normalizePathValue from \"./normalize-path-value.js\";\n\nconst formatFullSlug = (\n\t...parts: Array<string | null | undefined>\n): string | null => {\n\tconst hasRoot = parts.some((part) => part === \"/\");\n\tconst normalizedParts = parts\n\t\t.map((part) => normalizePathValue(part))\n\t\t.filter((part): part is string => part !== null && part !== undefined)\n\t\t.map((part) => {\n\t\t\tif (part === \"/\") return \"\";\n\t\t\treturn part.replace(/^\\/+|\\/+$/g, \"\");\n\t\t})\n\t\t.filter(Boolean);\n\n\tif (normalizedParts.length === 0) {\n\t\treturn hasRoot ? \"/\" : null;\n\t}\n\n\treturn `/${normalizedParts.join(\"/\")}`.replace(/\\/+/g, \"/\");\n};\n\nexport default formatFullSlug;\n","import type { ParentPageQueryResponse } from \"../services/get-parent-fields.js\";\nimport formatFullSlug from \"./format-fullslug.js\";\n\nconst buildFullSlug = (data: {\n\tparentFields: Array<ParentPageQueryResponse>;\n\ttargetLocale: string;\n\tslug: string | null | undefined;\n\tprefix?: string;\n}): string | null => {\n\tif (\n\t\tdata.slug === null ||\n\t\tdata.slug === undefined ||\n\t\tdata.slug.trim() === \"\"\n\t) {\n\t\treturn null;\n\t}\n\n\tconst targetParentFullSlugField = data.parentFields.find((field) => {\n\t\treturn field.locale === data.targetLocale;\n\t});\n\n\tif (targetParentFullSlugField?._fullSlug) {\n\t\treturn formatFullSlug(targetParentFullSlugField._fullSlug, data.slug);\n\t}\n\n\treturn formatFullSlug(data.prefix, data.slug);\n};\n\nexport default buildFullSlug;\n","import type { CollectionConfig } from \"../types/types.js\";\nimport normalizePathValue from \"./normalize-path-value.js\";\n\nconst normalizePrefix = (\n\tprefix: string | null | undefined,\n): string | undefined => {\n\tconst normalizedPrefix = normalizePathValue(prefix);\n\tif (!normalizedPrefix) return undefined;\n\n\tconst trimmed = normalizedPrefix.replace(/^\\/+|\\/+$/g, \"\");\n\treturn trimmed.length > 0 ? trimmed : undefined;\n};\n\nconst resolveCollectionPrefix = (data: {\n\tcollection: CollectionConfig;\n\tlocaleCode: string;\n}): string | undefined => {\n\tif (!data.collection.prefix) return undefined;\n\n\tif (typeof data.collection.prefix === \"string\") {\n\t\treturn normalizePrefix(data.collection.prefix);\n\t}\n\n\treturn normalizePrefix(data.collection.prefix[data.localeCode]);\n};\n\nexport default resolveCollectionPrefix;\n","import type {\n\tConfig,\n\tFieldInputSchema,\n\tServiceResponse,\n} from \"@lucidcms/core/types\";\nimport type { CollectionConfig } from \"../types/types.js\";\nimport buildFullSlug from \"../utils/build-fullslug-from-fullslug.js\";\nimport resolveCollectionPrefix from \"../utils/resolve-collection-prefix.js\";\nimport type { ParentPageQueryResponse } from \"./get-parent-fields.js\";\n\n/**\n *  Constructs the fullSlug from the slug and parentPage fields\n */\nconst constructParentFullSlug = (data: {\n\tcollection: CollectionConfig;\n\tparentFields: Array<ParentPageQueryResponse>;\n\tlocalization: Config[\"localization\"];\n\tfields: {\n\t\tslug: FieldInputSchema;\n\t};\n}): Awaited<ServiceResponse<Record<string, string | null>>> => {\n\t// initialise fullSlug with null values for each locale\n\tconst fullSlug: Record<string, string | null> =\n\t\tdata.localization.locales.reduce<Record<string, string | null>>(\n\t\t\t(acc, locale) => {\n\t\t\t\tacc[locale.code] = null;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{},\n\t\t);\n\n\t// if translations are enabled/set\n\tif (data.collection.localized && data.fields.slug.translations) {\n\t\tfor (let i = 0; i < data.localization.locales.length; i++) {\n\t\t\tconst locale = data.localization.locales[i];\n\t\t\tif (!locale) continue;\n\n\t\t\tfullSlug[locale.code] = buildFullSlug({\n\t\t\t\tparentFields: data.parentFields || [],\n\t\t\t\ttargetLocale: locale.code,\n\t\t\t\tslug: data.fields.slug.translations[locale.code],\n\t\t\t\tprefix: resolveCollectionPrefix({\n\t\t\t\t\tcollection: data.collection,\n\t\t\t\t\tlocaleCode: locale.code,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t} else {\n\t\tfullSlug[data.localization.defaultLocale] = buildFullSlug({\n\t\t\tparentFields: data.parentFields || [],\n\t\t\ttargetLocale: data.localization.defaultLocale,\n\t\t\tslug: data.fields.slug.value,\n\t\t\tprefix: resolveCollectionPrefix({\n\t\t\t\tcollection: data.collection,\n\t\t\t\tlocaleCode: data.localization.defaultLocale,\n\t\t\t}),\n\t\t});\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: fullSlug,\n\t};\n};\n\nexport default constructParentFullSlug;\n","/// <reference types=\"./object-utils.d.ts\" />\nexport function isEmpty(obj) {\n    if (Array.isArray(obj) || isString(obj) || isBuffer(obj)) {\n        return obj.length === 0;\n    }\n    else if (obj) {\n        return Object.keys(obj).length === 0;\n    }\n    return false;\n}\nexport function isUndefined(obj) {\n    return typeof obj === 'undefined' || obj === undefined;\n}\nexport function isString(obj) {\n    return typeof obj === 'string';\n}\nexport function isNumber(obj) {\n    return typeof obj === 'number';\n}\nexport function isBoolean(obj) {\n    return typeof obj === 'boolean';\n}\nexport function isNull(obj) {\n    return obj === null;\n}\nexport function isDate(obj) {\n    return obj instanceof Date;\n}\nexport function isBigInt(obj) {\n    return typeof obj === 'bigint';\n}\n// Don't change the returnd type to `obj is Buffer` to not create a\n// hard dependency to node.\nexport function isBuffer(obj) {\n    return typeof Buffer !== 'undefined' && Buffer.isBuffer(obj);\n}\nexport function isFunction(obj) {\n    return typeof obj === 'function';\n}\nexport function isObject(obj) {\n    return typeof obj === 'object' && obj !== null;\n}\nexport function isArrayBufferOrView(obj) {\n    return obj instanceof ArrayBuffer || ArrayBuffer.isView(obj);\n}\nexport function isPlainObject(obj) {\n    if (!isObject(obj) || getTag(obj) !== '[object Object]') {\n        return false;\n    }\n    if (Object.getPrototypeOf(obj) === null) {\n        return true;\n    }\n    let proto = obj;\n    while (Object.getPrototypeOf(proto) !== null) {\n        proto = Object.getPrototypeOf(proto);\n    }\n    return Object.getPrototypeOf(obj) === proto;\n}\nexport function getLast(arr) {\n    return arr[arr.length - 1];\n}\nexport function freeze(obj) {\n    return Object.freeze(obj);\n}\nexport function asArray(arg) {\n    if (isReadonlyArray(arg)) {\n        return arg;\n    }\n    else {\n        return [arg];\n    }\n}\nexport function asReadonlyArray(arg) {\n    if (isReadonlyArray(arg)) {\n        return arg;\n    }\n    else {\n        return freeze([arg]);\n    }\n}\nexport function isReadonlyArray(arg) {\n    return Array.isArray(arg);\n}\nexport function noop(obj) {\n    return obj;\n}\nexport function compare(obj1, obj2) {\n    if (isReadonlyArray(obj1) && isReadonlyArray(obj2)) {\n        return compareArrays(obj1, obj2);\n    }\n    else if (isObject(obj1) && isObject(obj2)) {\n        return compareObjects(obj1, obj2);\n    }\n    return obj1 === obj2;\n}\nexport function getMessage(error) {\n    return error instanceof Error ? error.message : String(error);\n}\nfunction compareArrays(arr1, arr2) {\n    if (arr1.length !== arr2.length) {\n        return false;\n    }\n    for (let i = 0; i < arr1.length; ++i) {\n        if (!compare(arr1[i], arr2[i])) {\n            return false;\n        }\n    }\n    return true;\n}\nfunction compareObjects(obj1, obj2) {\n    if (isBuffer(obj1) && isBuffer(obj2)) {\n        return compareBuffers(obj1, obj2);\n    }\n    else if (isDate(obj1) && isDate(obj2)) {\n        return compareDates(obj1, obj2);\n    }\n    return compareGenericObjects(obj1, obj2);\n}\nfunction compareBuffers(buf1, buf2) {\n    return Buffer.compare(buf1, buf2) === 0;\n}\nfunction compareDates(date1, date2) {\n    return date1.getTime() === date2.getTime();\n}\nfunction compareGenericObjects(obj1, obj2) {\n    const keys1 = Object.keys(obj1);\n    const keys2 = Object.keys(obj2);\n    if (keys1.length !== keys2.length) {\n        return false;\n    }\n    for (const key of keys1) {\n        if (!compare(obj1[key], obj2[key])) {\n            return false;\n        }\n    }\n    return true;\n}\nconst toString = Object.prototype.toString;\nfunction getTag(value) {\n    if (value == null) {\n        return value === undefined ? '[object Undefined]' : '[object Null]';\n    }\n    return toString.call(value);\n}\n","/// <reference types=\"./identifier-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const IdentifierNode = freeze({\n    is(node) {\n        return node.kind === 'IdentifierNode';\n    },\n    create(name) {\n        return freeze({\n            kind: 'IdentifierNode',\n            name,\n        });\n    },\n});\n","/// <reference types=\"./schemable-identifier-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { IdentifierNode } from './identifier-node.js';\n/**\n * @internal\n */\nexport const SchemableIdentifierNode = freeze({\n    is(node) {\n        return node.kind === 'SchemableIdentifierNode';\n    },\n    create(identifier) {\n        return freeze({\n            kind: 'SchemableIdentifierNode',\n            identifier: IdentifierNode.create(identifier),\n        });\n    },\n    createWithSchema(schema, identifier) {\n        return freeze({\n            kind: 'SchemableIdentifierNode',\n            schema: IdentifierNode.create(schema),\n            identifier: IdentifierNode.create(identifier),\n        });\n    },\n});\n","/// <reference types=\"./alias-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const AliasNode = freeze({\n    is(node) {\n        return node.kind === 'AliasNode';\n    },\n    create(node, alias) {\n        return freeze({\n            kind: 'AliasNode',\n            node,\n            alias,\n        });\n    },\n});\n","/// <reference types=\"./table-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { SchemableIdentifierNode } from './schemable-identifier-node.js';\n/**\n * @internal\n */\nexport const TableNode = freeze({\n    is(node) {\n        return node.kind === 'TableNode';\n    },\n    create(table) {\n        return freeze({\n            kind: 'TableNode',\n            table: SchemableIdentifierNode.create(table),\n        });\n    },\n    createWithSchema(schema, table) {\n        return freeze({\n            kind: 'TableNode',\n            table: SchemableIdentifierNode.createWithSchema(schema, table),\n        });\n    },\n});\n","/// <reference types=\"./operation-node-source.d.ts\" />\nimport { isFunction, isObject } from '../util/object-utils.js';\nexport function isOperationNodeSource(obj) {\n    return isObject(obj) && isFunction(obj.toOperationNode);\n}\n","/// <reference types=\"./expression.d.ts\" />\nimport { isOperationNodeSource, } from '../operation-node/operation-node-source.js';\nimport { isObject, isString } from '../util/object-utils.js';\nexport function isExpression(obj) {\n    return isObject(obj) && 'expressionType' in obj && isOperationNodeSource(obj);\n}\nexport function isAliasedExpression(obj) {\n    return (isObject(obj) &&\n        'expression' in obj &&\n        isString(obj.alias) &&\n        isOperationNodeSource(obj));\n}\n","/// <reference types=\"./select-modifier-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const SelectModifierNode = freeze({\n    is(node) {\n        return node.kind === 'SelectModifierNode';\n    },\n    create(modifier, of) {\n        return freeze({\n            kind: 'SelectModifierNode',\n            modifier,\n            of,\n        });\n    },\n    createWithExpression(modifier) {\n        return freeze({\n            kind: 'SelectModifierNode',\n            rawModifier: modifier,\n        });\n    },\n});\n","/// <reference types=\"./and-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const AndNode = freeze({\n    is(node) {\n        return node.kind === 'AndNode';\n    },\n    create(left, right) {\n        return freeze({\n            kind: 'AndNode',\n            left,\n            right,\n        });\n    },\n});\n","/// <reference types=\"./or-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const OrNode = freeze({\n    is(node) {\n        return node.kind === 'OrNode';\n    },\n    create(left, right) {\n        return freeze({\n            kind: 'OrNode',\n            left,\n            right,\n        });\n    },\n});\n","/// <reference types=\"./on-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { AndNode } from './and-node.js';\nimport { OrNode } from './or-node.js';\n/**\n * @internal\n */\nexport const OnNode = freeze({\n    is(node) {\n        return node.kind === 'OnNode';\n    },\n    create(filter) {\n        return freeze({\n            kind: 'OnNode',\n            on: filter,\n        });\n    },\n    cloneWithOperation(onNode, operator, operation) {\n        return freeze({\n            ...onNode,\n            on: operator === 'And'\n                ? AndNode.create(onNode.on, operation)\n                : OrNode.create(onNode.on, operation),\n        });\n    },\n});\n","/// <reference types=\"./join-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { OnNode } from './on-node.js';\n/**\n * @internal\n */\nexport const JoinNode = freeze({\n    is(node) {\n        return node.kind === 'JoinNode';\n    },\n    create(joinType, table) {\n        return freeze({\n            kind: 'JoinNode',\n            joinType,\n            table,\n            on: undefined,\n        });\n    },\n    createWithOn(joinType, table, on) {\n        return freeze({\n            kind: 'JoinNode',\n            joinType,\n            table,\n            on: OnNode.create(on),\n        });\n    },\n    cloneWithOn(joinNode, operation) {\n        return freeze({\n            ...joinNode,\n            on: joinNode.on\n                ? OnNode.cloneWithOperation(joinNode.on, 'And', operation)\n                : OnNode.create(operation),\n        });\n    },\n});\n","/// <reference types=\"./binary-operation-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const BinaryOperationNode = freeze({\n    is(node) {\n        return node.kind === 'BinaryOperationNode';\n    },\n    create(leftOperand, operator, rightOperand) {\n        return freeze({\n            kind: 'BinaryOperationNode',\n            leftOperand,\n            operator,\n            rightOperand,\n        });\n    },\n});\n","/// <reference types=\"./operator-node.d.ts\" />\nimport { freeze, isString } from '../util/object-utils.js';\nconst COMPARISON_OPERATORS_DICTIONARY = freeze({\n    '=': true,\n    '==': true,\n    '!=': true,\n    '<>': true,\n    '>': true,\n    '>=': true,\n    '<': true,\n    '<=': true,\n    in: true,\n    'not in': true,\n    is: true,\n    'is not': true,\n    like: true,\n    'not like': true,\n    match: true,\n    ilike: true,\n    'not ilike': true,\n    '@>': true,\n    '<@': true,\n    '^@': true,\n    '&&': true,\n    '?': true,\n    '?&': true,\n    '?|': true,\n    '!<': true,\n    '!>': true,\n    '<=>': true,\n    '!~': true,\n    '~': true,\n    '~*': true,\n    '!~*': true,\n    '@@': true,\n    '@@@': true,\n    '!!': true,\n    '<->': true,\n    regexp: true,\n    'is distinct from': true,\n    'is not distinct from': true,\n});\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport const COMPARISON_OPERATORS = Object.keys(COMPARISON_OPERATORS_DICTIONARY);\nconst ARITHMETIC_OPERATORS_DICTIONARY = freeze({\n    '+': true,\n    '-': true,\n    '*': true,\n    '/': true,\n    '%': true,\n    '^': true,\n    '&': true,\n    '|': true,\n    '#': true,\n    '<<': true,\n    '>>': true,\n});\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport const ARITHMETIC_OPERATORS = Object.keys(ARITHMETIC_OPERATORS_DICTIONARY);\nconst JSON_OPERATORS_DICTIONARY = freeze({\n    '->': true,\n    '->>': true,\n});\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport const JSON_OPERATORS = Object.keys(JSON_OPERATORS_DICTIONARY);\nconst BINARY_OPERATORS_DICTIONARY = freeze({\n    ...COMPARISON_OPERATORS_DICTIONARY,\n    ...ARITHMETIC_OPERATORS_DICTIONARY,\n    '||': true,\n});\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport const BINARY_OPERATORS = Object.keys(BINARY_OPERATORS_DICTIONARY);\nconst UNARY_FILTER_OPERATORS_DICTIONARY = freeze({\n    exists: true,\n    'not exists': true,\n});\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport const UNARY_FILTER_OPERATORS = Object.keys(UNARY_FILTER_OPERATORS_DICTIONARY);\nconst UNARY_OPERATORS_DICTIONARY = freeze({\n    ...UNARY_FILTER_OPERATORS_DICTIONARY,\n    '-': true,\n    not: true,\n});\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport const UNARY_OPERATORS = Object.keys(UNARY_OPERATORS_DICTIONARY);\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport const OPERATORS = [\n    ...BINARY_OPERATORS,\n    ...JSON_OPERATORS,\n    ...UNARY_OPERATORS,\n    'between',\n    'between symmetric',\n];\n/**\n * @internal\n */\nexport const OperatorNode = freeze({\n    is(node) {\n        return node.kind === 'OperatorNode';\n    },\n    create(operator) {\n        return freeze({\n            kind: 'OperatorNode',\n            operator,\n        });\n    },\n});\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport function isOperator(op) {\n    return isString(op) && OPERATORS.includes(op);\n}\nexport function isBinaryOperator(op) {\n    return isString(op) && BINARY_OPERATORS_DICTIONARY[op];\n}\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport function isComparisonOperator(op) {\n    return isString(op) && COMPARISON_OPERATORS.includes(op);\n}\n/**\n * @deprecated will be removed in version 0.30.x\n */\nexport function isArithmeticOperator(op) {\n    return isString(op) && ARITHMETIC_OPERATORS.includes(op);\n}\nexport function isJSONOperator(op) {\n    return isString(op) && JSON_OPERATORS_DICTIONARY[op];\n}\nexport function isUnaryOperator(op) {\n    return isString(op) && UNARY_OPERATORS_DICTIONARY[op];\n}\n","/// <reference types=\"./column-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { IdentifierNode } from './identifier-node.js';\n/**\n * @internal\n */\nexport const ColumnNode = freeze({\n    is(node) {\n        return node.kind === 'ColumnNode';\n    },\n    create(column) {\n        return freeze({\n            kind: 'ColumnNode',\n            column: IdentifierNode.create(column),\n        });\n    },\n});\n","/// <reference types=\"./select-all-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const SelectAllNode = freeze({\n    is(node) {\n        return node.kind === 'SelectAllNode';\n    },\n    create() {\n        return freeze({\n            kind: 'SelectAllNode',\n        });\n    },\n});\n","/// <reference types=\"./reference-node.d.ts\" />\nimport { SelectAllNode } from './select-all-node.js';\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const ReferenceNode = freeze({\n    is(node) {\n        return node.kind === 'ReferenceNode';\n    },\n    create(column, table) {\n        return freeze({\n            kind: 'ReferenceNode',\n            table,\n            column,\n        });\n    },\n    createSelectAll(table) {\n        return freeze({\n            kind: 'ReferenceNode',\n            table,\n            column: SelectAllNode.create(),\n        });\n    },\n});\n","/// <reference types=\"./dynamic-reference-builder.d.ts\" />\nimport { isOperationNodeSource, } from '../operation-node/operation-node-source.js';\nimport { parseSimpleReferenceExpression } from '../parser/reference-parser.js';\nimport { isObject, isString } from '../util/object-utils.js';\nexport class DynamicReferenceBuilder {\n    #dynamicReference;\n    get dynamicReference() {\n        return this.#dynamicReference;\n    }\n    /**\n     * @private\n     *\n     * This needs to be here just so that the typings work. Without this\n     * the generated .d.ts file contains no reference to the type param R\n     * which causes this type to be equal to DynamicReferenceBuilder with\n     * any R.\n     */\n    get refType() {\n        return undefined;\n    }\n    constructor(reference) {\n        this.#dynamicReference = reference;\n    }\n    toOperationNode() {\n        return parseSimpleReferenceExpression(this.#dynamicReference);\n    }\n}\nexport function isDynamicReferenceBuilder(obj) {\n    return (isObject(obj) &&\n        isOperationNodeSource(obj) &&\n        isString(obj.dynamicReference));\n}\n","/// <reference types=\"./order-by-item-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const OrderByItemNode = freeze({\n    is(node) {\n        return node.kind === 'OrderByItemNode';\n    },\n    create(orderBy, direction) {\n        return freeze({\n            kind: 'OrderByItemNode',\n            orderBy,\n            direction,\n        });\n    },\n    cloneWith(node, props) {\n        return freeze({\n            ...node,\n            ...props,\n        });\n    },\n});\n","/// <reference types=\"./raw-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const RawNode = freeze({\n    is(node) {\n        return node.kind === 'RawNode';\n    },\n    create(sqlFragments, parameters) {\n        return freeze({\n            kind: 'RawNode',\n            sqlFragments: freeze(sqlFragments),\n            parameters: freeze(parameters),\n        });\n    },\n    createWithSql(sql) {\n        return RawNode.create([sql], []);\n    },\n    createWithChild(child) {\n        return RawNode.create(['', ''], [child]);\n    },\n    createWithChildren(children) {\n        return RawNode.create(new Array(children.length + 1).fill(''), children);\n    },\n});\n","/// <reference types=\"./collate-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { IdentifierNode } from './identifier-node.js';\n/**\n * @internal\n */\nexport const CollateNode = freeze({\n    is(node) {\n        return node.kind === 'CollateNode';\n    },\n    create(collation) {\n        return freeze({\n            kind: 'CollateNode',\n            collation: IdentifierNode.create(collation),\n        });\n    },\n});\n","/// <reference types=\"./order-by-item-builder.d.ts\" />\nimport { CollateNode } from '../operation-node/collate-node.js';\nimport { OrderByItemNode } from '../operation-node/order-by-item-node.js';\nimport { RawNode } from '../operation-node/raw-node.js';\nimport { freeze } from '../util/object-utils.js';\nexport class OrderByItemBuilder {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    /**\n     * Adds `desc` to the `order by` item.\n     *\n     * See {@link asc} for the opposite.\n     */\n    desc() {\n        return new OrderByItemBuilder({\n            node: OrderByItemNode.cloneWith(this.#props.node, {\n                direction: RawNode.createWithSql('desc'),\n            }),\n        });\n    }\n    /**\n     * Adds `asc` to the `order by` item.\n     *\n     * See {@link desc} for the opposite.\n     */\n    asc() {\n        return new OrderByItemBuilder({\n            node: OrderByItemNode.cloneWith(this.#props.node, {\n                direction: RawNode.createWithSql('asc'),\n            }),\n        });\n    }\n    /**\n     * Adds `nulls last` to the `order by` item.\n     *\n     * This is only supported by some dialects like PostgreSQL and SQLite.\n     *\n     * See {@link nullsFirst} for the opposite.\n     */\n    nullsLast() {\n        return new OrderByItemBuilder({\n            node: OrderByItemNode.cloneWith(this.#props.node, { nulls: 'last' }),\n        });\n    }\n    /**\n     * Adds `nulls first` to the `order by` item.\n     *\n     * This is only supported by some dialects like PostgreSQL and SQLite.\n     *\n     * See {@link nullsLast} for the opposite.\n     */\n    nullsFirst() {\n        return new OrderByItemBuilder({\n            node: OrderByItemNode.cloneWith(this.#props.node, { nulls: 'first' }),\n        });\n    }\n    /**\n     * Adds `collate <collationName>` to the `order by` item.\n     */\n    collate(collation) {\n        return new OrderByItemBuilder({\n            node: OrderByItemNode.cloneWith(this.#props.node, {\n                collation: CollateNode.create(collation),\n            }),\n        });\n    }\n    toOperationNode() {\n        return this.#props.node;\n    }\n}\n","/// <reference types=\"./log-once.d.ts\" />\nconst LOGGED_MESSAGES = new Set();\n/**\n * Use for system-level logging, such as deprecation messages.\n * Logs a message and ensures it won't be logged again.\n */\nexport function logOnce(message) {\n    if (LOGGED_MESSAGES.has(message)) {\n        return;\n    }\n    LOGGED_MESSAGES.add(message);\n    console.log(message);\n}\n","/// <reference types=\"./order-by-parser.d.ts\" />\nimport { isDynamicReferenceBuilder, } from '../dynamic/dynamic-reference-builder.js';\nimport { isExpression } from '../expression/expression.js';\nimport { OrderByItemNode } from '../operation-node/order-by-item-node.js';\nimport { RawNode } from '../operation-node/raw-node.js';\nimport { OrderByItemBuilder } from '../query-builder/order-by-item-builder.js';\nimport { logOnce } from '../util/log-once.js';\nimport { isExpressionOrFactory, parseExpression, } from './expression-parser.js';\nimport { parseStringReference, } from './reference-parser.js';\nexport function isOrderByDirection(thing) {\n    return thing === 'asc' || thing === 'desc';\n}\nexport function parseOrderBy(args) {\n    if (args.length === 2) {\n        return [parseOrderByItem(args[0], args[1])];\n    }\n    if (args.length === 1) {\n        const [orderBy] = args;\n        if (Array.isArray(orderBy)) {\n            logOnce('orderBy(array) is deprecated, use multiple orderBy calls instead.');\n            return orderBy.map((item) => parseOrderByItem(item));\n        }\n        return [parseOrderByItem(orderBy)];\n    }\n    throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${args.length}`);\n}\nexport function parseOrderByItem(expr, modifiers) {\n    const parsedRef = parseOrderByExpression(expr);\n    if (OrderByItemNode.is(parsedRef)) {\n        if (modifiers) {\n            throw new Error('Cannot specify direction twice!');\n        }\n        return parsedRef;\n    }\n    return parseOrderByWithModifiers(parsedRef, modifiers);\n}\nfunction parseOrderByExpression(expr) {\n    if (isExpressionOrFactory(expr)) {\n        return parseExpression(expr);\n    }\n    if (isDynamicReferenceBuilder(expr)) {\n        return expr.toOperationNode();\n    }\n    const [ref, direction] = expr.split(' ');\n    if (direction) {\n        logOnce(\"`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead.\");\n        return parseOrderByWithModifiers(parseStringReference(ref), direction);\n    }\n    return parseStringReference(expr);\n}\nfunction parseOrderByWithModifiers(expr, modifiers) {\n    if (typeof modifiers === 'string') {\n        if (!isOrderByDirection(modifiers)) {\n            throw new Error(`Invalid order by direction: ${modifiers}`);\n        }\n        return OrderByItemNode.create(expr, RawNode.createWithSql(modifiers));\n    }\n    if (isExpression(modifiers)) {\n        logOnce(\"`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead.\");\n        return OrderByItemNode.create(expr, modifiers.toOperationNode());\n    }\n    const node = OrderByItemNode.create(expr);\n    if (!modifiers) {\n        return node;\n    }\n    return modifiers(new OrderByItemBuilder({ node })).toOperationNode();\n}\n","/// <reference types=\"./json-reference-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const JSONReferenceNode = freeze({\n    is(node) {\n        return node.kind === 'JSONReferenceNode';\n    },\n    create(reference, traversal) {\n        return freeze({\n            kind: 'JSONReferenceNode',\n            reference,\n            traversal,\n        });\n    },\n    cloneWithTraversal(node, traversal) {\n        return freeze({\n            ...node,\n            traversal,\n        });\n    },\n});\n","/// <reference types=\"./json-operator-chain-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const JSONOperatorChainNode = freeze({\n    is(node) {\n        return node.kind === 'JSONOperatorChainNode';\n    },\n    create(operator) {\n        return freeze({\n            kind: 'JSONOperatorChainNode',\n            operator,\n            values: freeze([]),\n        });\n    },\n    cloneWithValue(node, value) {\n        return freeze({\n            ...node,\n            values: freeze([...node.values, value]),\n        });\n    },\n});\n","/// <reference types=\"./json-path-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const JSONPathNode = freeze({\n    is(node) {\n        return node.kind === 'JSONPathNode';\n    },\n    create(inOperator) {\n        return freeze({\n            kind: 'JSONPathNode',\n            inOperator,\n            pathLegs: freeze([]),\n        });\n    },\n    cloneWithLeg(jsonPathNode, pathLeg) {\n        return freeze({\n            ...jsonPathNode,\n            pathLegs: freeze([...jsonPathNode.pathLegs, pathLeg]),\n        });\n    },\n});\n","/// <reference types=\"./reference-parser.d.ts\" />\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { ColumnNode } from '../operation-node/column-node.js';\nimport { ReferenceNode } from '../operation-node/reference-node.js';\nimport { TableNode } from '../operation-node/table-node.js';\nimport { isReadonlyArray, isString } from '../util/object-utils.js';\nimport { parseExpression, isExpressionOrFactory, } from './expression-parser.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { isOrderByDirection, parseOrderBy, } from './order-by-parser.js';\nimport { OperatorNode, isJSONOperator, } from '../operation-node/operator-node.js';\nimport { JSONReferenceNode } from '../operation-node/json-reference-node.js';\nimport { JSONOperatorChainNode } from '../operation-node/json-operator-chain-node.js';\nimport { JSONPathNode } from '../operation-node/json-path-node.js';\nexport function parseSimpleReferenceExpression(exp) {\n    if (isString(exp)) {\n        return parseStringReference(exp);\n    }\n    return exp.toOperationNode();\n}\nexport function parseReferenceExpressionOrList(arg) {\n    if (isReadonlyArray(arg)) {\n        return arg.map((it) => parseReferenceExpression(it));\n    }\n    else {\n        return [parseReferenceExpression(arg)];\n    }\n}\nexport function parseReferenceExpression(exp) {\n    if (isExpressionOrFactory(exp)) {\n        return parseExpression(exp);\n    }\n    return parseSimpleReferenceExpression(exp);\n}\nexport function parseJSONReference(ref, op) {\n    if (isJSONOperator(op)) {\n        return JSONReferenceNode.create(parseStringReference(ref), JSONOperatorChainNode.create(OperatorNode.create(op)));\n    }\n    if (op === '->$' || op === '->>$') {\n        return JSONReferenceNode.create(parseStringReference(ref), JSONPathNode.create(OperatorNode.create(op.slice(0, -1))));\n    }\n    throw new Error(`Invalid JSON operator: ${op}`);\n}\nexport function parseStringReference(ref) {\n    const COLUMN_SEPARATOR = '.';\n    if (!ref.includes(COLUMN_SEPARATOR)) {\n        return ReferenceNode.create(ColumnNode.create(ref));\n    }\n    const parts = ref.split(COLUMN_SEPARATOR).map(trim);\n    if (parts.length === 3) {\n        return parseStringReferenceWithTableAndSchema(parts);\n    }\n    if (parts.length === 2) {\n        return parseStringReferenceWithTable(parts);\n    }\n    throw new Error(`invalid column reference ${ref}`);\n}\nexport function parseAliasedStringReference(ref) {\n    const ALIAS_SEPARATOR = ' as ';\n    if (ref.includes(ALIAS_SEPARATOR)) {\n        const [columnRef, alias] = ref.split(ALIAS_SEPARATOR).map(trim);\n        return AliasNode.create(parseStringReference(columnRef), IdentifierNode.create(alias));\n    }\n    else {\n        return parseStringReference(ref);\n    }\n}\nexport function parseColumnName(column) {\n    return ColumnNode.create(column);\n}\nexport function parseOrderedColumnName(column) {\n    const ORDER_SEPARATOR = ' ';\n    if (column.includes(ORDER_SEPARATOR)) {\n        const [columnName, order] = column.split(ORDER_SEPARATOR).map(trim);\n        if (!isOrderByDirection(order)) {\n            throw new Error(`invalid order direction \"${order}\" next to \"${columnName}\"`);\n        }\n        return parseOrderBy([columnName, order])[0];\n    }\n    else {\n        return parseColumnName(column);\n    }\n}\nfunction parseStringReferenceWithTableAndSchema(parts) {\n    const [schema, table, column] = parts;\n    return ReferenceNode.create(ColumnNode.create(column), TableNode.createWithSchema(schema, table));\n}\nfunction parseStringReferenceWithTable(parts) {\n    const [table, column] = parts;\n    return ReferenceNode.create(ColumnNode.create(column), TableNode.create(table));\n}\nfunction trim(str) {\n    return str.trim();\n}\n","/// <reference types=\"./primitive-value-list-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const PrimitiveValueListNode = freeze({\n    is(node) {\n        return node.kind === 'PrimitiveValueListNode';\n    },\n    create(values) {\n        return freeze({\n            kind: 'PrimitiveValueListNode',\n            values: freeze([...values]),\n        });\n    },\n});\n","/// <reference types=\"./value-list-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const ValueListNode = freeze({\n    is(node) {\n        return node.kind === 'ValueListNode';\n    },\n    create(values) {\n        return freeze({\n            kind: 'ValueListNode',\n            values: freeze(values),\n        });\n    },\n});\n","/// <reference types=\"./value-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const ValueNode = freeze({\n    is(node) {\n        return node.kind === 'ValueNode';\n    },\n    create(value) {\n        return freeze({\n            kind: 'ValueNode',\n            value,\n        });\n    },\n    createImmediate(value) {\n        return freeze({\n            kind: 'ValueNode',\n            value,\n            immediate: true,\n        });\n    },\n});\n","/// <reference types=\"./value-parser.d.ts\" />\nimport { PrimitiveValueListNode } from '../operation-node/primitive-value-list-node.js';\nimport { ValueListNode } from '../operation-node/value-list-node.js';\nimport { ValueNode } from '../operation-node/value-node.js';\nimport { isBoolean, isNull, isNumber, isReadonlyArray, } from '../util/object-utils.js';\nimport { parseExpression, isExpressionOrFactory, } from './expression-parser.js';\nexport function parseValueExpressionOrList(arg) {\n    if (isReadonlyArray(arg)) {\n        return parseValueExpressionList(arg);\n    }\n    return parseValueExpression(arg);\n}\nexport function parseValueExpression(exp) {\n    if (isExpressionOrFactory(exp)) {\n        return parseExpression(exp);\n    }\n    return ValueNode.create(exp);\n}\nexport function isSafeImmediateValue(value) {\n    return isNumber(value) || isBoolean(value) || isNull(value);\n}\nexport function parseSafeImmediateValue(value) {\n    if (!isSafeImmediateValue(value)) {\n        throw new Error(`unsafe immediate value ${JSON.stringify(value)}`);\n    }\n    return ValueNode.createImmediate(value);\n}\nfunction parseValueExpressionList(arg) {\n    if (arg.some(isExpressionOrFactory)) {\n        return ValueListNode.create(arg.map((it) => parseValueExpression(it)));\n    }\n    return PrimitiveValueListNode.create(arg);\n}\n","/// <reference types=\"./parens-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const ParensNode = freeze({\n    is(node) {\n        return node.kind === 'ParensNode';\n    },\n    create(node) {\n        return freeze({\n            kind: 'ParensNode',\n            node,\n        });\n    },\n});\n","/// <reference types=\"./binary-operation-parser.d.ts\" />\nimport { BinaryOperationNode } from '../operation-node/binary-operation-node.js';\nimport { isBoolean, isNull, isUndefined } from '../util/object-utils.js';\nimport { isOperationNodeSource, } from '../operation-node/operation-node-source.js';\nimport { OperatorNode, isBinaryOperator, } from '../operation-node/operator-node.js';\nimport { parseReferenceExpression, } from './reference-parser.js';\nimport { parseValueExpression, parseValueExpressionOrList, } from './value-parser.js';\nimport { ValueNode } from '../operation-node/value-node.js';\nimport { AndNode } from '../operation-node/and-node.js';\nimport { ParensNode } from '../operation-node/parens-node.js';\nimport { OrNode } from '../operation-node/or-node.js';\nexport function parseValueBinaryOperationOrExpression(args) {\n    if (args.length === 3) {\n        return parseValueBinaryOperation(args[0], args[1], args[2]);\n    }\n    else if (args.length === 1) {\n        return parseValueExpression(args[0]);\n    }\n    throw new Error(`invalid arguments: ${JSON.stringify(args)}`);\n}\nexport function parseValueBinaryOperation(left, operator, right) {\n    if (isIsOperator(operator) && needsIsOperator(right)) {\n        return BinaryOperationNode.create(parseReferenceExpression(left), parseBinaryOperator(operator), ValueNode.createImmediate(right));\n    }\n    return BinaryOperationNode.create(parseReferenceExpression(left), parseBinaryOperator(operator), parseValueExpressionOrList(right));\n}\nexport function parseReferentialBinaryOperation(left, operator, right) {\n    return BinaryOperationNode.create(parseReferenceExpression(left), parseBinaryOperator(operator), parseReferenceExpression(right));\n}\nexport function parseFilterObject(obj, combinator) {\n    return parseFilterList(Object.entries(obj)\n        .filter(([, v]) => !isUndefined(v))\n        .map(([k, v]) => parseValueBinaryOperation(k, needsIsOperator(v) ? 'is' : '=', v)), combinator);\n}\nexport function parseFilterList(list, combinator, withParens = true) {\n    const combine = combinator === 'and' ? AndNode.create : OrNode.create;\n    if (list.length === 0) {\n        return BinaryOperationNode.create(ValueNode.createImmediate(1), OperatorNode.create('='), ValueNode.createImmediate(combinator === 'and' ? 1 : 0));\n    }\n    let node = toOperationNode(list[0]);\n    for (let i = 1; i < list.length; ++i) {\n        node = combine(node, toOperationNode(list[i]));\n    }\n    if (list.length > 1 && withParens) {\n        return ParensNode.create(node);\n    }\n    return node;\n}\nfunction isIsOperator(operator) {\n    return operator === 'is' || operator === 'is not';\n}\nfunction needsIsOperator(value) {\n    return isNull(value) || isBoolean(value);\n}\nfunction parseBinaryOperator(operator) {\n    if (isBinaryOperator(operator)) {\n        return OperatorNode.create(operator);\n    }\n    if (isOperationNodeSource(operator)) {\n        return operator.toOperationNode();\n    }\n    throw new Error(`invalid operator ${JSON.stringify(operator)}`);\n}\nfunction toOperationNode(nodeOrSource) {\n    return isOperationNodeSource(nodeOrSource)\n        ? nodeOrSource.toOperationNode()\n        : nodeOrSource;\n}\n","/// <reference types=\"./order-by-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const OrderByNode = freeze({\n    is(node) {\n        return node.kind === 'OrderByNode';\n    },\n    create(items) {\n        return freeze({\n            kind: 'OrderByNode',\n            items: freeze([...items]),\n        });\n    },\n    cloneWithItems(orderBy, items) {\n        return freeze({\n            ...orderBy,\n            items: freeze([...orderBy.items, ...items]),\n        });\n    },\n});\n","/// <reference types=\"./partition-by-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const PartitionByNode = freeze({\n    is(node) {\n        return node.kind === 'PartitionByNode';\n    },\n    create(items) {\n        return freeze({\n            kind: 'PartitionByNode',\n            items: freeze(items),\n        });\n    },\n    cloneWithItems(partitionBy, items) {\n        return freeze({\n            ...partitionBy,\n            items: freeze([...partitionBy.items, ...items]),\n        });\n    },\n});\n","/// <reference types=\"./over-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { OrderByNode } from './order-by-node.js';\nimport { PartitionByNode } from './partition-by-node.js';\n/**\n * @internal\n */\nexport const OverNode = freeze({\n    is(node) {\n        return node.kind === 'OverNode';\n    },\n    create() {\n        return freeze({\n            kind: 'OverNode',\n        });\n    },\n    cloneWithOrderByItems(overNode, items) {\n        return freeze({\n            ...overNode,\n            orderBy: overNode.orderBy\n                ? OrderByNode.cloneWithItems(overNode.orderBy, items)\n                : OrderByNode.create(items),\n        });\n    },\n    cloneWithPartitionByItems(overNode, items) {\n        return freeze({\n            ...overNode,\n            partitionBy: overNode.partitionBy\n                ? PartitionByNode.cloneWithItems(overNode.partitionBy, items)\n                : PartitionByNode.create(items),\n        });\n    },\n});\n","/// <reference types=\"./from-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const FromNode = freeze({\n    is(node) {\n        return node.kind === 'FromNode';\n    },\n    create(froms) {\n        return freeze({\n            kind: 'FromNode',\n            froms: freeze(froms),\n        });\n    },\n    cloneWithFroms(from, froms) {\n        return freeze({\n            ...from,\n            froms: freeze([...from.froms, ...froms]),\n        });\n    },\n});\n","/// <reference types=\"./group-by-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const GroupByNode = freeze({\n    is(node) {\n        return node.kind === 'GroupByNode';\n    },\n    create(items) {\n        return freeze({\n            kind: 'GroupByNode',\n            items: freeze(items),\n        });\n    },\n    cloneWithItems(groupBy, items) {\n        return freeze({\n            ...groupBy,\n            items: freeze([...groupBy.items, ...items]),\n        });\n    },\n});\n","/// <reference types=\"./having-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { AndNode } from './and-node.js';\nimport { OrNode } from './or-node.js';\n/**\n * @internal\n */\nexport const HavingNode = freeze({\n    is(node) {\n        return node.kind === 'HavingNode';\n    },\n    create(filter) {\n        return freeze({\n            kind: 'HavingNode',\n            having: filter,\n        });\n    },\n    cloneWithOperation(havingNode, operator, operation) {\n        return freeze({\n            ...havingNode,\n            having: operator === 'And'\n                ? AndNode.create(havingNode.having, operation)\n                : OrNode.create(havingNode.having, operation),\n        });\n    },\n});\n","/// <reference types=\"./insert-query-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const InsertQueryNode = freeze({\n    is(node) {\n        return node.kind === 'InsertQueryNode';\n    },\n    create(into, withNode, replace) {\n        return freeze({\n            kind: 'InsertQueryNode',\n            into,\n            ...(withNode && { with: withNode }),\n            replace,\n        });\n    },\n    createWithoutInto() {\n        return freeze({\n            kind: 'InsertQueryNode',\n        });\n    },\n    cloneWith(insertQuery, props) {\n        return freeze({\n            ...insertQuery,\n            ...props,\n        });\n    },\n});\n","/// <reference types=\"./list-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const ListNode = freeze({\n    is(node) {\n        return node.kind === 'ListNode';\n    },\n    create(items) {\n        return freeze({\n            kind: 'ListNode',\n            items: freeze(items),\n        });\n    },\n});\n","/// <reference types=\"./update-query-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { FromNode } from './from-node.js';\nimport { ListNode } from './list-node.js';\n/**\n * @internal\n */\nexport const UpdateQueryNode = freeze({\n    is(node) {\n        return node.kind === 'UpdateQueryNode';\n    },\n    create(tables, withNode) {\n        return freeze({\n            kind: 'UpdateQueryNode',\n            // For backwards compatibility, use the raw table node when there's only one table\n            // and don't rename the property to something like `tables`.\n            table: tables.length === 1 ? tables[0] : ListNode.create(tables),\n            ...(withNode && { with: withNode }),\n        });\n    },\n    createWithoutTable() {\n        return freeze({\n            kind: 'UpdateQueryNode',\n        });\n    },\n    cloneWithFromItems(updateQuery, fromItems) {\n        return freeze({\n            ...updateQuery,\n            from: updateQuery.from\n                ? FromNode.cloneWithFroms(updateQuery.from, fromItems)\n                : FromNode.create(fromItems),\n        });\n    },\n    cloneWithUpdates(updateQuery, updates) {\n        return freeze({\n            ...updateQuery,\n            updates: updateQuery.updates\n                ? freeze([...updateQuery.updates, ...updates])\n                : updates,\n        });\n    },\n    cloneWithLimit(updateQuery, limit) {\n        return freeze({\n            ...updateQuery,\n            limit,\n        });\n    },\n});\n","/// <reference types=\"./using-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const UsingNode = freeze({\n    is(node) {\n        return node.kind === 'UsingNode';\n    },\n    create(tables) {\n        return freeze({\n            kind: 'UsingNode',\n            tables: freeze(tables),\n        });\n    },\n    cloneWithTables(using, tables) {\n        return freeze({\n            ...using,\n            tables: freeze([...using.tables, ...tables]),\n        });\n    },\n});\n","/// <reference types=\"./delete-query-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { FromNode } from './from-node.js';\nimport { UsingNode } from './using-node.js';\nimport { QueryNode } from './query-node.js';\n/**\n * @internal\n */\nexport const DeleteQueryNode = freeze({\n    is(node) {\n        return node.kind === 'DeleteQueryNode';\n    },\n    create(fromItems, withNode) {\n        return freeze({\n            kind: 'DeleteQueryNode',\n            from: FromNode.create(fromItems),\n            ...(withNode && { with: withNode }),\n        });\n    },\n    // TODO: remove in v0.29\n    /**\n     * @deprecated Use `QueryNode.cloneWithoutOrderBy` instead.\n     */\n    cloneWithOrderByItems: (node, items) => QueryNode.cloneWithOrderByItems(node, items),\n    // TODO: remove in v0.29\n    /**\n     * @deprecated Use `QueryNode.cloneWithoutOrderBy` instead.\n     */\n    cloneWithoutOrderBy: (node) => QueryNode.cloneWithoutOrderBy(node),\n    cloneWithLimit(deleteNode, limit) {\n        return freeze({\n            ...deleteNode,\n            limit,\n        });\n    },\n    cloneWithoutLimit(deleteNode) {\n        return freeze({\n            ...deleteNode,\n            limit: undefined,\n        });\n    },\n    cloneWithUsing(deleteNode, tables) {\n        return freeze({\n            ...deleteNode,\n            using: deleteNode.using !== undefined\n                ? UsingNode.cloneWithTables(deleteNode.using, tables)\n                : UsingNode.create(tables),\n        });\n    },\n});\n","/// <reference types=\"./where-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { AndNode } from './and-node.js';\nimport { OrNode } from './or-node.js';\n/**\n * @internal\n */\nexport const WhereNode = freeze({\n    is(node) {\n        return node.kind === 'WhereNode';\n    },\n    create(filter) {\n        return freeze({\n            kind: 'WhereNode',\n            where: filter,\n        });\n    },\n    cloneWithOperation(whereNode, operator, operation) {\n        return freeze({\n            ...whereNode,\n            where: operator === 'And'\n                ? AndNode.create(whereNode.where, operation)\n                : OrNode.create(whereNode.where, operation),\n        });\n    },\n});\n","/// <reference types=\"./returning-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const ReturningNode = freeze({\n    is(node) {\n        return node.kind === 'ReturningNode';\n    },\n    create(selections) {\n        return freeze({\n            kind: 'ReturningNode',\n            selections: freeze(selections),\n        });\n    },\n    cloneWithSelections(returning, selections) {\n        return freeze({\n            ...returning,\n            selections: returning.selections\n                ? freeze([...returning.selections, ...selections])\n                : freeze(selections),\n        });\n    },\n});\n","/// <reference types=\"./explain-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const ExplainNode = freeze({\n    is(node) {\n        return node.kind === 'ExplainNode';\n    },\n    create(format, options) {\n        return freeze({\n            kind: 'ExplainNode',\n            format,\n            options,\n        });\n    },\n});\n","/// <reference types=\"./when-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const WhenNode = freeze({\n    is(node) {\n        return node.kind === 'WhenNode';\n    },\n    create(condition) {\n        return freeze({\n            kind: 'WhenNode',\n            condition,\n        });\n    },\n    cloneWithResult(whenNode, result) {\n        return freeze({\n            ...whenNode,\n            result,\n        });\n    },\n});\n","/// <reference types=\"./merge-query-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { WhenNode } from './when-node.js';\n/**\n * @internal\n */\nexport const MergeQueryNode = freeze({\n    is(node) {\n        return node.kind === 'MergeQueryNode';\n    },\n    create(into, withNode) {\n        return freeze({\n            kind: 'MergeQueryNode',\n            into,\n            ...(withNode && { with: withNode }),\n        });\n    },\n    cloneWithUsing(mergeNode, using) {\n        return freeze({\n            ...mergeNode,\n            using,\n        });\n    },\n    cloneWithWhen(mergeNode, when) {\n        return freeze({\n            ...mergeNode,\n            whens: mergeNode.whens\n                ? freeze([...mergeNode.whens, when])\n                : freeze([when]),\n        });\n    },\n    cloneWithThen(mergeNode, then) {\n        return freeze({\n            ...mergeNode,\n            whens: mergeNode.whens\n                ? freeze([\n                    ...mergeNode.whens.slice(0, -1),\n                    WhenNode.cloneWithResult(mergeNode.whens[mergeNode.whens.length - 1], then),\n                ])\n                : undefined,\n        });\n    },\n});\n","/// <reference types=\"./output-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const OutputNode = freeze({\n    is(node) {\n        return node.kind === 'OutputNode';\n    },\n    create(selections) {\n        return freeze({\n            kind: 'OutputNode',\n            selections: freeze(selections),\n        });\n    },\n    cloneWithSelections(output, selections) {\n        return freeze({\n            ...output,\n            selections: output.selections\n                ? freeze([...output.selections, ...selections])\n                : freeze(selections),\n        });\n    },\n});\n","/// <reference types=\"./query-node.d.ts\" />\nimport { InsertQueryNode } from './insert-query-node.js';\nimport { SelectQueryNode } from './select-query-node.js';\nimport { UpdateQueryNode } from './update-query-node.js';\nimport { DeleteQueryNode } from './delete-query-node.js';\nimport { WhereNode } from './where-node.js';\nimport { freeze } from '../util/object-utils.js';\nimport { ReturningNode } from './returning-node.js';\nimport { ExplainNode } from './explain-node.js';\nimport { MergeQueryNode } from './merge-query-node.js';\nimport { OutputNode } from './output-node.js';\nimport { OrderByNode } from './order-by-node.js';\n/**\n * @internal\n */\nexport const QueryNode = freeze({\n    is(node) {\n        return (SelectQueryNode.is(node) ||\n            InsertQueryNode.is(node) ||\n            UpdateQueryNode.is(node) ||\n            DeleteQueryNode.is(node) ||\n            MergeQueryNode.is(node));\n    },\n    cloneWithEndModifier(node, modifier) {\n        return freeze({\n            ...node,\n            endModifiers: node.endModifiers\n                ? freeze([...node.endModifiers, modifier])\n                : freeze([modifier]),\n        });\n    },\n    cloneWithWhere(node, operation) {\n        return freeze({\n            ...node,\n            where: node.where\n                ? WhereNode.cloneWithOperation(node.where, 'And', operation)\n                : WhereNode.create(operation),\n        });\n    },\n    cloneWithJoin(node, join) {\n        return freeze({\n            ...node,\n            joins: node.joins ? freeze([...node.joins, join]) : freeze([join]),\n        });\n    },\n    cloneWithReturning(node, selections) {\n        return freeze({\n            ...node,\n            returning: node.returning\n                ? ReturningNode.cloneWithSelections(node.returning, selections)\n                : ReturningNode.create(selections),\n        });\n    },\n    cloneWithoutReturning(node) {\n        return freeze({\n            ...node,\n            returning: undefined,\n        });\n    },\n    cloneWithoutWhere(node) {\n        return freeze({\n            ...node,\n            where: undefined,\n        });\n    },\n    cloneWithExplain(node, format, options) {\n        return freeze({\n            ...node,\n            explain: ExplainNode.create(format, options?.toOperationNode()),\n        });\n    },\n    cloneWithTop(node, top) {\n        return freeze({\n            ...node,\n            top,\n        });\n    },\n    cloneWithOutput(node, selections) {\n        return freeze({\n            ...node,\n            output: node.output\n                ? OutputNode.cloneWithSelections(node.output, selections)\n                : OutputNode.create(selections),\n        });\n    },\n    cloneWithOrderByItems(node, items) {\n        return freeze({\n            ...node,\n            orderBy: node.orderBy\n                ? OrderByNode.cloneWithItems(node.orderBy, items)\n                : OrderByNode.create(items),\n        });\n    },\n    cloneWithoutOrderBy(node) {\n        return freeze({\n            ...node,\n            orderBy: undefined,\n        });\n    },\n});\n","/// <reference types=\"./select-query-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { FromNode } from './from-node.js';\nimport { GroupByNode } from './group-by-node.js';\nimport { HavingNode } from './having-node.js';\nimport { QueryNode } from './query-node.js';\n/**\n * @internal\n */\nexport const SelectQueryNode = freeze({\n    is(node) {\n        return node.kind === 'SelectQueryNode';\n    },\n    create(withNode) {\n        return freeze({\n            kind: 'SelectQueryNode',\n            ...(withNode && { with: withNode }),\n        });\n    },\n    createFrom(fromItems, withNode) {\n        return freeze({\n            kind: 'SelectQueryNode',\n            from: FromNode.create(fromItems),\n            ...(withNode && { with: withNode }),\n        });\n    },\n    cloneWithSelections(select, selections) {\n        return freeze({\n            ...select,\n            selections: select.selections\n                ? freeze([...select.selections, ...selections])\n                : freeze(selections),\n        });\n    },\n    cloneWithDistinctOn(select, expressions) {\n        return freeze({\n            ...select,\n            distinctOn: select.distinctOn\n                ? freeze([...select.distinctOn, ...expressions])\n                : freeze(expressions),\n        });\n    },\n    cloneWithFrontModifier(select, modifier) {\n        return freeze({\n            ...select,\n            frontModifiers: select.frontModifiers\n                ? freeze([...select.frontModifiers, modifier])\n                : freeze([modifier]),\n        });\n    },\n    // TODO: remove in v0.29\n    /**\n     * @deprecated Use `QueryNode.cloneWithoutOrderBy` instead.\n     */\n    cloneWithOrderByItems: (node, items) => QueryNode.cloneWithOrderByItems(node, items),\n    cloneWithGroupByItems(selectNode, items) {\n        return freeze({\n            ...selectNode,\n            groupBy: selectNode.groupBy\n                ? GroupByNode.cloneWithItems(selectNode.groupBy, items)\n                : GroupByNode.create(items),\n        });\n    },\n    cloneWithLimit(selectNode, limit) {\n        return freeze({\n            ...selectNode,\n            limit,\n        });\n    },\n    cloneWithOffset(selectNode, offset) {\n        return freeze({\n            ...selectNode,\n            offset,\n        });\n    },\n    cloneWithFetch(selectNode, fetch) {\n        return freeze({\n            ...selectNode,\n            fetch,\n        });\n    },\n    cloneWithHaving(selectNode, operation) {\n        return freeze({\n            ...selectNode,\n            having: selectNode.having\n                ? HavingNode.cloneWithOperation(selectNode.having, 'And', operation)\n                : HavingNode.create(operation),\n        });\n    },\n    cloneWithSetOperations(selectNode, setOperations) {\n        return freeze({\n            ...selectNode,\n            setOperations: selectNode.setOperations\n                ? freeze([...selectNode.setOperations, ...setOperations])\n                : freeze([...setOperations]),\n        });\n    },\n    cloneWithoutSelections(select) {\n        return freeze({\n            ...select,\n            selections: [],\n        });\n    },\n    cloneWithoutLimit(select) {\n        return freeze({\n            ...select,\n            limit: undefined,\n        });\n    },\n    cloneWithoutOffset(select) {\n        return freeze({\n            ...select,\n            offset: undefined,\n        });\n    },\n    // TODO: remove in v0.29\n    /**\n     * @deprecated Use `QueryNode.cloneWithoutOrderBy` instead.\n     */\n    cloneWithoutOrderBy: (node) => QueryNode.cloneWithoutOrderBy(node),\n    cloneWithoutGroupBy(select) {\n        return freeze({\n            ...select,\n            groupBy: undefined,\n        });\n    },\n});\n","/// <reference types=\"./join-builder.d.ts\" />\nimport { JoinNode } from '../operation-node/join-node.js';\nimport { RawNode } from '../operation-node/raw-node.js';\nimport { parseValueBinaryOperationOrExpression, parseReferentialBinaryOperation, } from '../parser/binary-operation-parser.js';\nimport { freeze } from '../util/object-utils.js';\nexport class JoinBuilder {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    on(...args) {\n        return new JoinBuilder({\n            ...this.#props,\n            joinNode: JoinNode.cloneWithOn(this.#props.joinNode, parseValueBinaryOperationOrExpression(args)),\n        });\n    }\n    /**\n     * Just like {@link WhereInterface.whereRef} but adds an item to the join's\n     * `on` clause instead.\n     *\n     * See {@link WhereInterface.whereRef} for documentation and examples.\n     */\n    onRef(lhs, op, rhs) {\n        return new JoinBuilder({\n            ...this.#props,\n            joinNode: JoinNode.cloneWithOn(this.#props.joinNode, parseReferentialBinaryOperation(lhs, op, rhs)),\n        });\n    }\n    /**\n     * Adds `on true`.\n     */\n    onTrue() {\n        return new JoinBuilder({\n            ...this.#props,\n            joinNode: JoinNode.cloneWithOn(this.#props.joinNode, RawNode.createWithSql('true')),\n        });\n    }\n    /**\n     * Simply calls the provided function passing `this` as the only argument. `$call` returns\n     * what the provided function returns.\n     */\n    $call(func) {\n        return func(this);\n    }\n    toOperationNode() {\n        return this.#props.joinNode;\n    }\n}\n","/// <reference types=\"./partition-by-item-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const PartitionByItemNode = freeze({\n    is(node) {\n        return node.kind === 'PartitionByItemNode';\n    },\n    create(partitionBy) {\n        return freeze({\n            kind: 'PartitionByItemNode',\n            partitionBy,\n        });\n    },\n});\n","/// <reference types=\"./partition-by-parser.d.ts\" />\nimport { PartitionByItemNode } from '../operation-node/partition-by-item-node.js';\nimport { parseReferenceExpressionOrList, } from './reference-parser.js';\nexport function parsePartitionBy(partitionBy) {\n    return parseReferenceExpressionOrList(partitionBy).map(PartitionByItemNode.create);\n}\n","/// <reference types=\"./over-builder.d.ts\" />\nimport { OverNode } from '../operation-node/over-node.js';\nimport { QueryNode } from '../operation-node/query-node.js';\nimport { parseOrderBy, } from '../parser/order-by-parser.js';\nimport { parsePartitionBy, } from '../parser/partition-by-parser.js';\nimport { freeze } from '../util/object-utils.js';\nexport class OverBuilder {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    orderBy(...args) {\n        return new OverBuilder({\n            overNode: OverNode.cloneWithOrderByItems(this.#props.overNode, parseOrderBy(args)),\n        });\n    }\n    clearOrderBy() {\n        return new OverBuilder({\n            overNode: QueryNode.cloneWithoutOrderBy(this.#props.overNode),\n        });\n    }\n    partitionBy(partitionBy) {\n        return new OverBuilder({\n            overNode: OverNode.cloneWithPartitionByItems(this.#props.overNode, parsePartitionBy(partitionBy)),\n        });\n    }\n    /**\n     * Simply calls the provided function passing `this` as the only argument. `$call` returns\n     * what the provided function returns.\n     */\n    $call(func) {\n        return func(this);\n    }\n    toOperationNode() {\n        return this.#props.overNode;\n    }\n}\n","/// <reference types=\"./selection-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { ReferenceNode } from './reference-node.js';\nimport { SelectAllNode } from './select-all-node.js';\n/**\n * @internal\n */\nexport const SelectionNode = freeze({\n    is(node) {\n        return node.kind === 'SelectionNode';\n    },\n    create(selection) {\n        return freeze({\n            kind: 'SelectionNode',\n            selection: selection,\n        });\n    },\n    createSelectAll() {\n        return freeze({\n            kind: 'SelectionNode',\n            selection: SelectAllNode.create(),\n        });\n    },\n    createSelectAllFromTable(table) {\n        return freeze({\n            kind: 'SelectionNode',\n            selection: ReferenceNode.createSelectAll(table),\n        });\n    },\n});\n","/// <reference types=\"./select-parser.d.ts\" />\nimport { isFunction, isReadonlyArray, isString } from '../util/object-utils.js';\nimport { SelectionNode } from '../operation-node/selection-node.js';\nimport { parseAliasedStringReference } from './reference-parser.js';\nimport { isDynamicReferenceBuilder, } from '../dynamic/dynamic-reference-builder.js';\nimport { parseAliasedExpression, } from './expression-parser.js';\nimport { parseTable } from './table-parser.js';\nimport { expressionBuilder, } from '../expression/expression-builder.js';\nexport function parseSelectArg(selection) {\n    if (isFunction(selection)) {\n        return parseSelectArg(selection(expressionBuilder()));\n    }\n    else if (isReadonlyArray(selection)) {\n        return selection.map((it) => parseSelectExpression(it));\n    }\n    else {\n        return [parseSelectExpression(selection)];\n    }\n}\nfunction parseSelectExpression(selection) {\n    if (isString(selection)) {\n        return SelectionNode.create(parseAliasedStringReference(selection));\n    }\n    else if (isDynamicReferenceBuilder(selection)) {\n        return SelectionNode.create(selection.toOperationNode());\n    }\n    else {\n        return SelectionNode.create(parseAliasedExpression(selection));\n    }\n}\nexport function parseSelectAll(table) {\n    if (!table) {\n        return [SelectionNode.createSelectAll()];\n    }\n    else if (Array.isArray(table)) {\n        return table.map(parseSelectAllArg);\n    }\n    else {\n        return [parseSelectAllArg(table)];\n    }\n}\nfunction parseSelectAllArg(table) {\n    if (isString(table)) {\n        return SelectionNode.createSelectAllFromTable(parseTable(table));\n    }\n    throw new Error(`invalid value selectAll expression: ${JSON.stringify(table)}`);\n}\n","/// <reference types=\"./no-result-error.d.ts\" />\nexport class NoResultError extends Error {\n    /**\n     * The operation node tree of the query that was executed.\n     */\n    node;\n    constructor(node) {\n        super('no result');\n        this.node = node;\n    }\n}\nexport function isNoResultErrorConstructor(fn) {\n    return Object.prototype.hasOwnProperty.call(fn, 'prototype');\n}\n","/// <reference types=\"./top-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const TopNode = freeze({\n    is(node) {\n        return node.kind === 'TopNode';\n    },\n    create(expression, modifiers) {\n        return freeze({\n            kind: 'TopNode',\n            expression,\n            modifiers,\n        });\n    },\n});\n","/// <reference types=\"./top-parser.d.ts\" />\nimport { TopNode } from '../operation-node/top-node.js';\nimport { isBigInt, isNumber, isUndefined } from '../util/object-utils.js';\nexport function parseTop(expression, modifiers) {\n    if (!isNumber(expression) && !isBigInt(expression)) {\n        throw new Error(`Invalid top expression: ${expression}`);\n    }\n    if (!isUndefined(modifiers) && !isTopModifiers(modifiers)) {\n        throw new Error(`Invalid top modifiers: ${modifiers}`);\n    }\n    return TopNode.create(expression, modifiers);\n}\nfunction isTopModifiers(modifiers) {\n    return (modifiers === 'percent' ||\n        modifiers === 'with ties' ||\n        modifiers === 'percent with ties');\n}\n","/// <reference types=\"./limit-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const LimitNode = freeze({\n    is(node) {\n        return node.kind === 'LimitNode';\n    },\n    create(limit) {\n        return freeze({\n            kind: 'LimitNode',\n            limit,\n        });\n    },\n});\n","/// <reference types=\"./random-string.d.ts\" />\nconst CHARS = [\n    'A',\n    'B',\n    'C',\n    'D',\n    'E',\n    'F',\n    'G',\n    'H',\n    'I',\n    'J',\n    'K',\n    'L',\n    'M',\n    'N',\n    'O',\n    'P',\n    'Q',\n    'R',\n    'S',\n    'T',\n    'U',\n    'V',\n    'W',\n    'X',\n    'Y',\n    'Z',\n    'a',\n    'b',\n    'c',\n    'd',\n    'e',\n    'f',\n    'g',\n    'h',\n    'i',\n    'j',\n    'k',\n    'l',\n    'm',\n    'n',\n    'o',\n    'p',\n    'q',\n    'r',\n    's',\n    't',\n    'u',\n    'v',\n    'w',\n    'x',\n    'y',\n    'z',\n    '0',\n    '1',\n    '2',\n    '3',\n    '4',\n    '5',\n    '6',\n    '7',\n    '8',\n    '9',\n];\nexport function randomString(length) {\n    let chars = '';\n    for (let i = 0; i < length; ++i) {\n        chars += randomChar();\n    }\n    return chars;\n}\nfunction randomChar() {\n    return CHARS[~~(Math.random() * CHARS.length)];\n}\n","/// <reference types=\"./query-id.d.ts\" />\nimport { randomString } from './random-string.js';\nexport function createQueryId() {\n    return new LazyQueryId();\n}\nclass LazyQueryId {\n    #queryId;\n    get queryId() {\n        if (this.#queryId === undefined) {\n            this.#queryId = randomString(8);\n        }\n        return this.#queryId;\n    }\n}\n","/// <reference types=\"./deferred.d.ts\" />\nexport class Deferred {\n    #promise;\n    #resolve;\n    #reject;\n    constructor() {\n        this.#promise = new Promise((resolve, reject) => {\n            this.#reject = reject;\n            this.#resolve = resolve;\n        });\n    }\n    get promise() {\n        return this.#promise;\n    }\n    resolve = (value) => {\n        this.#resolve?.(value);\n        this.#resolve = this.#reject = undefined;\n    };\n    reject = (reason) => {\n        this.#reject?.(reason);\n        this.#reject = this.#resolve = undefined;\n    };\n}\n","/// <reference types=\"./provide-controlled-connection.d.ts\" />\nimport { Deferred } from './deferred.js';\nimport { freeze } from './object-utils.js';\nexport async function provideControlledConnection(connectionProvider, options) {\n    const connectionDefer = new Deferred();\n    const connectionReleaseDefer = new Deferred();\n    void connectionProvider\n        .provideConnection(async (connection) => {\n        connectionDefer.resolve(connection);\n        return await connectionReleaseDefer.promise;\n    }, options)\n        .catch((ex) => connectionDefer.reject(ex));\n    // Create composite of the connection and the release method instead of\n    // modifying the connection or creating a new nesting `DatabaseConnection`.\n    // This way we don't accidentally override any methods of 3rd party\n    // connections and don't return wrapped connections to drivers that\n    // expect a certain specific connection class.\n    return freeze({\n        connection: await connectionDefer.promise,\n        release: connectionReleaseDefer.resolve,\n    });\n}\n","/// <reference types=\"./abort.d.ts\" />\nimport { Deferred } from './deferred.js';\nimport { getMessage } from './object-utils.js';\nexport function getInflightQueryAbortHandler(abortStrategy = 'ignore query', connection, beforeThrow) {\n    if (abortStrategy === 'ignore query') {\n        return;\n    }\n    if (abortStrategy === 'cancel query') {\n        const handler = connection.cancelQuery;\n        if (!handler) {\n            throwUnsupportedInflightQueryAbortStrategyError(abortStrategy, connection.killSession ? 'kill session' : undefined);\n        }\n        return handler.bind(connection);\n    }\n    if (abortStrategy === 'kill session') {\n        const handler = connection.killSession;\n        if (!handler) {\n            throwUnsupportedInflightQueryAbortStrategyError(abortStrategy, connection.cancelQuery ? 'cancel query' : undefined);\n        }\n        return handler.bind(connection);\n    }\n    beforeThrow();\n    throw new Error(`Unexpected \\`inflightQueryAbortStrategy\\`: \"${abortStrategy}\"`);\n}\nfunction throwUnsupportedInflightQueryAbortStrategyError(abortStrategy, alt) {\n    throw new Error(`This dialect doesn't support \\`inflightQueryAbortStrategy\\` \"${abortStrategy}\". Use \"${'ignore query'}\"${alt ? ` or \"${alt}\"` : ''} instead.`);\n}\nexport function assertNotAborted(signal, timing, beforeThrow) {\n    if (signal?.aborted) {\n        beforeThrow?.();\n        throwReasonWithTiming(signal.reason, timing);\n    }\n}\nexport function throwReasonWithTiming(reason, timing) {\n    decorateWithTiming(reason, timing);\n    throw reason;\n}\nexport const ABORTED = {};\nexport async function waitOrAbort(promise, signal, name, onAbort) {\n    if (!signal) {\n        return promise;\n    }\n    assertNotAborted(signal, `before ${name}`, onAbort);\n    const { promise: abortPromise, resolve } = new Deferred();\n    const abortListener = () => resolve(ABORTED);\n    signal.addEventListener('abort', abortListener);\n    try {\n        assertNotAborted(signal, `before ${name}`, onAbort);\n        const result = await Promise.race([promise, abortPromise]);\n        if (result !== ABORTED) {\n            return result;\n        }\n        onAbort?.();\n        throwReasonWithTiming(signal.reason, `during ${name}`);\n    }\n    finally {\n        signal.removeEventListener('abort', abortListener);\n        resolve(ABORTED);\n    }\n}\nexport function printBackgroundFail(name) {\n    return (reason) => console.error(`\\`${name}\\` failed in the background after abortion: ${getMessage(reason)}`);\n}\nfunction decorateWithTiming(reason, timing) {\n    if (reason !== null &&\n        typeof reason === 'object' &&\n        !Object.isFrozen(reason)) {\n        // we use this in tests, but it can also be used to debug in userland.\n        Object.defineProperty(reason, '__kysely_timing__', {\n            configurable: true,\n            enumerable: false,\n            value: timing,\n            writable: false,\n        });\n    }\n}\n","/// <reference types=\"./query-executor-base.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { provideControlledConnection } from '../util/provide-controlled-connection.js';\nimport { ABORTED, assertNotAborted, getInflightQueryAbortHandler, printBackgroundFail, throwReasonWithTiming, } from '../util/abort.js';\nimport { Deferred } from '../util/deferred.js';\nconst NO_PLUGINS = freeze([]);\nexport class QueryExecutorBase {\n    #plugins;\n    constructor(plugins = NO_PLUGINS) {\n        this.#plugins = plugins;\n    }\n    get plugins() {\n        return this.#plugins;\n    }\n    transformQuery(node, queryId) {\n        for (const plugin of this.#plugins) {\n            const transformedNode = plugin.transformQuery({ node, queryId });\n            // We need to do a runtime check here. There is no good way\n            // to write types that enforce this constraint.\n            if (transformedNode.kind === node.kind) {\n                node = transformedNode;\n            }\n            else {\n                throw new Error([\n                    `KyselyPlugin.transformQuery must return a node`,\n                    `of the same kind that was given to it.`,\n                    `The plugin was given a ${node.kind}`,\n                    `but it returned a ${transformedNode.kind}`,\n                ].join(' '));\n            }\n        }\n        return node;\n    }\n    async executeQuery(compiledQuery, options) {\n        const { inflightQueryAbortStrategy = 'ignore query', signal } = options || {};\n        // intentionally isolating the simple common case from the new cancellation flow.\n        if (!signal) {\n            const result = await this.provideConnection(async (connection) => {\n                return await connection.executeQuery(compiledQuery);\n            }, options);\n            return await this.#transformResult(result, compiledQuery.queryId);\n        }\n        assertNotAborted(signal, 'before query execution');\n        options = freeze({ signal });\n        const { connection, release } = await provideControlledConnection(this, options);\n        const controlConnectionProvider = this.provideConnection.bind(this);\n        const { promise: abortPromise, resolve } = new Deferred();\n        const abortListener = () => resolve(ABORTED);\n        signal.addEventListener('abort', abortListener, { once: true });\n        try {\n            assertNotAborted(signal, 'before query execution', release);\n            const inflightQueryAbortHandler = getInflightQueryAbortHandler(inflightQueryAbortStrategy, connection, release);\n            if (inflightQueryAbortHandler && connection.collectSessionInfo) {\n                assertNotAborted(signal, 'before query execution', release);\n                const collectPromise = connection.collectSessionInfo();\n                const result = await Promise.race([abortPromise, collectPromise]).catch((error) => {\n                    release();\n                    throw error;\n                });\n                if (result === ABORTED) {\n                    void collectPromise\n                        .catch(printBackgroundFail('collectSessionInfo'))\n                        .finally(release);\n                    throwReasonWithTiming(signal.reason, 'before query execution');\n                }\n            }\n            const queryPromise = connection.executeQuery(compiledQuery, options);\n            const result = await Promise.race([abortPromise, queryPromise])\n                // only the query can error. in that case, we want to release immediately.\n                .catch((error) => {\n                release();\n                throw error;\n            });\n            if (result === ABORTED) {\n                void Promise.allSettled([\n                    queryPromise.catch(printBackgroundFail('query')),\n                    inflightQueryAbortHandler?.(controlConnectionProvider).catch(printBackgroundFail('inflightQueryAbortHandler')),\n                ])\n                    // the abort handler might use the same connection that runs the query.\n                    .finally(release);\n                throwReasonWithTiming(signal.reason, 'during query execution');\n            }\n            else {\n                release();\n            }\n            const transformPromise = this.#transformResult(result, compiledQuery.queryId, options);\n            const transformedResult = await Promise.race([\n                abortPromise,\n                transformPromise,\n            ]);\n            if (transformedResult === ABORTED) {\n                transformPromise.catch(printBackgroundFail('plugins.transformResult'));\n                throwReasonWithTiming(signal.reason, 'during result transformation');\n            }\n            return transformedResult;\n        }\n        finally {\n            resolve(ABORTED);\n            signal.removeEventListener('abort', abortListener);\n        }\n    }\n    async *stream(compiledQuery, chunkSize, options) {\n        const { signal } = options || {};\n        if (!signal) {\n            const { connection, release } = await provideControlledConnection(this);\n            try {\n                for await (const result of connection.streamQuery(compiledQuery, chunkSize)) {\n                    yield await this.#transformResult(result, compiledQuery.queryId, options);\n                }\n            }\n            finally {\n                release();\n            }\n            return;\n        }\n        options = freeze({ signal });\n        assertNotAborted(signal, 'before connection acquisition');\n        const { connection, release } = await provideControlledConnection(this, options);\n        const { promise: abortPromise, resolve } = new Deferred();\n        const abortListener = () => resolve(ABORTED);\n        signal.addEventListener('abort', abortListener, { once: true });\n        let asyncIterator;\n        let releasePrerequisite;\n        assertNotAborted(signal, 'before query streaming', release);\n        const { queryId } = compiledQuery;\n        try {\n            asyncIterator = connection.streamQuery(compiledQuery, chunkSize, options);\n            while (true) {\n                assertNotAborted(signal, 'during query streaming');\n                const nextPromise = asyncIterator.next();\n                const result = await Promise.race([abortPromise, nextPromise]);\n                if (result === ABORTED) {\n                    releasePrerequisite = nextPromise.catch(printBackgroundFail('iterator.next'));\n                    throwReasonWithTiming(signal.reason, 'during query streaming');\n                }\n                if (result.done) {\n                    break;\n                }\n                const transformPromise = this.#transformResult(result.value, queryId, options);\n                const transformedResult = await Promise.race([\n                    abortPromise,\n                    transformPromise,\n                ]);\n                if (transformedResult === ABORTED) {\n                    releasePrerequisite = transformPromise.catch(printBackgroundFail('plugins.transformResult'));\n                    throwReasonWithTiming(signal.reason, 'during result transformation');\n                }\n                yield transformedResult;\n            }\n        }\n        finally {\n            resolve(ABORTED);\n            signal.removeEventListener('abort', abortListener);\n            const cleanup = (asyncIterator?.return?.() || Promise.resolve())\n                .finally(() => releasePrerequisite)\n                .finally(release);\n            if (!releasePrerequisite) {\n                await cleanup;\n            }\n        }\n    }\n    async #transformResult(result, queryId, options) {\n        const { signal } = options || {};\n        for (const plugin of this.#plugins) {\n            result = await plugin.transformResult(freeze({ queryId, result, signal }));\n        }\n        return result;\n    }\n}\n","/// <reference types=\"./noop-query-executor.d.ts\" />\nimport { QueryExecutorBase } from './query-executor-base.js';\n/**\n * A {@link QueryExecutor} subclass that can be used when you don't\n * have a {@link QueryCompiler}, {@link ConnectionProvider} or any\n * other needed things to actually execute queries.\n */\nexport class NoopQueryExecutor extends QueryExecutorBase {\n    get adapter() {\n        throw new Error('this query cannot be compiled to SQL');\n    }\n    compileQuery() {\n        throw new Error('this query cannot be compiled to SQL');\n    }\n    provideConnection() {\n        throw new Error('this query cannot be executed');\n    }\n    withConnectionProvider() {\n        throw new Error('this query cannot have a connection provider');\n    }\n    withPlugin(plugin) {\n        return new NoopQueryExecutor([...this.plugins, plugin]);\n    }\n    withPlugins(plugins) {\n        return new NoopQueryExecutor([...this.plugins, ...plugins]);\n    }\n    withPluginAtFront(plugin) {\n        return new NoopQueryExecutor([plugin, ...this.plugins]);\n    }\n    withoutPlugins() {\n        return new NoopQueryExecutor([]);\n    }\n}\nexport const NOOP_QUERY_EXECUTOR = new NoopQueryExecutor();\n","/// <reference types=\"./parse-utils.d.ts\" />\nimport { JoinNode } from '../operation-node/join-node.js';\nimport { OverNode } from '../operation-node/over-node.js';\nimport { SelectQueryNode } from '../operation-node/select-query-node.js';\nimport { JoinBuilder } from '../query-builder/join-builder.js';\nimport { OverBuilder } from '../query-builder/over-builder.js';\nimport { createSelectQueryBuilder as newSelectQueryBuilder, } from '../query-builder/select-query-builder.js';\nimport { QueryCreator } from '../query-creator.js';\nimport { NOOP_QUERY_EXECUTOR } from '../query-executor/noop-query-executor.js';\nimport { createQueryId } from '../util/query-id.js';\nimport { parseTableExpression, parseTableExpressionOrList, } from './table-parser.js';\nexport function createSelectQueryBuilder() {\n    return newSelectQueryBuilder({\n        queryId: createQueryId(),\n        executor: NOOP_QUERY_EXECUTOR,\n        queryNode: SelectQueryNode.createFrom(parseTableExpressionOrList([])),\n    });\n}\nexport function createQueryCreator() {\n    return new QueryCreator({\n        executor: NOOP_QUERY_EXECUTOR,\n    });\n}\nexport function createJoinBuilder(joinType, table) {\n    return new JoinBuilder({\n        joinNode: JoinNode.create(joinType, parseTableExpression(table)),\n    });\n}\nexport function createOverBuilder() {\n    return new OverBuilder({\n        overNode: OverNode.create(),\n    });\n}\n","/// <reference types=\"./join-parser.d.ts\" />\nimport { JoinNode } from '../operation-node/join-node.js';\nimport { parseReferentialBinaryOperation } from './binary-operation-parser.js';\nimport { createJoinBuilder } from './parse-utils.js';\nimport { parseTableExpression, } from './table-parser.js';\nexport function parseJoin(joinType, args) {\n    if (args.length === 3) {\n        return parseSingleOnJoin(joinType, args[0], args[1], args[2]);\n    }\n    else if (args.length === 2) {\n        return parseCallbackJoin(joinType, args[0], args[1]);\n    }\n    else if (args.length === 1) {\n        return parseOnlessJoin(joinType, args[0]);\n    }\n    else {\n        throw new Error('not implemented');\n    }\n}\nfunction parseCallbackJoin(joinType, from, callback) {\n    return callback(createJoinBuilder(joinType, from)).toOperationNode();\n}\nfunction parseSingleOnJoin(joinType, from, lhsColumn, rhsColumn) {\n    return JoinNode.createWithOn(joinType, parseTableExpression(from), parseReferentialBinaryOperation(lhsColumn, '=', rhsColumn));\n}\nfunction parseOnlessJoin(joinType, from) {\n    return JoinNode.create(joinType, parseTableExpression(from));\n}\n","/// <reference types=\"./offset-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const OffsetNode = freeze({\n    is(node) {\n        return node.kind === 'OffsetNode';\n    },\n    create(offset) {\n        return freeze({\n            kind: 'OffsetNode',\n            offset,\n        });\n    },\n});\n","/// <reference types=\"./group-by-item-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const GroupByItemNode = freeze({\n    is(node) {\n        return node.kind === 'GroupByItemNode';\n    },\n    create(groupBy) {\n        return freeze({\n            kind: 'GroupByItemNode',\n            groupBy,\n        });\n    },\n});\n","/// <reference types=\"./group-by-parser.d.ts\" />\nimport { GroupByItemNode } from '../operation-node/group-by-item-node.js';\nimport { expressionBuilder, } from '../expression/expression-builder.js';\nimport { isFunction } from '../util/object-utils.js';\nimport { parseReferenceExpressionOrList, } from './reference-parser.js';\nexport function parseGroupBy(groupBy) {\n    groupBy = isFunction(groupBy) ? groupBy(expressionBuilder()) : groupBy;\n    return parseReferenceExpressionOrList(groupBy).map(GroupByItemNode.create);\n}\n","/// <reference types=\"./set-operation-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const SetOperationNode = freeze({\n    is(node) {\n        return node.kind === 'SetOperationNode';\n    },\n    create(operator, expression, all) {\n        return freeze({\n            kind: 'SetOperationNode',\n            operator,\n            expression,\n            all,\n        });\n    },\n});\n","/// <reference types=\"./set-operation-parser.d.ts\" />\nimport { createExpressionBuilder, } from '../expression/expression-builder.js';\nimport { SetOperationNode, } from '../operation-node/set-operation-node.js';\nimport { isFunction, isReadonlyArray } from '../util/object-utils.js';\nimport { parseExpression } from './expression-parser.js';\nexport function parseSetOperations(operator, expression, all) {\n    if (isFunction(expression)) {\n        expression = expression(createExpressionBuilder());\n    }\n    if (!isReadonlyArray(expression)) {\n        expression = [expression];\n    }\n    return expression.map((expr) => SetOperationNode.create(operator, parseExpression(expr), all));\n}\n","/// <reference types=\"./expression-wrapper.d.ts\" />\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { AndNode } from '../operation-node/and-node.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { isOperationNodeSource } from '../operation-node/operation-node-source.js';\nimport { OrNode } from '../operation-node/or-node.js';\nimport { ParensNode } from '../operation-node/parens-node.js';\nimport { parseValueBinaryOperationOrExpression, } from '../parser/binary-operation-parser.js';\nexport class ExpressionWrapper {\n    #node;\n    constructor(node) {\n        this.#node = node;\n    }\n    /** @private */\n    get expressionType() {\n        return undefined;\n    }\n    as(alias) {\n        return new AliasedExpressionWrapper(this, alias);\n    }\n    or(...args) {\n        return new OrWrapper(OrNode.create(this.#node, parseValueBinaryOperationOrExpression(args)));\n    }\n    and(...args) {\n        return new AndWrapper(AndNode.create(this.#node, parseValueBinaryOperationOrExpression(args)));\n    }\n    /**\n     * Change the output type of the expression.\n     *\n     * This method call doesn't change the SQL in any way. This methods simply\n     * returns a copy of this `ExpressionWrapper` with a new output type.\n     */\n    $castTo() {\n        return new ExpressionWrapper(this.#node);\n    }\n    /**\n     * Omit null from the expression's type.\n     *\n     * This function can be useful in cases where you know an expression can't be\n     * null, but Kysely is unable to infer it.\n     *\n     * This method call doesn't change the SQL in any way. This methods simply\n     * returns a copy of `this` with a new output type.\n     */\n    $notNull() {\n        return new ExpressionWrapper(this.#node);\n    }\n    toOperationNode() {\n        return this.#node;\n    }\n}\nexport class AliasedExpressionWrapper {\n    #expr;\n    #alias;\n    constructor(expr, alias) {\n        this.#expr = expr;\n        this.#alias = alias;\n    }\n    /** @private */\n    get expression() {\n        return this.#expr;\n    }\n    /** @private */\n    get alias() {\n        return this.#alias;\n    }\n    toOperationNode() {\n        return AliasNode.create(this.#expr.toOperationNode(), isOperationNodeSource(this.#alias)\n            ? this.#alias.toOperationNode()\n            : IdentifierNode.create(this.#alias));\n    }\n}\nexport class OrWrapper {\n    #node;\n    constructor(node) {\n        this.#node = node;\n    }\n    /** @private */\n    get expressionType() {\n        return undefined;\n    }\n    as(alias) {\n        return new AliasedExpressionWrapper(this, alias);\n    }\n    or(...args) {\n        return new OrWrapper(OrNode.create(this.#node, parseValueBinaryOperationOrExpression(args)));\n    }\n    /**\n     * Change the output type of the expression.\n     *\n     * This method call doesn't change the SQL in any way. This methods simply\n     * returns a copy of this `OrWrapper` with a new output type.\n     */\n    $castTo() {\n        return new OrWrapper(this.#node);\n    }\n    toOperationNode() {\n        return ParensNode.create(this.#node);\n    }\n}\nexport class AndWrapper {\n    #node;\n    constructor(node) {\n        this.#node = node;\n    }\n    /** @private */\n    get expressionType() {\n        return undefined;\n    }\n    as(alias) {\n        return new AliasedExpressionWrapper(this, alias);\n    }\n    and(...args) {\n        return new AndWrapper(AndNode.create(this.#node, parseValueBinaryOperationOrExpression(args)));\n    }\n    /**\n     * Change the output type of the expression.\n     *\n     * This method call doesn't change the SQL in any way. This methods simply\n     * returns a copy of this `AndWrapper` with a new output type.\n     */\n    $castTo() {\n        return new AndWrapper(this.#node);\n    }\n    toOperationNode() {\n        return ParensNode.create(this.#node);\n    }\n}\n","/// <reference types=\"./fetch-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { ValueNode } from './value-node.js';\n/**\n * @internal\n */\nexport const FetchNode = freeze({\n    is(node) {\n        return node.kind === 'FetchNode';\n    },\n    create(rowCount, modifier) {\n        return {\n            kind: 'FetchNode',\n            rowCount: ValueNode.create(rowCount),\n            modifier,\n        };\n    },\n});\n","/// <reference types=\"./fetch-parser.d.ts\" />\nimport { FetchNode } from '../operation-node/fetch-node.js';\nimport { isBigInt, isNumber } from '../util/object-utils.js';\nexport function parseFetch(rowCount, modifier) {\n    if (!isNumber(rowCount) && !isBigInt(rowCount)) {\n        throw new Error(`Invalid fetch row count: ${rowCount}`);\n    }\n    if (!isFetchModifier(modifier)) {\n        throw new Error(`Invalid fetch modifier: ${modifier}`);\n    }\n    return FetchNode.create(rowCount, modifier);\n}\nfunction isFetchModifier(value) {\n    return value === 'only' || value === 'with ties';\n}\n","/// <reference types=\"./select-query-builder.d.ts\" />\nvar _a;\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { SelectModifierNode } from '../operation-node/select-modifier-node.js';\nimport { parseJoin, } from '../parser/join-parser.js';\nimport { parseTable } from '../parser/table-parser.js';\nimport { parseSelectArg, parseSelectAll, } from '../parser/select-parser.js';\nimport { parseReferenceExpressionOrList, } from '../parser/reference-parser.js';\nimport { SelectQueryNode } from '../operation-node/select-query-node.js';\nimport { QueryNode } from '../operation-node/query-node.js';\nimport { parseOrderBy, } from '../parser/order-by-parser.js';\nimport { LimitNode } from '../operation-node/limit-node.js';\nimport { OffsetNode } from '../operation-node/offset-node.js';\nimport { asArray, freeze } from '../util/object-utils.js';\nimport { parseGroupBy } from '../parser/group-by-parser.js';\nimport { isNoResultErrorConstructor, NoResultError } from './no-result-error.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { parseSetOperations, } from '../parser/set-operation-parser.js';\nimport { parseValueBinaryOperationOrExpression, parseReferentialBinaryOperation, } from '../parser/binary-operation-parser.js';\nimport { ExpressionWrapper } from '../expression/expression-wrapper.js';\nimport { parseValueExpression, } from '../parser/value-parser.js';\nimport { parseFetch } from '../parser/fetch-parser.js';\nimport { parseTop } from '../parser/top-parser.js';\nclass SelectQueryBuilderImpl {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    get expressionType() {\n        return undefined;\n    }\n    get isSelectQueryBuilder() {\n        return true;\n    }\n    where(...args) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithWhere(this.#props.queryNode, parseValueBinaryOperationOrExpression(args)),\n        });\n    }\n    whereRef(lhs, op, rhs) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithWhere(this.#props.queryNode, parseReferentialBinaryOperation(lhs, op, rhs)),\n        });\n    }\n    having(...args) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithHaving(this.#props.queryNode, parseValueBinaryOperationOrExpression(args)),\n        });\n    }\n    havingRef(lhs, op, rhs) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithHaving(this.#props.queryNode, parseReferentialBinaryOperation(lhs, op, rhs)),\n        });\n    }\n    select(selection) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithSelections(this.#props.queryNode, parseSelectArg(selection)),\n        });\n    }\n    distinctOn(selection) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithDistinctOn(this.#props.queryNode, parseReferenceExpressionOrList(selection)),\n        });\n    }\n    modifyFront(modifier) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithFrontModifier(this.#props.queryNode, SelectModifierNode.createWithExpression(modifier.toOperationNode())),\n        });\n    }\n    modifyEnd(modifier) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.createWithExpression(modifier.toOperationNode())),\n        });\n    }\n    distinct() {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithFrontModifier(this.#props.queryNode, SelectModifierNode.create('Distinct')),\n        });\n    }\n    forUpdate(of) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('ForUpdate', of ? asArray(of).map(parseTable) : undefined)),\n        });\n    }\n    forShare(of) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('ForShare', of ? asArray(of).map(parseTable) : undefined)),\n        });\n    }\n    forKeyShare(of) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('ForKeyShare', of ? asArray(of).map(parseTable) : undefined)),\n        });\n    }\n    forNoKeyUpdate(of) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('ForNoKeyUpdate', of ? asArray(of).map(parseTable) : undefined)),\n        });\n    }\n    skipLocked() {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('SkipLocked')),\n        });\n    }\n    noWait() {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('NoWait')),\n        });\n    }\n    selectAll(table) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithSelections(this.#props.queryNode, parseSelectAll(table)),\n        });\n    }\n    innerJoin(...args) {\n        return this.#join('InnerJoin', args);\n    }\n    leftJoin(...args) {\n        return this.#join('LeftJoin', args);\n    }\n    rightJoin(...args) {\n        return this.#join('RightJoin', args);\n    }\n    fullJoin(...args) {\n        return this.#join('FullJoin', args);\n    }\n    crossJoin(...args) {\n        return this.#join('CrossJoin', args);\n    }\n    innerJoinLateral(...args) {\n        return this.#join('LateralInnerJoin', args);\n    }\n    leftJoinLateral(...args) {\n        return this.#join('LateralLeftJoin', args);\n    }\n    crossJoinLateral(...args) {\n        return this.#join('LateralCrossJoin', args);\n    }\n    crossApply(...args) {\n        return this.#join('CrossApply', args);\n    }\n    outerApply(...args) {\n        return this.#join('OuterApply', args);\n    }\n    #join(joinType, args) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithJoin(this.#props.queryNode, parseJoin(joinType, args)),\n        });\n    }\n    orderBy(...args) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithOrderByItems(this.#props.queryNode, parseOrderBy(args)),\n        });\n    }\n    groupBy(groupBy) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithGroupByItems(this.#props.queryNode, parseGroupBy(groupBy)),\n        });\n    }\n    limit(limit) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithLimit(this.#props.queryNode, LimitNode.create(parseValueExpression(limit))),\n        });\n    }\n    offset(offset) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithOffset(this.#props.queryNode, OffsetNode.create(parseValueExpression(offset))),\n        });\n    }\n    fetch(rowCount, modifier = 'only') {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithFetch(this.#props.queryNode, parseFetch(rowCount, modifier)),\n        });\n    }\n    top(expression, modifiers) {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithTop(this.#props.queryNode, parseTop(expression, modifiers)),\n        });\n    }\n    union(expression) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('union', expression, false)),\n        });\n    }\n    unionAll(expression) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('union', expression, true)),\n        });\n    }\n    intersect(expression) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('intersect', expression, false)),\n        });\n    }\n    intersectAll(expression) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('intersect', expression, true)),\n        });\n    }\n    except(expression) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('except', expression, false)),\n        });\n    }\n    exceptAll(expression) {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('except', expression, true)),\n        });\n    }\n    as(alias) {\n        return new AliasedSelectQueryBuilderImpl(this, alias);\n    }\n    clearSelect() {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithoutSelections(this.#props.queryNode),\n        });\n    }\n    clearWhere() {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithoutWhere(this.#props.queryNode),\n        });\n    }\n    clearLimit() {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithoutLimit(this.#props.queryNode),\n        });\n    }\n    clearOffset() {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithoutOffset(this.#props.queryNode),\n        });\n    }\n    clearOrderBy() {\n        return new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithoutOrderBy(this.#props.queryNode),\n        });\n    }\n    clearGroupBy() {\n        return new _a({\n            ...this.#props,\n            queryNode: SelectQueryNode.cloneWithoutGroupBy(this.#props.queryNode),\n        });\n    }\n    $call(func) {\n        return func(this);\n    }\n    $if(condition, func) {\n        if (condition) {\n            return func(this);\n        }\n        return new _a({\n            ...this.#props,\n        });\n    }\n    $castTo() {\n        return new _a(this.#props);\n    }\n    $narrowType() {\n        return new _a(this.#props);\n    }\n    $assertType() {\n        return new _a(this.#props);\n    }\n    $asTuple() {\n        return new ExpressionWrapper(this.toOperationNode());\n    }\n    $asScalar() {\n        return new ExpressionWrapper(this.toOperationNode());\n    }\n    withPlugin(plugin) {\n        return new _a({\n            ...this.#props,\n            executor: this.#props.executor.withPlugin(plugin),\n        });\n    }\n    toOperationNode() {\n        return this.#props.executor.transformQuery(this.#props.queryNode, this.#props.queryId);\n    }\n    compile() {\n        return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);\n    }\n    async execute(options) {\n        const compiledQuery = this.compile();\n        const result = await this.#props.executor.executeQuery(compiledQuery, options);\n        return result.rows;\n    }\n    async executeTakeFirst(options) {\n        const [result] = await this.execute(options);\n        return result;\n    }\n    async executeTakeFirstOrThrow(errorConstructorOrOptions) {\n        if (typeof errorConstructorOrOptions === 'function') {\n            errorConstructorOrOptions = {\n                errorConstructor: errorConstructorOrOptions,\n            };\n        }\n        const result = await this.executeTakeFirst(errorConstructorOrOptions);\n        if (result === undefined) {\n            const errorConstructor = errorConstructorOrOptions?.errorConstructor ?? NoResultError;\n            const error = isNoResultErrorConstructor(errorConstructor)\n                ? new errorConstructor(this.toOperationNode())\n                : errorConstructor(this.toOperationNode());\n            throw error;\n        }\n        return result;\n    }\n    async *stream(chunkSizeOrOptions) {\n        if (typeof chunkSizeOrOptions !== 'object') {\n            chunkSizeOrOptions = {\n                chunkSize: chunkSizeOrOptions,\n            };\n        }\n        const compiledQuery = this.compile();\n        const stream = this.#props.executor.stream(compiledQuery, chunkSizeOrOptions.chunkSize ?? 100, chunkSizeOrOptions);\n        for await (const item of stream) {\n            yield* item.rows;\n        }\n    }\n    async explain(format, options) {\n        const builder = new _a({\n            ...this.#props,\n            queryNode: QueryNode.cloneWithExplain(this.#props.queryNode, format, options),\n        });\n        return await builder.execute();\n    }\n}\n_a = SelectQueryBuilderImpl;\nexport function createSelectQueryBuilder(props) {\n    return new SelectQueryBuilderImpl(props);\n}\n/**\n * {@link SelectQueryBuilder} with an alias. The result of calling {@link SelectQueryBuilder.as}.\n */\nclass AliasedSelectQueryBuilderImpl {\n    #queryBuilder;\n    #alias;\n    constructor(queryBuilder, alias) {\n        this.#queryBuilder = queryBuilder;\n        this.#alias = alias;\n    }\n    get expression() {\n        return this.#queryBuilder;\n    }\n    get alias() {\n        return this.#alias;\n    }\n    get isAliasedSelectQueryBuilder() {\n        return true;\n    }\n    toOperationNode() {\n        return AliasNode.create(this.#queryBuilder.toOperationNode(), IdentifierNode.create(this.#alias));\n    }\n}\n","/// <reference types=\"./aggregate-function-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { WhereNode } from './where-node.js';\nimport { OrderByNode } from './order-by-node.js';\n/**\n * @internal\n */\nexport const AggregateFunctionNode = freeze({\n    is(node) {\n        return node.kind === 'AggregateFunctionNode';\n    },\n    create(aggregateFunction, aggregated = []) {\n        return freeze({\n            kind: 'AggregateFunctionNode',\n            func: aggregateFunction,\n            aggregated,\n        });\n    },\n    cloneWithDistinct(aggregateFunctionNode) {\n        return freeze({\n            ...aggregateFunctionNode,\n            distinct: true,\n        });\n    },\n    cloneWithOrderBy(aggregateFunctionNode, orderItems, withinGroup = false) {\n        const prop = withinGroup ? 'withinGroup' : 'orderBy';\n        return freeze({\n            ...aggregateFunctionNode,\n            [prop]: aggregateFunctionNode[prop]\n                ? OrderByNode.cloneWithItems(aggregateFunctionNode[prop], orderItems)\n                : OrderByNode.create(orderItems),\n        });\n    },\n    cloneWithFilter(aggregateFunctionNode, filter) {\n        return freeze({\n            ...aggregateFunctionNode,\n            filter: aggregateFunctionNode.filter\n                ? WhereNode.cloneWithOperation(aggregateFunctionNode.filter, 'And', filter)\n                : WhereNode.create(filter),\n        });\n    },\n    cloneWithOrFilter(aggregateFunctionNode, filter) {\n        return freeze({\n            ...aggregateFunctionNode,\n            filter: aggregateFunctionNode.filter\n                ? WhereNode.cloneWithOperation(aggregateFunctionNode.filter, 'Or', filter)\n                : WhereNode.create(filter),\n        });\n    },\n    cloneWithOver(aggregateFunctionNode, over) {\n        return freeze({\n            ...aggregateFunctionNode,\n            over,\n        });\n    },\n});\n","/// <reference types=\"./function-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const FunctionNode = freeze({\n    is(node) {\n        return node.kind === 'FunctionNode';\n    },\n    create(func, args) {\n        return freeze({\n            kind: 'FunctionNode',\n            func,\n            arguments: args,\n        });\n    },\n});\n","/// <reference types=\"./aggregate-function-builder.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { AggregateFunctionNode } from '../operation-node/aggregate-function-node.js';\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { createOverBuilder } from '../parser/parse-utils.js';\nimport { parseReferentialBinaryOperation, parseValueBinaryOperationOrExpression, } from '../parser/binary-operation-parser.js';\nimport { parseOrderBy, } from '../parser/order-by-parser.js';\nimport { QueryNode } from '../operation-node/query-node.js';\nexport class AggregateFunctionBuilder {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    /** @private */\n    get expressionType() {\n        return undefined;\n    }\n    /**\n     * Returns an aliased version of the function.\n     *\n     * In addition to slapping `as \"the_alias\"` to the end of the SQL,\n     * this method also provides strict typing:\n     *\n     * ```ts\n     * const result = await db\n     *   .selectFrom('person')\n     *   .select(\n     *     (eb) => eb.fn.count<number>('id').as('person_count')\n     *   )\n     *   .executeTakeFirstOrThrow()\n     *\n     * // `person_count: number` field exists in the result type.\n     * console.log(result.person_count)\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select count(\"id\") as \"person_count\"\n     * from \"person\"\n     * ```\n     */\n    as(alias) {\n        return new AliasedAggregateFunctionBuilder(this, alias);\n    }\n    /**\n     * Adds a `distinct` clause inside the function.\n     *\n     * ### Examples\n     *\n     * ```ts\n     * const result = await db\n     *   .selectFrom('person')\n     *   .select((eb) =>\n     *     eb.fn.count<number>('first_name').distinct().as('first_name_count')\n     *   )\n     *   .executeTakeFirstOrThrow()\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select count(distinct \"first_name\") as \"first_name_count\"\n     * from \"person\"\n     * ```\n     */\n    distinct() {\n        return new AggregateFunctionBuilder({\n            ...this.#props,\n            aggregateFunctionNode: AggregateFunctionNode.cloneWithDistinct(this.#props.aggregateFunctionNode),\n        });\n    }\n    orderBy(...args) {\n        return new AggregateFunctionBuilder({\n            ...this.#props,\n            aggregateFunctionNode: QueryNode.cloneWithOrderByItems(this.#props.aggregateFunctionNode, parseOrderBy(args)),\n        });\n    }\n    clearOrderBy() {\n        return new AggregateFunctionBuilder({\n            ...this.#props,\n            aggregateFunctionNode: QueryNode.cloneWithoutOrderBy(this.#props.aggregateFunctionNode),\n        });\n    }\n    withinGroupOrderBy(...args) {\n        return new AggregateFunctionBuilder({\n            ...this.#props,\n            aggregateFunctionNode: AggregateFunctionNode.cloneWithOrderBy(this.#props.aggregateFunctionNode, parseOrderBy(args), true),\n        });\n    }\n    filterWhere(...args) {\n        return new AggregateFunctionBuilder({\n            ...this.#props,\n            aggregateFunctionNode: AggregateFunctionNode.cloneWithFilter(this.#props.aggregateFunctionNode, parseValueBinaryOperationOrExpression(args)),\n        });\n    }\n    /**\n     * Adds a `filter` clause with a nested `where` clause after the function, where\n     * both sides of the operator are references to columns.\n     *\n     * Similar to {@link WhereInterface}'s `whereRef` method.\n     *\n     * ### Examples\n     *\n     * Count people with same first and last names versus general public:\n     *\n     * ```ts\n     * const result = await db\n     *   .selectFrom('person')\n     *   .select((eb) => [\n     *     eb.fn\n     *       .count<number>('id')\n     *       .filterWhereRef('first_name', '=', 'last_name')\n     *       .as('repeat_name_count'),\n     *     eb.fn.count<number>('id').as('total_count'),\n     *   ])\n     *   .executeTakeFirstOrThrow()\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select\n     *   count(\"id\") filter(where \"first_name\" = \"last_name\") as \"repeat_name_count\",\n     *   count(\"id\") as \"total_count\"\n     * from \"person\"\n     * ```\n     */\n    filterWhereRef(lhs, op, rhs) {\n        return new AggregateFunctionBuilder({\n            ...this.#props,\n            aggregateFunctionNode: AggregateFunctionNode.cloneWithFilter(this.#props.aggregateFunctionNode, parseReferentialBinaryOperation(lhs, op, rhs)),\n        });\n    }\n    /**\n     * Adds an `over` clause (window functions) after the function.\n     *\n     * ### Examples\n     *\n     * ```ts\n     * const result = await db\n     *   .selectFrom('person')\n     *   .select(\n     *     (eb) => eb.fn.avg<number>('age').over().as('average_age')\n     *   )\n     *   .execute()\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select avg(\"age\") over() as \"average_age\"\n     * from \"person\"\n     * ```\n     *\n     * Also supports passing a callback that returns an over builder,\n     * allowing to add partition by and sort by clauses inside over.\n     *\n     * ```ts\n     * const result = await db\n     *   .selectFrom('person')\n     *   .select(\n     *     (eb) => eb.fn.avg<number>('age').over(\n     *       ob => ob.partitionBy('last_name').orderBy('first_name', 'asc')\n     *     ).as('average_age')\n     *   )\n     *   .execute()\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select avg(\"age\") over(partition by \"last_name\" order by \"first_name\" asc) as \"average_age\"\n     * from \"person\"\n     * ```\n     */\n    over(over) {\n        const builder = createOverBuilder();\n        return new AggregateFunctionBuilder({\n            ...this.#props,\n            aggregateFunctionNode: AggregateFunctionNode.cloneWithOver(this.#props.aggregateFunctionNode, (over ? over(builder) : builder).toOperationNode()),\n        });\n    }\n    /**\n     * Simply calls the provided function passing `this` as the only argument. `$call` returns\n     * what the provided function returns.\n     */\n    $call(func) {\n        return func(this);\n    }\n    /**\n     * Casts the expression to the given type.\n     *\n     * This method call doesn't change the SQL in any way. This methods simply\n     * returns a copy of this `AggregateFunctionBuilder` with a new output type.\n     */\n    $castTo() {\n        return new AggregateFunctionBuilder(this.#props);\n    }\n    /**\n     * Omit null from the expression's type.\n     *\n     * This function can be useful in cases where you know an expression can't be\n     * null, but Kysely is unable to infer it.\n     *\n     * This method call doesn't change the SQL in any way. This methods simply\n     * returns a copy of `this` with a new output type.\n     */\n    $notNull() {\n        return new AggregateFunctionBuilder(this.#props);\n    }\n    toOperationNode() {\n        return this.#props.aggregateFunctionNode;\n    }\n}\n/**\n * {@link AggregateFunctionBuilder} with an alias. The result of calling {@link AggregateFunctionBuilder.as}.\n */\nexport class AliasedAggregateFunctionBuilder {\n    #aggregateFunctionBuilder;\n    #alias;\n    constructor(aggregateFunctionBuilder, alias) {\n        this.#aggregateFunctionBuilder = aggregateFunctionBuilder;\n        this.#alias = alias;\n    }\n    /** @private */\n    get expression() {\n        return this.#aggregateFunctionBuilder;\n    }\n    /** @private */\n    get alias() {\n        return this.#alias;\n    }\n    toOperationNode() {\n        return AliasNode.create(this.#aggregateFunctionBuilder.toOperationNode(), IdentifierNode.create(this.#alias));\n    }\n}\n","/// <reference types=\"./function-module.d.ts\" />\nimport { ExpressionWrapper } from '../expression/expression-wrapper.js';\nimport { AggregateFunctionNode } from '../operation-node/aggregate-function-node.js';\nimport { FunctionNode } from '../operation-node/function-node.js';\nimport { parseReferenceExpressionOrList, } from '../parser/reference-parser.js';\nimport { parseSelectAll } from '../parser/select-parser.js';\nimport { AggregateFunctionBuilder } from './aggregate-function-builder.js';\nimport { isString } from '../util/object-utils.js';\nimport { parseTable } from '../parser/table-parser.js';\nexport function createFunctionModule() {\n    const fn = (name, args) => {\n        return new ExpressionWrapper(FunctionNode.create(name, parseReferenceExpressionOrList(args ?? [])));\n    };\n    const agg = (name, args) => {\n        return new AggregateFunctionBuilder({\n            aggregateFunctionNode: AggregateFunctionNode.create(name, args ? parseReferenceExpressionOrList(args) : undefined),\n        });\n    };\n    return Object.assign(fn, {\n        agg,\n        avg(column) {\n            return agg('avg', [column]);\n        },\n        coalesce(...values) {\n            return fn('coalesce', values);\n        },\n        count(column) {\n            return agg('count', [column]);\n        },\n        countAll(table) {\n            return new AggregateFunctionBuilder({\n                aggregateFunctionNode: AggregateFunctionNode.create('count', parseSelectAll(table)),\n            });\n        },\n        max(column) {\n            return agg('max', [column]);\n        },\n        min(column) {\n            return agg('min', [column]);\n        },\n        sum(column) {\n            return agg('sum', [column]);\n        },\n        any(column) {\n            return fn('any', [column]);\n        },\n        jsonAgg(table) {\n            return new AggregateFunctionBuilder({\n                aggregateFunctionNode: AggregateFunctionNode.create('json_agg', [\n                    isString(table) ? parseTable(table) : table.toOperationNode(),\n                ]),\n            });\n        },\n        toJson(table) {\n            return new ExpressionWrapper(FunctionNode.create('to_json', [\n                isString(table) ? parseTable(table) : table.toOperationNode(),\n            ]));\n        },\n    });\n}\n","/// <reference types=\"./unary-operation-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const UnaryOperationNode = freeze({\n    is(node) {\n        return node.kind === 'UnaryOperationNode';\n    },\n    create(operator, operand) {\n        return freeze({\n            kind: 'UnaryOperationNode',\n            operator,\n            operand,\n        });\n    },\n});\n","/// <reference types=\"./unary-operation-parser.d.ts\" />\nimport { isUnaryOperator, OperatorNode, } from '../operation-node/operator-node.js';\nimport { UnaryOperationNode } from '../operation-node/unary-operation-node.js';\nimport { parseReferenceExpression, } from './reference-parser.js';\nexport function parseExists(operand) {\n    return parseUnaryOperation('exists', operand);\n}\nexport function parseNotExists(operand) {\n    return parseUnaryOperation('not exists', operand);\n}\nexport function parseUnaryOperation(operator, operand) {\n    if (isUnaryOperator(operator)) {\n        return UnaryOperationNode.create(OperatorNode.create(operator), parseReferenceExpression(operand));\n    }\n    throw new Error(`invalid unary operator ${JSON.stringify(operator)}`);\n}\n","/// <reference types=\"./case-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nimport { WhenNode } from './when-node.js';\n/**\n * @internal\n */\nexport const CaseNode = freeze({\n    is(node) {\n        return node.kind === 'CaseNode';\n    },\n    create(value) {\n        return freeze({\n            kind: 'CaseNode',\n            value,\n        });\n    },\n    cloneWithWhen(caseNode, when) {\n        return freeze({\n            ...caseNode,\n            when: freeze(caseNode.when ? [...caseNode.when, when] : [when]),\n        });\n    },\n    cloneWithThen(caseNode, then) {\n        return freeze({\n            ...caseNode,\n            when: caseNode.when\n                ? freeze([\n                    ...caseNode.when.slice(0, -1),\n                    WhenNode.cloneWithResult(caseNode.when[caseNode.when.length - 1], then),\n                ])\n                : undefined,\n        });\n    },\n    cloneWith(caseNode, props) {\n        return freeze({\n            ...caseNode,\n            ...props,\n        });\n    },\n});\n","/// <reference types=\"./case-builder.d.ts\" />\nimport { ExpressionWrapper } from '../expression/expression-wrapper.js';\nimport { freeze } from '../util/object-utils.js';\nimport { parseReferenceExpression, } from '../parser/reference-parser.js';\nimport { CaseNode } from '../operation-node/case-node.js';\nimport { WhenNode } from '../operation-node/when-node.js';\nimport { parseReferentialBinaryOperation, parseValueBinaryOperationOrExpression, } from '../parser/binary-operation-parser.js';\nimport { isSafeImmediateValue, parseSafeImmediateValue, parseValueExpression, } from '../parser/value-parser.js';\nexport class CaseBuilder {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    when(...args) {\n        return new CaseThenBuilder({\n            ...this.#props,\n            node: CaseNode.cloneWithWhen(this.#props.node, WhenNode.create(parseValueBinaryOperationOrExpression(args))),\n        });\n    }\n    whenRef(lhs, op, rhs) {\n        return new CaseThenBuilder({\n            ...this.#props,\n            node: CaseNode.cloneWithWhen(this.#props.node, WhenNode.create(parseReferentialBinaryOperation(lhs, op, rhs))),\n        });\n    }\n}\nexport class CaseThenBuilder {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    then(valueExpression) {\n        return new CaseWhenBuilder({\n            ...this.#props,\n            node: CaseNode.cloneWithThen(this.#props.node, isSafeImmediateValue(valueExpression)\n                ? parseSafeImmediateValue(valueExpression)\n                : parseValueExpression(valueExpression)),\n        });\n    }\n    /**\n     * Adds a `then` clause to the `case` statement where the value is a reference to a column.\n     *\n     * See {@link then} for value-first variant.\n     *\n     * A `thenRef` call can be followed by {@link Whenable.when}, {@link Whenable.whenRef},\n     * {@link CaseWhenBuilder.else}, {@link CaseWhenBuilder.elseRef},\n     * {@link CaseWhenBuilder.end} or {@link CaseWhenBuilder.endCase} call.\n     */\n    thenRef(expression) {\n        return new CaseWhenBuilder({\n            ...this.#props,\n            node: CaseNode.cloneWithThen(this.#props.node, parseReferenceExpression(expression)),\n        });\n    }\n}\nexport class CaseWhenBuilder {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    when(...args) {\n        return new CaseThenBuilder({\n            ...this.#props,\n            node: CaseNode.cloneWithWhen(this.#props.node, WhenNode.create(parseValueBinaryOperationOrExpression(args))),\n        });\n    }\n    whenRef(lhs, op, rhs) {\n        return new CaseThenBuilder({\n            ...this.#props,\n            node: CaseNode.cloneWithWhen(this.#props.node, WhenNode.create(parseReferentialBinaryOperation(lhs, op, rhs))),\n        });\n    }\n    else(valueExpression) {\n        return new CaseEndBuilder({\n            ...this.#props,\n            node: CaseNode.cloneWith(this.#props.node, {\n                else: isSafeImmediateValue(valueExpression)\n                    ? parseSafeImmediateValue(valueExpression)\n                    : parseValueExpression(valueExpression),\n            }),\n        });\n    }\n    /**\n     * Adds an `else` clause to the `case` statement where the value is a reference to a column.\n     *\n     * See {@link else} for value-first variant.\n     *\n     * An `elseRef` call must be followed by an {@link Endable.end} or {@link Endable.endCase} call.\n     */\n    elseRef(expression) {\n        return new CaseEndBuilder({\n            ...this.#props,\n            node: CaseNode.cloneWith(this.#props.node, {\n                else: parseReferenceExpression(expression),\n            }),\n        });\n    }\n    end() {\n        return new ExpressionWrapper(CaseNode.cloneWith(this.#props.node, { isStatement: false }));\n    }\n    endCase() {\n        return new ExpressionWrapper(CaseNode.cloneWith(this.#props.node, { isStatement: true }));\n    }\n}\nexport class CaseEndBuilder {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    end() {\n        return new ExpressionWrapper(CaseNode.cloneWith(this.#props.node, { isStatement: false }));\n    }\n    endCase() {\n        return new ExpressionWrapper(CaseNode.cloneWith(this.#props.node, { isStatement: true }));\n    }\n}\n","/// <reference types=\"./json-path-leg-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const JSONPathLegNode = freeze({\n    is(node) {\n        return node.kind === 'JSONPathLegNode';\n    },\n    create(type, value) {\n        return freeze({\n            kind: 'JSONPathLegNode',\n            type,\n            value,\n        });\n    },\n});\n","/// <reference types=\"./json-path-builder.d.ts\" />\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { JSONOperatorChainNode } from '../operation-node/json-operator-chain-node.js';\nimport { JSONPathLegNode, } from '../operation-node/json-path-leg-node.js';\nimport { JSONPathNode } from '../operation-node/json-path-node.js';\nimport { JSONReferenceNode } from '../operation-node/json-reference-node.js';\nimport { isOperationNodeSource } from '../operation-node/operation-node-source.js';\nimport { ValueNode } from '../operation-node/value-node.js';\nconst HASH_NEGATIVE_INDEX_REGEX = /^#-\\d+$/;\nexport class JSONPathBuilder {\n    #node;\n    constructor(node) {\n        this.#node = node;\n    }\n    /**\n     * Access an element of a JSON array in a specific location.\n     *\n     * Since there's no guarantee an element exists in the given array location, the\n     * resulting type is always nullable. If you're sure the element exists, you\n     * should use {@link SelectQueryBuilder.$assertType} to narrow the type safely.\n     *\n     * See also {@link key} to access properties of JSON objects.\n     *\n     * ### Examples\n     *\n     * ```ts\n     * await db.selectFrom('person')\n     *   .select(eb =>\n     *     eb.ref('nicknames', '->').at(0).as('primary_nickname')\n     *   )\n     *   .execute()\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select \"nicknames\"->0 as \"primary_nickname\" from \"person\"\n     *```\n     *\n     * Combined with {@link key}:\n     *\n     * ```ts\n     * db.selectFrom('person').select(eb =>\n     *   eb.ref('experience', '->').at(0).key('role').as('first_role')\n     * )\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select \"experience\"->0->'role' as \"first_role\" from \"person\"\n     * ```\n     *\n     * You can use `'last'` to access the last element of the array in MySQL:\n     *\n     * ```ts\n     * db.selectFrom('person').select(eb =>\n     *   eb.ref('nicknames', '->$').at('last').as('last_nickname')\n     * )\n     * ```\n     *\n     * The generated SQL (MySQL):\n     *\n     * ```sql\n     * select `nicknames`->'$[last]' as `last_nickname` from `person`\n     * ```\n     *\n     * Or `'#-1'` in SQLite:\n     *\n     * ```ts\n     * db.selectFrom('person').select(eb =>\n     *   eb.ref('nicknames', '->>$').at('#-1').as('last_nickname')\n     * )\n     * ```\n     *\n     * The generated SQL (SQLite):\n     *\n     * ```sql\n     * select \"nicknames\"->>'$[#-1]' as `last_nickname` from `person`\n     * ```\n     */\n    at(index) {\n        if ((typeof index !== 'number' && typeof index !== 'string') ||\n            (typeof index === 'number' && !Number.isInteger(index)) ||\n            (typeof index === 'string' &&\n                index !== 'last' &&\n                !HASH_NEGATIVE_INDEX_REGEX.test(index))) {\n            throw new Error(`Unexpected index value in .at(...): ${index}`);\n        }\n        return this.#createBuilderWithPathLeg('ArrayLocation', index);\n    }\n    /**\n     * Access a property of a JSON object.\n     *\n     * If a field is optional, the resulting type will be nullable.\n     *\n     * See also {@link at} to access elements of JSON arrays.\n     *\n     * ### Examples\n     *\n     * ```ts\n     * db.selectFrom('person').select(eb =>\n     *   eb.ref('address', '->').key('city').as('city')\n     * )\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select \"address\"->'city' as \"city\" from \"person\"\n     * ```\n     *\n     * Going deeper:\n     *\n     * ```ts\n     * db.selectFrom('person').select(eb =>\n     *   eb.ref('profile', '->$').key('website').key('url').as('website_url')\n     * )\n     * ```\n     *\n     * The generated SQL (MySQL):\n     *\n     * ```sql\n     * select `profile`->'$.website.url' as `website_url` from `person`\n     * ```\n     *\n     * Combined with {@link at}:\n     *\n     * ```ts\n     * db.selectFrom('person').select(eb =>\n     *   eb.ref('profile', '->').key('addresses').at(0).key('city').as('city')\n     * )\n     * ```\n     *\n     * The generated SQL (PostgreSQL):\n     *\n     * ```sql\n     * select \"profile\"->'addresses'->0->'city' as \"city\" from \"person\"\n     * ```\n     */\n    key(key) {\n        return this.#createBuilderWithPathLeg('Member', key);\n    }\n    #createBuilderWithPathLeg(legType, value) {\n        if (JSONReferenceNode.is(this.#node)) {\n            return new TraversedJSONPathBuilder(JSONReferenceNode.cloneWithTraversal(this.#node, JSONPathNode.is(this.#node.traversal)\n                ? JSONPathNode.cloneWithLeg(this.#node.traversal, JSONPathLegNode.create(legType, value))\n                : JSONOperatorChainNode.cloneWithValue(this.#node.traversal, ValueNode.createImmediate(value))));\n        }\n        return new TraversedJSONPathBuilder(JSONPathNode.cloneWithLeg(this.#node, JSONPathLegNode.create(legType, value)));\n    }\n}\nexport class TraversedJSONPathBuilder extends JSONPathBuilder {\n    #node;\n    constructor(node) {\n        super(node);\n        this.#node = node;\n    }\n    /** @private */\n    get expressionType() {\n        return undefined;\n    }\n    as(alias) {\n        return new AliasedJSONPathBuilder(this, alias);\n    }\n    /**\n     * Change the output type of the json path.\n     *\n     * This method call doesn't change the SQL in any way. This methods simply\n     * returns a copy of this `JSONPathBuilder` with a new output type.\n     */\n    $castTo() {\n        return new TraversedJSONPathBuilder(this.#node);\n    }\n    $notNull() {\n        return new TraversedJSONPathBuilder(this.#node);\n    }\n    toOperationNode() {\n        return this.#node;\n    }\n}\nexport class AliasedJSONPathBuilder {\n    #jsonPath;\n    #alias;\n    constructor(jsonPath, alias) {\n        this.#jsonPath = jsonPath;\n        this.#alias = alias;\n    }\n    /** @private */\n    get expression() {\n        return this.#jsonPath;\n    }\n    /** @private */\n    get alias() {\n        return this.#alias;\n    }\n    toOperationNode() {\n        return AliasNode.create(this.#jsonPath.toOperationNode(), isOperationNodeSource(this.#alias)\n            ? this.#alias.toOperationNode()\n            : IdentifierNode.create(this.#alias));\n    }\n}\n","/// <reference types=\"./tuple-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const TupleNode = freeze({\n    is(node) {\n        return node.kind === 'TupleNode';\n    },\n    create(values) {\n        return freeze({\n            kind: 'TupleNode',\n            values: freeze(values),\n        });\n    },\n});\n","/// <reference types=\"./data-type-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nconst SIMPLE_COLUMN_DATA_TYPES = freeze({\n    bigint: true,\n    bigserial: true,\n    binary: true,\n    blob: true,\n    boolean: true,\n    bytea: true,\n    char: true,\n    date: true,\n    datemultirange: true,\n    daterange: true,\n    datetime: true,\n    datetime2: true,\n    decimal: true,\n    'double precision': true,\n    float4: true,\n    float8: true,\n    int2: true,\n    int4: true,\n    int4multirange: true,\n    int4range: true,\n    int8: true,\n    int8multirange: true,\n    int8range: true,\n    integer: true,\n    json: true,\n    jsonb: true,\n    numeric: true,\n    nummultirange: true,\n    numrange: true,\n    real: true,\n    serial: true,\n    smallint: true,\n    text: true,\n    time: true,\n    timestamp: true,\n    timestamptz: true,\n    timetz: true,\n    tsmultirange: true,\n    tsrange: true,\n    tstzmultirange: true,\n    tstzrange: true,\n    uuid: true,\n    varbinary: true,\n    varchar: true,\n});\nconst COLUMN_DATA_TYPE_REGEX = freeze([\n    /^varchar\\(\\d+\\)$/,\n    /^char\\(\\d+\\)$/,\n    /^decimal\\(\\d+, \\d+\\)$/,\n    /^numeric\\(\\d+, \\d+\\)$/,\n    /^binary\\(\\d+\\)$/,\n    /^datetime\\(\\d+\\)$/,\n    /^time\\(\\d+\\)$/,\n    /^timetz\\(\\d+\\)$/,\n    /^timestamp\\(\\d+\\)$/,\n    /^timestamptz\\(\\d+\\)$/,\n    /^datetime2\\(\\d+\\)$/,\n    /^varbinary\\(\\d+\\)$/,\n]);\n/**\n * @internal\n */\nexport const DataTypeNode = freeze({\n    is(node) {\n        return node.kind === 'DataTypeNode';\n    },\n    create(dataType) {\n        return freeze({\n            kind: 'DataTypeNode',\n            dataType,\n        });\n    },\n});\nexport function isColumnDataType(dataType) {\n    return (SIMPLE_COLUMN_DATA_TYPES[dataType] ||\n        COLUMN_DATA_TYPE_REGEX.some((r) => r.test(dataType)));\n}\n","/// <reference types=\"./data-type-parser.d.ts\" />\nimport { DataTypeNode, isColumnDataType, } from '../operation-node/data-type-node.js';\nimport { isOperationNodeSource } from '../operation-node/operation-node-source.js';\nexport function parseDataTypeExpression(dataType) {\n    if (isOperationNodeSource(dataType)) {\n        return dataType.toOperationNode();\n    }\n    if (isColumnDataType(dataType)) {\n        return DataTypeNode.create(dataType);\n    }\n    throw new Error(`invalid column data type ${JSON.stringify(dataType)}`);\n}\n","/// <reference types=\"./cast-node.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\n/**\n * @internal\n */\nexport const CastNode = freeze({\n    is(node) {\n        return node.kind === 'CastNode';\n    },\n    create(expression, dataType) {\n        return freeze({\n            kind: 'CastNode',\n            expression,\n            dataType,\n        });\n    },\n});\n","/// <reference types=\"./expression-builder.d.ts\" />\nimport { createSelectQueryBuilder, } from '../query-builder/select-query-builder.js';\nimport { SelectQueryNode } from '../operation-node/select-query-node.js';\nimport { parseTableExpressionOrList, parseTable, } from '../parser/table-parser.js';\nimport { createQueryId } from '../util/query-id.js';\nimport { createFunctionModule, } from '../query-builder/function-module.js';\nimport { parseJSONReference, parseReferenceExpression, parseStringReference, } from '../parser/reference-parser.js';\nimport { parseFilterList, parseFilterObject, parseValueBinaryOperation, parseValueBinaryOperationOrExpression, } from '../parser/binary-operation-parser.js';\nimport { ParensNode } from '../operation-node/parens-node.js';\nimport { ExpressionWrapper } from './expression-wrapper.js';\nimport { OperatorNode, } from '../operation-node/operator-node.js';\nimport { parseUnaryOperation } from '../parser/unary-operation-parser.js';\nimport { parseSafeImmediateValue, parseValueExpression, } from '../parser/value-parser.js';\nimport { NOOP_QUERY_EXECUTOR } from '../query-executor/noop-query-executor.js';\nimport { CaseBuilder } from '../query-builder/case-builder.js';\nimport { CaseNode } from '../operation-node/case-node.js';\nimport { isReadonlyArray, isUndefined } from '../util/object-utils.js';\nimport { JSONPathBuilder } from '../query-builder/json-path-builder.js';\nimport { BinaryOperationNode } from '../operation-node/binary-operation-node.js';\nimport { AndNode } from '../operation-node/and-node.js';\nimport { TupleNode } from '../operation-node/tuple-node.js';\nimport { JSONPathNode } from '../operation-node/json-path-node.js';\nimport { parseDataTypeExpression, } from '../parser/data-type-parser.js';\nimport { CastNode } from '../operation-node/cast-node.js';\nexport function createExpressionBuilder(executor = NOOP_QUERY_EXECUTOR) {\n    function binary(lhs, op, rhs) {\n        return new ExpressionWrapper(parseValueBinaryOperation(lhs, op, rhs));\n    }\n    function unary(op, expr) {\n        return new ExpressionWrapper(parseUnaryOperation(op, expr));\n    }\n    const eb = Object.assign(binary, {\n        fn: undefined,\n        eb: undefined,\n        selectFrom(table) {\n            return createSelectQueryBuilder({\n                queryId: createQueryId(),\n                executor,\n                queryNode: SelectQueryNode.createFrom(parseTableExpressionOrList(table)),\n            });\n        },\n        case(reference) {\n            return new CaseBuilder({\n                node: CaseNode.create(isUndefined(reference)\n                    ? undefined\n                    : parseReferenceExpression(reference)),\n            });\n        },\n        ref(reference, op) {\n            if (isUndefined(op)) {\n                return new ExpressionWrapper(parseStringReference(reference));\n            }\n            return new JSONPathBuilder(parseJSONReference(reference, op));\n        },\n        jsonPath() {\n            return new JSONPathBuilder(JSONPathNode.create());\n        },\n        table(table) {\n            return new ExpressionWrapper(parseTable(table));\n        },\n        val(value) {\n            return new ExpressionWrapper(parseValueExpression(value));\n        },\n        refTuple(...values) {\n            return new ExpressionWrapper(TupleNode.create(values.map(parseReferenceExpression)));\n        },\n        tuple(...values) {\n            return new ExpressionWrapper(TupleNode.create(values.map(parseValueExpression)));\n        },\n        lit(value) {\n            return new ExpressionWrapper(parseSafeImmediateValue(value));\n        },\n        unary,\n        not(expr) {\n            return unary('not', expr);\n        },\n        exists(expr) {\n            return unary('exists', expr);\n        },\n        neg(expr) {\n            return unary('-', expr);\n        },\n        between(expr, start, end) {\n            return new ExpressionWrapper(BinaryOperationNode.create(parseReferenceExpression(expr), OperatorNode.create('between'), AndNode.create(parseValueExpression(start), parseValueExpression(end))));\n        },\n        betweenSymmetric(expr, start, end) {\n            return new ExpressionWrapper(BinaryOperationNode.create(parseReferenceExpression(expr), OperatorNode.create('between symmetric'), AndNode.create(parseValueExpression(start), parseValueExpression(end))));\n        },\n        and(exprs) {\n            if (isReadonlyArray(exprs)) {\n                return new ExpressionWrapper(parseFilterList(exprs, 'and'));\n            }\n            return new ExpressionWrapper(parseFilterObject(exprs, 'and'));\n        },\n        or(exprs) {\n            if (isReadonlyArray(exprs)) {\n                return new ExpressionWrapper(parseFilterList(exprs, 'or'));\n            }\n            return new ExpressionWrapper(parseFilterObject(exprs, 'or'));\n        },\n        parens(...args) {\n            const node = parseValueBinaryOperationOrExpression(args);\n            if (ParensNode.is(node)) {\n                // No double wrapping.\n                return new ExpressionWrapper(node);\n            }\n            else {\n                return new ExpressionWrapper(ParensNode.create(node));\n            }\n        },\n        cast(expr, dataType) {\n            return new ExpressionWrapper(CastNode.create(parseReferenceExpression(expr), parseDataTypeExpression(dataType)));\n        },\n    });\n    eb.fn = createFunctionModule();\n    eb.eb = eb;\n    return eb;\n}\nexport function expressionBuilder(_) {\n    return createExpressionBuilder();\n}\n","/// <reference types=\"./expression-parser.d.ts\" />\nimport { isAliasedExpression, isExpression, } from '../expression/expression.js';\nimport { isOperationNodeSource } from '../operation-node/operation-node-source.js';\nimport { expressionBuilder, } from '../expression/expression-builder.js';\nimport { isFunction } from '../util/object-utils.js';\nexport function parseExpression(exp) {\n    if (isOperationNodeSource(exp)) {\n        return exp.toOperationNode();\n    }\n    else if (isFunction(exp)) {\n        return exp(expressionBuilder()).toOperationNode();\n    }\n    throw new Error(`invalid expression: ${JSON.stringify(exp)}`);\n}\nexport function parseAliasedExpression(exp) {\n    if (isOperationNodeSource(exp)) {\n        return exp.toOperationNode();\n    }\n    else if (isFunction(exp)) {\n        return exp(expressionBuilder()).toOperationNode();\n    }\n    throw new Error(`invalid aliased expression: ${JSON.stringify(exp)}`);\n}\nexport function isExpressionOrFactory(obj) {\n    return isExpression(obj) || isAliasedExpression(obj) || isFunction(obj);\n}\n","/// <reference types=\"./dynamic-table-builder.d.ts\" />\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { isOperationNodeSource, } from '../operation-node/operation-node-source.js';\nimport { parseTable } from '../parser/table-parser.js';\nimport { isObject, isString } from '../util/object-utils.js';\nexport class DynamicTableBuilder {\n    #table;\n    get table() {\n        return this.#table;\n    }\n    constructor(table) {\n        this.#table = table;\n    }\n    as(alias) {\n        return new AliasedDynamicTableBuilder(this.#table, alias);\n    }\n}\nexport class AliasedDynamicTableBuilder {\n    #table;\n    #alias;\n    get table() {\n        return this.#table;\n    }\n    get alias() {\n        return this.#alias;\n    }\n    constructor(table, alias) {\n        this.#table = table;\n        this.#alias = alias;\n    }\n    toOperationNode() {\n        return AliasNode.create(parseTable(this.#table), IdentifierNode.create(this.#alias));\n    }\n}\nexport function isAliasedDynamicTableBuilder(obj) {\n    return (isObject(obj) &&\n        isOperationNodeSource(obj) &&\n        isString(obj.table) &&\n        isString(obj.alias));\n}\n","/// <reference types=\"./table-parser.d.ts\" />\nimport { isReadonlyArray, isString } from '../util/object-utils.js';\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { TableNode } from '../operation-node/table-node.js';\nimport { parseAliasedExpression, } from './expression-parser.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { isAliasedDynamicTableBuilder, } from '../dynamic/dynamic-table-builder.js';\nexport function parseTableExpressionOrList(table) {\n    if (isReadonlyArray(table)) {\n        return table.map((it) => parseTableExpression(it));\n    }\n    else {\n        return [parseTableExpression(table)];\n    }\n}\nexport function parseTableExpression(table) {\n    if (isString(table)) {\n        return parseAliasedTable(table);\n    }\n    else if (isAliasedDynamicTableBuilder(table)) {\n        return table.toOperationNode();\n    }\n    else {\n        return parseAliasedExpression(table);\n    }\n}\nexport function parseAliasedTable(from) {\n    const ALIAS_SEPARATOR = ' as ';\n    if (from.includes(ALIAS_SEPARATOR)) {\n        const [table, alias] = from.split(ALIAS_SEPARATOR).map(trim);\n        return AliasNode.create(parseTable(table), IdentifierNode.create(alias));\n    }\n    else {\n        return parseTable(from);\n    }\n}\nexport function parseTable(from) {\n    const SCHEMA_SEPARATOR = '.';\n    if (from.includes(SCHEMA_SEPARATOR)) {\n        const [schema, table] = from.split(SCHEMA_SEPARATOR).map(trim);\n        return TableNode.createWithSchema(schema, table);\n    }\n    else {\n        return TableNode.create(from);\n    }\n}\nfunction trim(str) {\n    return str.trim();\n}\n","/// <reference types=\"./raw-builder.d.ts\" />\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { freeze } from '../util/object-utils.js';\nimport { NOOP_QUERY_EXECUTOR } from '../query-executor/noop-query-executor.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { isOperationNodeSource } from '../operation-node/operation-node-source.js';\nclass RawBuilderImpl {\n    #props;\n    constructor(props) {\n        this.#props = freeze(props);\n    }\n    get expressionType() {\n        return undefined;\n    }\n    get isRawBuilder() {\n        return true;\n    }\n    as(alias) {\n        return new AliasedRawBuilderImpl(this, alias);\n    }\n    $castTo() {\n        return new RawBuilderImpl({ ...this.#props });\n    }\n    $notNull() {\n        return new RawBuilderImpl(this.#props);\n    }\n    withPlugin(plugin) {\n        return new RawBuilderImpl({\n            ...this.#props,\n            plugins: this.#props.plugins !== undefined\n                ? freeze([...this.#props.plugins, plugin])\n                : freeze([plugin]),\n        });\n    }\n    toOperationNode() {\n        return this.#toOperationNode(this.#getExecutor());\n    }\n    compile(executorProvider) {\n        return this.#compile(this.#getExecutor(executorProvider));\n    }\n    async execute(executorProvider, options) {\n        const executor = this.#getExecutor(executorProvider);\n        return executor.executeQuery(this.#compile(executor), options);\n    }\n    #getExecutor(executorProvider) {\n        const executor = executorProvider !== undefined\n            ? executorProvider.getExecutor()\n            : NOOP_QUERY_EXECUTOR;\n        return this.#props.plugins !== undefined\n            ? executor.withPlugins(this.#props.plugins)\n            : executor;\n    }\n    #toOperationNode(executor) {\n        return executor.transformQuery(this.#props.rawNode, this.#props.queryId);\n    }\n    #compile(executor) {\n        return executor.compileQuery(this.#toOperationNode(executor), this.#props.queryId);\n    }\n}\nexport function createRawBuilder(props) {\n    return new RawBuilderImpl(props);\n}\nclass AliasedRawBuilderImpl {\n    #rawBuilder;\n    #alias;\n    constructor(rawBuilder, alias) {\n        this.#rawBuilder = rawBuilder;\n        this.#alias = alias;\n    }\n    get expression() {\n        return this.#rawBuilder;\n    }\n    get alias() {\n        return this.#alias;\n    }\n    get rawBuilder() {\n        return this.#rawBuilder;\n    }\n    toOperationNode() {\n        return AliasNode.create(this.#rawBuilder.toOperationNode(), isOperationNodeSource(this.#alias)\n            ? this.#alias.toOperationNode()\n            : IdentifierNode.create(this.#alias));\n    }\n}\n","/// <reference types=\"./sql.d.ts\" />\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { isOperationNodeSource } from '../operation-node/operation-node-source.js';\nimport { RawNode } from '../operation-node/raw-node.js';\nimport { ValueNode } from '../operation-node/value-node.js';\nimport { parseStringReference } from '../parser/reference-parser.js';\nimport { parseTable } from '../parser/table-parser.js';\nimport { parseValueExpression } from '../parser/value-parser.js';\nimport { createQueryId } from '../util/query-id.js';\nimport { createRawBuilder } from './raw-builder.js';\nexport const sql = Object.assign((sqlFragments, ...parameters) => {\n    return createRawBuilder({\n        queryId: createQueryId(),\n        rawNode: RawNode.create(sqlFragments, parameters?.map(parseParameter) ?? []),\n    });\n}, {\n    ref(columnReference) {\n        return createRawBuilder({\n            queryId: createQueryId(),\n            rawNode: RawNode.createWithChild(parseStringReference(columnReference)),\n        });\n    },\n    val(value) {\n        return createRawBuilder({\n            queryId: createQueryId(),\n            rawNode: RawNode.createWithChild(parseValueExpression(value)),\n        });\n    },\n    table(tableReference) {\n        return createRawBuilder({\n            queryId: createQueryId(),\n            rawNode: RawNode.createWithChild(parseTable(tableReference)),\n        });\n    },\n    id(...ids) {\n        const fragments = new Array(ids.length + 1).fill('.');\n        fragments[0] = '';\n        fragments[fragments.length - 1] = '';\n        return createRawBuilder({\n            queryId: createQueryId(),\n            rawNode: RawNode.create(fragments, ids.map(IdentifierNode.create)),\n        });\n    },\n    lit(value) {\n        return createRawBuilder({\n            queryId: createQueryId(),\n            rawNode: RawNode.createWithChild(ValueNode.createImmediate(value)),\n        });\n    },\n    raw(sql) {\n        return createRawBuilder({\n            queryId: createQueryId(),\n            rawNode: RawNode.createWithSql(sql),\n        });\n    },\n    join(array, separator = sql `, `) {\n        const nodes = new Array(Math.max(2 * array.length - 1, 0));\n        const sep = separator.toOperationNode();\n        for (let i = 0; i < array.length; ++i) {\n            nodes[2 * i] = parseParameter(array[i]);\n            if (i !== array.length - 1) {\n                nodes[2 * i + 1] = sep;\n            }\n        }\n        return createRawBuilder({\n            queryId: createQueryId(),\n            rawNode: RawNode.createWithChildren(nodes),\n        });\n    },\n});\nfunction parseParameter(param) {\n    if (isOperationNodeSource(param)) {\n        return param.toOperationNode();\n    }\n    return parseValueExpression(param);\n}\n","import { type SelectQueryBuilder, sql } from \"kysely\";\n\nconst applyTenantScope = <DB, TB extends keyof DB, O>(\n\tquery: SelectQueryBuilder<DB, TB, O>,\n\tprops: {\n\t\ttenantKey: string | null | undefined;\n\t\tcolumn: string;\n\t},\n) => {\n\tif (props.tenantKey == null) return query;\n\treturn query.where(\n\t\tsql<boolean>`(${sql.ref(props.column)} = ${props.tenantKey} or ${sql.ref(props.column)} is null)`,\n\t);\n};\n\nexport const applyDocumentVersionTenantScope = <DB, TB extends keyof DB, O>(\n\tquery: SelectQueryBuilder<DB, TB, O>,\n\tprops: {\n\t\ttenantKey: string | null | undefined;\n\t\tdocumentTable: string;\n\t\tversionTable: string;\n\t},\n) => {\n\tif (props.tenantKey == null) return query;\n\treturn query.where(\n\t\tsql<boolean>`exists (\n\t\t\tselect 1\n\t\t\tfrom ${sql.table(props.documentTable)} as tenant_document\n\t\t\twhere tenant_document.id = ${sql.ref(`${props.versionTable}.document_id`)}\n\t\t\tand (\n\t\t\t\ttenant_document.tenant_key = ${props.tenantKey}\n\t\t\t\tor tenant_document.tenant_key is null\n\t\t\t)\n\t\t)`,\n\t);\n};\n\nexport default applyTenantScope;\n","import { buildTableName } from \"@lucidcms/core/plugin\";\nimport type {\n\tLucidBrickTableName,\n\tServiceResponse,\n} from \"@lucidcms/core/types\";\nimport constants from \"../constants.js\";\n\n/**\n * Resolves the top-level relation table used by the parent page field.\n */\nconst getParentPageRelationTable = (\n\tcollectionKey: string,\n\ttableNameByteLimit: number | null,\n): Awaited<ServiceResponse<LucidBrickTableName>> => {\n\tconst tableNameRes = buildTableName<LucidBrickTableName>(\n\t\t\"cf_relation\",\n\t\t{\n\t\t\tcollection: collectionKey,\n\t\t\tfieldPath: [constants.fields.parentPage.key],\n\t\t},\n\t\ttableNameByteLimit,\n\t);\n\tif (tableNameRes.error) {\n\t\treturn {\n\t\t\terror: tableNameRes.error,\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: tableNameRes.data.name,\n\t};\n};\n\nexport default getParentPageRelationTable;\n","import { copy, prefixGeneratedColName } from \"@lucidcms/core/plugin\";\nimport type {\n\tCollectionTableNames,\n\tDocumentVersionType,\n\tFieldInputSchema,\n\tServiceFn,\n} from \"@lucidcms/core/types\";\nimport constants from \"../constants.js\";\nimport { applyDocumentVersionTenantScope } from \"../utils/apply-tenant-scope.js\";\nimport getParentPageId from \"../utils/get-parent-page-id.js\";\nimport getParentPageRelationTable from \"../utils/get-parent-page-relation-table.js\";\n\nexport type ParentPageQueryResponse = {\n\t_slug: string | null;\n\t_fullSlug: string | null;\n\t_parentPage: number | null;\n\tdocument_id: number;\n\tlocale: string;\n};\n\n/**\n *  Get the parent document pages fields\n */\nconst getParentFields: ServiceFn<\n\t[\n\t\t{\n\t\t\tdefaultLocale: string;\n\t\t\tversionType: Exclude<DocumentVersionType, \"revision\">;\n\t\t\tcollectionKey: string;\n\t\t\ttenantKey: string | null;\n\t\t\tfields: {\n\t\t\t\tparentPage: FieldInputSchema;\n\t\t\t};\n\t\t\ttables: CollectionTableNames;\n\t\t\tmissingParentIsEmpty?: boolean;\n\t\t},\n\t],\n\tArray<ParentPageQueryResponse>\n> = async (context, data) => {\n\ttry {\n\t\tconst parentPageId = getParentPageId(data.fields.parentPage);\n\t\tif (parentPageId === null) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: [],\n\t\t\t};\n\t\t}\n\n\t\tconst {\n\t\t\tdocument: documentTable,\n\t\t\tversion: versionTable,\n\t\t\tdocumentFields: fieldsTable,\n\t\t} = data.tables;\n\n\t\tconst slugColumn = prefixGeneratedColName(constants.fields.slug.key);\n\t\tconst parentPageColumn = prefixGeneratedColName(\"document_id\");\n\t\tconst fullSlugColumn = prefixGeneratedColName(\n\t\t\tconstants.fields.fullSlug.key,\n\t\t);\n\t\tconst parentPageTableRes = getParentPageRelationTable(\n\t\t\tdata.collectionKey,\n\t\t\tcontext.config.db.config.tableNameByteLimit,\n\t\t);\n\t\tif (parentPageTableRes.error) return parentPageTableRes;\n\t\tconst parentPageTable = parentPageTableRes.data;\n\t\tconst defaultFieldsAlias = \"default_fields\";\n\n\t\tconst parentFieldsQuery = context.db.client\n\t\t\t.selectFrom(fieldsTable)\n\t\t\t.innerJoin(\n\t\t\t\tversionTable,\n\t\t\t\t`${versionTable}.id`,\n\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t)\n\t\t\t.leftJoin(`${fieldsTable} as ${defaultFieldsAlias}`, (join) =>\n\t\t\t\tjoin\n\t\t\t\t\t.onRef(\n\t\t\t\t\t\t`${defaultFieldsAlias}.document_version_id`,\n\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t\t\t)\n\t\t\t\t\t.on(`${defaultFieldsAlias}.locale`, \"=\", data.defaultLocale),\n\t\t\t)\n\t\t\t.leftJoin(parentPageTable, (join) =>\n\t\t\t\tjoin\n\t\t\t\t\t.onRef(\n\t\t\t\t\t\t`${parentPageTable}.parent_id`,\n\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t`${defaultFieldsAlias}.id`,\n\t\t\t\t\t)\n\t\t\t\t\t.on(`${parentPageTable}.locale`, \"=\", data.defaultLocale),\n\t\t\t)\n\t\t\t// @ts-expect-error\n\t\t\t.select([\n\t\t\t\t`${fieldsTable}.${slugColumn}`,\n\t\t\t\t`${fieldsTable}.${fullSlugColumn}`,\n\t\t\t\t`${parentPageTable}.${parentPageColumn}`,\n\t\t\t\t`${versionTable}.document_id`,\n\t\t\t\t`${fieldsTable}.locale`,\n\t\t\t])\n\t\t\t.where(`${versionTable}.document_id`, \"=\", parentPageId)\n\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType);\n\n\t\tconst parentFields = await applyDocumentVersionTenantScope(\n\t\t\tparentFieldsQuery,\n\t\t\t{\n\t\t\t\ttenantKey: data.tenantKey,\n\t\t\t\tdocumentTable,\n\t\t\t\tversionTable,\n\t\t\t},\n\t\t).execute();\n\n\t\tif (!parentFields || parentFields.length === 0) {\n\t\t\tif (data.missingParentIsEmpty) {\n\t\t\t\treturn {\n\t\t\t\t\terror: undefined,\n\t\t\t\t\tdata: [],\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\terror: {\n\t\t\t\t\ttype: \"basic\",\n\t\t\t\t\tstatus: 404,\n\t\t\t\t\tmessage: copy(\n\t\t\t\t\t\t\"server:plugin.pages.parents.published.version.not.found\",\n\t\t\t\t\t),\n\t\t\t\t\terrors: {\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey: constants.fields.parentPage.key,\n\t\t\t\t\t\t\t\tlocaleCode: data.defaultLocale,\n\t\t\t\t\t\t\t\tmessage: copy(\n\t\t\t\t\t\t\t\t\t\"server:plugin.pages.parents.published.version.not.found\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: parentFields as unknown as Array<ParentPageQueryResponse>,\n\t\t};\n\t} catch (_error) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\"server:plugin.pages.parents.fields.fetch.failed\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n};\n\nexport default getParentFields;\n","import { copy } from \"@lucidcms/core/plugin\";\nimport type { ServiceResponse } from \"@lucidcms/core/types\";\nimport type {\n\tCollectionConfig,\n\tPluginOptionsInternal,\n} from \"../types/types.js\";\n\n/**\n *  Fetches the target collection from the plugin options\n */\nconst getTargetCollection = (data: {\n\toptions: PluginOptionsInternal;\n\tcollectionKey: string;\n}): Awaited<ServiceResponse<CollectionConfig>> => {\n\tconst targetCollection = data.options.collections.find(\n\t\t(c) => c.key === data.collectionKey,\n\t);\n\t//* should never happen\n\tif (!targetCollection) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\"server:plugin.pages.collections.not.found\", {\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tcollection: data.collectionKey,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: targetCollection,\n\t};\n};\n\nexport default getTargetCollection;\n","import type {\n\tFieldInputSchema,\n\tInternalCollectionDocument,\n\tInternalDocumentField,\n\tLucidHookDocuments,\n} from \"@lucidcms/core/types\";\nimport constants from \"../../constants.js\";\nimport type { PluginOptionsInternal } from \"../../types/types.js\";\nimport getParentPageId from \"../../utils/get-parent-page-id.js\";\nimport constructParentFullSlug from \"../construct-parent-fullslug.js\";\nimport getParentFields, {\n\ttype ParentPageQueryResponse,\n} from \"../get-parent-fields.js\";\nimport getTargetCollection from \"../get-target-collection.js\";\n\nconst snapshotVersionType = \"snapshot\";\n\nconst cloneFieldAsInput = (field: InternalDocumentField): FieldInputSchema => {\n\tconst input: FieldInputSchema = {\n\t\tkey: field.key,\n\t\ttype: field.type as FieldInputSchema[\"type\"],\n\t};\n\n\tif (field.translations !== undefined) {\n\t\tinput.translations = { ...field.translations };\n\t}\n\tif (field.value !== undefined) {\n\t\tinput.value = field.value;\n\t}\n\n\treturn input;\n};\n\nconst findField = (\n\tfields: InternalDocumentField[],\n\tkey: string,\n\ttype: InternalDocumentField[\"type\"],\n): InternalDocumentField | undefined => {\n\treturn fields.find((field) => field.key === key && field.type === type);\n};\n\n/**\n * Replaces only the formatted fullSlug field on the fetched document. Snapshot\n * previews need an effective value, but the stored snapshot must remain frozen.\n */\nconst updateFullSlugField = (data: {\n\tdocument: InternalCollectionDocument;\n\tfullSlug: Record<string, string | null>;\n\tdefaultLocale: string;\n}): InternalCollectionDocument => {\n\treturn {\n\t\t...data.document,\n\t\tfields:\n\t\t\tdata.document.fields?.map((field) => {\n\t\t\t\tif (\n\t\t\t\t\tfield.key !== constants.fields.fullSlug.key ||\n\t\t\t\t\tfield.type !== \"text\"\n\t\t\t\t) {\n\t\t\t\t\treturn field;\n\t\t\t\t}\n\n\t\t\t\tif (field.translations !== undefined) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...field,\n\t\t\t\t\t\ttranslations: {\n\t\t\t\t\t\t\t...field.translations,\n\t\t\t\t\t\t\t...data.fullSlug,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...field,\n\t\t\t\t\tvalue: data.fullSlug[data.defaultLocale] ?? null,\n\t\t\t\t};\n\t\t\t}) ?? null,\n\t};\n};\n\n/**\n * Derives pages fullSlug values for operation-backed snapshot reads using the\n * publish target version. This keeps scheduled-release previews aligned with\n * the environment they will publish to without persisting derived values that\n * would be unfilterable or stale as parent versions change.\n */\nconst afterFetchHandler =\n\t(\n\t\toptions: PluginOptionsInternal,\n\t): LucidHookDocuments<\"afterFetch\">[\"handler\"] =>\n\tasync (context, data) => {\n\t\tif (data.data.versionType !== snapshotVersionType) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst targetCollectionRes = getTargetCollection({\n\t\t\toptions,\n\t\t\tcollectionKey: data.meta.collectionKey,\n\t\t});\n\t\tif (targetCollectionRes.error) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst documents: InternalCollectionDocument[] = [];\n\n\t\tfor (const document of data.data.documents) {\n\t\t\tconst fields = document.fields;\n\t\t\tif (!fields || fields.length === 0) {\n\t\t\t\tdocuments.push(document);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst slugField = findField(fields, constants.fields.slug.key, \"text\");\n\t\t\tconst parentPageField = findField(\n\t\t\t\tfields,\n\t\t\t\tconstants.fields.parentPage.key,\n\t\t\t\t\"relation\",\n\t\t\t);\n\t\t\tconst fullSlugField = findField(\n\t\t\t\tfields,\n\t\t\t\tconstants.fields.fullSlug.key,\n\t\t\t\t\"text\",\n\t\t\t);\n\n\t\t\tif (!slugField || !parentPageField || !fullSlugField) {\n\t\t\t\tdocuments.push(document);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst slug = cloneFieldAsInput(slugField);\n\t\t\tconst parentPage = cloneFieldAsInput(parentPageField);\n\n\t\t\tlet parentFieldsData: Array<ParentPageQueryResponse> = [];\n\t\t\tconst parentPageId = getParentPageId(parentPage);\n\n\t\t\tif (parentPageId !== null) {\n\t\t\t\tconst parentFieldsRes = await getParentFields(context, {\n\t\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\t\tversionType: data.data.relationVersionType,\n\t\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tparentPage,\n\t\t\t\t\t},\n\t\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t\t\tmissingParentIsEmpty: true,\n\t\t\t\t});\n\t\t\t\tif (parentFieldsRes.error) return parentFieldsRes;\n\n\t\t\t\tparentFieldsData = parentFieldsRes.data;\n\t\t\t}\n\n\t\t\tconst fullSlugRes = constructParentFullSlug({\n\t\t\t\tparentFields: parentFieldsData,\n\t\t\t\tlocalization: context.config.localization,\n\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t\tfields: {\n\t\t\t\t\tslug,\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (fullSlugRes.error) return fullSlugRes;\n\n\t\t\tdocuments.push(\n\t\t\t\tupdateFullSlugField({\n\t\t\t\t\tdocument,\n\t\t\t\t\tfullSlug: fullSlugRes.data,\n\t\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tdata.data.documents = documents;\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t};\n\nexport default afterFetchHandler;\n","import type { DescendantFieldsResponse } from \"../services/get-descendant-fields.js\";\nimport formatFullSlug from \"./format-fullslug.js\";\n\nconst buildFullSlugFromSlugs = (data: {\n\ttargetLocale: string;\n\tcurrentDescendant: DescendantFieldsResponse;\n\tdescendants: Array<DescendantFieldsResponse>;\n\ttopLevelFullSlug?: string;\n}): string | null => {\n\tconst rowForLocale = data.currentDescendant.rows.find(\n\t\t(row) => row.locale === data.targetLocale,\n\t);\n\n\tif (!rowForLocale?._slug) return null;\n\n\tconst slugFieldValue = rowForLocale._slug;\n\tconst parentPageValue = rowForLocale._parentPage;\n\n\tif (!parentPageValue) {\n\t\treturn formatFullSlug(data.topLevelFullSlug, slugFieldValue);\n\t}\n\n\tconst parentDescendant = data.descendants.find(\n\t\t(descendant) => descendant.document_id === parentPageValue,\n\t);\n\n\tif (!parentDescendant) {\n\t\treturn formatFullSlug(data.topLevelFullSlug, slugFieldValue);\n\t}\n\n\tconst parentFullSlug = buildFullSlugFromSlugs({\n\t\ttargetLocale: data.targetLocale,\n\t\tcurrentDescendant: parentDescendant,\n\t\tdescendants: data.descendants,\n\t\ttopLevelFullSlug: data.topLevelFullSlug,\n\t});\n\n\treturn formatFullSlug(\n\t\tparentFullSlug || data.topLevelFullSlug,\n\t\tslugFieldValue,\n\t);\n};\n\nexport default buildFullSlugFromSlugs;\n","import type {\n\tConfig,\n\tFieldInputSchema,\n\tServiceResponse,\n} from \"@lucidcms/core/types\";\nimport type { DescendantFieldsResponse } from \"../services/get-descendant-fields.js\";\nimport type { CollectionConfig } from \"../types/types.js\";\nimport buildFullSlug from \"../utils/build-fullslug-from-slugs.js\";\nimport resolveCollectionPrefix from \"../utils/resolve-collection-prefix.js\";\n\n/**\n *  Constructs the fullSlug for the child documents\n */\nconst constructChildFullSlug = (data: {\n\tdescendants: DescendantFieldsResponse[];\n\tlocalization: Config[\"localization\"];\n\tparentFullSlugField?: FieldInputSchema;\n\tcollection: CollectionConfig;\n}): Awaited<\n\tServiceResponse<\n\t\tArray<{\n\t\t\tdocumentId: number;\n\t\t\tversionId: number;\n\t\t\tfullSlugs: Record<string, string | null>;\n\t\t}>\n\t>\n> => {\n\tconst documentFullSlugs: Array<{\n\t\tdocumentId: number;\n\t\tversionId: number;\n\t\tfullSlugs: Record<string, string | null>;\n\t}> = [];\n\n\tfor (const descendant of data.descendants) {\n\t\tconst fullSlug: Record<string, string | null> = {};\n\n\t\tif (data.collection.localized) {\n\t\t\tif (\n\t\t\t\tdata.parentFullSlugField !== undefined &&\n\t\t\t\t!data.parentFullSlugField.translations\n\t\t\t)\n\t\t\t\tbreak;\n\n\t\t\tfor (const locale of data.localization.locales) {\n\t\t\t\tconst currentFullSlugValue =\n\t\t\t\t\tdata.parentFullSlugField?.translations?.[locale.code];\n\n\t\t\t\tif (data.parentFullSlugField !== undefined && !currentFullSlugValue) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfullSlug[locale.code] = buildFullSlug({\n\t\t\t\t\ttargetLocale: locale.code,\n\t\t\t\t\tcurrentDescendant: descendant,\n\t\t\t\t\tdescendants: data.descendants,\n\t\t\t\t\ttopLevelFullSlug:\n\t\t\t\t\t\tcurrentFullSlugValue ??\n\t\t\t\t\t\tresolveCollectionPrefix({\n\t\t\t\t\t\t\tcollection: data.collection,\n\t\t\t\t\t\t\tlocaleCode: locale.code,\n\t\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tif (\n\t\t\t\tdata.parentFullSlugField !== undefined &&\n\t\t\t\t!data.parentFullSlugField.value\n\t\t\t)\n\t\t\t\tbreak;\n\n\t\t\tfullSlug[data.localization.defaultLocale] = buildFullSlug({\n\t\t\t\ttargetLocale: data.localization.defaultLocale,\n\t\t\t\tcurrentDescendant: descendant,\n\t\t\t\tdescendants: data.descendants,\n\t\t\t\ttopLevelFullSlug:\n\t\t\t\t\tdata.parentFullSlugField?.value ??\n\t\t\t\t\tresolveCollectionPrefix({\n\t\t\t\t\t\tcollection: data.collection,\n\t\t\t\t\t\tlocaleCode: data.localization.defaultLocale,\n\t\t\t\t\t}),\n\t\t\t});\n\t\t}\n\n\t\tdocumentFullSlugs.push({\n\t\t\tdocumentId: descendant.document_id,\n\t\t\tversionId: descendant.document_version_id,\n\t\t\tfullSlugs: fullSlug,\n\t\t});\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: documentFullSlugs,\n\t};\n};\n\nexport default constructChildFullSlug;\n","import { inspect } from \"node:util\";\nimport { copy, prefixGeneratedColName } from \"@lucidcms/core/plugin\";\nimport type {\n\tDocumentVersionType,\n\tLucidBrickTableName,\n\tLucidDocumentTableName,\n\tLucidVersionTableName,\n\tServiceFn,\n} from \"@lucidcms/core/types\";\nimport constants from \"../constants.js\";\nimport { applyDocumentVersionTenantScope } from \"../utils/apply-tenant-scope.js\";\nimport getParentPageRelationTable from \"../utils/get-parent-page-relation-table.js\";\n\nexport type DescendantFieldsResponse = {\n\tdocument_id: number;\n\tdocument_version_id: number;\n\trows: {\n\t\tlocale: string;\n\t\t_slug: string | null;\n\t\t_fullSlug: string | null;\n\t\t_parentPage: number | null;\n\t}[];\n};\n\n/**\n *  Get the descendant document pages fields\n */\nconst getDescendantFields: ServiceFn<\n\t[\n\t\t{\n\t\t\tids: number[];\n\t\t\tversionType: Exclude<DocumentVersionType, \"revision\">;\n\t\t\tcollectionKey: string;\n\t\t\ttables: {\n\t\t\t\tdocument: LucidDocumentTableName;\n\t\t\t\tdocumentFields: LucidBrickTableName;\n\t\t\t\tversion: LucidVersionTableName;\n\t\t\t};\n\t\t},\n\t],\n\tArray<DescendantFieldsResponse>\n> = async (context, data) => {\n\ttry {\n\t\tif (data.ids.length === 0) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: [],\n\t\t\t};\n\t\t}\n\n\t\tconst {\n\t\t\tdocument: documentTable,\n\t\t\tdocumentFields: fieldsTable,\n\t\t\tversion: versionTable,\n\t\t} = data.tables;\n\t\tconst slugColumn = prefixGeneratedColName(constants.fields.slug.key);\n\t\tconst fullSlugColumn = prefixGeneratedColName(\n\t\t\tconstants.fields.fullSlug.key,\n\t\t);\n\t\tconst parentPageColumn = prefixGeneratedColName(\"document_id\");\n\t\tconst parentPageTableRes = getParentPageRelationTable(\n\t\t\tdata.collectionKey,\n\t\t\tcontext.config.db.config.tableNameByteLimit,\n\t\t);\n\t\tif (parentPageTableRes.error) return parentPageTableRes;\n\t\tconst parentPageTable = parentPageTableRes.data;\n\t\tconst defaultFieldsAlias = \"default_fields\";\n\n\t\tconst sourceDocuments = await context.db.client\n\t\t\t.selectFrom(documentTable)\n\t\t\t.select([\"id\", \"tenant_key\"])\n\t\t\t.where(\"id\", \"in\", data.ids)\n\t\t\t.execute();\n\n\t\tconst sourceIdsByTenant = new Map<string | null, number[]>();\n\t\tfor (const sourceDocument of sourceDocuments) {\n\t\t\tconst tenantKey = sourceDocument.tenant_key ?? null;\n\t\t\tsourceIdsByTenant.set(tenantKey, [\n\t\t\t\t...(sourceIdsByTenant.get(tenantKey) ?? []),\n\t\t\t\tsourceDocument.id,\n\t\t\t]);\n\t\t}\n\n\t\tconst descendants = (\n\t\t\tawait Promise.all(\n\t\t\t\tArray.from(sourceIdsByTenant.entries()).map(([tenantKey, ids]) =>\n\t\t\t\t\tcontext.db.client\n\t\t\t\t\t\t.withRecursive(\"recursive_cte\", (db) =>\n\t\t\t\t\t\t\tapplyDocumentVersionTenantScope(\n\t\t\t\t\t\t\t\tdb\n\t\t\t\t\t\t\t\t\t.selectFrom(parentPageTable)\n\t\t\t\t\t\t\t\t\t.innerJoin(\n\t\t\t\t\t\t\t\t\t\tversionTable,\n\t\t\t\t\t\t\t\t\t\t`${versionTable}.id`,\n\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.document_version_id`,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.select([\n\t\t\t\t\t\t\t\t\t\t`${versionTable}.document_id as document_id`,\n\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.${parentPageColumn} as parent_id`,\n\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.document_version_id`,\n\t\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t\t\t.where(({ eb }) =>\n\t\t\t\t\t\t\t\t\t\teb(`${parentPageTable}.${parentPageColumn}`, \"in\", ids),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.where(\n\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.locale`,\n\t\t\t\t\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttenantKey,\n\t\t\t\t\t\t\t\t\tdocumentTable,\n\t\t\t\t\t\t\t\t\tversionTable,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t).unionAll(\n\t\t\t\t\t\t\t\tapplyDocumentVersionTenantScope(\n\t\t\t\t\t\t\t\t\tdb\n\t\t\t\t\t\t\t\t\t\t.selectFrom(parentPageTable)\n\t\t\t\t\t\t\t\t\t\t.innerJoin(\n\t\t\t\t\t\t\t\t\t\t\tversionTable,\n\t\t\t\t\t\t\t\t\t\t\t`${versionTable}.id`,\n\t\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.document_version_id`,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.innerJoin(\n\t\t\t\t\t\t\t\t\t\t\t\"recursive_cte as rc\",\n\t\t\t\t\t\t\t\t\t\t\t\"rc.document_id\",\n\t\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.${parentPageColumn}`,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.select([\n\t\t\t\t\t\t\t\t\t\t\t`${versionTable}.document_id as document_id`,\n\t\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.${parentPageColumn} as parent_id`,\n\t\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.document_version_id`,\n\t\t\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t\t\t\t.where(\n\t\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.locale`,\n\t\t\t\t\t\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttenantKey,\n\t\t\t\t\t\t\t\t\t\tdocumentTable,\n\t\t\t\t\t\t\t\t\t\tversionTable,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.selectFrom(\"recursive_cte\")\n\t\t\t\t\t\t.select((eb) => [\n\t\t\t\t\t\t\t\"document_id\",\n\t\t\t\t\t\t\t\"document_version_id\",\n\t\t\t\t\t\t\tcontext.config.db\n\t\t\t\t\t\t\t\t.jsonArrayFrom(\n\t\t\t\t\t\t\t\t\teb\n\t\t\t\t\t\t\t\t\t\t.selectFrom(fieldsTable)\n\t\t\t\t\t\t\t\t\t\t.innerJoin(\n\t\t\t\t\t\t\t\t\t\t\tversionTable,\n\t\t\t\t\t\t\t\t\t\t\t`${versionTable}.id`,\n\t\t\t\t\t\t\t\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.leftJoin(\n\t\t\t\t\t\t\t\t\t\t\t`${fieldsTable} as ${defaultFieldsAlias}`,\n\t\t\t\t\t\t\t\t\t\t\t(join) =>\n\t\t\t\t\t\t\t\t\t\t\t\tjoin\n\t\t\t\t\t\t\t\t\t\t\t\t\t.onRef(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`${defaultFieldsAlias}.document_version_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t.on(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`${defaultFieldsAlias}.locale`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.leftJoin(parentPageTable, (join) =>\n\t\t\t\t\t\t\t\t\t\t\tjoin\n\t\t\t\t\t\t\t\t\t\t\t\t.onRef(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.parent_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t`${defaultFieldsAlias}.id`,\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t.on(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.locale`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\t\t\t\t.select([\n\t\t\t\t\t\t\t\t\t\t\t`${fieldsTable}.locale`,\n\t\t\t\t\t\t\t\t\t\t\t`${fieldsTable}.${slugColumn} as _slug`,\n\t\t\t\t\t\t\t\t\t\t\t`${fieldsTable}.${fullSlugColumn} as _fullSlug`,\n\t\t\t\t\t\t\t\t\t\t\t`${parentPageTable}.${parentPageColumn} as _parentPage`,\n\t\t\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t\t\t\t.whereRef(\n\t\t\t\t\t\t\t\t\t\t\t`${versionTable}.document_id`,\n\t\t\t\t\t\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t\t\t\t\t\t\"recursive_cte.document_id\",\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.as(\"rows\"),\n\t\t\t\t\t\t])\n\t\t\t\t\t\t.where(({ eb }) => eb(\"document_id\", \"not in\", data.ids))\n\t\t\t\t\t\t.execute(),\n\t\t\t\t),\n\t\t\t)\n\t\t).flat();\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: descendants.filter((d, i, self) => {\n\t\t\t\treturn (\n\t\t\t\t\tself.findIndex(\n\t\t\t\t\t\t(e) =>\n\t\t\t\t\t\t\te.document_id === d.document_id &&\n\t\t\t\t\t\t\te.document_version_id === d.document_version_id,\n\t\t\t\t\t) === i\n\t\t\t\t);\n\t\t\t}) as DescendantFieldsResponse[],\n\t\t};\n\t} catch (error) {\n\t\tconsole.log(\n\t\t\tinspect(error, {\n\t\t\t\tdepth: Number.POSITIVE_INFINITY,\n\t\t\t\tcolors: true,\n\t\t\t}),\n\t\t);\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\"server:plugin.pages.descendants.fields.fetch.failed\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n};\n\nexport default getDescendantFields;\n","import { copy, prefixGeneratedColName } from \"@lucidcms/core/plugin\";\nimport type {\n\tDocumentVersionType,\n\tLucidBrickTableName,\n\tLucidDocumentTableName,\n\tLucidVersionTableName,\n\tServiceFn,\n} from \"@lucidcms/core/types\";\nimport constants from \"../constants.js\";\nimport { applyDocumentVersionTenantScope } from \"../utils/apply-tenant-scope.js\";\nimport getParentPageRelationTable from \"../utils/get-parent-page-relation-table.js\";\n\nexport type VersionFieldsQueryResponse = {\n\tlocale: string;\n\tdocument_id: number;\n\t_slug: string | null;\n\t_fullSlug: string | null;\n\t_parentPage: number | null;\n};\n\n/**\n *  Get the target document versions slug, fullSlug and parentPage fields\n */\nconst getDocumentVersionFields: ServiceFn<\n\t[\n\t\t{\n\t\t\tdocumentId: number;\n\t\t\tversionId: number;\n\t\t\tversionType: Exclude<DocumentVersionType, \"revision\">;\n\t\t\tcollectionKey: string;\n\t\t\ttenantKey: string | null;\n\t\t\ttables: {\n\t\t\t\tdocument: LucidDocumentTableName;\n\t\t\t\tversion: LucidVersionTableName;\n\t\t\t\tdocumentFields: LucidBrickTableName;\n\t\t\t};\n\t\t},\n\t],\n\tArray<VersionFieldsQueryResponse> | null\n> = async (context, data) => {\n\ttry {\n\t\tconst {\n\t\t\tdocument: documentTable,\n\t\t\tversion: versionTable,\n\t\t\tdocumentFields: fieldsTable,\n\t\t} = data.tables;\n\t\tconst slugColumn = prefixGeneratedColName(constants.fields.slug.key);\n\t\tconst fullSlugColumn = prefixGeneratedColName(\n\t\t\tconstants.fields.fullSlug.key,\n\t\t);\n\t\tconst parentPageColumn = prefixGeneratedColName(\"document_id\");\n\t\tconst parentPageTableRes = getParentPageRelationTable(\n\t\t\tdata.collectionKey,\n\t\t\tcontext.config.db.config.tableNameByteLimit,\n\t\t);\n\t\tif (parentPageTableRes.error) return parentPageTableRes;\n\t\tconst parentPageTable = parentPageTableRes.data;\n\t\tconst defaultFieldsAlias = \"default_fields\";\n\n\t\tconst fieldsQuery = context.db.client\n\t\t\t.selectFrom(fieldsTable)\n\t\t\t.innerJoin(\n\t\t\t\tversionTable,\n\t\t\t\t`${versionTable}.id`,\n\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t)\n\t\t\t.leftJoin(`${fieldsTable} as ${defaultFieldsAlias}`, (join) =>\n\t\t\t\tjoin\n\t\t\t\t\t.onRef(\n\t\t\t\t\t\t`${defaultFieldsAlias}.document_version_id`,\n\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t\t\t)\n\t\t\t\t\t.on(\n\t\t\t\t\t\t`${defaultFieldsAlias}.locale`,\n\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\t),\n\t\t\t)\n\t\t\t.leftJoin(parentPageTable, (join) =>\n\t\t\t\tjoin\n\t\t\t\t\t.onRef(\n\t\t\t\t\t\t`${parentPageTable}.parent_id`,\n\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t`${defaultFieldsAlias}.id`,\n\t\t\t\t\t)\n\t\t\t\t\t.on(\n\t\t\t\t\t\t`${parentPageTable}.locale`,\n\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\t),\n\t\t\t)\n\t\t\t// @ts-expect-error\n\t\t\t.select([\n\t\t\t\t`${fieldsTable}.locale`,\n\t\t\t\t`${versionTable}.document_id`,\n\t\t\t\t`${fieldsTable}.${slugColumn}`,\n\t\t\t\t`${fieldsTable}.${fullSlugColumn}`,\n\t\t\t\t`${parentPageTable}.${parentPageColumn}`,\n\t\t\t])\n\t\t\t.where(`${versionTable}.document_id`, \"=\", data.documentId)\n\t\t\t.where(`${versionTable}.id`, \"=\", data.versionId)\n\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType);\n\n\t\tconst fields = await applyDocumentVersionTenantScope(fieldsQuery, {\n\t\t\ttenantKey: data.tenantKey,\n\t\t\tdocumentTable,\n\t\t\tversionTable,\n\t\t}).execute();\n\n\t\tif (!fields || fields.length === 0) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: null,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: fields as unknown as VersionFieldsQueryResponse[],\n\t\t};\n\t} catch (_error) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\n\t\t\t\t\t\"server:plugin.pages.documents.version.fields.fetch.failed\",\n\t\t\t\t),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n};\n\nexport default getDocumentVersionFields;\n","import type { PluginOptions, PluginOptionsInternal } from \"../types/types.js\";\n\nconst pluginOptions = (given: PluginOptions): PluginOptionsInternal => {\n\treturn {\n\t\tcollections: given.collections.map((c) => {\n\t\t\tconst fullSlug = c.ui?.fullSlug ?? false;\n\n\t\t\treturn {\n\t\t\t\tkey: c.key,\n\t\t\t\tlocalized: c.localized ?? false,\n\t\t\t\tprefix: c.prefix,\n\t\t\t\tui: {\n\t\t\t\t\tfullSlug,\n\t\t\t\t\ttab: c.ui?.tab,\n\t\t\t\t\twidths: {\n\t\t\t\t\t\tfullSlug: c.ui?.widths?.fullSlug ?? (fullSlug ? 6 : 12),\n\t\t\t\t\t\tslug: c.ui?.widths?.slug ?? (fullSlug ? 6 : 12),\n\t\t\t\t\t\tparentPage: c.ui?.widths?.parentPage ?? 12,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tunique: c.unique ?? true,\n\t\t\t\t// fallbackSlugSource: c.fallbackSlugSource ?? undefined,\n\t\t\t};\n\t\t}),\n\t};\n};\n\nexport default pluginOptions;\n","import { type CollectionBuilder, copy, z } from \"@lucidcms/core\";\nimport type { WritableDraft } from \"immer\";\nimport constants from \"../constants.js\";\nimport type { CollectionConfig } from \"../types/types.js\";\n\nconst slugSlashMessage = 'Only use a slash when the slug is exactly \"/\".';\nconst slugSpaceMessage = \"The slug cannot contain spaces.\";\nconst slugFormatMessage =\n\t\"The slug may only contain letters, numbers, underscores, and hyphens.\";\n\nconst registerFields = (\n\tcollection: WritableDraft<CollectionBuilder>,\n\tconfig: CollectionConfig,\n) => {\n\tif (config.ui.tab) collection.addToTab(config.ui.tab);\n\n\tcollection\n\t\t.addText(constants.fields.fullSlug.key, {\n\t\t\tdetails: {\n\t\t\t\tlabel: copy(\"admin:plugin.pages.fields.full.slug.label\", {\n\t\t\t\t\tdefaultMessage: \"Full slug\",\n\t\t\t\t}),\n\t\t\t},\n\t\t\tlocalized: config.localized,\n\t\t\tui: {\n\t\t\t\thidden: !config.ui.fullSlug,\n\t\t\t\tdisabled: true,\n\t\t\t\twidth: config.ui.widths.fullSlug,\n\t\t\t},\n\t\t\tai: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t\tshowInList: config.ui.fullSlug,\n\t\t})\n\t\t.addText(constants.fields.slug.key, {\n\t\t\tdetails: {\n\t\t\t\tlabel: copy(\"admin:plugin.pages.fields.slug.label\", {\n\t\t\t\t\tdefaultMessage: \"Slug\",\n\t\t\t\t}),\n\t\t\t},\n\t\t\tlocalized: config.localized,\n\t\t\tui: {\n\t\t\t\thidden: false,\n\t\t\t\tdisabled: false,\n\t\t\t\twidth: config.ui.widths.slug,\n\t\t\t},\n\t\t\tai: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t\tvalidation: {\n\t\t\t\trequired: true,\n\t\t\t\tzod: z.string().superRefine((value, ctx) => {\n\t\t\t\t\tif (value === \"/\") return;\n\t\t\t\t\tif (value.includes(\"/\")) {\n\t\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\t\tmessage: slugSlashMessage,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (/\\s/.test(value)) {\n\t\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\t\tmessage: slugSpaceMessage,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (/^[a-zA-Z0-9_-]+$/.test(value)) return;\n\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tmessage: slugFormatMessage,\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t},\n\t\t\tuseAsLabel: true,\n\t\t\tshowInList: true,\n\t\t})\n\t\t.addRelation(constants.fields.parentPage.key, {\n\t\t\tcollection: collection.key,\n\t\t\tdetails: {\n\t\t\t\tlabel: copy(\"admin:plugin.pages.fields.parent.page.label\", {\n\t\t\t\t\tdefaultMessage: \"Parent page\",\n\t\t\t\t}),\n\t\t\t},\n\t\t\tmultiple: false,\n\t\t\tui: {\n\t\t\t\thidden: false,\n\t\t\t\tdisabled: false,\n\t\t\t\twidth: config.ui.widths.parentPage,\n\t\t\t},\n\t\t\tshowInList: true,\n\t\t});\n};\n\nexport default registerFields;\n","import type { FieldInputSchema, ServiceResponse } from \"@lucidcms/core/types\";\nimport type { CollectionConfig } from \"../types/types.js\";\n\n/**\n *  Update the fullSlug field with the computed value\n */\nconst setFullSlug = (data: {\n\tfullSlug: Record<string, string | null>;\n\tcollection: CollectionConfig;\n\tdefaultLocale: string;\n\tfields: {\n\t\tfullSlug: FieldInputSchema;\n\t};\n}): Awaited<ServiceResponse<undefined>> => {\n\tif (data.collection.localized) {\n\t\tdata.fields.fullSlug.translations = data.fullSlug;\n\t} else {\n\t\tdata.fields.fullSlug.value = data.fullSlug[data.defaultLocale];\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default setFullSlug;\n","import { copy, prefixGeneratedColName } from \"@lucidcms/core/plugin\";\nimport type {\n\tDocumentVersionType,\n\tLucidBrickTableName,\n\tLucidVersionTableName,\n\tServiceFn,\n} from \"@lucidcms/core/types\";\nimport constants from \"../constants.js\";\nimport normalizePathValue from \"../utils/normalize-path-value.js\";\n\n/**\n *  Update the fullSlug fields with the computed value\n */\nconst updateFullSlugFields: ServiceFn<\n\t[\n\t\t{\n\t\t\tdocFullSlugs: Array<{\n\t\t\t\tdocumentId: number;\n\t\t\t\tversionId: number;\n\t\t\t\tfullSlugs: Record<string, string | null>;\n\t\t\t}>;\n\t\t\tversionType: Exclude<DocumentVersionType, \"revision\">;\n\t\t\ttables: {\n\t\t\t\tdocumentFields: LucidBrickTableName;\n\t\t\t\tversion: LucidVersionTableName;\n\t\t\t};\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\ttry {\n\t\tconst { documentFields: fieldsTable, version: versionTable } = data.tables;\n\t\tconst fullSlugColumn = prefixGeneratedColName(\n\t\t\tconstants.fields.fullSlug.key,\n\t\t);\n\n\t\tconst updateFullSlugsPromises = [];\n\n\t\tfor (const doc of data.docFullSlugs) {\n\t\t\tfor (const [locale, fullSlug] of Object.entries(doc.fullSlugs)) {\n\t\t\t\tupdateFullSlugsPromises.push(\n\t\t\t\t\tcontext.db.client\n\t\t\t\t\t\t.updateTable(fieldsTable)\n\t\t\t\t\t\t.set({ [fullSlugColumn]: normalizePathValue(fullSlug) })\n\t\t\t\t\t\t.where((eb) =>\n\t\t\t\t\t\t\teb.exists(\n\t\t\t\t\t\t\t\teb\n\t\t\t\t\t\t\t\t\t.selectFrom(versionTable)\n\t\t\t\t\t\t\t\t\t.selectAll()\n\t\t\t\t\t\t\t\t\t.where(`${versionTable}.id`, \"=\", doc.versionId)\n\t\t\t\t\t\t\t\t\t.where(`${versionTable}.document_id`, \"=\", doc.documentId)\n\t\t\t\t\t\t\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.where(\"document_version_id\", \"=\", doc.versionId)\n\t\t\t\t\t\t.where(\"locale\", \"=\", locale)\n\t\t\t\t\t\t.execute(),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tawait Promise.all(updateFullSlugsPromises);\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t} catch (_error) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\"server:plugin.pages.full.slug.children.update.failed\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n};\n\nexport default updateFullSlugFields;\n","import { copy, prefixGeneratedColName } from \"@lucidcms/core/plugin\";\nimport type {\n\tDocumentVersionType,\n\tLucidBrickTableName,\n\tLucidVersionTableName,\n\tServiceFn,\n} from \"@lucidcms/core/types\";\nimport constants from \"../constants.js\";\nimport normalizePathValue from \"../utils/normalize-path-value.js\";\n\n/**\n *  Update the slug fields with the computed value\n */\nconst updateSlugFields: ServiceFn<\n\t[\n\t\t{\n\t\t\tdocSlugs: Array<{\n\t\t\t\tdocumentId: number;\n\t\t\t\tversionId: number;\n\t\t\t\tslugs: Record<string, string | null>;\n\t\t\t}>;\n\t\t\tversionType: Exclude<DocumentVersionType, \"revision\">;\n\t\t\ttables: {\n\t\t\t\tdocumentFields: LucidBrickTableName;\n\t\t\t\tversion: LucidVersionTableName;\n\t\t\t};\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\ttry {\n\t\tconst { documentFields: fieldsTable, version: versionTable } = data.tables;\n\t\tconst slugColumn = prefixGeneratedColName(constants.fields.slug.key);\n\n\t\tconst updateSlugsPromises = [];\n\n\t\tfor (const doc of data.docSlugs) {\n\t\t\tfor (const [locale, slug] of Object.entries(doc.slugs)) {\n\t\t\t\tupdateSlugsPromises.push(\n\t\t\t\t\tcontext.db.client\n\t\t\t\t\t\t.updateTable(fieldsTable)\n\t\t\t\t\t\t.set({ [slugColumn]: normalizePathValue(slug) })\n\t\t\t\t\t\t.where((eb) =>\n\t\t\t\t\t\t\teb.exists(\n\t\t\t\t\t\t\t\teb\n\t\t\t\t\t\t\t\t\t.selectFrom(versionTable)\n\t\t\t\t\t\t\t\t\t.selectAll()\n\t\t\t\t\t\t\t\t\t.where(`${versionTable}.id`, \"=\", doc.versionId)\n\t\t\t\t\t\t\t\t\t.where(`${versionTable}.document_id`, \"=\", doc.documentId)\n\t\t\t\t\t\t\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.where(\"document_version_id\", \"=\", doc.versionId)\n\t\t\t\t\t\t.where(\"locale\", \"=\", locale)\n\t\t\t\t\t\t.execute(),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tawait Promise.all(updateSlugsPromises);\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t} catch (_error) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\"server:plugin.pages.full.slug.children.update.failed\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n};\n\nexport default updateSlugFields;\n","import type { LucidHookDocuments } from \"@lucidcms/core/types\";\nimport constants from \"../../constants.js\";\nimport type { PluginOptionsInternal } from \"../../types/types.js\";\nimport {\n\tconstructChildFullSlug,\n\tgetDescendantFields,\n\tgetTargetCollection,\n\tupdateFullSlugFields,\n} from \"../index.js\";\n\nconst afterUpsertHandler =\n\t(\n\t\toptions: PluginOptionsInternal,\n\t): LucidHookDocuments<\"afterUpsert\">[\"handler\"] =>\n\tasync (context, data) => {\n\t\t// ----------------------------------------------------------------\n\t\t// Validation / Setup\n\t\tconst targetCollectionRes = getTargetCollection({\n\t\t\toptions,\n\t\t\tcollectionKey: data.meta.collectionKey,\n\t\t});\n\t\tif (targetCollectionRes.error) {\n\t\t\t//* early return as doesnt apply to the current collection\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\t// ----------------------------------------------------------------\n\t\t// Build and store fullSlugs\n\t\tconst descendantsRes = await getDescendantFields(context, {\n\t\t\tids: [data.data.documentId],\n\t\t\tversionType: data.data.versionType,\n\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\ttables: data.meta.collectionTableNames,\n\t\t});\n\t\tif (descendantsRes.error) return descendantsRes;\n\n\t\t// exit early - nothing to do\n\t\tif (descendantsRes.data.length === 0) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst currentFullSlugField = data.data.fields.find((field) => {\n\t\t\treturn field.key === constants.fields.fullSlug.key;\n\t\t});\n\t\tif (!currentFullSlugField) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst docFullSlugsRes = constructChildFullSlug({\n\t\t\tdescendants: descendantsRes.data,\n\t\t\tlocalization: context.config.localization,\n\t\t\tparentFullSlugField: currentFullSlugField,\n\t\t\tcollection: targetCollectionRes.data,\n\t\t});\n\t\tif (docFullSlugsRes.error) return docFullSlugsRes;\n\n\t\tconst updateFullSlugFieldsRes = await updateFullSlugFields(context, {\n\t\t\tdocFullSlugs: docFullSlugsRes.data,\n\t\t\tversionType: data.data.versionType,\n\t\t\ttables: data.meta.collectionTableNames,\n\t\t});\n\t\tif (updateFullSlugFieldsRes.error) return updateFullSlugFieldsRes;\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t};\n\nexport default afterUpsertHandler;\n","import { copy } from \"@lucidcms/core/plugin\";\nimport type {\n\tFieldError,\n\tFieldInputSchema,\n\tServiceResponse,\n} from \"@lucidcms/core/types\";\n\n/**\n *  Returns an error if the required fields do not exist\n */\nconst checkFieldsExist = (data: {\n\tfields: {\n\t\tslug: FieldInputSchema | undefined;\n\t\tparentPage: FieldInputSchema | undefined;\n\t\tfullSlug: FieldInputSchema | undefined;\n\t};\n}): Awaited<\n\tServiceResponse<{\n\t\tslug: FieldInputSchema;\n\t\tparentPage: FieldInputSchema;\n\t\tfullSlug: FieldInputSchema;\n\t}>\n> => {\n\tconst fieldErrors: FieldError[] = [];\n\n\tif (data.fields.slug === undefined) {\n\t\tfieldErrors.push({\n\t\t\tkey: \"slug\",\n\t\t\tlocaleCode: null,\n\t\t\tmessage: copy(\"server:plugin.pages.fields.validation.required\"),\n\t\t});\n\t}\n\tif (data.fields.parentPage === undefined) {\n\t\tfieldErrors.push({\n\t\t\tkey: \"parentPage\",\n\t\t\tlocaleCode: null,\n\t\t\tmessage: copy(\"server:plugin.pages.fields.validation.required\"),\n\t\t});\n\t}\n\tif (data.fields.fullSlug === undefined) {\n\t\tfieldErrors.push({\n\t\t\tkey: \"fullSlug\",\n\t\t\tlocaleCode: null,\n\t\t\tmessage: copy(\"server:plugin.pages.fields.validation.required\"),\n\t\t});\n\t}\n\n\tif (fieldErrors.length) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tmessage: copy(\"server:plugin.pages.fields.required.missing\"),\n\t\t\t\tstatus: 400,\n\t\t\t\terrors: {\n\t\t\t\t\tfields: fieldErrors,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: {\n\t\t\tslug: data.fields.slug as FieldInputSchema,\n\t\t\tparentPage: data.fields.parentPage as FieldInputSchema,\n\t\t\tfullSlug: data.fields.fullSlug as FieldInputSchema,\n\t\t},\n\t};\n};\n\nexport default checkFieldsExist;\n","import { copy, prefixGeneratedColName } from \"@lucidcms/core/plugin\";\nimport type {\n\tCollectionTableNames,\n\tDocumentVersionType,\n\tFieldInputSchema,\n\tServiceFn,\n} from \"@lucidcms/core/types\";\nimport constants from \"../../constants.js\";\nimport { applyDocumentVersionTenantScope } from \"../../utils/apply-tenant-scope.js\";\nimport getParentPageId from \"../../utils/get-parent-page-id.js\";\nimport getParentPageRelationTable from \"../../utils/get-parent-page-relation-table.js\";\n\n/**\n *  Recursively checks all parent pages for a circular reference and errors in that case\n */\nconst checkCircularParents: ServiceFn<\n\t[\n\t\t{\n\t\t\tdefaultLocale: string;\n\t\t\tdocumentId: number;\n\t\t\tversionType: Exclude<DocumentVersionType, \"revision\">;\n\t\t\tcollectionKey: string;\n\t\t\ttenantKey: string | null;\n\t\t\tfields: {\n\t\t\t\tparentPage: FieldInputSchema;\n\t\t\t};\n\t\t\ttables: CollectionTableNames;\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\ttry {\n\t\tconst parentPageId = getParentPageId(data.fields.parentPage);\n\n\t\tif (!data.documentId || parentPageId === null) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst { document: documentTable, version: versionTable } = data.tables;\n\t\tconst parentPageField = prefixGeneratedColName(\"document_id\");\n\t\tconst parentPageTableRes = getParentPageRelationTable(\n\t\t\tdata.collectionKey,\n\t\t\tcontext.config.db.config.tableNameByteLimit,\n\t\t);\n\t\tif (parentPageTableRes.error) return parentPageTableRes;\n\t\tconst parentPageTable = parentPageTableRes.data;\n\n\t\tconst result = await context.db.client\n\t\t\t.withRecursive(\"ancestors\", (db) =>\n\t\t\t\tapplyDocumentVersionTenantScope(\n\t\t\t\t\tdb\n\t\t\t\t\t\t.selectFrom(parentPageTable)\n\t\t\t\t\t\t.innerJoin(\n\t\t\t\t\t\t\tversionTable,\n\t\t\t\t\t\t\t`${versionTable}.id`,\n\t\t\t\t\t\t\t`${parentPageTable}.document_version_id`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.select([\n\t\t\t\t\t\t\t`${versionTable}.document_id as current_id`,\n\t\t\t\t\t\t\t`${parentPageTable}.${parentPageField} as parent_id`,\n\t\t\t\t\t\t])\n\t\t\t\t\t\t.where(`${parentPageTable}.locale`, \"=\", data.defaultLocale)\n\t\t\t\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType)\n\t\t\t\t\t\t.where(`${versionTable}.document_id`, \"=\", parentPageId),\n\t\t\t\t\t{\n\t\t\t\t\t\ttenantKey: data.tenantKey,\n\t\t\t\t\t\tdocumentTable,\n\t\t\t\t\t\tversionTable,\n\t\t\t\t\t},\n\t\t\t\t).unionAll(\n\t\t\t\t\tapplyDocumentVersionTenantScope(\n\t\t\t\t\t\tdb\n\t\t\t\t\t\t\t.selectFrom(parentPageTable)\n\t\t\t\t\t\t\t.innerJoin(\n\t\t\t\t\t\t\t\tversionTable,\n\t\t\t\t\t\t\t\t`${versionTable}.id`,\n\t\t\t\t\t\t\t\t`${parentPageTable}.document_version_id`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.innerJoin(\n\t\t\t\t\t\t\t\t\"ancestors\",\n\t\t\t\t\t\t\t\t\"ancestors.parent_id\",\n\t\t\t\t\t\t\t\t`${versionTable}.document_id`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.select([\n\t\t\t\t\t\t\t\t`${versionTable}.document_id as current_id`,\n\t\t\t\t\t\t\t\t`${parentPageTable}.${parentPageField} as parent_id`,\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t.where(`${parentPageTable}.locale`, \"=\", data.defaultLocale)\n\t\t\t\t\t\t\t.where(`${versionTable}.type`, \"=\", data.versionType),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttenantKey: data.tenantKey,\n\t\t\t\t\t\t\tdocumentTable,\n\t\t\t\t\t\t\tversionTable,\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.selectFrom(\"ancestors\")\n\t\t\t.select(\"parent_id\")\n\t\t\t.where(\"parent_id\", \"=\", data.documentId)\n\t\t\t.executeTakeFirst();\n\n\t\tif (result) {\n\t\t\treturn {\n\t\t\t\terror: {\n\t\t\t\t\ttype: \"basic\",\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tmessage: copy(\"server:plugin.pages.parents.circular\"),\n\t\t\t\t\terrors: {\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey: constants.fields.parentPage.key,\n\t\t\t\t\t\t\t\tlocaleCode: data.defaultLocale, //* parentPage doesnt use translations so always use default locale\n\t\t\t\t\t\t\t\tmessage: copy(\"server:plugin.pages.parents.circular\"),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t} catch (_error) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\"server:plugin.pages.parents.circular.check.failed\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n};\n\nexport default checkCircularParents;\n","import type { CollectionBuilder } from \"@lucidcms/core\";\nimport { copy } from \"@lucidcms/core/plugin\";\nimport type { ErrorCopy, ServiceFn } from \"@lucidcms/core/types\";\n\ntype Translate = Parameters<ServiceFn<[], undefined>>[0][\"translate\"];\ntype UniqueFieldLabelSource = {\n\tkey: string;\n};\n\nexport const formatUniqueFieldList = (fields: string[]) => {\n\treturn fields.filter((field) => field.length > 0).join(\", \");\n};\n\nexport const resolveUniqueFieldLabel = (data: {\n\ttranslate: Translate;\n\tcollection: CollectionBuilder;\n\tfield: UniqueFieldLabelSource;\n}) => {\n\tconst label = data.collection.fields.get(data.field.key)?.details?.label;\n\tif (typeof label === \"string\") return label.trim() || data.field.key;\n\n\tconst translatedLabel = label ? data.translate(label) : undefined;\n\treturn translatedLabel?.trim() || data.field.key;\n};\n\nconst getDuplicateRouteMessage = (data: {\n\ttranslate: Translate;\n\tcollectionInstance: CollectionBuilder;\n\tuniqueFields: UniqueFieldLabelSource[];\n\tduplicateMessage?: ErrorCopy;\n}) => {\n\tif (data.duplicateMessage) return data.duplicateMessage;\n\n\tif (data.uniqueFields.length === 0) {\n\t\treturn copy(\"server:plugin.pages.full.slug.duplicate\");\n\t}\n\n\treturn copy(\"server:plugin.pages.full.slug.duplicate.with.fields\", {\n\t\tdata: {\n\t\t\tfields: formatUniqueFieldList(\n\t\t\t\tdata.uniqueFields.map((field) =>\n\t\t\t\t\tresolveUniqueFieldLabel({\n\t\t\t\t\t\ttranslate: data.translate,\n\t\t\t\t\t\tcollection: data.collectionInstance,\n\t\t\t\t\t\tfield,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t\t},\n\t});\n};\n\nexport default getDuplicateRouteMessage;\n","import type {\n\tProjectedFullSlug,\n\tRouteUniquenessConflict,\n\tRouteUniquenessItem,\n} from \"../types/types.js\";\nimport normalizePathValue from \"./normalize-path-value.js\";\n\n/** Serializes unique values with stable object key ordering for route keys. */\nconst stableStringify = (value: unknown): string => {\n\tif (value === undefined || value === null) return \"null\";\n\tif (value instanceof Date) return JSON.stringify(value.toISOString());\n\tif (typeof value !== \"object\") return JSON.stringify(value);\n\tif (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\n\tconst object = value as Record<string, unknown>;\n\treturn `{${Object.keys(object)\n\t\t.sort()\n\t\t.map((key) => `${JSON.stringify(key)}:${stableStringify(object[key])}`)\n\t\t.join(\",\")}}`;\n};\n\n/** Combines locale, fullSlug, and unique values into an exact collision key. */\nconst routeKey = (item: RouteUniquenessItem) => {\n\treturn [item.locale, item.fullSlug, stableStringify(item.uniqueValues)].join(\n\t\t\"::\",\n\t);\n};\n\n/** Flattens projected per-locale fullSlugs into comparable route items. */\nexport const buildRouteUniquenessItems = (data: {\n\tprojectedFullSlugs: ProjectedFullSlug[];\n\tdefaultLocale: string;\n}): RouteUniquenessItem[] => {\n\tconst items: RouteUniquenessItem[] = [];\n\n\tfor (const projected of data.projectedFullSlugs) {\n\t\tfor (const [locale, fullSlug] of Object.entries(projected.fullSlugs)) {\n\t\t\tconst normalizedFullSlug = normalizePathValue(fullSlug);\n\t\t\tif (typeof normalizedFullSlug !== \"string\") continue;\n\n\t\t\titems.push({\n\t\t\t\tdocumentId: projected.documentId,\n\t\t\t\tversionId: projected.versionId,\n\t\t\t\tlocale,\n\t\t\t\tfullSlug: normalizedFullSlug,\n\t\t\t\tuniqueValues:\n\t\t\t\t\tprojected.uniqueValues?.[locale] ??\n\t\t\t\t\tprojected.uniqueValues?.[data.defaultLocale] ??\n\t\t\t\t\t{},\n\t\t\t});\n\t\t}\n\t}\n\n\treturn items;\n};\n\n/** Finds duplicate routes within the set we are about to write. */\nexport const findProjectedRouteDuplicates = (\n\titems: RouteUniquenessItem[],\n): RouteUniquenessConflict[] => {\n\tconst seen = new Map<string, RouteUniquenessItem>();\n\tconst conflicts: RouteUniquenessConflict[] = [];\n\n\tfor (const item of items) {\n\t\tconst key = routeKey(item);\n\t\tif (seen.has(key)) {\n\t\t\tconflicts.push({\n\t\t\t\tlocale: item.locale,\n\t\t\t\tfullSlug: item.fullSlug,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tseen.set(key, item);\n\t}\n\n\treturn conflicts;\n};\n\n/** Finds projected routes that already exist in stored route items. */\nexport const findExistingRouteCollisions = (data: {\n\tprojectedItems: RouteUniquenessItem[];\n\texistingItems: RouteUniquenessItem[];\n}): RouteUniquenessConflict[] => {\n\tconst projectedByKey = new Map<string, RouteUniquenessItem>();\n\tfor (const item of data.projectedItems) {\n\t\tprojectedByKey.set(routeKey(item), item);\n\t}\n\n\tconst conflicts: RouteUniquenessConflict[] = [];\n\tfor (const item of data.existingItems) {\n\t\tconst projected = projectedByKey.get(routeKey(item));\n\t\tif (!projected) continue;\n\n\t\tconflicts.push({\n\t\t\tlocale: projected.locale,\n\t\t\tfullSlug: projected.fullSlug,\n\t\t});\n\t}\n\n\treturn conflicts;\n};\n","import type { CollectionBuilder } from \"@lucidcms/core\";\nimport {\n\tbuildTableName,\n\tcopy,\n\tprefixGeneratedColName,\n} from \"@lucidcms/core/plugin\";\nimport type {\n\tConfig,\n\tFieldInputSchema,\n\tLucidBrickTableName,\n\tServiceResponse,\n} from \"@lucidcms/core/types\";\nimport type { CollectionConfig, RouteUniqueValues } from \"../../types/types.js\";\n\nconst columnBackedFieldTypes = new Set([\n\t\"text\",\n\t\"textarea\",\n\t\"select\",\n\t\"number\",\n\t\"datetime\",\n]);\n\nconst relationBackedFieldTypes = new Set([\"relation\", \"media\", \"user\"]);\n\nconst relationFieldTableTypes = {\n\trelation: \"cf_relation\",\n\tmedia: \"cf_media\",\n\tuser: \"cf_user\",\n} as const;\n\nconst relationFieldValueColumns = {\n\trelation: [\n\t\tprefixGeneratedColName(\"collection_key\"),\n\t\tprefixGeneratedColName(\"document_id\"),\n\t],\n\tmedia: [prefixGeneratedColName(\"media_id\")],\n\tuser: [prefixGeneratedColName(\"user_id\")],\n} as const;\n\nexport type RelationUniqueFieldType = keyof typeof relationFieldTableTypes;\n\ntype BaseUniqueField = {\n\tkey: string;\n\tlocalized: boolean;\n};\n\nexport type ColumnUniqueField = BaseUniqueField & {\n\tstorage: \"column\";\n\tcolumn: string;\n};\n\nexport type RelationUniqueField = BaseUniqueField & {\n\tstorage: \"relation-table\";\n\tfieldType: RelationUniqueFieldType;\n\ttable: LucidBrickTableName;\n\tvalueColumns: readonly `_${string}`[];\n};\n\nexport type UniqueField = ColumnUniqueField | RelationUniqueField;\n\nexport type UniqueFieldQueryRow = {\n\tdocument_id: number;\n\tdocument_version_id: number;\n\tlocale: string;\n\t[key: string]: unknown;\n};\n\nexport type RelationUniqueFieldQueryRow = {\n\tdocument_version_id: number;\n\tlocale: string;\n\tposition: number;\n\t[key: string]: unknown;\n};\n\nexport type RelationUniqueValueMap = Map<string, unknown[]>;\n\n/** Builds stable SQL aliases for selected unique field column values. */\nexport const uniqueFieldAlias = (index: number) => `unique_field_${index}`;\n\nexport const isColumnUniqueField = (\n\tfield: UniqueField,\n): field is ColumnUniqueField => field.storage === \"column\";\n\nexport const isRelationUniqueField = (\n\tfield: UniqueField,\n): field is RelationUniqueField => field.storage === \"relation-table\";\n\nconst isRelationBackedFieldType = (\n\ttype: string,\n): type is RelationUniqueFieldType => relationBackedFieldTypes.has(type);\n\nconst buildRelationFieldTable = (data: {\n\tcollectionKey: string;\n\tfieldKey: string;\n\tfieldType: RelationUniqueFieldType;\n\ttableNameByteLimit: number | null;\n}): Awaited<ServiceResponse<LucidBrickTableName>> => {\n\tconst tableNameRes = buildTableName<LucidBrickTableName>(\n\t\trelationFieldTableTypes[data.fieldType],\n\t\t{\n\t\t\tcollection: data.collectionKey,\n\t\t\tfieldPath: [data.fieldKey],\n\t\t},\n\t\tdata.tableNameByteLimit,\n\t);\n\tif (tableNameRes.error) {\n\t\treturn {\n\t\t\terror: tableNameRes.error,\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: tableNameRes.data.name,\n\t};\n};\n\n/** Resolves and validates the configured top-level fields used with unique.fields. */\nexport const getUniqueFields = (\n\tcollection: CollectionBuilder,\n\tcollectionConfig: CollectionConfig,\n\ttableNameByteLimit: number | null,\n): Awaited<ServiceResponse<UniqueField[]>> => {\n\tconst uniqueFieldKeys =\n\t\tcollectionConfig.unique === true || collectionConfig.unique === false\n\t\t\t? []\n\t\t\t: (collectionConfig.unique.fields ?? []);\n\tconst uniqueFields: UniqueField[] = [];\n\n\tfor (const fieldKey of uniqueFieldKeys) {\n\t\tconst field = collection.fields.get(fieldKey);\n\t\tif (!field) {\n\t\t\treturn {\n\t\t\t\terror: {\n\t\t\t\t\ttype: \"basic\",\n\t\t\t\t\tstatus: 500,\n\t\t\t\t\tmessage: copy(\"server:plugin.pages.unique.field.invalid\", {\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tfield: fieldKey,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst localized =\n\t\t\tcollection.getData.localized === true && field.localizedEnabled === true;\n\n\t\tif (columnBackedFieldTypes.has(field.type)) {\n\t\t\tuniqueFields.push({\n\t\t\t\tkey: fieldKey,\n\t\t\t\tstorage: \"column\",\n\t\t\t\tcolumn: prefixGeneratedColName(fieldKey),\n\t\t\t\tlocalized,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isRelationBackedFieldType(field.type)) {\n\t\t\tconst relationTableRes = buildRelationFieldTable({\n\t\t\t\tcollectionKey: collectionConfig.key,\n\t\t\t\tfieldKey,\n\t\t\t\tfieldType: field.type,\n\t\t\t\ttableNameByteLimit,\n\t\t\t});\n\t\t\tif (relationTableRes.error) return relationTableRes;\n\n\t\t\tuniqueFields.push({\n\t\t\t\tkey: fieldKey,\n\t\t\t\tstorage: \"relation-table\",\n\t\t\t\tfieldType: field.type,\n\t\t\t\ttable: relationTableRes.data,\n\t\t\t\tvalueColumns: relationFieldValueColumns[field.type],\n\t\t\t\tlocalized,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\"server:plugin.pages.unique.field.invalid\", {\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tfield: fieldKey,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: uniqueFields,\n\t};\n};\n\nconst compareRelationTargets = (\n\ta: { collectionKey: string; id: number },\n\tb: { collectionKey: string; id: number },\n) => {\n\tconst collectionCompare = a.collectionKey.localeCompare(b.collectionKey);\n\tif (collectionCompare !== 0) return collectionCompare;\n\n\treturn a.id - b.id;\n};\n\nconst normalizeRelationIds = (value: unknown): number[] => {\n\tif (!Array.isArray(value)) return [];\n\n\treturn value\n\t\t.filter((item): item is number => {\n\t\t\treturn typeof item === \"number\" && Number.isFinite(item);\n\t\t})\n\t\t.sort((a, b) => a - b);\n};\n\nconst normalizeRelationTargets = (\n\tvalue: unknown,\n): Array<{ collectionKey: string; id: number }> => {\n\tif (!Array.isArray(value)) return [];\n\n\treturn value\n\t\t.filter(\n\t\t\t(item): item is { collectionKey: string; id: number } =>\n\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\titem !== null &&\n\t\t\t\t\"collectionKey\" in item &&\n\t\t\t\t\"id\" in item &&\n\t\t\t\ttypeof item.collectionKey === \"string\" &&\n\t\t\t\ttypeof item.id === \"number\" &&\n\t\t\t\tNumber.isFinite(item.id),\n\t\t)\n\t\t.map((item) => ({\n\t\t\tcollectionKey: item.collectionKey,\n\t\t\tid: item.id,\n\t\t}))\n\t\t.sort(compareRelationTargets);\n};\n\nexport const normalizeUniqueFieldValue = (\n\tfield: UniqueField,\n\tvalue: unknown,\n) => {\n\tif (isColumnUniqueField(field)) return value ?? null;\n\tif (field.fieldType === \"relation\") return normalizeRelationTargets(value);\n\n\treturn normalizeRelationIds(value);\n};\n\n/** Reads the field value that applies to a specific locale. */\nconst getUniqueFieldValueForLocale = (data: {\n\tfield: FieldInputSchema | undefined;\n\tlocaleCode: string;\n\tdefaultLocale: string;\n\tlocalized: boolean;\n}) => {\n\tif (!data.field) return null;\n\n\tif (data.localized) {\n\t\tif (data.field.translations) {\n\t\t\treturn data.field.translations[data.localeCode] ?? null;\n\t\t}\n\t\tif (data.localeCode === data.defaultLocale) {\n\t\t\treturn data.field.value ?? null;\n\t\t}\n\t\treturn null;\n\t}\n\n\tif (data.field.value !== undefined) return data.field.value;\n\tif (data.field.translations) {\n\t\treturn data.field.translations[data.defaultLocale] ?? null;\n\t}\n\treturn null;\n};\n\n/** Builds locale-keyed unique values from the fields currently being saved. */\nexport const getUniqueValuesFromFields = (data: {\n\tfields: FieldInputSchema[];\n\tlocalization: Config[\"localization\"];\n\tuniqueFields: UniqueField[];\n}): RouteUniqueValues => {\n\tconst values: RouteUniqueValues = {};\n\n\tfor (const locale of data.localization.locales) {\n\t\tconst localeValues: Record<string, unknown> = {};\n\n\t\tfor (const uniqueField of data.uniqueFields) {\n\t\t\tconst field = data.fields.find((f) => f.key === uniqueField.key);\n\t\t\tlocaleValues[uniqueField.key] = normalizeUniqueFieldValue(\n\t\t\t\tuniqueField,\n\t\t\t\tgetUniqueFieldValueForLocale({\n\t\t\t\t\tfield,\n\t\t\t\t\tlocaleCode: locale.code,\n\t\t\t\t\tdefaultLocale: data.localization.defaultLocale,\n\t\t\t\t\tlocalized: uniqueField.localized,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tvalues[locale.code] = localeValues;\n\t}\n\n\treturn values;\n};\n\nexport const relationUniqueValueKey = (data: {\n\tversionId: number;\n\tlocaleCode: string;\n\tfieldKey: string;\n}) => `${data.versionId}:${data.localeCode}:${data.fieldKey}`;\n\nconst getRelationRowValue = (\n\tfield: RelationUniqueField,\n\trow: RelationUniqueFieldQueryRow,\n) => {\n\tif (field.fieldType === \"relation\") {\n\t\tconst collectionKey = row[prefixGeneratedColName(\"collection_key\")];\n\t\tconst id = row[prefixGeneratedColName(\"document_id\")];\n\n\t\tif (typeof collectionKey !== \"string\") return null;\n\t\tif (typeof id !== \"number\" || !Number.isFinite(id)) return null;\n\n\t\treturn {\n\t\t\tcollectionKey,\n\t\t\tid,\n\t\t};\n\t}\n\n\tconst idColumn =\n\t\tfield.fieldType === \"media\"\n\t\t\t? prefixGeneratedColName(\"media_id\")\n\t\t\t: prefixGeneratedColName(\"user_id\");\n\tconst id = row[idColumn];\n\tif (typeof id !== \"number\" || !Number.isFinite(id)) return null;\n\n\treturn id;\n};\n\nexport const relationRowsToUniqueValueMap = (data: {\n\tfield: RelationUniqueField;\n\trows: RelationUniqueFieldQueryRow[];\n}): RelationUniqueValueMap => {\n\tconst groupedRows = new Map<string, unknown[]>();\n\n\tfor (const row of data.rows) {\n\t\tconst value = getRelationRowValue(data.field, row);\n\t\tif (value === null) continue;\n\n\t\tconst key = relationUniqueValueKey({\n\t\t\tversionId: row.document_version_id,\n\t\t\tlocaleCode: row.locale,\n\t\t\tfieldKey: data.field.key,\n\t\t});\n\t\tgroupedRows.set(key, [...(groupedRows.get(key) ?? []), value]);\n\t}\n\n\tconst values = new Map<string, unknown[]>();\n\tfor (const [key, rowValues] of groupedRows) {\n\t\tvalues.set(\n\t\t\tkey,\n\t\t\tnormalizeUniqueFieldValue(data.field, rowValues) as unknown[],\n\t\t);\n\t}\n\n\treturn values;\n};\n\nexport const mergeRelationUniqueValueMaps = (\n\tmaps: RelationUniqueValueMap[],\n): RelationUniqueValueMap => {\n\tconst merged = new Map<string, unknown[]>();\n\tfor (const map of maps) {\n\t\tfor (const [key, value] of map) {\n\t\t\tmerged.set(key, value);\n\t\t}\n\t}\n\n\treturn merged;\n};\n\nconst getRelationUniqueValue = (data: {\n\tfield: RelationUniqueField;\n\trelationValues: RelationUniqueValueMap;\n\tversionId: number;\n\tlocaleCode: string;\n\tdefaultLocale: string;\n}) => {\n\tconst localeCode = data.field.localized\n\t\t? data.localeCode\n\t\t: data.defaultLocale;\n\n\treturn (\n\t\tdata.relationValues.get(\n\t\t\trelationUniqueValueKey({\n\t\t\t\tversionId: data.versionId,\n\t\t\t\tlocaleCode,\n\t\t\t\tfieldKey: data.field.key,\n\t\t\t}),\n\t\t) ?? []\n\t);\n};\n\n/** Maps selected unique field aliases and relation-table rows to configured field keys. */\nexport const rowToUniqueValues = (data: {\n\trow: UniqueFieldQueryRow | undefined;\n\tuniqueFields: UniqueField[];\n\trelationValues: RelationUniqueValueMap;\n\tversionId: number;\n\tlocaleCode: string;\n\tdefaultLocale: string;\n}) => {\n\tconst values: Record<string, unknown> = {};\n\n\tfor (const [index, field] of data.uniqueFields.entries()) {\n\t\tvalues[field.key] = isColumnUniqueField(field)\n\t\t\t? normalizeUniqueFieldValue(field, data.row?.[uniqueFieldAlias(index)])\n\t\t\t: getRelationUniqueValue({\n\t\t\t\t\tfield,\n\t\t\t\t\trelationValues: data.relationValues,\n\t\t\t\t\tversionId: data.versionId,\n\t\t\t\t\tlocaleCode: data.localeCode,\n\t\t\t\t\tdefaultLocale: data.defaultLocale,\n\t\t\t\t});\n\t}\n\n\treturn values;\n};\n","import type { CollectionBuilder } from \"@lucidcms/core\";\nimport { copy, prefixGeneratedColName } from \"@lucidcms/core/plugin\";\nimport type {\n\tCollectionTableNames,\n\tDocumentVersionType,\n\tErrorCopy,\n\tFieldError,\n\tFieldInputSchema,\n\tServiceFn,\n\tServiceResponse,\n} from \"@lucidcms/core/types\";\nimport { sql } from \"kysely\";\nimport constants from \"../../constants.js\";\nimport type {\n\tCollectionConfig,\n\tProjectedFullSlug,\n\tRouteUniquenessItem,\n\tRouteUniqueValues,\n} from \"../../types/types.js\";\nimport applyTenantScope from \"../../utils/apply-tenant-scope.js\";\nimport getDuplicateRouteMessage from \"../../utils/duplicate-route-message.js\";\nimport normalizePathValue from \"../../utils/normalize-path-value.js\";\nimport {\n\tbuildRouteUniquenessItems,\n\tfindExistingRouteCollisions,\n\tfindProjectedRouteDuplicates,\n} from \"../../utils/route-uniqueness.js\";\nimport {\n\tgetUniqueFields,\n\tgetUniqueValuesFromFields,\n\tisColumnUniqueField,\n\tisRelationUniqueField,\n\tmergeRelationUniqueValueMaps,\n\ttype RelationUniqueFieldQueryRow,\n\ttype RelationUniqueValueMap,\n\trelationRowsToUniqueValueMap,\n\trowToUniqueValues,\n\ttype UniqueField,\n\ttype UniqueFieldQueryRow,\n\tuniqueFieldAlias,\n} from \"./fullslug-unique-fields.js\";\n\ntype ServiceContext = Parameters<ServiceFn<[], undefined>>[0];\n\n/** Reads generated relation-table rows for relation-backed unique fields. */\nconst getStoredRelationUniqueValues = async (\n\tcontext: ServiceContext,\n\tdata: {\n\t\tuniqueFields: UniqueField[];\n\t\tversionIds: number[];\n\t\tlocaleValues: string[];\n\t\tdefaultLocale: string;\n\t},\n): Promise<RelationUniqueValueMap> => {\n\tconst relationFields = data.uniqueFields.filter(isRelationUniqueField);\n\tif (relationFields.length === 0 || data.versionIds.length === 0) {\n\t\treturn new Map();\n\t}\n\n\tconst relationValueMaps = await Promise.all(\n\t\trelationFields.map(async (field) => {\n\t\t\tconst locales = field.localized\n\t\t\t\t? data.localeValues\n\t\t\t\t: [data.defaultLocale];\n\n\t\t\tconst rows = (await context.db.client\n\t\t\t\t.selectFrom(field.table)\n\t\t\t\t.select([\n\t\t\t\t\t`${field.table}.document_version_id`,\n\t\t\t\t\t`${field.table}.locale`,\n\t\t\t\t\t`${field.table}.position`,\n\t\t\t\t\t...field.valueColumns.map((column) => `${field.table}.${column}`),\n\t\t\t\t])\n\t\t\t\t.where(`${field.table}.document_version_id`, \"in\", data.versionIds)\n\t\t\t\t.where(`${field.table}.locale`, \"in\", locales)\n\t\t\t\t.orderBy(`${field.table}.position`)\n\t\t\t\t.execute()) as RelationUniqueFieldQueryRow[];\n\n\t\t\treturn relationRowsToUniqueValueMap({\n\t\t\t\tfield,\n\t\t\t\trows,\n\t\t\t});\n\t\t}),\n\t);\n\n\treturn mergeRelationUniqueValueMaps(relationValueMaps);\n};\n\n/** Adds stored unique field values to projected routes before comparison. */\nconst ensureProjectedUniqueValues = async (\n\tcontext: ServiceContext,\n\tdata: {\n\t\tprojectedFullSlugs: ProjectedFullSlug[];\n\t\tuniqueFields: UniqueField[];\n\t\tdefaultLocale: string;\n\t\ttables: CollectionTableNames;\n\t},\n): ServiceResponse<ProjectedFullSlug[]> => {\n\tif (data.uniqueFields.length === 0) {\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: data.projectedFullSlugs.map((projected) => ({\n\t\t\t\t...projected,\n\t\t\t\tuniqueValues:\n\t\t\t\t\tprojected.uniqueValues ??\n\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\tObject.keys(projected.fullSlugs).map((locale) => [locale, {}]),\n\t\t\t\t\t),\n\t\t\t})),\n\t\t};\n\t}\n\n\tconst versionIds = [\n\t\t...new Set(\n\t\t\tdata.projectedFullSlugs\n\t\t\t\t.filter((projected) => !projected.uniqueValues)\n\t\t\t\t.map((projected) => projected.versionId),\n\t\t),\n\t];\n\n\tconst rowsByVersionLocale = new Map<string, UniqueFieldQueryRow>();\n\tconst localeValues = [\n\t\t...new Set(\n\t\t\tdata.projectedFullSlugs.flatMap((projected) => [\n\t\t\t\t...Object.keys(projected.fullSlugs),\n\t\t\t\tdata.defaultLocale,\n\t\t\t]),\n\t\t),\n\t];\n\tlet relationValues: RelationUniqueValueMap = new Map();\n\n\tif (versionIds.length > 0) {\n\t\tconst { documentFields: fieldsTable, version: versionTable } = data.tables;\n\t\tconst defaultFieldsAlias = \"default_fields\";\n\t\tconst hasDefaultLocalePartition = data.uniqueFields.some(\n\t\t\t(field) => isColumnUniqueField(field) && !field.localized,\n\t\t);\n\t\trelationValues = await getStoredRelationUniqueValues(context, {\n\t\t\tuniqueFields: data.uniqueFields,\n\t\t\tversionIds,\n\t\t\tlocaleValues,\n\t\t\tdefaultLocale: data.defaultLocale,\n\t\t});\n\n\t\tconst query = context.db.client\n\t\t\t.selectFrom(fieldsTable)\n\t\t\t.innerJoin(\n\t\t\t\tversionTable,\n\t\t\t\t`${versionTable}.id`,\n\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t)\n\t\t\t.$if(hasDefaultLocalePartition, (qb) =>\n\t\t\t\tqb.leftJoin(`${fieldsTable} as ${defaultFieldsAlias}`, (join) =>\n\t\t\t\t\tjoin\n\t\t\t\t\t\t.onRef(\n\t\t\t\t\t\t\t`${defaultFieldsAlias}.document_version_id`,\n\t\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.on(`${defaultFieldsAlias}.locale`, \"=\", data.defaultLocale),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.select([\n\t\t\t\t`${versionTable}.document_id`,\n\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t\t`${fieldsTable}.locale`,\n\t\t\t])\n\t\t\t.select(\n\t\t\t\tdata.uniqueFields.flatMap((field, index) => {\n\t\t\t\t\tif (!isColumnUniqueField(field)) return [];\n\n\t\t\t\t\treturn [\n\t\t\t\t\t\tsql<unknown>`${sql.ref(\n\t\t\t\t\t\t\t`${field.localized ? fieldsTable : defaultFieldsAlias}.${\n\t\t\t\t\t\t\t\tfield.column\n\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t)}`.as(uniqueFieldAlias(index)),\n\t\t\t\t\t];\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.where(`${fieldsTable}.document_version_id`, \"in\", versionIds);\n\n\t\tconst rows = (await query.execute()) as UniqueFieldQueryRow[];\n\t\tfor (const row of rows) {\n\t\t\trowsByVersionLocale.set(`${row.document_version_id}:${row.locale}`, row);\n\t\t}\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: data.projectedFullSlugs.map((projected) => {\n\t\t\tif (projected.uniqueValues) return projected;\n\n\t\t\tconst uniqueValues: RouteUniqueValues = {};\n\t\t\tfor (const locale of Object.keys(projected.fullSlugs)) {\n\t\t\t\tconst row = rowsByVersionLocale.get(`${projected.versionId}:${locale}`);\n\t\t\t\tuniqueValues[locale] = rowToUniqueValues({\n\t\t\t\t\trow,\n\t\t\t\t\tuniqueFields: data.uniqueFields,\n\t\t\t\t\trelationValues,\n\t\t\t\t\tversionId: projected.versionId,\n\t\t\t\t\tlocaleCode: locale,\n\t\t\t\t\tdefaultLocale: data.defaultLocale,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...projected,\n\t\t\t\tuniqueValues,\n\t\t\t};\n\t\t}),\n\t};\n};\n\n/** Fetches existing routes that could collide with the projected fullSlugs. */\nconst getExistingRouteItems = async (\n\tcontext: ServiceContext,\n\tdata: {\n\t\tprojectedItems: RouteUniquenessItem[];\n\t\tuniqueFields: UniqueField[];\n\t\tversionType: Exclude<DocumentVersionType, \"revision\">;\n\t\tcollectionKey: string;\n\t\ttenantKey: string | null;\n\t\ttables: CollectionTableNames;\n\t\texcludeDocumentIds: number[];\n\t\tdefaultLocale: string;\n\t},\n): ServiceResponse<RouteUniquenessItem[]> => {\n\tif (data.projectedItems.length === 0) {\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: [],\n\t\t};\n\t}\n\n\tconst fullSlugValues = [\n\t\t...new Set(data.projectedItems.map((item) => item.fullSlug)),\n\t];\n\tconst localeValues = [\n\t\t...new Set(data.projectedItems.map((item) => item.locale)),\n\t];\n\n\tconst {\n\t\tdocument: documentTable,\n\t\tversion: versionTable,\n\t\tdocumentFields: fieldsTable,\n\t} = data.tables;\n\tconst fullSlugColumn = prefixGeneratedColName(constants.fields.fullSlug.key);\n\tconst defaultFieldsAlias = \"default_fields\";\n\tconst hasDefaultLocalePartition = data.uniqueFields.some(\n\t\t(field) => isColumnUniqueField(field) && !field.localized,\n\t);\n\n\tconst query = context.db.client\n\t\t.selectFrom(documentTable)\n\t\t.innerJoin(\n\t\t\tversionTable,\n\t\t\t// @ts-expect-error\n\t\t\t`${versionTable}.document_id`,\n\t\t\t`${documentTable}.id`,\n\t\t)\n\t\t.innerJoin(\n\t\t\tfieldsTable,\n\t\t\t// @ts-expect-error\n\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t`${versionTable}.id`,\n\t\t)\n\t\t.$if(hasDefaultLocalePartition, (qb) =>\n\t\t\t// @ts-expect-error\n\t\t\tqb.leftJoin(`${fieldsTable} as ${defaultFieldsAlias}`, (join) =>\n\t\t\t\tjoin\n\t\t\t\t\t.onRef(\n\t\t\t\t\t\t`${defaultFieldsAlias}.document_version_id`,\n\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t`${fieldsTable}.document_version_id`,\n\t\t\t\t\t)\n\t\t\t\t\t.on(`${defaultFieldsAlias}.locale`, \"=\", data.defaultLocale),\n\t\t\t),\n\t\t)\n\t\t// @ts-expect-error\n\t\t.select([\n\t\t\t`${documentTable}.id as document_id`,\n\t\t\t`${versionTable}.id as document_version_id`,\n\t\t\t`${fieldsTable}.locale`,\n\t\t\t`${fieldsTable}.${fullSlugColumn} as _fullSlug`,\n\t\t])\n\t\t.select(\n\t\t\tdata.uniqueFields.flatMap((field, index) => {\n\t\t\t\tif (!isColumnUniqueField(field)) return [];\n\n\t\t\t\treturn [\n\t\t\t\t\tsql<unknown>`${sql.ref(\n\t\t\t\t\t\t`${field.localized ? fieldsTable : defaultFieldsAlias}.${\n\t\t\t\t\t\t\tfield.column\n\t\t\t\t\t\t}`,\n\t\t\t\t\t)}`.as(uniqueFieldAlias(index)),\n\t\t\t\t];\n\t\t\t}),\n\t\t)\n\t\t// @ts-expect-error\n\t\t.where(({ eb, and }) =>\n\t\t\tand([\n\t\t\t\teb(\n\t\t\t\t\tsql<string>`lower(${sql.ref(`${fieldsTable}.${fullSlugColumn}`)})`,\n\t\t\t\t\t\"in\",\n\t\t\t\t\tfullSlugValues,\n\t\t\t\t),\n\t\t\t\teb(`${fieldsTable}.locale`, \"in\", localeValues),\n\t\t\t\teb(`${versionTable}.type`, \"=\", data.versionType),\n\t\t\t]),\n\t\t)\n\t\t.where(`${documentTable}.collection_key`, \"=\", data.collectionKey)\n\t\t.where(\n\t\t\t`${documentTable}.is_deleted`,\n\t\t\t\"=\",\n\t\t\tcontext.config.db.getDefault(\"boolean\", \"false\"),\n\t\t);\n\n\tconst filteredQuery =\n\t\tdata.excludeDocumentIds.length > 0\n\t\t\t? query.where(`${documentTable}.id`, \"not in\", data.excludeDocumentIds)\n\t\t\t: query;\n\n\tconst rows = (await applyTenantScope(filteredQuery, {\n\t\ttenantKey: data.tenantKey,\n\t\tcolumn: `${documentTable}.tenant_key`,\n\t}).execute()) as Array<\n\t\tUniqueFieldQueryRow & {\n\t\t\t_fullSlug: string | null;\n\t\t}\n\t>;\n\tconst existingVersionIds = [\n\t\t...new Set(rows.map((row) => row.document_version_id)),\n\t];\n\tconst relationValues = await getStoredRelationUniqueValues(context, {\n\t\tuniqueFields: data.uniqueFields,\n\t\tversionIds: existingVersionIds,\n\t\tlocaleValues: [...new Set([...localeValues, data.defaultLocale])],\n\t\tdefaultLocale: data.defaultLocale,\n\t});\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: rows.map((row) => ({\n\t\t\tdocumentId: row.document_id,\n\t\t\tversionId: row.document_version_id,\n\t\t\tlocale: row.locale,\n\t\t\tfullSlug: normalizePathValue(row._fullSlug) ?? \"\",\n\t\t\tuniqueValues: rowToUniqueValues({\n\t\t\t\trow,\n\t\t\t\tuniqueFields: data.uniqueFields,\n\t\t\t\trelationValues,\n\t\t\t\tversionId: row.document_version_id,\n\t\t\t\tlocaleCode: row.locale,\n\t\t\t\tdefaultLocale: data.defaultLocale,\n\t\t\t}),\n\t\t})),\n\t};\n};\n\n/** Checks projected fullSlug routes against themselves and existing routes. */\nconst checkFullSlugUniqueness: ServiceFn<\n\t[\n\t\t{\n\t\t\tcollection: CollectionConfig;\n\t\t\tcollectionInstance: CollectionBuilder;\n\t\t\tprojectedFullSlugs: ProjectedFullSlug[];\n\t\t\tversionType: Exclude<DocumentVersionType, \"revision\">;\n\t\t\tcollectionKey: string;\n\t\t\ttenantKey: string | null;\n\t\t\ttables: CollectionTableNames;\n\t\t\texcludeDocumentIds?: number[];\n\t\t\tinputFields?: {\n\t\t\t\tdocumentId: number;\n\t\t\t\tversionId: number;\n\t\t\t\tfields: FieldInputSchema[];\n\t\t\t};\n\t\t\tduplicateMessage?: ErrorCopy;\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\ttry {\n\t\tif (data.collection.unique === false) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst uniqueFieldsRes = getUniqueFields(\n\t\t\tdata.collectionInstance,\n\t\t\tdata.collection,\n\t\t\tcontext.config.db.config.tableNameByteLimit,\n\t\t);\n\t\tif (uniqueFieldsRes.error) return uniqueFieldsRes;\n\n\t\tconst projectedFullSlugs = data.projectedFullSlugs.map((projected) => {\n\t\t\tif (\n\t\t\t\t!data.inputFields ||\n\t\t\t\tprojected.documentId !== data.inputFields.documentId ||\n\t\t\t\tprojected.versionId !== data.inputFields.versionId\n\t\t\t) {\n\t\t\t\treturn projected;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...projected,\n\t\t\t\tuniqueValues: getUniqueValuesFromFields({\n\t\t\t\t\tfields: data.inputFields.fields,\n\t\t\t\t\tlocalization: context.config.localization,\n\t\t\t\t\tuniqueFields: uniqueFieldsRes.data,\n\t\t\t\t}),\n\t\t\t};\n\t\t});\n\n\t\tconst projectedWithUniqueValuesRes = await ensureProjectedUniqueValues(\n\t\t\tcontext,\n\t\t\t{\n\t\t\t\tprojectedFullSlugs,\n\t\t\t\tuniqueFields: uniqueFieldsRes.data,\n\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\ttables: data.tables,\n\t\t\t},\n\t\t);\n\t\tif (projectedWithUniqueValuesRes.error) return projectedWithUniqueValuesRes;\n\n\t\tconst projectedItems = buildRouteUniquenessItems({\n\t\t\tprojectedFullSlugs: projectedWithUniqueValuesRes.data,\n\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t});\n\t\tconst projectedDuplicates = findProjectedRouteDuplicates(projectedItems);\n\n\t\tif (projectedDuplicates.length > 0) {\n\t\t\tconst message = getDuplicateRouteMessage({\n\t\t\t\ttranslate: context.translate,\n\t\t\t\tcollectionInstance: data.collectionInstance,\n\t\t\t\tuniqueFields: uniqueFieldsRes.data,\n\t\t\t\tduplicateMessage: data.duplicateMessage,\n\t\t\t});\n\t\t\tconst fieldErrors: FieldError[] = projectedDuplicates.map((conflict) => ({\n\t\t\t\tkey: constants.fields.slug.key,\n\t\t\t\tlocaleCode: conflict.locale,\n\t\t\t\tmessage,\n\t\t\t}));\n\n\t\t\treturn {\n\t\t\t\terror: {\n\t\t\t\t\ttype: \"basic\",\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tmessage,\n\t\t\t\t\terrors: {\n\t\t\t\t\t\tfields: fieldErrors,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst existingItemsRes = await getExistingRouteItems(context, {\n\t\t\tprojectedItems,\n\t\t\tuniqueFields: uniqueFieldsRes.data,\n\t\t\tversionType: data.versionType,\n\t\t\tcollectionKey: data.collectionKey,\n\t\t\ttenantKey: data.tenantKey,\n\t\t\ttables: data.tables,\n\t\t\texcludeDocumentIds: data.excludeDocumentIds ?? [],\n\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t});\n\t\tif (existingItemsRes.error) return existingItemsRes;\n\n\t\tconst existingCollisions = findExistingRouteCollisions({\n\t\t\tprojectedItems,\n\t\t\texistingItems: existingItemsRes.data,\n\t\t});\n\n\t\tif (existingCollisions.length > 0) {\n\t\t\tconst message = getDuplicateRouteMessage({\n\t\t\t\ttranslate: context.translate,\n\t\t\t\tcollectionInstance: data.collectionInstance,\n\t\t\t\tuniqueFields: uniqueFieldsRes.data,\n\t\t\t\tduplicateMessage: data.duplicateMessage,\n\t\t\t});\n\t\t\tconst fieldErrors: FieldError[] = existingCollisions.map((conflict) => ({\n\t\t\t\tkey: constants.fields.slug.key,\n\t\t\t\tlocaleCode: conflict.locale,\n\t\t\t\tmessage,\n\t\t\t}));\n\n\t\t\treturn {\n\t\t\t\terror: {\n\t\t\t\t\ttype: \"basic\",\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tmessage,\n\t\t\t\t\terrors: {\n\t\t\t\t\t\tfields: fieldErrors,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t} catch (_error) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 500,\n\t\t\t\tmessage: copy(\"server:plugin.pages.full.slug.duplicate.check.failed\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n};\n\nexport default checkFullSlugUniqueness;\n","import { copy } from \"@lucidcms/core/plugin\";\nimport type { FieldInputSchema, ServiceResponse } from \"@lucidcms/core/types\";\nimport constants from \"../../constants.js\";\nimport getParentPageId from \"../../utils/get-parent-page-id.js\";\n\n/**\n *  Returns an error if the parentPage field is set to the same document as the current document\n */\nconst checkParentIsPageOfSelf = (data: {\n\tdefaultLocale: string;\n\tdocumentId: number;\n\tfields: {\n\t\tparentPage: FieldInputSchema;\n\t};\n}): Awaited<ServiceResponse<undefined>> => {\n\tconst parentPageId = getParentPageId(data.fields.parentPage);\n\n\tif (parentPageId !== null && parentPageId === data.documentId) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 400,\n\t\t\t\tmessage: copy(\"server:plugin.pages.parents.self.denied\"),\n\t\t\t\terrors: {\n\t\t\t\t\tfields: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: constants.fields.parentPage.key,\n\t\t\t\t\t\t\tlocaleCode: data.defaultLocale, //* parentPage doesnt use translations so always use default locale\n\t\t\t\t\t\t\tmessage: copy(\"server:plugin.pages.parents.self.denied\"),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default checkParentIsPageOfSelf;\n","import { copy } from \"@lucidcms/core/plugin\";\nimport type {\n\tFieldError,\n\tFieldInputSchema,\n\tServiceResponse,\n} from \"@lucidcms/core/types\";\nimport constants from \"../../constants.js\";\nimport type { CollectionConfig } from \"../../types/types.js\";\nimport getParentPageId from \"../../utils/get-parent-page-id.js\";\n\n/**\n *  If slug is / and parentPage is set (would cause fullSlug to be the same as parentPage just with trailing slash)\n */\nconst checkRootSlugWithParent = (data: {\n\tcollection: CollectionConfig;\n\tdefaultLocale: string;\n\tfields: {\n\t\tslug: FieldInputSchema;\n\t\tparentPage: FieldInputSchema;\n\t};\n}): Awaited<ServiceResponse<undefined>> => {\n\tconst parentPageId = getParentPageId(data.fields.parentPage);\n\n\tif (data.collection.localized && data.fields.slug.translations) {\n\t\tconst fieldErrors: FieldError[] = [];\n\t\tfor (const [key, value] of Object.entries(data.fields.slug.translations)) {\n\t\t\tif (value === \"/\" && parentPageId !== null) {\n\t\t\t\tfieldErrors.push({\n\t\t\t\t\tkey: constants.fields.slug.key,\n\t\t\t\t\tlocaleCode: key,\n\t\t\t\t\tmessage: copy(\"server:plugin.pages.slug.root.with.parent.denied\"),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (fieldErrors.length > 0) {\n\t\t\treturn {\n\t\t\t\terror: {\n\t\t\t\t\ttype: \"basic\",\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tmessage: copy(\"server:plugin.pages.slug.root.with.parent.denied\"),\n\t\t\t\t\terrors: {\n\t\t\t\t\t\tfields: fieldErrors,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\t} else if (data.fields.slug.value === \"/\" && parentPageId !== null) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tstatus: 400,\n\t\t\t\tmessage: copy(\"server:plugin.pages.slug.root.with.parent.denied\"),\n\t\t\t\terrors: {\n\t\t\t\t\tfields: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: constants.fields.parentPage.key,\n\t\t\t\t\t\t\tmessage: copy(\"server:plugin.pages.slug.root.with.parent.denied\"),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default checkRootSlugWithParent;\n","import { copy } from \"@lucidcms/core/plugin\";\nimport type { LucidHookDocuments } from \"@lucidcms/core/types\";\nimport type { PluginOptionsInternal } from \"../../types/types.js\";\nimport { checkFullSlugUniqueness } from \"../checks/index.js\";\nimport {\n\tconstructChildFullSlug,\n\tgetDescendantFields,\n\tgetTargetCollection,\n\tupdateFullSlugFields,\n} from \"../index.js\";\n\n/**\n * Handles the before delete hook for documents. What this does is:\n * - Updates all of the descendants of the deleted document fullSlug fields so that they dont include the deleted document's slug\n */\nconst beforeDeleteHandler =\n\t(\n\t\toptions: PluginOptionsInternal,\n\t): LucidHookDocuments<\"beforeDelete\">[\"handler\"] =>\n\tasync (context, data) => {\n\t\t// ----------------------------------------------------------------\n\t\t// Validation / Setup\n\t\tconst targetCollectionRes = getTargetCollection({\n\t\t\toptions,\n\t\t\tcollectionKey: data.meta.collectionKey,\n\t\t});\n\t\tif (targetCollectionRes.error) {\n\t\t\t//* early return as doesnt apply to the current collection\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\t// Process both latest and all configured environments\n\t\tconst versionTypes = [\n\t\t\t\"latest\",\n\t\t\t...(data.meta.collection.getData.environments?.map((env) => env.key) ||\n\t\t\t\t[]),\n\t\t];\n\n\t\tfor (const versionType of versionTypes) {\n\t\t\tconst descendantsRes = await getDescendantFields(context, {\n\t\t\t\tids: data.data.ids,\n\t\t\t\tversionType,\n\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t});\n\t\t\tif (descendantsRes.error) return descendantsRes;\n\n\t\t\t// Skip to next version type if no descendants found\n\t\t\tif (descendantsRes.data.length === 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst docFullSlugsRes = constructChildFullSlug({\n\t\t\t\tdescendants: descendantsRes.data,\n\t\t\t\tlocalization: context.config.localization,\n\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t});\n\t\t\tif (docFullSlugsRes.error) return docFullSlugsRes;\n\n\t\t\tconst projectedDocumentIds = docFullSlugsRes.data.map(\n\t\t\t\t(doc) => doc.documentId,\n\t\t\t);\n\t\t\tconst checkFullSlugUniquenessRes = await checkFullSlugUniqueness(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t\t\tcollectionInstance: data.meta.collection,\n\t\t\t\t\tprojectedFullSlugs: docFullSlugsRes.data,\n\t\t\t\t\tversionType,\n\t\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t\t\texcludeDocumentIds: [...data.data.ids, ...projectedDocumentIds],\n\t\t\t\t\tduplicateMessage: copy(\n\t\t\t\t\t\t\"server:plugin.pages.full.slug.duplicate.on.delete\",\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (checkFullSlugUniquenessRes.error) return checkFullSlugUniquenessRes;\n\n\t\t\tconst updateFullSlugFieldsRes = await updateFullSlugFields(context, {\n\t\t\t\tdocFullSlugs: docFullSlugsRes.data,\n\t\t\t\tversionType,\n\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t});\n\t\t\tif (updateFullSlugFieldsRes.error) return updateFullSlugFieldsRes;\n\t\t}\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t};\n\nexport default beforeDeleteHandler;\n","import type { LucidHookDocuments } from \"@lucidcms/core/types\";\nimport constants from \"../../constants.js\";\nimport type { PluginOptionsInternal } from \"../../types/types.js\";\nimport getParentPageId from \"../../utils/get-parent-page-id.js\";\nimport {\n\tcheckCircularParents,\n\tcheckFieldsExist,\n\tcheckFullSlugUniqueness,\n\tcheckParentIsPageOfSelf,\n\tcheckRootSlugWithParent,\n} from \"../checks/index.js\";\nimport type { ParentPageQueryResponse } from \"../get-parent-fields.js\";\nimport {\n\tconstructChildFullSlug,\n\tconstructParentFullSlug,\n\tgetDescendantFields,\n\tgetParentFields,\n\tgetTargetCollection,\n\tsetFullSlug,\n} from \"../index.js\";\n\nconst beforeUpsertHandler =\n\t(\n\t\toptions: PluginOptionsInternal,\n\t): LucidHookDocuments<\"beforeUpsert\">[\"handler\"] =>\n\tasync (context, data) => {\n\t\t// ----------------------------------------------------------------\n\t\t// Validation / Setup\n\n\t\tconst targetCollectionRes = getTargetCollection({\n\t\t\toptions,\n\t\t\tcollectionKey: data.meta.collectionKey,\n\t\t});\n\t\tif (targetCollectionRes.error) {\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst checkFieldsExistRes = checkFieldsExist({\n\t\t\tfields: {\n\t\t\t\tslug: data.data.fields?.find(\n\t\t\t\t\t(f) => f.key === constants.fields.slug.key && f.type === \"text\",\n\t\t\t\t),\n\t\t\t\tparentPage: data.data.fields?.find(\n\t\t\t\t\t(f) =>\n\t\t\t\t\t\tf.key === constants.fields.parentPage.key && f.type === \"relation\",\n\t\t\t\t),\n\t\t\t\t//* dont care what this value is - only needed to update translations/value\n\t\t\t\tfullSlug: data.data.fields?.find(\n\t\t\t\t\t(f) => f.key === constants.fields.fullSlug.key && f.type === \"text\",\n\t\t\t\t),\n\t\t\t},\n\t\t});\n\t\tif (checkFieldsExistRes.error) return checkFieldsExistRes;\n\t\tconst { slug, parentPage, fullSlug } = checkFieldsExistRes.data;\n\n\t\tconst checkParentIsPageOfSelfRes = checkParentIsPageOfSelf({\n\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\tdocumentId: data.data.documentId,\n\t\t\tfields: {\n\t\t\t\tparentPage: parentPage,\n\t\t\t},\n\t\t});\n\t\tif (checkParentIsPageOfSelfRes.error) return checkParentIsPageOfSelfRes;\n\n\t\tconst checkRootSlugWithParentRes = checkRootSlugWithParent({\n\t\t\tcollection: targetCollectionRes.data,\n\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\tfields: {\n\t\t\t\tslug: slug,\n\t\t\t\tparentPage: parentPage,\n\t\t\t},\n\t\t});\n\t\tif (checkRootSlugWithParentRes.error) return checkRootSlugWithParentRes;\n\n\t\t// ----------------------------------------------------------------\n\t\t// Build, validate and set fullSlug\n\n\t\tlet parentFieldsData: Array<ParentPageQueryResponse> = [];\n\t\tconst parentPageId = getParentPageId(parentPage);\n\n\t\t// parent page checks and query\n\t\tif (parentPageId !== null) {\n\t\t\tconst circularParentsRes = await checkCircularParents(context, {\n\t\t\t\tdocumentId: data.data.documentId,\n\t\t\t\tversionType: data.data.versionType,\n\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\t\tfields: {\n\t\t\t\t\tparentPage: parentPage,\n\t\t\t\t},\n\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t});\n\t\t\tif (circularParentsRes.error) return circularParentsRes;\n\n\t\t\tconst parentFieldsRes = await getParentFields(context, {\n\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\tversionType: data.data.versionType,\n\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\t\tfields: {\n\t\t\t\t\tparentPage: parentPage,\n\t\t\t\t},\n\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t});\n\t\t\tif (parentFieldsRes.error) return parentFieldsRes;\n\n\t\t\tparentFieldsData = parentFieldsRes.data;\n\t\t}\n\n\t\t// fullSlug construction\n\t\tconst fullSlugRes = constructParentFullSlug({\n\t\t\tparentFields: parentFieldsData,\n\t\t\tlocalization: context.config.localization,\n\t\t\tcollection: targetCollectionRes.data,\n\t\t\tfields: {\n\t\t\t\tslug: slug,\n\t\t\t},\n\t\t});\n\t\tif (fullSlugRes.error) return fullSlugRes;\n\n\t\tconst candidateFullSlugField = { ...fullSlug };\n\t\tsetFullSlug({\n\t\t\tfullSlug: fullSlugRes.data,\n\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\tcollection: targetCollectionRes.data,\n\t\t\tfields: {\n\t\t\t\tfullSlug: candidateFullSlugField,\n\t\t\t},\n\t\t});\n\n\t\tconst projectedFullSlugs = [\n\t\t\t{\n\t\t\t\tdocumentId: data.data.documentId,\n\t\t\t\tversionId: data.data.versionId,\n\t\t\t\tfullSlugs: fullSlugRes.data,\n\t\t\t},\n\t\t];\n\n\t\tconst descendantsRes = await getDescendantFields(context, {\n\t\t\tids: [data.data.documentId],\n\t\t\tversionType: data.data.versionType,\n\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\ttables: data.meta.collectionTableNames,\n\t\t});\n\t\tif (descendantsRes.error) return descendantsRes;\n\n\t\tif (descendantsRes.data.length > 0) {\n\t\t\tconst descendantFullSlugsRes = constructChildFullSlug({\n\t\t\t\tdescendants: descendantsRes.data,\n\t\t\t\tlocalization: context.config.localization,\n\t\t\t\tparentFullSlugField: candidateFullSlugField,\n\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t});\n\t\t\tif (descendantFullSlugsRes.error) return descendantFullSlugsRes;\n\n\t\t\tprojectedFullSlugs.push(...descendantFullSlugsRes.data);\n\t\t}\n\n\t\tconst checkFullSlugUniquenessRes = await checkFullSlugUniqueness(context, {\n\t\t\tcollection: targetCollectionRes.data,\n\t\t\tcollectionInstance: data.meta.collection,\n\t\t\tprojectedFullSlugs,\n\t\t\tversionType: data.data.versionType,\n\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\ttables: data.meta.collectionTableNames,\n\t\t\texcludeDocumentIds: projectedFullSlugs.map((doc) => doc.documentId),\n\t\t\tinputFields: {\n\t\t\t\tdocumentId: data.data.documentId,\n\t\t\t\tversionId: data.data.versionId,\n\t\t\t\tfields: data.data.fields ?? [],\n\t\t\t},\n\t\t});\n\t\tif (checkFullSlugUniquenessRes.error) return checkFullSlugUniquenessRes;\n\n\t\tsetFullSlug({\n\t\t\tfullSlug: fullSlugRes.data,\n\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\tcollection: targetCollectionRes.data,\n\t\t\tfields: {\n\t\t\t\tfullSlug: fullSlug,\n\t\t\t},\n\t\t});\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t};\n\nexport default beforeUpsertHandler;\n","import type { FieldInputSchema } from \"@lucidcms/core/types\";\nimport type { VersionFieldsQueryResponse } from \"../services/get-document-version-fields.js\";\n\nconst fieldResToSchema = (\n\tkey: string,\n\tlocalized: boolean,\n\tdefaultLocale: string,\n\titems: VersionFieldsQueryResponse[],\n\trelationCollectionKey?: string,\n): FieldInputSchema => {\n\t// Determine field type based on key\n\tconst fieldType = getFieldTypeFromKey(key);\n\n\tif (!fieldType) {\n\t\tthrow new Error(`Unable to determine field type for key: ${key}`);\n\t}\n\n\tconst result: FieldInputSchema = {\n\t\tkey: key,\n\t\ttype: fieldType,\n\t};\n\n\tif (localized) {\n\t\tresult.translations = {};\n\n\t\tfor (const item of items) {\n\t\t\tif (fieldType === \"text\") {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tresult.translations[item.locale] = item[`_${key}`] as string | null;\n\t\t\t} else if (fieldType === \"relation\") {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tconst relationId = item[`_${key}`];\n\t\t\t\tresult.translations[item.locale] =\n\t\t\t\t\ttypeof relationId === \"number\" && relationCollectionKey\n\t\t\t\t\t\t? [{ id: relationId, collectionKey: relationCollectionKey }]\n\t\t\t\t\t\t: [];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst defaultItem =\n\t\t\titems.find((item) => item.locale === defaultLocale) || items[0];\n\n\t\tif (fieldType === \"text\") {\n\t\t\t// @ts-expect-error\n\t\t\tresult.value = defaultItem[`_${key}`] as string | null;\n\t\t} else if (fieldType === \"relation\") {\n\t\t\t// @ts-expect-error\n\t\t\tconst relationId = defaultItem[`_${key}`];\n\t\t\tresult.value =\n\t\t\t\ttypeof relationId === \"number\" && relationCollectionKey\n\t\t\t\t\t? [{ id: relationId, collectionKey: relationCollectionKey }]\n\t\t\t\t\t: [];\n\t\t}\n\t}\n\n\treturn result;\n};\n\n// Helper function to determine field type based on key\nfunction getFieldTypeFromKey(\n\tkey: string,\n): FieldInputSchema[\"type\"] | undefined {\n\tswitch (key) {\n\t\tcase \"slug\":\n\t\tcase \"fullSlug\":\n\t\t\treturn \"text\";\n\t\tcase \"parentPage\":\n\t\t\treturn \"relation\";\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport default fieldResToSchema;\n","import type { LucidHookDocuments } from \"@lucidcms/core/types\";\nimport constants from \"../../constants.js\";\nimport type { PluginOptionsInternal } from \"../../types/types.js\";\nimport fieldResToSchema from \"../../utils/field-res-to-schema.js\";\nimport getParentPageId from \"../../utils/get-parent-page-id.js\";\nimport {\n\tcheckCircularParents,\n\tcheckFieldsExist,\n\tcheckFullSlugUniqueness,\n} from \"../checks/index.js\";\nimport type { ParentPageQueryResponse } from \"../get-parent-fields.js\";\nimport {\n\tconstructChildFullSlug,\n\tconstructParentFullSlug,\n\tgetDescendantFields,\n\tgetDocumentVersionFields,\n\tgetParentFields,\n\tgetTargetCollection,\n\tsetFullSlug,\n\tupdateFullSlugFields,\n\tupdateSlugFields,\n} from \"../index.js\";\nimport afterUpsertHandler from \"./after-upsert-handler.js\";\n\nconst versionPromoteHandler =\n\t(\n\t\toptions: PluginOptionsInternal,\n\t): LucidHookDocuments<\"versionPromote\">[\"handler\"] =>\n\tasync (context, data) => {\n\t\t// ----------------------------------------------------------------\n\t\t// Validation / Setup\n\t\tconst targetCollectionRes = getTargetCollection({\n\t\t\toptions,\n\t\t\tcollectionKey: data.meta.collectionKey,\n\t\t});\n\t\tif (targetCollectionRes.error) {\n\t\t\t//* early return as doesnt apply to the current collection\n\t\t\treturn {\n\t\t\t\terror: undefined,\n\t\t\t\tdata: undefined,\n\t\t\t};\n\t\t}\n\n\t\tlet createFullSlug = true;\n\n\t\t// fetch the document versions, slug and parent page fields\n\t\tconst docVersionFieldRes = await getDocumentVersionFields(context, {\n\t\t\tdocumentId: data.data.documentId,\n\t\t\tversionId: data.data.versionId,\n\t\t\tversionType: data.data.versionType,\n\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\ttables: data.meta.collectionTableNames,\n\t\t});\n\t\tif (docVersionFieldRes.error) return docVersionFieldRes;\n\t\tif (docVersionFieldRes.data === null) createFullSlug = false;\n\n\t\t// Format fields\n\t\tconst checkFieldsExistRes = checkFieldsExist({\n\t\t\tfields: {\n\t\t\t\tslug: fieldResToSchema(\n\t\t\t\t\tconstants.fields.slug.key,\n\t\t\t\t\ttargetCollectionRes.data.localized,\n\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\tdocVersionFieldRes.data || [],\n\t\t\t\t),\n\t\t\t\tparentPage: fieldResToSchema(\n\t\t\t\t\tconstants.fields.parentPage.key,\n\t\t\t\t\tfalse,\n\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\tdocVersionFieldRes.data || [],\n\t\t\t\t\ttargetCollectionRes.data.key,\n\t\t\t\t),\n\t\t\t\tfullSlug: fieldResToSchema(\n\t\t\t\t\tconstants.fields.fullSlug.key,\n\t\t\t\t\ttargetCollectionRes.data.localized,\n\t\t\t\t\tcontext.config.localization.defaultLocale,\n\t\t\t\t\tdocVersionFieldRes.data || [],\n\t\t\t\t),\n\t\t\t},\n\t\t});\n\t\tif (checkFieldsExistRes.error) return checkFieldsExistRes;\n\t\tconst { slug, parentPage, fullSlug } = checkFieldsExistRes.data;\n\n\t\t// ----------------------------------------------------------------\n\t\t// create fullSlug - close to the beforeUpsert hook\n\t\tif (createFullSlug) {\n\t\t\tlet parentFieldsData: Array<ParentPageQueryResponse> = [];\n\t\t\tconst parentPageId = getParentPageId(parentPage);\n\n\t\t\t// parent page checks and query\n\t\t\tif (parentPageId !== null) {\n\t\t\t\tconst circularParentsRes = await checkCircularParents(context, {\n\t\t\t\t\tdocumentId: data.data.documentId,\n\t\t\t\t\tversionType: data.data.versionType,\n\t\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tparentPage: parentPage,\n\t\t\t\t\t},\n\t\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t\t});\n\t\t\t\tif (circularParentsRes.error) return circularParentsRes;\n\n\t\t\t\tconst parentFieldsRes = await getParentFields(context, {\n\t\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\t\tversionType: data.data.versionType,\n\t\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tparentPage: parentPage,\n\t\t\t\t\t},\n\t\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t\t});\n\t\t\t\tif (parentFieldsRes.error) return parentFieldsRes;\n\n\t\t\t\tparentFieldsData = parentFieldsRes.data;\n\t\t\t}\n\n\t\t\t// fullSlug construction\n\t\t\tconst fullSlugRes = constructParentFullSlug({\n\t\t\t\tparentFields: parentFieldsData,\n\t\t\t\tlocalization: context.config.localization,\n\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t\tfields: {\n\t\t\t\t\tslug: slug,\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (fullSlugRes.error) return fullSlugRes;\n\n\t\t\tconst candidateFullSlugField = { ...fullSlug };\n\t\t\tsetFullSlug({\n\t\t\t\tfullSlug: fullSlugRes.data,\n\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t\tfields: {\n\t\t\t\t\tfullSlug: candidateFullSlugField,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tconst projectedFullSlugs = [\n\t\t\t\t{\n\t\t\t\t\tdocumentId: data.data.documentId,\n\t\t\t\t\tversionId: data.data.versionId,\n\t\t\t\t\tfullSlugs: fullSlugRes.data,\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tconst descendantsRes = await getDescendantFields(context, {\n\t\t\t\tids: [data.data.documentId],\n\t\t\t\tversionType: data.data.versionType,\n\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t});\n\t\t\tif (descendantsRes.error) return descendantsRes;\n\n\t\t\tif (descendantsRes.data.length > 0) {\n\t\t\t\tconst descendantFullSlugsRes = constructChildFullSlug({\n\t\t\t\t\tdescendants: descendantsRes.data,\n\t\t\t\t\tlocalization: context.config.localization,\n\t\t\t\t\tparentFullSlugField: candidateFullSlugField,\n\t\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t\t});\n\t\t\t\tif (descendantFullSlugsRes.error) return descendantFullSlugsRes;\n\n\t\t\t\tprojectedFullSlugs.push(...descendantFullSlugsRes.data);\n\t\t\t}\n\n\t\t\tconst checkFullSlugUniquenessRes = await checkFullSlugUniqueness(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t\t\tcollectionInstance: data.meta.collection,\n\t\t\t\t\tprojectedFullSlugs,\n\t\t\t\t\tversionType: data.data.versionType,\n\t\t\t\t\tcollectionKey: targetCollectionRes.data.key,\n\t\t\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t\t\texcludeDocumentIds: projectedFullSlugs.map((doc) => doc.documentId),\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (checkFullSlugUniquenessRes.error) return checkFullSlugUniquenessRes;\n\n\t\t\tsetFullSlug({\n\t\t\t\tfullSlug: fullSlugRes.data,\n\t\t\t\tdefaultLocale: context.config.localization.defaultLocale,\n\t\t\t\tcollection: targetCollectionRes.data,\n\t\t\t\tfields: {\n\t\t\t\t\tfullSlug: fullSlug,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tconst updateSlugRes = await updateSlugFields(context, {\n\t\t\t\tdocSlugs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdocumentId: data.data.documentId,\n\t\t\t\t\t\tversionId: data.data.versionId,\n\t\t\t\t\t\tslugs: slug.translations || {\n\t\t\t\t\t\t\t[context.config.localization.defaultLocale]: slug.value || null,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tversionType: data.data.versionType,\n\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t});\n\t\t\tif (updateSlugRes.error) return updateSlugRes;\n\n\t\t\tconst updateFullSlugRes = await updateFullSlugFields(context, {\n\t\t\t\tdocFullSlugs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdocumentId: data.data.documentId,\n\t\t\t\t\t\tversionId: data.data.versionId,\n\t\t\t\t\t\tfullSlugs: fullSlugRes.data,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tversionType: data.data.versionType,\n\t\t\t\ttables: data.meta.collectionTableNames,\n\t\t\t});\n\t\t\tif (updateFullSlugRes.error) return updateFullSlugRes;\n\t\t}\n\n\t\t// ----------------------------------------------------------------\n\t\t// run the afterUpsert hook to update all of the documents versions potential descendants\n\t\tconst afterUpsertRes = await afterUpsertHandler(options)(context, {\n\t\t\tmeta: {\n\t\t\t\tcollection: data.meta.collection,\n\t\t\t\tcollectionKey: data.meta.collectionKey,\n\t\t\t\tuserId: data.meta.userId,\n\t\t\t\tcollectionTableNames: data.meta.collectionTableNames,\n\t\t\t\ttenantKey: data.meta.tenantKey,\n\t\t\t},\n\t\t\tdata: {\n\t\t\t\tdocumentId: data.data.documentId,\n\t\t\t\tversionId: data.data.versionId,\n\t\t\t\tversionType: data.data.versionType,\n\t\t\t\tbricks: [],\n\t\t\t\tfields: [slug, parentPage, fullSlug],\n\t\t\t},\n\t\t});\n\t\tif (afterUpsertRes.error) return afterUpsertRes;\n\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t};\n\nexport default versionPromoteHandler;\n","import { logger } from \"@lucidcms/core\";\nimport type { LucidPlugin } from \"@lucidcms/core/types\";\nimport { LUCID_VERSION, PLUGIN_KEY } from \"./constants.js\";\nimport {\n\tafterFetchHandler,\n\tafterUpsertHandler,\n\tbeforeDeleteHandler,\n\tbeforeUpsertHandler,\n\tversionPromoteHandler,\n} from \"./services/hooks/index.js\";\nimport { pluginOptions, registerFields } from \"./services/index.js\";\nimport type { PluginOptions } from \"./types/types.js\";\n\nconst plugin: LucidPlugin<PluginOptions> = (plugin) => {\n\tconst options = pluginOptions(plugin);\n\n\treturn {\n\t\tkey: PLUGIN_KEY,\n\t\tlucid: LUCID_VERSION,\n\t\trecipe: (draft) => {\n\t\t\tdraft.i18n.sources.push(\"@lucidcms/plugin-pages/translations\");\n\n\t\t\tfor (const collectionConfig of options.collections) {\n\t\t\t\tconst collectionInstance = draft.collections.find(\n\t\t\t\t\t(c) => c.key === collectionConfig.key,\n\t\t\t\t);\n\t\t\t\tif (!collectionInstance) {\n\t\t\t\t\tlogger.warn({\n\t\t\t\t\t\tmessage: \"Pages collection was not found\",\n\t\t\t\t\t\tscope: PLUGIN_KEY,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tcollection: collectionConfig.key,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tregisterFields(collectionInstance, collectionConfig);\n\n\t\t\t\tif (!collectionInstance.config.hooks) {\n\t\t\t\t\tcollectionInstance.config.hooks = [];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (draft.hooks && Array.isArray(draft.hooks)) {\n\t\t\t\tdraft.hooks.push({\n\t\t\t\t\tservice: \"documents\",\n\t\t\t\t\tevent: \"beforeUpsert\",\n\t\t\t\t\thandler: beforeUpsertHandler(options),\n\t\t\t\t});\n\t\t\t\tdraft.hooks.push({\n\t\t\t\t\tservice: \"documents\",\n\t\t\t\t\tevent: \"afterUpsert\",\n\t\t\t\t\thandler: afterUpsertHandler(options),\n\t\t\t\t});\n\t\t\t\tdraft.hooks.push({\n\t\t\t\t\tservice: \"documents\",\n\t\t\t\t\tevent: \"afterFetch\",\n\t\t\t\t\thandler: afterFetchHandler(options),\n\t\t\t\t});\n\t\t\t\tdraft.hooks.push({\n\t\t\t\t\tservice: \"documents\",\n\t\t\t\t\tevent: \"beforeDelete\",\n\t\t\t\t\thandler: beforeDeleteHandler(options),\n\t\t\t\t});\n\t\t\t\tdraft.hooks.push({\n\t\t\t\t\tservice: \"documents\",\n\t\t\t\t\tevent: \"versionPromote\",\n\t\t\t\t\thandler: versionPromoteHandler(options),\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t};\n};\n\nexport default plugin;\n","import plugin from \"./plugin.js\";\n\nexport { default as pagesPlugin } from \"./plugin.js\";\n\nexport default plugin;\n"],"x_google_ignoreList":[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107],"mappings":";;;;AAAA,MAAa,aAAa;AAC1B,MAAa,gBAAgB;AAE7B,IAAA,oBAAe,EACd,QAAQ;CACP,YAAY,EACX,KAAK,aACN;CACA,MAAM,EACL,KAAK,OACN;CACA,UAAU,EACT,KAAK,WACN;AACD,EACD;;;;;;ACVA,MAAM,mBAAmB,UAA2C;CACnE,IAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,GAAG,OAAO;CAExC,MAAM,kBAAkB,MAAM,MAAM;CACpC,IAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAC9D,OAAO;CAER,IAAI,EAAE,QAAQ,kBAAk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