"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    TextField: ()=>TextField_TextField
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const index_cjs_namespaceObject = require("../../../layouts/index.cjs");
const external_react_namespaceObject = require("react");
const external_NodePropertiesPanel_styles_cjs_namespaceObject = require("../NodePropertiesPanel.styles.cjs");
const TextField_TextField = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ field, value, onChange, error }) {
    const [localValue, setLocalValue] = (0, external_react_namespaceObject.useState)(value || '');
    const debounceTimer = (0, external_react_namespaceObject.useRef)(null);
    (0, external_react_namespaceObject.useEffect)(()=>{
        setLocalValue(value || '');
    }, [
        value
    ]);
    (0, external_react_namespaceObject.useEffect)(()=>()=>{
            if (debounceTimer.current) {
                clearTimeout(debounceTimer.current);
                debounceTimer.current = null;
            }
        }, []);
    const handleChange = (0, external_react_namespaceObject.useCallback)((e)=>{
        const newValue = e.target.value;
        setLocalValue(newValue);
        if (debounceTimer.current) {
            clearTimeout(debounceTimer.current);
            debounceTimer.current = null;
        }
        const debounceDelay = field.debounce || 0;
        if (debounceDelay > 0) debounceTimer.current = setTimeout(()=>{
            onChange(newValue);
            debounceTimer.current = null;
        }, debounceDelay);
        else onChange(newValue);
    }, [
        field.debounce,
        onChange
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_cjs_namespaceObject.Column, {
        gap: 4,
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodePropertiesPanel_styles_cjs_namespaceObject.FieldLabel, {
                children: field.label
            }),
            'textarea' === field.type ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodePropertiesPanel_styles_cjs_namespaceObject.TextArea, {
                className: "nodrag",
                value: localValue,
                onChange: handleChange,
                placeholder: field.placeholder,
                disabled: field.disabled,
                rows: field.rows || 3,
                hasError: !!error
            }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_NodePropertiesPanel_styles_cjs_namespaceObject.InputWrapper, {
                children: [
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodePropertiesPanel_styles_cjs_namespaceObject.TextInput, {
                        className: "nodrag",
                        type: "text",
                        value: localValue,
                        onChange: handleChange,
                        placeholder: field.placeholder,
                        disabled: field.disabled,
                        hasError: !!error,
                        style: {
                            flex: 1
                        }
                    }),
                    field.suffix && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodePropertiesPanel_styles_cjs_namespaceObject.InputSuffix, {
                        children: field.suffix
                    })
                ]
            }),
            field.helpText && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodePropertiesPanel_styles_cjs_namespaceObject.FieldHelpText, {
                children: field.helpText
            }),
            error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodePropertiesPanel_styles_cjs_namespaceObject.FieldError, {
                children: error
            })
        ]
    });
});
exports.TextField = __webpack_exports__.TextField;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "TextField"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
