"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 ('undefined' != 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__, {
    useCompiledAction: ()=>useCompiledAction
});
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const index_js_namespaceObject = require("../../../hooks/index.js");
const external_hooks_js_namespaceObject = require("../hooks.js");
const useCompiledAction = (useAction, actionCallback)=>{
    const compile = (0, index_js_namespaceObject.useCompile)();
    const scope = (0, schema_namespaceObject.useExpressionScope)();
    const compiledUseAction = (0, external_react_namespaceObject.useMemo)(()=>{
        if ('function' == typeof useAction) return useAction;
        if ('string' == typeof useAction && useAction.startsWith('{{')) {
            const match = useAction.match(/\{\{\s*([^}]+)\s*\}\}/);
            if (match && match[1]) {
                const expression = match[1].trim();
                const func = scope[expression];
                if ('function' == typeof func) return func;
                const compiled = compile(useAction);
                if ('function' == typeof compiled) return compiled;
                console.warn("useAction not found in scope or compilation failed: ".concat(expression), scope);
                return external_hooks_js_namespaceObject.useA;
            }
            const compiled = compile(useAction);
            if ('function' == typeof compiled) return compiled;
            console.warn("useAction compilation failed: ".concat(useAction), compiled);
            return external_hooks_js_namespaceObject.useA;
        }
        console.warn("useAction is not a function or string reference:", useAction);
        return external_hooks_js_namespaceObject.useA;
    }, [
        useAction,
        compile,
        scope
    ]);
    return compiledUseAction(actionCallback);
};
exports.useCompiledAction = __webpack_exports__.useCompiledAction;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
    "useCompiledAction"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
    value: true
});
