import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
const SearchAndJumpContext = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)({
    open: false,
    setOpen: (open)=>{}
});
const SearchAndJumpProvider = (param)=>{
    let { children } = param;
    const [open, setOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(SearchAndJumpContext.Provider, {
        value: {
            open,
            setOpen
        },
        children: [
            children,
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(SearchAndJump, {
                open: open,
                setOpen: setOpen
            })
        ]
    });
};
const useSearchAndJump = ()=>(0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(SearchAndJumpContext);
const SearchAndJump = (param)=>{
    let { open, setOpen } = param;
    const inputRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)();
    (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
        if (open && inputRef.current) setTimeout(()=>{
            inputRef.current.focus();
        }, 0);
    }, [
        open,
        inputRef
    ]);
    const handleOk = ()=>{
        setOpen(false);
    };
    const handleCancel = ()=>{
        setOpen(false);
    };
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Modal, {
        title: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Input, {
            style: {
                width: '100%'
            },
            autoFocus: true,
            ref: inputRef
        }),
        closable: false,
        open: open,
        onOk: handleOk,
        onCancel: handleCancel,
        footer: null,
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("p", {})
    });
};
export { SearchAndJump, SearchAndJumpContext, SearchAndJumpProvider, useSearchAndJump };
