'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React from 'react';
import { FieldLabel } from '../../../../fields/FieldLabel/index.js';
import { useField } from '../../../../forms/useField/index.js';
import { WhereBuilder } from '../../../WhereBuilder/index.js';
import './index.scss';
export const QueryPresetsWhereField = ({ field: { label, required } })=>{
    const { path, setValue, value } = useField();
    const relatedCollectionField = useField({
        path: 'relatedCollection'
    });
    const relatedCollection = relatedCollectionField.value;
    if (!relatedCollection) {
        return /*#__PURE__*/ _jsxDEV("div", {
            className: "field-type query-preset-where-field",
            children: [
                /*#__PURE__*/ _jsxDEV(FieldLabel, {
                    as: "h3",
                    label: label,
                    path: path,
                    required: required
                }, void 0, false, {
                    fileName: "src/elements/QueryPresets/fields/WhereField/index.tsx",
                    lineNumber: 21,
                    columnNumber: 9
                }, this),
                /*#__PURE__*/ _jsxDEV("p", {
                    className: "query-preset-where-field__hint",
                    children: "Select the related collection to configure filters."
                }, void 0, false, {
                    fileName: "src/elements/QueryPresets/fields/WhereField/index.tsx",
                    lineNumber: 22,
                    columnNumber: 9
                }, this)
            ]
        }, void 0, true, {
            fileName: "src/elements/QueryPresets/fields/WhereField/index.tsx",
            lineNumber: 20,
            columnNumber: 7
        }, this);
    }
    return /*#__PURE__*/ _jsxDEV("div", {
        className: "field-type query-preset-where-field",
        children: [
            /*#__PURE__*/ _jsxDEV(FieldLabel, {
                as: "h3",
                label: label,
                path: path,
                required: required
            }, void 0, false, {
                fileName: "src/elements/QueryPresets/fields/WhereField/index.tsx",
                lineNumber: 31,
                columnNumber: 7
            }, this),
            /*#__PURE__*/ _jsxDEV(WhereBuilder, {
                collectionSlug: relatedCollection,
                onChange: (where)=>setValue(where),
                value: value ?? undefined
            }, void 0, false, {
                fileName: "src/elements/QueryPresets/fields/WhereField/index.tsx",
                lineNumber: 32,
                columnNumber: 7
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/elements/QueryPresets/fields/WhereField/index.tsx",
        lineNumber: 30,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map