import { jsx } from "react/jsx-runtime";
import "react";
import { observer, useField, useFieldSchema } from "@tachybase/schema";
import { useRequest } from "../../../api-client/index.mjs";
import { useRecord } from "../../../record-provider/index.mjs";
import { useActionContext } from "../action/index.mjs";
import { Select, defaultFieldNames } from "../select/index.mjs";
import { getValues } from "./shared.mjs";
const ReadPretty = observer((props)=>{
    const fieldNames = {
        ...defaultFieldNames,
        ...props.fieldNames
    };
    const field = useField();
    const fieldSchema = useFieldSchema();
    const record = useRecord();
    const { snapshot } = useActionContext();
    const { data } = useRequest(snapshot ? async ()=>({
            data: record[fieldSchema.name]
        }) : {
        action: 'list',
        ...props.service,
        params: {
            paginate: false,
            filter: {
                [fieldNames.value]: {
                    $in: getValues(field.value, fieldNames)
                }
            }
        }
    }, {
        refreshDeps: [
            props.service,
            field.value
        ]
    });
    return /*#__PURE__*/ jsx(Select.ReadPretty, {
        ...props,
        options: null == data ? void 0 : data.data
    });
}, {
    displayName: 'ReadPretty'
});
export { ReadPretty };
