'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    CollapsibleProvider: function() {
        return CollapsibleProvider;
    },
    useCollapsible: function() {
        return useCollapsible;
    }
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const Context = /*#__PURE__*/ (0, _react.createContext)({
    collapsed: false,
    isVisible: true,
    toggle: ()=>{},
    withinCollapsible: true
});
const CollapsibleProvider = ({ children, collapsed, toggle, withinCollapsible = true })=>{
    const { collapsed: parentIsCollapsed, isVisible } = useCollapsible();
    const contextValue = _react.default.useMemo(()=>{
        return {
            collapsed: Boolean(collapsed),
            isVisible: isVisible && !parentIsCollapsed,
            toggle,
            withinCollapsible
        };
    }, [
        collapsed,
        withinCollapsible,
        toggle,
        parentIsCollapsed,
        isVisible
    ]);
    return /*#__PURE__*/ _react.default.createElement(Context.Provider, {
        value: contextValue
    }, children);
};
const useCollapsible = ()=>(0, _react.useContext)(Context);

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9lbGVtZW50cy9Db2xsYXBzaWJsZS9wcm92aWRlci50c3giXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBjbGllbnQnXG5pbXBvcnQgUmVhY3QsIHsgY3JlYXRlQ29udGV4dCwgdXNlQ29udGV4dCB9IGZyb20gJ3JlYWN0J1xuXG50eXBlIENvbnRleHRUeXBlID0ge1xuICBjb2xsYXBzZWQ6IGJvb2xlYW5cbiAgaXNWaXNpYmxlOiBib29sZWFuXG4gIHRvZ2dsZTogKCkgPT4gdm9pZFxuICB3aXRoaW5Db2xsYXBzaWJsZTogYm9vbGVhblxufVxuY29uc3QgQ29udGV4dCA9IGNyZWF0ZUNvbnRleHQoe1xuICBjb2xsYXBzZWQ6IGZhbHNlLFxuICBpc1Zpc2libGU6IHRydWUsXG4gIHRvZ2dsZTogKCkgPT4ge30sXG4gIHdpdGhpbkNvbGxhcHNpYmxlOiB0cnVlLFxufSlcblxuZXhwb3J0IGNvbnN0IENvbGxhcHNpYmxlUHJvdmlkZXI6IFJlYWN0LkZDPHtcbiAgY2hpbGRyZW4/OiBSZWFjdC5SZWFjdE5vZGVcbiAgY29sbGFwc2VkPzogYm9vbGVhblxuICB0b2dnbGU6ICgpID0+IHZvaWRcbiAgd2l0aGluQ29sbGFwc2libGU/OiBib29sZWFuXG59PiA9ICh7IGNoaWxkcmVuLCBjb2xsYXBzZWQsIHRvZ2dsZSwgd2l0aGluQ29sbGFwc2libGUgPSB0cnVlIH0pID0+IHtcbiAgY29uc3QgeyBjb2xsYXBzZWQ6IHBhcmVudElzQ29sbGFwc2VkLCBpc1Zpc2libGUgfSA9IHVzZUNvbGxhcHNpYmxlKClcblxuICBjb25zd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