"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__, {
    useNavigationStack: ()=>useNavigationStack
});
const external_react_namespaceObject = require("react");
function useNavigationStack(initialItem) {
    const [stack, setStack] = (0, external_react_namespaceObject.useState)(initialItem ? [
        initialItem
    ] : []);
    const stackRef = (0, external_react_namespaceObject.useRef)(stack);
    stackRef.current = stack;
    const push = (0, external_react_namespaceObject.useCallback)((item)=>{
        setStack((prev)=>[
                ...prev,
                item
            ]);
    }, []);
    const pop = (0, external_react_namespaceObject.useCallback)(()=>{
        const currentStack = stackRef.current;
        if (0 === currentStack.length) return null;
        const poppedItem = currentStack.at(-1);
        setStack((prev)=>prev.slice(0, -1));
        return poppedItem;
    }, []);
    const clear = (0, external_react_namespaceObject.useCallback)(()=>{
        setStack([]);
    }, []);
    const canGoBack = stack.length > 0;
    const current = canGoBack ? stack.at(-1) : null;
    const isEmpty = !canGoBack;
    return {
        stack,
        current,
        canGoBack,
        isEmpty,
        push,
        pop,
        clear
    };
}
exports.useNavigationStack = __webpack_exports__.useNavigationStack;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "useNavigationStack"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
